diff options
-rw-r--r-- | gdb/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/aarch64-tdep.c | 68 |
2 files changed, 30 insertions, 42 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index adafc19..02e8fea 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,7 @@ +2019-04-15 Alan Hayward <alan.hayward@arm.com> + + * aarch64-tdep.c (aarch64_gdbarch_init): Move gdbarch lookup. + 2019-04-13 Andrew Burgess <andrew.burgess@embecosm.com> * dwarf2read.c (dwarf2_init_complex_target_type): Handle complex diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 1b3977b..ea3f5ec 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3192,36 +3192,37 @@ aarch64_cannot_store_register (struct gdbarch *gdbarch, int regnum) static struct gdbarch * aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) { - struct gdbarch_tdep *tdep; - struct gdbarch *gdbarch; - struct gdbarch_list *best_arch; - struct tdesc_arch_data *tdesc_data = NULL; - const struct target_desc *tdesc = info.target_desc; - int i; - int valid_p = 1; - const struct tdesc_feature *feature_core; - const struct tdesc_feature *feature_fpu; - const struct tdesc_feature *feature_sve; + const struct tdesc_feature *feature_core, *feature_fpu, *feature_sve; const struct tdesc_feature *feature_pauth; - int num_regs = 0; - int num_pseudo_regs = 0; - int first_pauth_regnum = -1; - int pauth_ra_state_offset = -1; + bool valid_p = true; + int i, num_regs = 0, num_pseudo_regs = 0; + int first_pauth_regnum = -1, pauth_ra_state_offset = -1; + + /* If there is already a candidate, use it. */ + for (gdbarch_list *best_arch = gdbarch_list_lookup_by_info (arches, &info); + best_arch != nullptr; + best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) + { + struct gdbarch_tdep *tdep = gdbarch_tdep (best_arch->gdbarch); + if (tdep) + return best_arch->gdbarch; + } /* Ensure we always have a target description. */ + const struct target_desc *tdesc = info.target_desc; if (!tdesc_has_registers (tdesc)) tdesc = aarch64_read_description (0, false); gdb_assert (tdesc); - feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.core"); + feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core"); feature_fpu = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.fpu"); feature_sve = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sve"); feature_pauth = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth"); - if (feature_core == NULL) - return NULL; + if (feature_core == nullptr) + return nullptr; - tdesc_data = tdesc_data_alloc (); + struct tdesc_arch_data *tdesc_data = tdesc_data_alloc (); /* Validate the description provides the mandatory core R registers and allocate their numbers. */ @@ -3233,9 +3234,9 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) num_regs = AARCH64_X0_REGNUM + i; /* Add the V registers. */ - if (feature_fpu != NULL) + if (feature_fpu != nullptr) { - if (feature_sve != NULL) + if (feature_sve != nullptr) error (_("Program contains both fpu and SVE features.")); /* Validate the description provides the mandatory V registers @@ -3249,7 +3250,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } /* Add the SVE registers. */ - if (feature_sve != NULL) + if (feature_sve != nullptr) { /* Validate the description provides the mandatory SVE registers and allocate their numbers. */ @@ -3262,7 +3263,7 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) num_pseudo_regs += 32; /* add the Vn register pseudos. */ } - if (feature_fpu != NULL || feature_sve != NULL) + if (feature_fpu != nullptr || feature_sve != nullptr) { num_pseudo_regs += 32; /* add the Qn scalar register pseudos */ num_pseudo_regs += 32; /* add the Dn scalar register pseudos */ @@ -3290,30 +3291,14 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) if (!valid_p) { tdesc_data_cleanup (tdesc_data); - return NULL; + return nullptr; } /* AArch64 code is always little-endian. */ info.byte_order_for_code = BFD_ENDIAN_LITTLE; - /* If there is already a candidate, use it. */ - for (best_arch = gdbarch_list_lookup_by_info (arches, &info); - best_arch != NULL; - best_arch = gdbarch_list_lookup_by_info (best_arch->next, &info)) - { - /* Found a match. */ - break; - } - - if (best_arch != NULL) - { - if (tdesc_data != NULL) - tdesc_data_cleanup (tdesc_data); - return best_arch->gdbarch; - } - - tdep = XCNEW (struct gdbarch_tdep); - gdbarch = gdbarch_alloc (&info, tdep); + struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep); + struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep); /* This should be low enough for everything. */ tdep->lowest_pc = 0x20; @@ -3324,7 +3309,6 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->pauth_ra_state_regnum = (feature_pauth == NULL) ? -1 : pauth_ra_state_offset + num_regs; - set_gdbarch_push_dummy_call (gdbarch, aarch64_push_dummy_call); set_gdbarch_frame_align (gdbarch, aarch64_frame_align); |