gdb/
[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 struct arch_lwp_info;
26
27 /* Ways to "resume" a thread. */
28
29 enum 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
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. */
44
45 struct 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
71 /* The last resume GDB requested on this thread. */
72 enum resume_kind last_resume_kind;
73
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
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
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
96 /* Non-zero if we expect a duplicated SIGINT. */
97 int ignore_sigint;
98
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
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
111 /* The processor core this LWP was last seen on. */
112 int core;
113
114 /* Arch-specific additions. */
115 struct arch_lwp_info *arch_private;
116
117 /* Next LWP in list. */
118 struct lwp_info *next;
119 };
120
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;
125
126 /* Iterate over each active thread (light-weight process). */
127 #define ALL_LWPS(LP) \
128 for ((LP) = lwp_list; \
129 (LP) != NULL; \
130 (LP) = (LP)->next)
131
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
137 /* Attempt to initialize libthread_db. */
138 void check_for_thread_db (void);
139
140 int thread_db_attach_lwp (ptid_t ptid);
141
142 /* Return the set of signals used by the threads library. */
143 extern void lin_thread_get_thread_signals (sigset_t *mask);
144
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);
148
149 /* linux-nat functions for handling fork events. */
150 extern void linux_enable_event_reporting (ptid_t ptid);
151
152 extern int lin_lwp_attach_lwp (ptid_t ptid);
153
154 extern void linux_stop_lwp (struct lwp_info *lwp);
155
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 *,
159 void *),
160 void *data);
161
162 /* Create a prototype generic GNU/Linux target. The client can
163 override it with local methods. */
164 struct target_ops * linux_target (void);
165
166 /* Create a generic GNU/Linux target using traditional
167 ptrace register access. */
168 struct target_ops *
169 linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
170
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 *);
174
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 *));
177
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. */
181 void linux_nat_set_siginfo_fixup (struct target_ops *,
182 int (*) (struct siginfo *,
183 gdb_byte *,
184 int));
185
186 /* Register a method to call prior to resuming a thread. */
187
188 void linux_nat_set_prepare_to_resume (struct target_ops *,
189 void (*) (struct lwp_info *));
190
191 /* Update linux-nat internal state when changing from one fork
192 to another. */
193 void linux_nat_switch_fork (ptid_t new_ptid);
194
195 /* Return the saved siginfo associated with PTID. */
196 struct siginfo *linux_nat_get_siginfo (ptid_t ptid);
197
198 /* Compute and return the processor core of a given thread. */
199 int linux_nat_core_of_thread_1 (ptid_t ptid);
200
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));
This page took 0.0342 seconds and 4 git commands to generate.