OLD | NEW |
1 /* Internal interfaces for the GNU/Linux specific target code for gdbserver. | 1 /* Internal interfaces for the GNU/Linux specific target code for gdbserver. |
2 Copyright (C) 2002, 2004-2005, 2007-2012 Free Software Foundation, | 2 Copyright (C) 2002, 2004-2005, 2007-2012 Free Software Foundation, |
3 Inc. | 3 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 #ifdef HAVE_THREAD_DB_H | 20 #ifdef HAVE_THREAD_DB_H |
21 #include <thread_db.h> | 21 #include <thread_db.h> |
22 #endif | 22 #endif |
| 23 #include <signal.h> |
23 | 24 |
| 25 #include "gdbthread.h" |
24 #include "gdb_proc_service.h" | 26 #include "gdb_proc_service.h" |
25 | 27 |
| 28 #define PTRACE_ARG3_TYPE void * |
| 29 #define PTRACE_ARG4_TYPE void * |
| 30 #define PTRACE_XFER_TYPE long |
| 31 |
26 #ifdef HAVE_LINUX_REGSETS | 32 #ifdef HAVE_LINUX_REGSETS |
27 typedef void (*regset_fill_func) (struct regcache *, void *); | 33 typedef void (*regset_fill_func) (struct regcache *, void *); |
28 typedef void (*regset_store_func) (struct regcache *, const void *); | 34 typedef void (*regset_store_func) (struct regcache *, const void *); |
29 enum regset_type { | 35 enum regset_type { |
30 GENERAL_REGS, | 36 GENERAL_REGS, |
31 FP_REGS, | 37 FP_REGS, |
32 EXTENDED_REGS, | 38 EXTENDED_REGS, |
33 }; | 39 }; |
34 | 40 |
35 struct regset_info | 41 struct regset_info |
36 { | 42 { |
37 int get_request, set_request; | 43 int get_request, set_request; |
38 /* If NT_TYPE isn't 0, it will be passed to ptrace as the 3rd | 44 /* If NT_TYPE isn't 0, it will be passed to ptrace as the 3rd |
39 argument and the 4th argument should be "const struct iovec *". */ | 45 argument and the 4th argument should be "const struct iovec *". */ |
40 int nt_type; | 46 int nt_type; |
41 int size; | 47 int size; |
42 enum regset_type type; | 48 enum regset_type type; |
43 regset_fill_func fill_function; | 49 regset_fill_func fill_function; |
44 regset_store_func store_function; | 50 regset_store_func store_function; |
45 }; | 51 }; |
46 extern struct regset_info target_regsets[]; | 52 extern struct regset_info target_regsets[]; |
47 #endif | 53 #endif |
48 | 54 |
49 struct siginfo; | |
50 | |
51 struct process_info_private | 55 struct process_info_private |
52 { | 56 { |
53 /* Arch-specific additions. */ | 57 /* Arch-specific additions. */ |
54 struct arch_process_info *arch_private; | 58 struct arch_process_info *arch_private; |
55 | 59 |
56 /* libthread_db-specific additions. Not NULL if this process has loaded | 60 /* libthread_db-specific additions. Not NULL if this process has loaded |
57 thread_db, and it is active. */ | 61 thread_db, and it is active. */ |
58 struct thread_db *thread_db; | 62 struct thread_db *thread_db; |
59 | 63 |
60 /* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */ | 64 /* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */ |
61 CORE_ADDR r_debug; | 65 CORE_ADDR r_debug; |
62 }; | 66 }; |
63 | 67 |
64 struct lwp_info; | 68 struct lwp_info; |
65 | 69 |
66 struct linux_target_ops | 70 struct linux_target_ops |
67 { | 71 { |
68 /* Architecture-specific setup. */ | 72 /* Architecture-specific setup. */ |
69 void (*arch_setup) (void); | 73 void (*arch_setup) (void); |
70 | 74 |
71 int num_regs; | 75 int num_regs; |
72 int *regmap; | 76 int *regmap; |
| 77 |
| 78 /* Regset support bitmap: 1 for registers that are transferred as a part |
| 79 of a regset, 0 for ones that need to be handled individually. This |
| 80 can be NULL if all registers are transferred with regsets or regsets |
| 81 are not supported. */ |
| 82 unsigned char *regset_bitmap; |
73 int (*cannot_fetch_register) (int); | 83 int (*cannot_fetch_register) (int); |
74 | 84 |
75 /* Returns 0 if we can store the register, 1 if we can not | 85 /* Returns 0 if we can store the register, 1 if we can not |
76 store the register, and 2 if failure to store the register | 86 store the register, and 2 if failure to store the register |
77 is acceptable. */ | 87 is acceptable. */ |
78 int (*cannot_store_register) (int); | 88 int (*cannot_store_register) (int); |
| 89 |
| 90 /* Hook to fetch a register in some non-standard way. Used for |
| 91 example by backends that have read-only registers with hardcoded |
| 92 values (e.g., IA64's gr0/fr0/fr1). Returns true if register |
| 93 REGNO was supplied, false if not, and we should fallback to the |
| 94 standard ptrace methods. */ |
| 95 int (*fetch_register) (struct regcache *regcache, int regno); |
| 96 |
79 CORE_ADDR (*get_pc) (struct regcache *regcache); | 97 CORE_ADDR (*get_pc) (struct regcache *regcache); |
80 void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); | 98 void (*set_pc) (struct regcache *regcache, CORE_ADDR newpc); |
81 const unsigned char *breakpoint; | 99 const unsigned char *breakpoint; |
82 int breakpoint_len; | 100 int breakpoint_len; |
83 CORE_ADDR (*breakpoint_reinsert_addr) (void); | 101 CORE_ADDR (*breakpoint_reinsert_addr) (void); |
84 | 102 |
85 int decr_pc_after_break; | 103 int decr_pc_after_break; |
86 int (*breakpoint_at) (CORE_ADDR pc); | 104 int (*breakpoint_at) (CORE_ADDR pc); |
87 | 105 |
88 /* Breakpoint and watchpoint related functions. See target.h for | 106 /* Breakpoint and watchpoint related functions. See target.h for |
89 comments. */ | 107 comments. */ |
90 int (*insert_point) (char type, CORE_ADDR addr, int len); | 108 int (*insert_point) (char type, CORE_ADDR addr, int len); |
91 int (*remove_point) (char type, CORE_ADDR addr, int len); | 109 int (*remove_point) (char type, CORE_ADDR addr, int len); |
92 int (*stopped_by_watchpoint) (void); | 110 int (*stopped_by_watchpoint) (void); |
93 CORE_ADDR (*stopped_data_address) (void); | 111 CORE_ADDR (*stopped_data_address) (void); |
94 | 112 |
95 /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular | 113 /* Hooks to reformat register data for PEEKUSR/POKEUSR (in particular |
96 for registers smaller than an xfer unit). */ | 114 for registers smaller than an xfer unit). */ |
97 void (*collect_ptrace_register) (struct regcache *regcache, | 115 void (*collect_ptrace_register) (struct regcache *regcache, |
98 int regno, char *buf); | 116 int regno, char *buf); |
99 void (*supply_ptrace_register) (struct regcache *regcache, | 117 void (*supply_ptrace_register) (struct regcache *regcache, |
100 int regno, const char *buf); | 118 int regno, const char *buf); |
101 | 119 |
102 /* Hook to convert from target format to ptrace format and back. | 120 /* Hook to convert from target format to ptrace format and back. |
103 Returns true if any conversion was done; false otherwise. | 121 Returns true if any conversion was done; false otherwise. |
104 If DIRECTION is 1, then copy from INF to NATIVE. | 122 If DIRECTION is 1, then copy from INF to NATIVE. |
105 If DIRECTION is 0, copy from NATIVE to INF. */ | 123 If DIRECTION is 0, copy from NATIVE to INF. */ |
106 int (*siginfo_fixup) (struct siginfo *native, void *inf, int direction); | 124 int (*siginfo_fixup) (siginfo_t *native, void *inf, int direction); |
107 | 125 |
108 /* Hook to call when a new process is created or attached to. | 126 /* Hook to call when a new process is created or attached to. |
109 If extra per-process architecture-specific data is needed, | 127 If extra per-process architecture-specific data is needed, |
110 allocate it here. */ | 128 allocate it here. */ |
111 struct arch_process_info * (*new_process) (void); | 129 struct arch_process_info * (*new_process) (void); |
112 | 130 |
113 /* Hook to call when a new thread is detected. | 131 /* Hook to call when a new thread is detected. |
114 If extra per-thread architecture-specific data is needed, | 132 If extra per-thread architecture-specific data is needed, |
115 allocate it here. */ | 133 allocate it here. */ |
116 struct arch_lwp_info * (*new_thread) (void); | 134 struct arch_lwp_info * (*new_thread) (void); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 THREAD_KNOWN is set. */ | 276 THREAD_KNOWN is set. */ |
259 td_thrhandle_t th; | 277 td_thrhandle_t th; |
260 #endif | 278 #endif |
261 | 279 |
262 /* Arch-specific additions. */ | 280 /* Arch-specific additions. */ |
263 struct arch_lwp_info *arch_private; | 281 struct arch_lwp_info *arch_private; |
264 }; | 282 }; |
265 | 283 |
266 extern struct inferior_list all_lwps; | 284 extern struct inferior_list all_lwps; |
267 | 285 |
268 char *linux_child_pid_to_exec_file (int pid); | 286 int linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine); |
269 int elf_64_file_p (const char *file); | |
270 | 287 |
271 void linux_attach_lwp (unsigned long pid); | 288 void linux_attach_lwp (unsigned long pid); |
272 struct lwp_info *find_lwp_pid (ptid_t ptid); | 289 struct lwp_info *find_lwp_pid (ptid_t ptid); |
273 void linux_stop_lwp (struct lwp_info *lwp); | 290 void linux_stop_lwp (struct lwp_info *lwp); |
274 | 291 |
275 /* From thread-db.c */ | 292 /* From thread-db.c */ |
276 int thread_db_init (int use_events); | 293 int thread_db_init (int use_events); |
277 void thread_db_detach (struct process_info *); | 294 void thread_db_detach (struct process_info *); |
278 void thread_db_mourn (struct process_info *); | 295 void thread_db_mourn (struct process_info *); |
279 int thread_db_handle_monitor_command (char *); | 296 int thread_db_handle_monitor_command (char *); |
280 int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, | 297 int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, |
281 CORE_ADDR load_module, CORE_ADDR *address); | 298 CORE_ADDR load_module, CORE_ADDR *address); |
282 int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp); | 299 int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp); |
OLD | NEW |