public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: gdb-patches@sourceware.org
Cc: Maxim Grigoriev <maxim2405@gmail.com>,
	Woody LaRue <larue@cadence.com>,	Marc Gauthier <marc@cadence.com>,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH v2 1/5] gdb: xtensa: clean up xtensa_default_isa initialization
Date: Wed, 22 Feb 2017 02:09:00 -0000	[thread overview]
Message-ID: <1487729356-10432-2-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1487729356-10432-1-git-send-email-jcmvbkbc@gmail.com>

This fixes segfault in native gdb because isa is not initialized at the
point of call to xtensa_isa_maxlength.

gdb/
2017-02-21  Max Filippov  <jcmvbkbc@gmail.com>

	* xtensa-tdep.c (xtensa_scan_prologue, call0_analyze_prologue):
	Drop xtensa_default_isa initialization.
	(xtensa_gdbarch_init): Initialize xtensa_default_isa.
---
Changes v1->v2:
- clean up xtensa_default_isa initialization;
- move directory name up in the commit message.

 gdb/xtensa-tdep.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index 376f4c7..efbd5ab 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.1.4

  parent reply	other threads:[~2017-02-22  2:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-22  2:09 [PATCH v2 0/5] xtensa: support call0 ABI native linux gdb and gdbserver Max Filippov
2017-02-22  2:09 ` [PATCH v2 3/5] gdb: xtensa-linux: add call0 support Max Filippov
2017-02-22  2:09 ` [PATCH v2 2/5] gdb: gdbserver: xtensa: make C0_NREGS available Max Filippov
2017-02-22  2:09 ` [PATCH v2 4/5] gdbserver: xtensa: add call0 support Max Filippov
2017-02-22  2:09 ` Max Filippov [this message]
2017-02-22  2:11 ` [PATCH v2 5/5] gdb: xtensa: fix test for privileged register number Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487729356-10432-2-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=larue@cadence.com \
    --cc=marc@cadence.com \
    --cc=maxim2405@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).