| 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-2013 Free Software Foundation, Inc. |
| 3 Inc. | |
| 4 | 3 |
| 5 This file is part of GDB. | 4 This file is part of GDB. |
| 6 | 5 |
| 7 This program is free software; you can redistribute it and/or modify | 6 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 | 7 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 | 8 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 9 (at your option) any later version. |
| 11 | 10 |
| 12 This program is distributed in the hope that it will be useful, | 11 This program is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 GNU General Public License for more details. | 14 GNU General Public License for more details. |
| 16 | 15 |
| 17 You should have received a copy of the GNU General Public License | 16 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/>. */ | 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 19 | 18 |
| 20 #ifdef HAVE_THREAD_DB_H | 19 #include "gdb_thread_db.h" |
| 21 #include <thread_db.h> | |
| 22 #endif | |
| 23 #include <signal.h> | 20 #include <signal.h> |
| 24 | 21 |
| 25 #include "gdbthread.h" | 22 #include "gdbthread.h" |
| 26 #include "gdb_proc_service.h" | 23 #include "gdb_proc_service.h" |
| 27 | 24 |
| 28 #define PTRACE_ARG3_TYPE void * | 25 /* Included for ptrace type definitions. */ |
| 29 #define PTRACE_ARG4_TYPE void * | 26 #include "linux-ptrace.h" |
| 27 |
| 30 #define PTRACE_XFER_TYPE long | 28 #define PTRACE_XFER_TYPE long |
| 31 | 29 |
| 32 #ifdef HAVE_LINUX_REGSETS | 30 #ifdef HAVE_LINUX_REGSETS |
| 33 typedef void (*regset_fill_func) (struct regcache *, void *); | 31 typedef void (*regset_fill_func) (struct regcache *, void *); |
| 34 typedef void (*regset_store_func) (struct regcache *, const void *); | 32 typedef void (*regset_store_func) (struct regcache *, const void *); |
| 35 enum regset_type { | 33 enum regset_type { |
| 36 GENERAL_REGS, | 34 GENERAL_REGS, |
| 37 FP_REGS, | 35 FP_REGS, |
| 38 EXTENDED_REGS, | 36 EXTENDED_REGS, |
| 39 }; | 37 }; |
| 40 | 38 |
| 41 struct regset_info | 39 struct regset_info |
| 42 { | 40 { |
| 43 int get_request, set_request; | 41 int get_request, set_request; |
| 44 /* If NT_TYPE isn't 0, it will be passed to ptrace as the 3rd | 42 /* If NT_TYPE isn't 0, it will be passed to ptrace as the 3rd |
| 45 argument and the 4th argument should be "const struct iovec *". */ | 43 argument and the 4th argument should be "const struct iovec *". */ |
| 46 int nt_type; | 44 int nt_type; |
| 47 int size; | 45 int size; |
| 48 enum regset_type type; | 46 enum regset_type type; |
| 49 regset_fill_func fill_function; | 47 regset_fill_func fill_function; |
| 50 regset_store_func store_function; | 48 regset_store_func store_function; |
| 51 }; | 49 }; |
| 52 extern struct regset_info target_regsets[]; | 50 |
| 51 /* Aggregation of all the supported regsets of a given |
| 52 architecture/mode. */ |
| 53 |
| 54 struct regsets_info |
| 55 { |
| 56 /* The regsets array. */ |
| 57 struct regset_info *regsets; |
| 58 |
| 59 /* The number of regsets in the REGSETS array. */ |
| 60 int num_regsets; |
| 61 |
| 62 /* If we get EIO on a regset, do not try it again. Note the set of |
| 63 supported regsets may depend on processor mode on biarch |
| 64 machines. This is a (lazily allocated) array holding one boolean |
| 65 byte (0/1) per regset, with each element corresponding to the |
| 66 regset in the REGSETS array above at the same offset. */ |
| 67 char *disabled_regsets; |
| 68 }; |
| 69 |
| 53 #endif | 70 #endif |
| 54 | 71 |
| 72 /* Mapping between the general-purpose registers in `struct user' |
| 73 format and GDB's register array layout. */ |
| 74 |
| 75 struct usrregs_info |
| 76 { |
| 77 /* The number of registers accessible. */ |
| 78 int num_regs; |
| 79 |
| 80 /* The registers map. */ |
| 81 int *regmap; |
| 82 }; |
| 83 |
| 84 /* All info needed to access an architecture/mode's registers. */ |
| 85 |
| 86 struct regs_info |
| 87 { |
| 88 /* Regset support bitmap: 1 for registers that are transferred as a part |
| 89 of a regset, 0 for ones that need to be handled individually. This |
| 90 can be NULL if all registers are transferred with regsets or regsets |
| 91 are not supported. */ |
| 92 unsigned char *regset_bitmap; |
| 93 |
| 94 /* Info used when accessing registers with PTRACE_PEEKUSER / |
| 95 PTRACE_POKEUSER. This can be NULL if all registers are |
| 96 transferred with regsets .*/ |
| 97 struct usrregs_info *usrregs; |
| 98 |
| 99 #ifdef HAVE_LINUX_REGSETS |
| 100 /* Info used when accessing registers with regsets. */ |
| 101 struct regsets_info *regsets_info; |
| 102 #endif |
| 103 }; |
| 104 |
| 55 struct process_info_private | 105 struct process_info_private |
| 56 { | 106 { |
| 57 /* Arch-specific additions. */ | 107 /* Arch-specific additions. */ |
| 58 struct arch_process_info *arch_private; | 108 struct arch_process_info *arch_private; |
| 59 | 109 |
| 60 /* libthread_db-specific additions. Not NULL if this process has loaded | 110 /* libthread_db-specific additions. Not NULL if this process has loaded |
| 61 thread_db, and it is active. */ | 111 thread_db, and it is active. */ |
| 62 struct thread_db *thread_db; | 112 struct thread_db *thread_db; |
| 63 | 113 |
| 64 /* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */ | 114 /* &_r_debug. 0 if not yet determined. -1 if no PT_DYNAMIC in Phdrs. */ |
| 65 CORE_ADDR r_debug; | 115 CORE_ADDR r_debug; |
| 116 |
| 117 /* This flag is true iff we've just created or attached to the first |
| 118 LWP of this process but it has not stopped yet. As soon as it |
| 119 does, we need to call the low target's arch_setup callback. */ |
| 120 int new_inferior; |
| 66 }; | 121 }; |
| 67 | 122 |
| 68 struct lwp_info; | 123 struct lwp_info; |
| 69 | 124 |
| 70 struct linux_target_ops | 125 struct linux_target_ops |
| 71 { | 126 { |
| 72 /* Architecture-specific setup. */ | 127 /* Architecture-specific setup. */ |
| 73 void (*arch_setup) (void); | 128 void (*arch_setup) (void); |
| 74 | 129 |
| 75 int num_regs; | 130 const struct regs_info *(*regs_info) (void); |
| 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; | |
| 83 int (*cannot_fetch_register) (int); | 131 int (*cannot_fetch_register) (int); |
| 84 | 132 |
| 85 /* Returns 0 if we can store the register, 1 if we can not | 133 /* Returns 0 if we can store the register, 1 if we can not |
| 86 store the register, and 2 if failure to store the register | 134 store the register, and 2 if failure to store the register |
| 87 is acceptable. */ | 135 is acceptable. */ |
| 88 int (*cannot_store_register) (int); | 136 int (*cannot_store_register) (int); |
| 89 | 137 |
| 90 /* Hook to fetch a register in some non-standard way. Used for | 138 /* Hook to fetch a register in some non-standard way. Used for |
| 91 example by backends that have read-only registers with hardcoded | 139 example by backends that have read-only registers with hardcoded |
| 92 values (e.g., IA64's gr0/fr0/fr1). Returns true if register | 140 values (e.g., IA64's gr0/fr0/fr1). Returns true if register |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 char *err); | 210 char *err); |
| 163 | 211 |
| 164 /* Return the bytecode operations vector for the current inferior. | 212 /* Return the bytecode operations vector for the current inferior. |
| 165 Returns NULL if bytecode compilation is not supported. */ | 213 Returns NULL if bytecode compilation is not supported. */ |
| 166 struct emit_ops *(*emit_ops) (void); | 214 struct emit_ops *(*emit_ops) (void); |
| 167 | 215 |
| 168 /* Return the minimum length of an instruction that can be safely overwritten | 216 /* Return the minimum length of an instruction that can be safely overwritten |
| 169 for use as a fast tracepoint. */ | 217 for use as a fast tracepoint. */ |
| 170 int (*get_min_fast_tracepoint_insn_len) (void); | 218 int (*get_min_fast_tracepoint_insn_len) (void); |
| 171 | 219 |
| 220 /* Returns true if the low target supports range stepping. */ |
| 221 int (*supports_range_stepping) (void); |
| 172 }; | 222 }; |
| 173 | 223 |
| 174 extern struct linux_target_ops the_low_target; | 224 extern struct linux_target_ops the_low_target; |
| 175 | 225 |
| 176 #define ptid_of(proc) ((proc)->head.id) | 226 #define ptid_of(proc) ((proc)->head.id) |
| 177 #define pid_of(proc) ptid_get_pid ((proc)->head.id) | 227 #define pid_of(proc) ptid_get_pid ((proc)->head.id) |
| 178 #define lwpid_of(proc) ptid_get_lwp ((proc)->head.id) | 228 #define lwpid_of(proc) ptid_get_lwp ((proc)->head.id) |
| 179 | 229 |
| 180 #define get_lwp(inf) ((struct lwp_info *)(inf)) | 230 #define get_lwp(inf) ((struct lwp_info *)(inf)) |
| 181 #define get_thread_lwp(thr) (get_lwp (inferior_target_data (thr))) | 231 #define get_thread_lwp(thr) (get_lwp (inferior_target_data (thr))) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 CORE_ADDR stopped_data_address; | 281 CORE_ADDR stopped_data_address; |
| 232 | 282 |
| 233 /* If this is non-zero, it is a breakpoint to be reinserted at our next | 283 /* If this is non-zero, it is a breakpoint to be reinserted at our next |
| 234 stop (SIGTRAP stops only). */ | 284 stop (SIGTRAP stops only). */ |
| 235 CORE_ADDR bp_reinsert; | 285 CORE_ADDR bp_reinsert; |
| 236 | 286 |
| 237 /* If this flag is set, the last continue operation at the ptrace | 287 /* If this flag is set, the last continue operation at the ptrace |
| 238 level on this process was a single-step. */ | 288 level on this process was a single-step. */ |
| 239 int stepping; | 289 int stepping; |
| 240 | 290 |
| 291 /* Range to single step within. This is a copy of the step range |
| 292 passed along the last resume request. See 'struct |
| 293 thread_resume'. */ |
| 294 CORE_ADDR step_range_start; /* Inclusive */ |
| 295 CORE_ADDR step_range_end; /* Exclusive */ |
| 296 |
| 241 /* If this flag is set, we need to set the event request flags the | 297 /* If this flag is set, we need to set the event request flags the |
| 242 next time we see this LWP stop. */ | 298 next time we see this LWP stop. */ |
| 243 int must_set_ptrace_flags; | 299 int must_set_ptrace_flags; |
| 244 | 300 |
| 245 /* If this is non-zero, it points to a chain of signals which need to | 301 /* If this is non-zero, it points to a chain of signals which need to |
| 246 be delivered to this process. */ | 302 be delivered to this process. */ |
| 247 struct pending_signals *pending_signals; | 303 struct pending_signals *pending_signals; |
| 248 | 304 |
| 249 /* A link used when resuming. It is initialized from the resume request, | 305 /* A link used when resuming. It is initialized from the resume request, |
| 250 and then processed and cleared in linux_resume_one_lwp. */ | 306 and then processed and cleared in linux_resume_one_lwp. */ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 263 struct pending_signals *pending_signals_to_report; | 319 struct pending_signals *pending_signals_to_report; |
| 264 | 320 |
| 265 /* When collecting_fast_tracepoint is first found to be 1, we insert | 321 /* When collecting_fast_tracepoint is first found to be 1, we insert |
| 266 a exit-jump-pad-quickly breakpoint. This is it. */ | 322 a exit-jump-pad-quickly breakpoint. This is it. */ |
| 267 struct breakpoint *exit_jump_pad_bkpt; | 323 struct breakpoint *exit_jump_pad_bkpt; |
| 268 | 324 |
| 269 /* True if the LWP was seen stop at an internal breakpoint and needs | 325 /* True if the LWP was seen stop at an internal breakpoint and needs |
| 270 stepping over later when it is resumed. */ | 326 stepping over later when it is resumed. */ |
| 271 int need_step_over; | 327 int need_step_over; |
| 272 | 328 |
| 329 #ifdef USE_THREAD_DB |
| 273 int thread_known; | 330 int thread_known; |
| 274 #ifdef HAVE_THREAD_DB_H | |
| 275 /* The thread handle, used for e.g. TLS access. Only valid if | 331 /* The thread handle, used for e.g. TLS access. Only valid if |
| 276 THREAD_KNOWN is set. */ | 332 THREAD_KNOWN is set. */ |
| 277 td_thrhandle_t th; | 333 td_thrhandle_t th; |
| 278 #endif | 334 #endif |
| 279 | 335 |
| 280 /* Arch-specific additions. */ | 336 /* Arch-specific additions. */ |
| 281 struct arch_lwp_info *arch_private; | 337 struct arch_lwp_info *arch_private; |
| 282 }; | 338 }; |
| 283 | 339 |
| 284 extern struct inferior_list all_lwps; | 340 extern struct inferior_list all_lwps; |
| 285 | 341 |
| 286 int linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine); | 342 int linux_pid_exe_is_elf_64_file (int pid, unsigned int *machine); |
| 287 | 343 |
| 288 void linux_attach_lwp (unsigned long pid); | 344 void linux_attach_lwp (unsigned long pid); |
| 289 struct lwp_info *find_lwp_pid (ptid_t ptid); | 345 struct lwp_info *find_lwp_pid (ptid_t ptid); |
| 290 void linux_stop_lwp (struct lwp_info *lwp); | 346 void linux_stop_lwp (struct lwp_info *lwp); |
| 291 | 347 |
| 348 #ifdef HAVE_LINUX_REGSETS |
| 349 void initialize_regsets_info (struct regsets_info *regsets_info); |
| 350 #endif |
| 351 |
| 352 void initialize_low_arch (void); |
| 353 |
| 292 /* From thread-db.c */ | 354 /* From thread-db.c */ |
| 293 int thread_db_init (int use_events); | 355 int thread_db_init (int use_events); |
| 294 void thread_db_detach (struct process_info *); | 356 void thread_db_detach (struct process_info *); |
| 295 void thread_db_mourn (struct process_info *); | 357 void thread_db_mourn (struct process_info *); |
| 296 int thread_db_handle_monitor_command (char *); | 358 int thread_db_handle_monitor_command (char *); |
| 297 int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, | 359 int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, |
| 298 CORE_ADDR load_module, CORE_ADDR *address); | 360 CORE_ADDR load_module, CORE_ADDR *address); |
| 299 int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp); | 361 int thread_db_look_up_one_symbol (const char *name, CORE_ADDR *addrp); |
| OLD | NEW |