*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / linux-nat.h
CommitLineData
0274a8ce 1/* Native debugging support for GNU/Linux (LWP layer).
10d6c8cd 2
0fb0cc75 3 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
10d6c8cd 4 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
25/* Structure describing an LWP. This is public only for the purposes
26 of ALL_LWPS; target-specific code should generally not access it
27 directly. */
0274a8ce
MS
28
29struct lwp_info
30{
31 /* The process id of the LWP. This is a combination of the LWP id
32 and overall process id. */
33 ptid_t ptid;
34
35 /* Non-zero if this LWP is cloned. In this context "cloned" means
36 that the LWP is reporting to its parent using a signal other than
37 SIGCHLD. */
38 int cloned;
39
40 /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report
41 it back yet). */
42 int signalled;
43
44 /* Non-zero if this LWP is stopped. */
45 int stopped;
46
47 /* Non-zero if this LWP will be/has been resumed. Note that an LWP
48 can be marked both as stopped and resumed at the same time. This
49 happens if we try to resume an LWP that has a wait status
50 pending. We shouldn't let the LWP run until that wait status has
51 been processed, but we should not report that wait status if GDB
52 didn't try to let the LWP run. */
53 int resumed;
54
55 /* If non-zero, a pending wait status. */
56 int status;
57
58 /* Non-zero if we were stepping this LWP. */
59 int step;
60
9f0bdab8
DJ
61 /* Non-zero si_signo if this LWP stopped with a trap. si_addr may
62 be the address of a hardware watchpoint. */
63 struct siginfo siginfo;
64
57380f4e
DJ
65 /* Non-zero if we expect a duplicated SIGINT. */
66 int ignore_sigint;
67
a2f23071
DJ
68 /* If WAITSTATUS->KIND != TARGET_WAITKIND_SPURIOUS, the waitstatus
69 for this LWP's last event. This may correspond to STATUS above,
70 or to a local variable in lin_lwp_wait. */
71 struct target_waitstatus waitstatus;
72
a96d9b2e
SDJ
73 /* Signal wether we are in a SYSCALL_ENTRY or
74 in a SYSCALL_RETURN event.
75 Values:
76 - TARGET_WAITKIND_SYSCALL_ENTRY
77 - TARGET_WAITKIND_SYSCALL_RETURN */
78 int syscall_state;
79
0274a8ce
MS
80 /* Next LWP in list. */
81 struct lwp_info *next;
82};
83
9f0bdab8
DJ
84/* The global list of LWPs, for ALL_LWPS. Unlike the threads list,
85 there is always at least one LWP on the list while the GNU/Linux
86 native target is active. */
87extern struct lwp_info *lwp_list;
88
89/* Iterate over the PTID each active thread (light-weight process). There
90 must be at least one. */
91#define ALL_LWPS(LP, PTID) \
92 for ((LP) = lwp_list, (PTID) = (LP)->ptid; \
93 (LP) != NULL; \
94 (LP) = (LP)->next, (PTID) = (LP) ? (LP)->ptid : (PTID))
95
17faa917
DJ
96#define GET_LWP(ptid) ptid_get_lwp (ptid)
97#define GET_PID(ptid) ptid_get_pid (ptid)
98#define is_lwp(ptid) (GET_LWP (ptid) != 0)
99#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0)
100
0ec9a092
DJ
101/* Attempt to initialize libthread_db. */
102void check_for_thread_db (void);
0274a8ce 103
4c28f408
PA
104int thread_db_attach_lwp (ptid_t ptid);
105
bfb39158
DJ
106/* Find process PID's pending signal set from /proc/pid/status. */
107void linux_proc_pending_signals (int pid, sigset_t *pending, sigset_t *blocked, sigset_t *ignored);
108
4d062f1a
PA
109/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not
110 found. */
111extern int linux_proc_get_tgid (int lwpid);
112
4de4c07c 113/* linux-nat functions for handling fork events. */
4de4c07c 114extern void linux_enable_event_reporting (ptid_t ptid);
0274a8ce 115
93815fbf 116extern int lin_lwp_attach_lwp (ptid_t ptid);
9ee57c33 117
0274a8ce 118/* Iterator function for lin-lwp's lwp list. */
d90e17a7
PA
119struct lwp_info *iterate_over_lwps (ptid_t filter,
120 int (*callback) (struct lwp_info *,
0274a8ce
MS
121 void *),
122 void *data);
10d6c8cd 123
155bd5d1
AC
124/* Create a prototype generic GNU/Linux target. The client can
125 override it with local methods. */
10d6c8cd 126struct target_ops * linux_target (void);
f973ed9c 127
910122bf
UW
128/* Create a generic GNU/Linux target using traditional
129 ptrace register access. */
130struct target_ops *
7714d83a 131linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int));
910122bf 132
155bd5d1 133/* Register the customized GNU/Linux target. This should be used
f973ed9c
DJ
134 instead of calling add_target directly. */
135void linux_nat_add_target (struct target_ops *);
136
9f0bdab8
DJ
137/* Register a method to call whenever a new thread is attached. */
138void linux_nat_set_new_thread (struct target_ops *, void (*) (ptid_t));
139
5b009018
PA
140/* Register a method that converts a siginfo object between the layout
141 that ptrace returns, and the layout in the architecture of the
142 inferior. */
143void linux_nat_set_siginfo_fixup (struct target_ops *,
144 int (*) (struct siginfo *,
145 gdb_byte *,
146 int));
147
f973ed9c
DJ
148/* Update linux-nat internal state when changing from one fork
149 to another. */
150void linux_nat_switch_fork (ptid_t new_ptid);
9f0bdab8
DJ
151
152/* Return the saved siginfo associated with PTID. */
153struct siginfo *linux_nat_get_siginfo (ptid_t ptid);
This page took 0.483807 seconds and 4 git commands to generate.