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