1 /* Native debugging support for GNU/Linux (LWP layer).
3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 2010, 2011 Free Software Foundation, Inc.
6 This file is part of GDB.
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.
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.
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/>. */
27 /* Ways to "resume" a thread. */
31 /* Thread should continue. */
34 /* Thread should single-step. */
37 /* Thread should be stopped. */
41 /* Structure describing an LWP. This is public only for the purposes
42 of ALL_LWPS; target-specific code should generally not access it
47 /* The process id of the LWP. This is a combination of the LWP id
48 and overall process id. */
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
56 /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
60 /* Non-zero if this LWP is stopped. */
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. */
71 /* The last resume GDB requested on this thread. */
72 enum resume_kind last_resume_kind
;
74 /* If non-zero, a pending wait status. */
77 /* Non-zero if we were stepping this LWP. */
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
;
84 /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data
86 int stopped_by_watchpoint
;
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
;
96 /* Non-zero if we expect a duplicated SIGINT. */
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
;
104 /* Signal wether we are in a SYSCALL_ENTRY or
105 in a SYSCALL_RETURN event.
107 - TARGET_WAITKIND_SYSCALL_ENTRY
108 - TARGET_WAITKIND_SYSCALL_RETURN */
111 /* The processor core this LWP was last seen on. */
114 /* Arch-specific additions. */
115 struct arch_lwp_info
*arch_private
;
117 /* Next LWP in list. */
118 struct lwp_info
*next
;
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. */
124 extern struct lwp_info
*lwp_list
;
126 /* Iterate over each active thread (light-weight process). */
127 #define ALL_LWPS(LP) \
128 for ((LP) = lwp_list; \
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)
137 /* Attempt to initialize libthread_db. */
138 void check_for_thread_db (void);
140 int thread_db_attach_lwp (ptid_t ptid
);
142 /* Return the set of signals used by the threads library. */
143 extern void lin_thread_get_thread_signals (sigset_t
*mask
);
145 /* Find process PID's pending signal set from /proc/pid/status. */
146 void linux_proc_pending_signals (int pid
, sigset_t
*pending
,
147 sigset_t
*blocked
, sigset_t
*ignored
);
149 /* linux-nat functions for handling fork events. */
150 extern void linux_enable_event_reporting (ptid_t ptid
);
152 extern int lin_lwp_attach_lwp (ptid_t ptid
);
154 extern void linux_stop_lwp (struct lwp_info
*lwp
);
156 /* Iterator function for lin-lwp's lwp list. */
157 struct lwp_info
*iterate_over_lwps (ptid_t filter
,
158 int (*callback
) (struct lwp_info
*,
162 /* Create a prototype generic GNU/Linux target. The client can
163 override it with local methods. */
164 struct target_ops
* linux_target (void);
166 /* Create a generic GNU/Linux target using traditional
167 ptrace register access. */
169 linux_trad_target (CORE_ADDR (*register_u_offset
)(struct gdbarch
*, int, int));
171 /* Register the customized GNU/Linux target. This should be used
172 instead of calling add_target directly. */
173 void linux_nat_add_target (struct target_ops
*);
175 /* Register a method to call whenever a new thread is attached. */
176 void linux_nat_set_new_thread (struct target_ops
*, void (*) (struct lwp_info
*));
178 /* Register a method that converts a siginfo object between the layout
179 that ptrace returns, and the layout in the architecture of the
181 void linux_nat_set_siginfo_fixup (struct target_ops
*,
182 int (*) (struct siginfo
*,
186 /* Register a method to call prior to resuming a thread. */
188 void linux_nat_set_prepare_to_resume (struct target_ops
*,
189 void (*) (struct lwp_info
*));
191 /* Update linux-nat internal state when changing from one fork
193 void linux_nat_switch_fork (ptid_t new_ptid
);
195 /* Return the saved siginfo associated with PTID. */
196 struct siginfo
*linux_nat_get_siginfo (ptid_t ptid
);
198 /* Compute and return the processor core of a given thread. */
199 int linux_nat_core_of_thread_1 (ptid_t ptid
);
201 /* Set alternative SIGTRAP-like events recognizer. */
202 void linux_nat_set_status_is_event (struct target_ops
*t
,
203 int (*status_is_event
) (int status
));