From a43986283d61ffd4d7dc9b20c0ecb73cd345206c Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Fri, 18 Nov 2016 09:39:41 -0800 Subject: [PATCH] gdb: xtensa: clean up xtensa_default_isa initialization This fixes segfault in native gdb because isa is not initialized at the point of call to xtensa_isa_maxlength. gdb/ 2017-03-27 Max Filippov * xtensa-tdep.c (xtensa_scan_prologue, call0_analyze_prologue): Drop xtensa_default_isa initialization. (xtensa_gdbarch_init): Initialize xtensa_default_isa. --- gdb/ChangeLog | 6 ++++++ gdb/xtensa-tdep.c | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 106388f0483..0490511ed38 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2017-03-27 Max Filippov + + * xtensa-tdep.c (xtensa_scan_prologue, call0_analyze_prologue): + Drop xtensa_default_isa initialization. + (xtensa_gdbarch_init): Initialize xtensa_default_isa. + 2017-03-27 Pedro Alves * dwarf2read.c (file_entry) : Add comment. diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index 376f4c7340c..efbd5ab1b54 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1151,8 +1151,6 @@ xtensa_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR current_pc) if (start_addr == 0) return fp_regnum; - if (!xtensa_default_isa) - xtensa_default_isa = xtensa_isa_init (0, 0); isa = xtensa_default_isa; gdb_assert (XTENSA_ISA_BSZ >= xtensa_isa_maxlength (isa)); ins = xtensa_insnbuf_alloc (isa); @@ -2427,8 +2425,6 @@ call0_analyze_prologue (struct gdbarch *gdbarch, cache->call0 = 1; rtmp = (xtensa_c0reg_t*) alloca(nregs * sizeof(xtensa_c0reg_t)); - if (!xtensa_default_isa) - xtensa_default_isa = xtensa_isa_init (0, 0); isa = xtensa_default_isa; gdb_assert (XTENSA_ISA_BSZ >= xtensa_isa_maxlength (isa)); ins = xtensa_insnbuf_alloc (isa); @@ -3186,6 +3182,9 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) DEBUGTRACE ("gdbarch_init()\n"); + if (!xtensa_default_isa) + xtensa_default_isa = xtensa_isa_init (0, 0); + /* We have to set the byte order before we call gdbarch_alloc. */ info.byte_order = XCHAL_HAVE_BE ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE; -- 2.30.2