* boards/native-stdiogdbserver.exp: New file.
[deliverable/binutils-gdb.git] / gdb / linux-nat.h
CommitLineData
0274a8ce 1/* Native debugging support for GNU/Linux (LWP layer).
10d6c8cd 2
4c38e0a4 3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
7b6bb8da 4 2010, 2011 Free Software Foundation, Inc.
0274a8ce
MS
5
6 This file is part of GDB.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
a9762ec7 10 the Free Software Foundation; either version 3 of the License, or
0274a8ce
MS
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
a9762ec7 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
0274a8ce 20
a2f23071
DJ
21#include "target.h"
22
9f0bdab8
DJ
23#include <signal.h>
24
7b50312a
PA
25struct arch_lwp_info;
26
25289eb2
PA
27/* Ways to "resume" a thread. */
28
29enum resume_kind
30{
31 /* Thread should continue. */
32 resume_continue,
33
34 /* Thread should single-step. */
35 resume_step,
36
37 /* Thread should be stopped. */
38 resume_stop
39};
40
9f0bdab8
DJ
41/* Structure describing an LWP. This is public only for the purposes
42 of ALL_LWPS; target-specific code should generally not access it
43 directly. */
0274a8ce
MS
44
45struct lwp_info
46{
47 /* The process id of the LWP. This is a combination of the LWP id
48 and overall process id. */
49 ptid_t ptid;
50
51 /* Non-zero if this LWP is cloned. In this context "cloned" means
52 that the LWP is reporting to its parent using a signal other than
53 SIGCHLD. */
54 int cloned;
55
56 /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
57 it back yet). */
58 int signalled;
59
60 /* Non-zero if this LWP is stopped. */
61 int stopped;
62
63 /* Non-zero if this LWP will be/has been resumed. Note that an LWP
64 can be marked both as stopped and resumed at the same time. This
65 happens if we try to resume an LWP that has a wait status
66 pending. We shouldn't let the LWP run until that wait status has
67 been processed, but we should not report that wait status if GDB
68 didn't try to let the LWP run. */
69 int resumed;
70
25289eb2
PA
71 /* The last resume GDB requested on this thread. */
72 enum resume_kind last_resume_kind;
73
0274a8ce
MS
74 /* If non-zero, a pending wait status. */
75 int status;
76
77 /* Non-zero if we were stepping this LWP. */
78 int step;
79
9f0bdab8
DJ
80 /* Non-zero si_signo if this LWP stopped with a trap. si_addr may
81 be the address of a hardware watchpoint. */
82 struct siginfo siginfo;
83
ebec9a0f
PA
84 /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
85 watchpoint trap. */
86 int stopped_by_watchpoint;
87
88 /* On architectures where it is possible to know the data address of
89 a triggered watchpoint, STOPPED_DATA_ADDRESS_P is non-zero, and
90 STOPPED_DATA_ADDRESS contains such data address. Otherwise,
91 STOPPED_DATA_ADDRESS_P is false, and STOPPED_DATA_ADDRESS is
92 undefined. Only valid if STOPPED_BY_WATCHPOINT is true. */
93 int stopped_data_address_p;
94 CORE_ADDR stopped_data_address;
95
57380f4e
DJ
96 /* Non-zero if we expect a duplicated SIGINT. */
97 int ignore_sigint;
98
a2f23071
DJ
99 /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
100 for this LWP's last event. This may correspond to STATUS above,
101 or to a local variable in lin_lwp_wait. */
102 struct target_waitstatus waitstatus;
103
a96d9b2e
SDJ
104 /* Signal wether we are in a SYSCALL_ENTRY or
105 in a SYSCALL_RETURN event.
106 Values:
107 - TARGET_WAITKIND_SYSCALL_ENTRY
108 - TARGET_WAITKIND_SYSCALL_RETURN */
109 int syscall_state;
110
dc146f7c
VP
111 /* The processor core this LWP was last seen on. */
112 int core;
113
7b50312a
PA
114 /* Arch-specific additions. */
115 struct arch_lwp_info *arch_private;
116
0274a8ce
MS
117 /* Next LWP in list. */
118 struct lwp_info *next;
119};
120
9f0bdab8
DJ
121/* The global list of LWPs, for ALL_LWPS. Unlike the threads list,
122 there is always at least one LWP on the list while the GNU/Linux
123 native target is active. */
124extern struct lwp_info *lwp_list;
125
4c38200f
PA
126/* Iterate over each active thread (light-weight process). */
127#define ALL_LWPS(LP) \
128 for ((LP) = lwp_list; \
9f0bdab8 129 (LP) != NULL; \
4c38200f 130 (LP) = (LP)->next)
9f0bdab8 131
17faa917
DJ
132#define GET_LWP(ptid) ptid_get_lwp (ptid)
133#define GET_PID(ptid) ptid_get_pid (ptid)
134#define is_lwp(ptid) (GET_LWP (ptid) != 0)
135#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0)
136
0ec9a092
DJ
137/* Attempt to initialize libthread_db. */
138void check_for_thread_db (void);
0274a8ce 139
4c28f408
PA
140int thread_db_attach_lwp (ptid_t ptid);
141
669211f5
UW
142/* Return the set of signals used by the threads library. */
143extern void lin_thread_get_thread_signals (sigset_t *mask);
144
bfb39158 145/* Find process PID's pending signal set from /proc/pid/status. */
3e43a32a
MS
146void linux_proc_pending_signals (int pid, sigset_t *pending,
147 sigset_t *blocked, sigset_t *ignored);
bfb39158 148
4de4c07c 149/* linux-nat functions for handling fork events. */
4de4c07c 150extern void linux_enable_event_reporting (ptid_t ptid);
0274a8ce 151
93815fbf 152extern int lin_lwp_attach_lwp (ptid_t ptid);
9ee57c33 153
7b50312a
PA
154extern void linux_stop_lwp (struct lwp_info *lwp);
155
0274a8ce 156/* Iterator function for lin-lwp's lwp list. */
d90e17a7
PA
157struct lwp_info *iterate_over_lwps (ptid_t filter,
158 int (*callback) (struct lwp_info *,
0274a8ce
MS
159 void *),
160 void *data);
10d6c8cd 161
155bd5d1
AC
162/* Create a prototype generic GNU/Linux target. The client can
163 override it with local methods. */
10d6c8cd 164struct target_ops * linux_target (void);
f973ed9c 165
910122bf
UW
166/* Create a generic GNU/Linux target using traditional
167 ptrace register access. */
168struct target_ops *
7714d83a 169linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
910122bf 170
155bd5d1 171/* Register the customized GNU/Linux target. This should be used
f973ed9c
DJ
172 instead of calling add_target directly. */
173void linux_nat_add_target (struct target_ops *);
174
9f0bdab8 175/* Register a method to call whenever a new thread is attached. */
7b50312a 176void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *));
9f0bdab8 177
5b009018
PA
178/* Register a method that converts a siginfo object between the layout
179 that ptrace returns, and the layout in the architecture of the
180 inferior. */
181void linux_nat_set_siginfo_fixup (struct target_ops *,
182 int (*) (struct siginfo *,
183 gdb_byte *,
184 int));
185
7b50312a
PA
186/* Register a method to call prior to resuming a thread. */
187
188void linux_nat_set_prepare_to_resume (struct target_ops *,
189 void (*) (struct lwp_info *));
190
f973ed9c
DJ
191/* Update linux-nat internal state when changing from one fork
192 to another. */
193void linux_nat_switch_fork (ptid_t new_ptid);
9f0bdab8
DJ
194
195/* Return the saved siginfo associated with PTID. */
196struct siginfo *linux_nat_get_siginfo (ptid_t ptid);
dc146f7c
VP
197
198/* Compute and return the processor core of a given thread. */
199int linux_nat_core_of_thread_1 (ptid_t ptid);
26ab7092
JK
200
201/* Set alternative SIGTRAP-like events recognizer. */
202void linux_nat_set_status_is_event (struct target_ops *t,
203 int (*status_is_event) (int status));
This page took 0.704597 seconds and 4 git commands to generate.