From: Jason Thorpe Date: Fri, 26 Apr 2002 01:08:19 +0000 (+0000) Subject: * alpha-tdep.h (gdbarch_tdep): Add jb_pc and jb_elt_size members. X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=accc6d1ff368635135fb961397da748a4505008c;p=deliverable%2Fbinutils-gdb.git * alpha-tdep.h (gdbarch_tdep): Add jb_pc and jb_elt_size members. * alpha-linux-tdep.c (alpha_linux_init_abi): Initialize tdep->jb_pc and tdep->jb_elt_size. * alpha-osf1-tdep.c (alpha_osf1_init_abi): Likewise. * alphafbsd-tdep.c (alphafbsd_init_abi): Likewise. * alphanbsd-tdep.c (alphanbsd_init_abi): Likewise. * alpha-nat.c (get_longjmp_target): Remove. (JB_ELEMENT_SIZE): Ditto. (JB_PC): Ditto. * alpha-tdep.c (alpha_get_longjmp_target): New function. (alpha_gdbarch_init): Default tdep->jb_pc to -1. If the OS ABI sets jb_pc to a valid value, set gdbarch_get_longjmp_target to alpha_get_longjmp_target. (alpha_dump_tdep): Report tdep->jb_pc and tdep->jb_elt_size. * config/alpha/nm-linux.h (GET_LONGJMP_TARGET): Remove. * config/alpha/nm-osf.h (GET_LONGJMP_TARGET): Remove. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aa51e97ceb..d4078a345a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,22 @@ +2002-04-25 Jason Thorpe + + * alpha-tdep.h (gdbarch_tdep): Add jb_pc and jb_elt_size members. + * alpha-linux-tdep.c (alpha_linux_init_abi): Initialize + tdep->jb_pc and tdep->jb_elt_size. + * alpha-osf1-tdep.c (alpha_osf1_init_abi): Likewise. + * alphafbsd-tdep.c (alphafbsd_init_abi): Likewise. + * alphanbsd-tdep.c (alphanbsd_init_abi): Likewise. + * alpha-nat.c (get_longjmp_target): Remove. + (JB_ELEMENT_SIZE): Ditto. + (JB_PC): Ditto. + * alpha-tdep.c (alpha_get_longjmp_target): New function. + (alpha_gdbarch_init): Default tdep->jb_pc to -1. If the + OS ABI sets jb_pc to a valid value, set gdbarch_get_longjmp_target + to alpha_get_longjmp_target. + (alpha_dump_tdep): Report tdep->jb_pc and tdep->jb_elt_size. + * config/alpha/nm-linux.h (GET_LONGJMP_TARGET): Remove. + * config/alpha/nm-osf.h (GET_LONGJMP_TARGET): Remove. + 2002-04-25 Andrew Cagney * README: Update to GDB 5.2. diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c index ed7a7c640a..05a954457f 100644 --- a/gdb/alpha-linux-tdep.c +++ b/gdb/alpha-linux-tdep.c @@ -100,6 +100,9 @@ alpha_linux_init_abi (struct gdbarch_info info, set_gdbarch_pc_in_sigtramp (gdbarch, alpha_linux_pc_in_sigtramp); tdep->dynamic_sigtramp_offset = alpha_linux_sigtramp_offset; + + tdep->jb_pc = 2; + tdep->jb_elt_size = 8; } void diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c index a21346b49a..580dcc0e80 100644 --- a/gdb/alpha-nat.c +++ b/gdb/alpha-nat.c @@ -41,40 +41,6 @@ static void fetch_osf_core_registers (char *, unsigned, int, CORE_ADDR); static void fetch_elf_core_registers (char *, unsigned, int, CORE_ADDR); -/* Size of elements in jmpbuf */ - -#define JB_ELEMENT_SIZE 8 - -/* The definition for JB_PC in machine/reg.h is wrong. - And we can't get at the correct definition in setjmp.h as it is - not always available (eg. if _POSIX_SOURCE is defined which is the - default). As the defintion is unlikely to change (see comment - in , define the correct value here. */ - -#undef JB_PC -#define JB_PC 2 - -/* Figure out where the longjmp will land. - We expect the first arg to be a pointer to the jmp_buf structure from which - we extract the pc (JB_PC) that we will land at. The pc is copied into PC. - This routine returns true on success. */ - -int -get_longjmp_target (CORE_ADDR *pc) -{ - CORE_ADDR jb_addr; - char raw_buffer[ALPHA_MAX_REGISTER_RAW_SIZE]; - - jb_addr = read_register (ALPHA_A0_REGNUM); - - if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, raw_buffer, - sizeof (CORE_ADDR))) - return 0; - - *pc = extract_address (raw_buffer, sizeof (CORE_ADDR)); - return 1; -} - /* Extract the register values out of the core file and store them where `read_register' will find them. diff --git a/gdb/alpha-osf1-tdep.c b/gdb/alpha-osf1-tdep.c index cba9134b07..be8f7042bf 100644 --- a/gdb/alpha-osf1-tdep.c +++ b/gdb/alpha-osf1-tdep.c @@ -52,6 +52,9 @@ alpha_osf1_init_abi (struct gdbarch_info info, set_gdbarch_pc_in_sigtramp (gdbarch, alpha_osf1_pc_in_sigtramp); tdep->skip_sigtramp_frame = alpha_osf1_skip_sigtramp_frame; + + tdep->jb_pc = 2; + tdep->jb_elt_size = 8; } void diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 4bec6bcbfe..81c932c57b 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -78,6 +78,8 @@ static gdbarch_fix_call_dummy_ftype alpha_fix_call_dummy; static gdbarch_init_frame_pc_first_ftype alpha_init_frame_pc_first; static gdbarch_init_extra_frame_info_ftype alpha_init_extra_frame_info; +static gdbarch_get_longjmp_target_ftype alpha_get_longjmp_target; + struct frame_extra_info { alpha_extra_func_info_t proc_desc; @@ -1617,6 +1619,28 @@ alpha_extract_struct_value_address (char *regbuf) REGISTER_RAW_SIZE (ALPHA_V0_REGNUM))); } +/* Figure out where the longjmp will land. + We expect the first arg to be a pointer to the jmp_buf structure from + which we extract the PC (JB_PC) that we will land at. The PC is copied + into the "pc". This routine returns true on success. */ + +static int +alpha_get_longjmp_target (CORE_ADDR *pc) +{ + struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); + CORE_ADDR jb_addr; + char raw_buffer[ALPHA_MAX_REGISTER_RAW_SIZE]; + + jb_addr = read_register (ALPHA_A0_REGNUM); + + if (target_read_memory (jb_addr + (tdep->jb_pc * tdep->jb_elt_size), + raw_buffer, tdep->jb_elt_size)) + return 0; + + *pc = extract_address (raw_buffer, tdep->jb_elt_size); + return 1; +} + /* alpha_software_single_step() is called just before we want to resume the inferior, if we want to single-step it but there is no hardware or kernel single-step support (NetBSD on Alpha, for example). We find @@ -1975,6 +1999,8 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->dynamic_sigtramp_offset = NULL; tdep->skip_sigtramp_frame = NULL; + tdep->jb_pc = -1; /* longjmp support not enabled by default */ + /* Type sizes */ set_gdbarch_short_bit (gdbarch, 16); set_gdbarch_int_bit (gdbarch, 32); @@ -2113,6 +2139,12 @@ alpha_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } } + /* Now that we have tuned the configuration, set a few final things + based on what the OS ABI has told us. */ + + if (tdep->jb_pc >= 0) + set_gdbarch_get_longjmp_target (gdbarch, alpha_get_longjmp_target); + return gdbarch; } @@ -2134,6 +2166,13 @@ alpha_dump_tdep (struct gdbarch *current_gdbarch, struct ui_file *file) fprintf_unfiltered (file, "alpha_dump_tdep: vm_min_address = 0x%lx\n", (long) tdep->vm_min_address); + + fprintf_unfiltered (file, + "alpha_dump_tdep: jb_pc = %d\n", + tdep->jb_pc); + fprintf_unfiltered (file, + "alpha_dump_tdep: jb_elt_size = %ld\n", + (long) tdep->jb_elt_size); } void diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h index a9a724d27a..8b1cf3ece6 100644 --- a/gdb/alpha-tdep.h +++ b/gdb/alpha-tdep.h @@ -105,6 +105,11 @@ struct gdbarch_tdep /* If FRAME refers to a sigtramp frame, return the address of the next frame. */ CORE_ADDR (*skip_sigtramp_frame) (struct frame_info *, CORE_ADDR); + + int jb_pc; /* Offset to PC value in jump buffer. + If htis is negative, longjmp support + will be disabled. */ + size_t jb_elt_size; /* And the size of each entry in the buf. */ }; void alpha_software_single_step (enum target_signal, int); diff --git a/gdb/alphafbsd-tdep.c b/gdb/alphafbsd-tdep.c index 2e52252fc1..3c1e64da3e 100644 --- a/gdb/alphafbsd-tdep.c +++ b/gdb/alphafbsd-tdep.c @@ -70,6 +70,9 @@ alphafbsd_init_abi (struct gdbarch_info info, set_gdbarch_pc_in_sigtramp (gdbarch, alphafbsd_pc_in_sigtramp); set_gdbarch_use_struct_convention (gdbarch, alphafbsd_use_struct_convention); + + tdep->jb_pc = 2; + tdep->jb_elt_size = 8; } void diff --git a/gdb/alphanbsd-tdep.c b/gdb/alphanbsd-tdep.c index c29b3f92fd..33c3cd7f0a 100644 --- a/gdb/alphanbsd-tdep.c +++ b/gdb/alphanbsd-tdep.c @@ -145,6 +145,9 @@ alphanbsd_init_abi (struct gdbarch_info info, alphanbsd_solib_svr4_fetch_link_map_offsets); tdep->dynamic_sigtramp_offset = alphanbsd_sigtramp_offset; + + tdep->jb_pc = 2; + tdep->jb_elt_size = 8; } void diff --git a/gdb/config/alpha/nm-linux.h b/gdb/config/alpha/nm-linux.h index 5d5e945c77..05ac551812 100644 --- a/gdb/config/alpha/nm-linux.h +++ b/gdb/config/alpha/nm-linux.h @@ -25,15 +25,6 @@ #include "nm-linux.h" -/* Figure out where the longjmp will land. We expect that we have just entered - longjmp and haven't yet setup the stack frame, so the args are still in the - argument regs. A0_REGNUM points at the jmp_buf structure from which we - extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. - This routine returns true on success */ - -#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) -extern int get_longjmp_target (CORE_ADDR *); - /* ptrace register ``addresses'' are absolute. */ #define U_REGS_OFFSET 0 diff --git a/gdb/config/alpha/nm-osf.h b/gdb/config/alpha/nm-osf.h index 5fc99e4ad5..1316603c5b 100644 --- a/gdb/config/alpha/nm-osf.h +++ b/gdb/config/alpha/nm-osf.h @@ -18,15 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* Figure out where the longjmp will land. We expect that we have just entered - longjmp and haven't yet setup the stack frame, so the args are still in the - argument regs. A0_REGNUM points at the jmp_buf structure from which we - extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. - This routine returns true on success */ - -#define GET_LONGJMP_TARGET(ADDR) get_longjmp_target(ADDR) -extern int get_longjmp_target (CORE_ADDR *); - /* ptrace register ``addresses'' are absolute. */ #define U_REGS_OFFSET 0