OLD | NEW |
1 /* Native debugging support for GNU/Linux (LWP layer). | 1 /* Native debugging support for GNU/Linux (LWP layer). |
2 | 2 |
3 Copyright (C) 2000-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2000-2013 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GDB. | 5 This file is part of GDB. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
19 | 19 |
20 #include "target.h" | 20 #include "target.h" |
21 | 21 |
22 #include <signal.h> | 22 #include <signal.h> |
23 | 23 |
24 struct arch_lwp_info; | 24 struct arch_lwp_info; |
25 | 25 |
26 /* Ways to "resume" a thread. */ | |
27 | |
28 enum resume_kind | |
29 { | |
30 /* Thread should continue. */ | |
31 resume_continue, | |
32 | |
33 /* Thread should single-step. */ | |
34 resume_step, | |
35 | |
36 /* Thread should be stopped. */ | |
37 resume_stop | |
38 }; | |
39 | |
40 /* Structure describing an LWP. This is public only for the purposes | 26 /* Structure describing an LWP. This is public only for the purposes |
41 of ALL_LWPS; target-specific code should generally not access it | 27 of ALL_LWPS; target-specific code should generally not access it |
42 directly. */ | 28 directly. */ |
43 | 29 |
44 struct lwp_info | 30 struct lwp_info |
45 { | 31 { |
46 /* The process id of the LWP. This is a combination of the LWP id | 32 /* The process id of the LWP. This is a combination of the LWP id |
47 and overall process id. */ | 33 and overall process id. */ |
48 ptid_t ptid; | 34 ptid_t ptid; |
49 | 35 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 there is always at least one LWP on the list while the GNU/Linux | 103 there is always at least one LWP on the list while the GNU/Linux |
118 native target is active. */ | 104 native target is active. */ |
119 extern struct lwp_info *lwp_list; | 105 extern struct lwp_info *lwp_list; |
120 | 106 |
121 /* Iterate over each active thread (light-weight process). */ | 107 /* Iterate over each active thread (light-weight process). */ |
122 #define ALL_LWPS(LP) \ | 108 #define ALL_LWPS(LP) \ |
123 for ((LP) = lwp_list; \ | 109 for ((LP) = lwp_list; \ |
124 (LP) != NULL; \ | 110 (LP) != NULL; \ |
125 (LP) = (LP)->next) | 111 (LP) = (LP)->next) |
126 | 112 |
127 #define GET_LWP(ptid) ptid_get_lwp (ptid) | |
128 #define GET_PID(ptid) ptid_get_pid (ptid) | |
129 #define is_lwp(ptid) (GET_LWP (ptid) != 0) | |
130 #define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) | |
131 | |
132 /* Attempt to initialize libthread_db. */ | 113 /* Attempt to initialize libthread_db. */ |
133 void check_for_thread_db (void); | 114 void check_for_thread_db (void); |
134 | 115 |
135 int thread_db_attach_lwp (ptid_t ptid); | 116 int thread_db_attach_lwp (ptid_t ptid); |
136 | 117 |
137 /* Return the set of signals used by the threads library. */ | 118 /* Return the set of signals used by the threads library. */ |
138 extern void lin_thread_get_thread_signals (sigset_t *mask); | 119 extern void lin_thread_get_thread_signals (sigset_t *mask); |
139 | 120 |
140 /* Find process PID's pending signal set from /proc/pid/status. */ | 121 /* Find process PID's pending signal set from /proc/pid/status. */ |
141 void linux_proc_pending_signals (int pid, sigset_t *pending, | 122 void linux_proc_pending_signals (int pid, sigset_t *pending, |
142 sigset_t *blocked, sigset_t *ignored); | 123 sigset_t *blocked, sigset_t *ignored); |
143 | 124 |
144 /* linux-nat functions for handling fork events. */ | |
145 extern void linux_enable_event_reporting (ptid_t ptid); | |
146 | |
147 extern int lin_lwp_attach_lwp (ptid_t ptid); | 125 extern int lin_lwp_attach_lwp (ptid_t ptid); |
148 | 126 |
149 extern void linux_stop_lwp (struct lwp_info *lwp); | 127 extern void linux_stop_lwp (struct lwp_info *lwp); |
150 | 128 |
151 /* Iterator function for lin-lwp's lwp list. */ | 129 /* Iterator function for lin-lwp's lwp list. */ |
152 struct lwp_info *iterate_over_lwps (ptid_t filter, | 130 struct lwp_info *iterate_over_lwps (ptid_t filter, |
153 int (*callback) (struct lwp_info *, | 131 int (*callback) (struct lwp_info *, |
154 void *), | 132 void *), |
155 void *data); | 133 void *data); |
156 | 134 |
157 typedef int (*linux_nat_iterate_watchpoint_lwps_ftype) (struct lwp_info *lwp, | |
158 void *arg); | |
159 | |
160 extern void linux_nat_iterate_watchpoint_lwps | |
161 (linux_nat_iterate_watchpoint_lwps_ftype callback, void *callback_data); | |
162 | |
163 /* Create a prototype generic GNU/Linux target. The client can | 135 /* Create a prototype generic GNU/Linux target. The client can |
164 override it with local methods. */ | 136 override it with local methods. */ |
165 struct target_ops * linux_target (void); | 137 struct target_ops * linux_target (void); |
166 | 138 |
167 /* Create a generic GNU/Linux target using traditional | 139 /* Create a generic GNU/Linux target using traditional |
168 ptrace register access. */ | 140 ptrace register access. */ |
169 struct target_ops * | 141 struct target_ops * |
170 linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int)); | 142 linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int)); |
171 | 143 |
172 /* Register the customized GNU/Linux target. This should be used | 144 /* Register the customized GNU/Linux target. This should be used |
173 instead of calling add_target directly. */ | 145 instead of calling add_target directly. */ |
174 void linux_nat_add_target (struct target_ops *); | 146 void linux_nat_add_target (struct target_ops *); |
175 | 147 |
176 /* Register a method to call whenever a new thread is attached. */ | 148 /* Register a method to call whenever a new thread is attached. */ |
177 void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *)
); | 149 void linux_nat_set_new_thread (struct target_ops *, void (*) (struct lwp_info *)
); |
178 | 150 |
| 151 |
| 152 /* Register a method to call whenever a new fork is attached. */ |
| 153 typedef void (linux_nat_new_fork_ftype) (struct lwp_info *parent, |
| 154 pid_t child_pid); |
| 155 void linux_nat_set_new_fork (struct target_ops *ops, |
| 156 linux_nat_new_fork_ftype *fn); |
| 157 |
| 158 /* Register a method to call whenever a process is killed or |
| 159 detached. */ |
| 160 typedef void (linux_nat_forget_process_ftype) (pid_t pid); |
| 161 void linux_nat_set_forget_process (struct target_ops *ops, |
| 162 linux_nat_forget_process_ftype *fn); |
| 163 |
| 164 /* Call the method registered with the function above. PID is the |
| 165 process to forget about. */ |
| 166 void linux_nat_forget_process (pid_t pid); |
| 167 |
179 /* Register a method that converts a siginfo object between the layout | 168 /* Register a method that converts a siginfo object between the layout |
180 that ptrace returns, and the layout in the architecture of the | 169 that ptrace returns, and the layout in the architecture of the |
181 inferior. */ | 170 inferior. */ |
182 void linux_nat_set_siginfo_fixup (struct target_ops *, | 171 void linux_nat_set_siginfo_fixup (struct target_ops *, |
183 int (*) (siginfo_t *, | 172 int (*) (siginfo_t *, |
184 gdb_byte *, | 173 gdb_byte *, |
185 int)); | 174 int)); |
186 | 175 |
187 /* Register a method to call prior to resuming a thread. */ | 176 /* Register a method to call prior to resuming a thread. */ |
188 | 177 |
189 void linux_nat_set_prepare_to_resume (struct target_ops *, | 178 void linux_nat_set_prepare_to_resume (struct target_ops *, |
190 void (*) (struct lwp_info *)); | 179 void (*) (struct lwp_info *)); |
191 | 180 |
192 /* Update linux-nat internal state when changing from one fork | 181 /* Update linux-nat internal state when changing from one fork |
193 to another. */ | 182 to another. */ |
194 void linux_nat_switch_fork (ptid_t new_ptid); | 183 void linux_nat_switch_fork (ptid_t new_ptid); |
195 | 184 |
196 /* Store the saved siginfo associated with PTID in *SIGINFO. | 185 /* Store the saved siginfo associated with PTID in *SIGINFO. |
197 Return 1 if it was retrieved successfully, 0 otherwise (*SIGINFO is | 186 Return 1 if it was retrieved successfully, 0 otherwise (*SIGINFO is |
198 uninitialized in such case). */ | 187 uninitialized in such case). */ |
199 int linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo); | 188 int linux_nat_get_siginfo (ptid_t ptid, siginfo_t *siginfo); |
200 | 189 |
201 /* Set alternative SIGTRAP-like events recognizer. */ | 190 /* Set alternative SIGTRAP-like events recognizer. */ |
202 void linux_nat_set_status_is_event (struct target_ops *t, | 191 void linux_nat_set_status_is_event (struct target_ops *t, |
203 int (*status_is_event) (int status)); | 192 int (*status_is_event) (int status)); |
OLD | NEW |