diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 37fe06e6951..3210957528a 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,28 @@ +2017-07-13 Pedro Alves + + * amd64-darwin-tdep.c (x86_darwin_init_abi_64): Pass tdesc_amd64 + as default tdesc. + * amd64-dicos-tdep.c (amd64_dicos_init_abi): + * amd64-fbsd-tdep.c (amd64fbsd_init_abi): + * amd64-linux-tdep.c (amd64_linux_init_abi): Pass + tdesc_amd64_linux as default tdesc. Get final tdesc from the + tdep. + (amd64_x32_linux_init_abi): Pass tdesc_x32_linux as default tdesc. + Get final tdesc from the tdep. + * amd64-nbsd-tdep.c (amd64nbsd_init_abi): Pass tdesc_amd64 as + default tdesc. + * amd64-obsd-tdep.c (amd64obsd_init_abi): Likewise. + * amd64-sol2-tdep.c (amd64_sol2_init_abi): Likewise. + * amd64-tdep.c (amd64_init_abi): Add 'default_tdesc' parameter. + Use it as default tdesc. + (amd64_x32_init_abi): Add 'default_tdesc' parameter, and pass it + down to amd_init_abi. No longer handle fallback tdesc here. + * amd64-tdep.h (tdesc_x32): Declare. + (amd64_init_abi, amd64_x32_init_abi): Add 'default_tdesc' + parameter. + * amd64-windows-tdep.c (amd64_windows_init_abi): Pass tdesc_amd64 + as default tdesc. + 2017-07-13 Andreas Arnez * s390-linux-tdep.c (s390_process_record): Add support for diff --git a/gdb/amd64-darwin-tdep.c b/gdb/amd64-darwin-tdep.c index db400cd0c84..be26d9e3c4b 100644 --- a/gdb/amd64-darwin-tdep.c +++ b/gdb/amd64-darwin-tdep.c @@ -99,7 +99,7 @@ x86_darwin_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); tdep->struct_return = reg_struct_return; diff --git a/gdb/amd64-dicos-tdep.c b/gdb/amd64-dicos-tdep.c index ee408912126..7bdb167e82d 100644 --- a/gdb/amd64-dicos-tdep.c +++ b/gdb/amd64-dicos-tdep.c @@ -25,7 +25,7 @@ static void amd64_dicos_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); dicos_init_abi (gdbarch); } diff --git a/gdb/amd64-fbsd-tdep.c b/gdb/amd64-fbsd-tdep.c index 48bb2093252..ad4d787998d 100644 --- a/gdb/amd64-fbsd-tdep.c +++ b/gdb/amd64-fbsd-tdep.c @@ -217,7 +217,7 @@ amd64fbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64fbsd_r_reg_offset); tdep->sizeof_gregset = 22 * 8; - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); tdep->sigtramp_p = amd64fbsd_sigtramp_p; tdep->sigtramp_start = amd64fbsd_sigtramp_start_addr; diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index 4ef0f783ab5..cf2478924b6 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -1863,7 +1863,6 @@ static void amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - const struct target_desc *tdesc = info.target_desc; struct tdesc_arch_data *tdesc_data = (struct tdesc_arch_data *) info.tdep_info; const struct tdesc_feature *feature; @@ -1875,15 +1874,13 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset); tdep->sizeof_gregset = 27 * 8; - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64_linux); + + const target_desc *tdesc = tdep->tdesc; /* Reserve a number for orig_rax. */ set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); - if (! tdesc_has_registers (tdesc)) - tdesc = tdesc_amd64_linux; - tdep->tdesc = tdesc; - feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); if (feature == NULL) return; @@ -2080,7 +2077,6 @@ static void amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - const struct target_desc *tdesc = info.target_desc; struct tdesc_arch_data *tdesc_data = (struct tdesc_arch_data *) info.tdep_info; const struct tdesc_feature *feature; @@ -2092,14 +2088,12 @@ amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64_linux_gregset_reg_offset); tdep->sizeof_gregset = 27 * 8; - amd64_x32_init_abi (info, gdbarch); + amd64_x32_init_abi (info, gdbarch, tdesc_x32_linux); /* Reserve a number for orig_rax. */ set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); - if (! tdesc_has_registers (tdesc)) - tdesc = tdesc_x32_linux; - tdep->tdesc = tdesc; + const target_desc *tdesc = tdep->tdesc; feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); if (feature == NULL) diff --git a/gdb/amd64-nbsd-tdep.c b/gdb/amd64-nbsd-tdep.c index db6f19f63ed..02bf42776e1 100644 --- a/gdb/amd64-nbsd-tdep.c +++ b/gdb/amd64-nbsd-tdep.c @@ -103,7 +103,7 @@ amd64nbsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64nbsd_r_reg_offset); tdep->sizeof_gregset = 26 * 8; - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); tdep->jb_pc_offset = 7 * 8; diff --git a/gdb/amd64-obsd-tdep.c b/gdb/amd64-obsd-tdep.c index 72895b6fc6e..ad90c20b5af 100644 --- a/gdb/amd64-obsd-tdep.c +++ b/gdb/amd64-obsd-tdep.c @@ -419,7 +419,7 @@ amd64obsd_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); obsd_init_abi (info, gdbarch); /* Initialize general-purpose register set details. */ diff --git a/gdb/amd64-sol2-tdep.c b/gdb/amd64-sol2-tdep.c index 51fe9dbe4fb..ca474db8b2e 100644 --- a/gdb/amd64-sol2-tdep.c +++ b/gdb/amd64-sol2-tdep.c @@ -99,7 +99,7 @@ amd64_sol2_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->gregset_num_regs = ARRAY_SIZE (amd64_sol2_gregset_reg_offset); tdep->sizeof_gregset = 28 * 8; - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); tdep->sigtramp_p = amd64_sol2_sigtramp_p; tdep->sigcontext_addr = amd64_sol2_mcontext_addr; diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 9ff7dfc5134..6171bc598d5 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -3005,7 +3005,8 @@ static const int amd64_record_regmap[] = }; void -amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, + target_desc *default_tdesc) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); const struct target_desc *tdesc = info.target_desc; @@ -3022,7 +3023,7 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) tdep->fpregset = &amd64_fpregset; if (! tdesc_has_registers (tdesc)) - tdesc = tdesc_amd64; + tdesc = default_tdesc; tdep->tdesc = tdesc; tdep->num_core_regs = AMD64_NUM_GREGS + I387_NUM_REGS; @@ -3196,16 +3197,12 @@ amd64_x32_pseudo_register_type (struct gdbarch *gdbarch, int regnum) } void -amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) +amd64_x32_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, + target_desc *default_tdesc) { struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - const struct target_desc *tdesc = info.target_desc; - - amd64_init_abi (info, gdbarch); - if (! tdesc_has_registers (tdesc)) - tdesc = tdesc_x32; - tdep->tdesc = tdesc; + amd64_init_abi (info, gdbarch, default_tdesc); tdep->num_dword_regs = 17; set_tdesc_pseudo_register_type (gdbarch, amd64_x32_pseudo_register_type); diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h index 87f0ba30738..d4c6c9aeaab 100644 --- a/gdb/amd64-tdep.h +++ b/gdb/amd64-tdep.h @@ -88,6 +88,7 @@ enum amd64_regnum #define AMD64_NUM_REGS (AMD64_GSBASE_REGNUM + 1) extern struct target_desc *tdesc_amd64; +extern struct target_desc *tdesc_x32; extern struct displaced_step_closure *amd64_displaced_step_copy_insn (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, @@ -97,9 +98,17 @@ extern void amd64_displaced_step_fixup (struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to, struct regcache *regs); -extern void amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch); +/* Initialize the ABI for amd64. Uses DEFAULT_TDESC as fallback + tdesc, if INFO does not specify one. */ +extern void amd64_init_abi (struct gdbarch_info info, + struct gdbarch *gdbarch, + target_desc *default_tdesc); + +/* Initialize the ABI for x32. Uses DEFAULT_TDESC as fallback tdesc, + if INFO does not specify one. */ extern void amd64_x32_init_abi (struct gdbarch_info info, - struct gdbarch *gdbarch); + struct gdbarch *gdbarch, + target_desc *default_tdesc); extern const struct target_desc *amd64_target_description (uint64_t xcr0); /* Fill register REGNUM in REGCACHE with the appropriate diff --git a/gdb/amd64-windows-tdep.c b/gdb/amd64-windows-tdep.c index f1acdb9bec2..9158282cf9a 100644 --- a/gdb/amd64-windows-tdep.c +++ b/gdb/amd64-windows-tdep.c @@ -1224,7 +1224,7 @@ amd64_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) */ frame_unwind_append_unwinder (gdbarch, &amd64_windows_frame_unwind); - amd64_init_abi (info, gdbarch); + amd64_init_abi (info, gdbarch, tdesc_amd64); windows_init_abi (info, gdbarch);