Commit | Line | Data |
---|---|---|
58caa3dc | 1 | /* Internal interfaces for the GNU/Linux specific target code for gdbserver. |
9b254dd1 | 2 | Copyright (C) 2002, 2004, 2005, 2007, 2008 Free Software Foundation, Inc. |
58caa3dc DJ |
3 | |
4 | This file is part of GDB. | |
5 | ||
6 | This program is free software; you can redistribute it and/or modify | |
7 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 8 | the Free Software Foundation; either version 3 of the License, or |
58caa3dc DJ |
9 | (at your option) any later version. |
10 | ||
11 | This program is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
58caa3dc | 18 | |
dae5f5cf DJ |
19 | #ifdef HAVE_THREAD_DB_H |
20 | #include <thread_db.h> | |
21 | #endif | |
22 | ||
58caa3dc | 23 | #ifdef HAVE_LINUX_REGSETS |
0d62e5e8 DJ |
24 | typedef void (*regset_fill_func) (void *); |
25 | typedef void (*regset_store_func) (const void *); | |
26 | enum regset_type { | |
27 | GENERAL_REGS, | |
28 | FP_REGS, | |
29 | EXTENDED_REGS, | |
30 | }; | |
31 | ||
58caa3dc DJ |
32 | struct regset_info |
33 | { | |
34 | int get_request, set_request; | |
35 | int size; | |
0d62e5e8 DJ |
36 | enum regset_type type; |
37 | regset_fill_func fill_function; | |
38 | regset_store_func store_function; | |
58caa3dc DJ |
39 | }; |
40 | extern struct regset_info target_regsets[]; | |
41 | #endif | |
2ec06d2e DJ |
42 | |
43 | struct linux_target_ops | |
44 | { | |
d05b4ac3 UW |
45 | /* Architecture-specific setup. */ |
46 | void (*arch_setup) (void); | |
47 | ||
2ec06d2e DJ |
48 | int num_regs; |
49 | int *regmap; | |
50 | int (*cannot_fetch_register) (int); | |
bc1e36ca DJ |
51 | |
52 | /* Returns 0 if we can store the register, 1 if we can not | |
53 | store the register, and 2 if failure to store the register | |
54 | is acceptable. */ | |
2ec06d2e | 55 | int (*cannot_store_register) (int); |
0d62e5e8 | 56 | CORE_ADDR (*get_pc) (void); |
611cb4a5 | 57 | void (*set_pc) (CORE_ADDR newpc); |
f450004a | 58 | const unsigned char *breakpoint; |
611cb4a5 DJ |
59 | int breakpoint_len; |
60 | CORE_ADDR (*breakpoint_reinsert_addr) (void); | |
0d62e5e8 DJ |
61 | |
62 | ||
63 | int decr_pc_after_break; | |
64 | int (*breakpoint_at) (CORE_ADDR pc); | |
e013ee27 OF |
65 | |
66 | /* Watchpoint related functions. See target.h for comments. */ | |
67 | int (*insert_watchpoint) (char type, CORE_ADDR addr, int len); | |
68 | int (*remove_watchpoint) (char type, CORE_ADDR addr, int len); | |
69 | int (*stopped_by_watchpoint) (void); | |
70 | CORE_ADDR (*stopped_data_address) (void); | |
71 | ||
ee1a7ae4 UW |
72 | /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular |
73 | for registers smaller than an xfer unit). */ | |
74 | void (*collect_ptrace_register) (int regno, char *buf); | |
75 | void (*supply_ptrace_register) (int regno, const char *buf); | |
23181151 DJ |
76 | |
77 | /* What string to report to GDB when it asks for the architecture, | |
78 | or NULL not to answer. */ | |
79 | const char *arch_string; | |
2ec06d2e DJ |
80 | }; |
81 | ||
82 | extern struct linux_target_ops the_low_target; | |
0d62e5e8 DJ |
83 | |
84 | #define get_process(inf) ((struct process_info *)(inf)) | |
85 | #define get_thread_process(thr) (get_process (inferior_target_data (thr))) | |
86 | #define get_process_thread(proc) ((struct thread_info *) \ | |
87 | find_inferior_id (&all_threads, \ | |
24a09b5f | 88 | get_process (proc)->lwpid)) |
0d62e5e8 DJ |
89 | |
90 | struct process_info | |
91 | { | |
92 | struct inferior_list_entry head; | |
a1928bad | 93 | unsigned long lwpid; |
0d62e5e8 | 94 | |
ae13219e DJ |
95 | /* If this flag is set, the next SIGSTOP will be ignored (the |
96 | process will be immediately resumed). This means that either we | |
97 | sent the SIGSTOP to it ourselves and got some other pending event | |
98 | (so the SIGSTOP is still pending), or that we stopped the | |
99 | inferior implicitly via PTRACE_ATTACH and have not waited for it | |
100 | yet. */ | |
0d62e5e8 DJ |
101 | int stop_expected; |
102 | ||
103 | /* If this flag is set, the process is known to be stopped right now (stop | |
104 | event already received in a wait()). */ | |
105 | int stopped; | |
106 | ||
32ca6d61 DJ |
107 | /* When stopped is set, the last wait status recorded for this process. */ |
108 | int last_status; | |
109 | ||
0d62e5e8 DJ |
110 | /* If this flag is set, STATUS_PENDING is a waitstatus that has not yet |
111 | been reported. */ | |
112 | int status_pending_p; | |
113 | int status_pending; | |
114 | ||
115 | /* If this flag is set, the pending status is a (GDB-placed) breakpoint. */ | |
116 | int pending_is_breakpoint; | |
117 | CORE_ADDR pending_stop_pc; | |
118 | ||
119 | /* If this is non-zero, it is a breakpoint to be reinserted at our next | |
120 | stop (SIGTRAP stops only). */ | |
121 | CORE_ADDR bp_reinsert; | |
122 | ||
123 | /* If this flag is set, the last continue operation on this process | |
124 | was a single-step. */ | |
125 | int stepping; | |
126 | ||
127 | /* If this is non-zero, it points to a chain of signals which need to | |
128 | be delivered to this process. */ | |
129 | struct pending_signals *pending_signals; | |
5544ad89 DJ |
130 | |
131 | /* A link used when resuming. It is initialized from the resume request, | |
132 | and then processed and cleared in linux_resume_one_process. */ | |
133 | ||
134 | struct thread_resume *resume; | |
dae5f5cf | 135 | |
24a09b5f DJ |
136 | int thread_known; |
137 | unsigned long tid; | |
dae5f5cf | 138 | #ifdef HAVE_THREAD_DB_H |
24a09b5f DJ |
139 | /* The thread handle, used for e.g. TLS access. Only valid if |
140 | THREAD_KNOWN is set. */ | |
dae5f5cf DJ |
141 | td_thrhandle_t th; |
142 | #endif | |
0d62e5e8 | 143 | }; |
5544ad89 | 144 | |
0d62e5e8 DJ |
145 | extern struct inferior_list all_processes; |
146 | ||
24a09b5f | 147 | void linux_attach_lwp (unsigned long pid); |
0d62e5e8 | 148 | |
24a09b5f | 149 | int thread_db_init (int use_events); |
dae5f5cf DJ |
150 | int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, |
151 | CORE_ADDR load_module, CORE_ADDR *address); |