From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Use "get_current_arch" instead of "get_objfile_arch" on SystemTap SDT code (and fix ARM bug)
Date: Thu, 05 Dec 2013 06:34:00 -0000 [thread overview]
Message-ID: <1386225226-18549-1-git-send-email-sergiodj@redhat.com> (raw)
While implementing another patch and testing things on ARM, I found a
strange bug (at least initially). There was an expression on some
probe's argument that did a displacement of the "fp" register (i.e.,
"[fp, #-8]"). However, during the evaluation of the parsed expression
GDB got confused and could not access the "fp" register due to an
invalid address being returned.
After a good deal of time spent on the investigation of this, I found
that the culprit was the gdbarch being used; it did not provide the
correct number of pseudo-registers for the architecture, and thus the
internal number of the "fp" register ended up being completely wrong.
Then, I began to read the code, and found this on gdb/objfiles.h:struct
objfile_per_bfd_storage:
/* The gdbarch associated with the BFD. Note that this gdbarch is
determined solely from BFD information, without looking at target
information. The gdbarch determined from a running target may
differ from this e.g. with respect to register types and names. */
struct gdbarch *gdbarch;
Well, then the fix became obvious. I replaced all the occurrences of
"get_objfile_arch" on gdb/stap-probe.c to "get_current_arch", and voilà .
This patch has been tested on both x86_64 Fedora 17 and ARM Fedora 19.
2013-12-05 Sergio Durigan Junior <sergiodj@redhat.com>
* stap-probe.c (stap_parse_probe_arguments): Use "get_current_arch"
instead of "get_objfile_arch".
(stap_can_evaluate_probe_arguments): Likewise.
(handle_stap_probe): Likewise.
(stap_gen_info_probes_table_values): Likewise.
---
gdb/ChangeLog | 8 ++++++++
gdb/stap-probe.c | 8 ++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f5ba7d3..ec56b57 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2013-12-05 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * stap-probe.c (stap_parse_probe_arguments): Use "get_current_arch"
+ instead of "get_objfile_arch".
+ (stap_can_evaluate_probe_arguments): Likewise.
+ (handle_stap_probe): Likewise.
+ (stap_gen_info_probes_table_values): Likewise.
+
2013-12-05 Joel Brobecker <brobecker@adacore.com>
Tristan Gingold <gingold@adacore.com>
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index a734793..3ab54b0 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -917,7 +917,7 @@ static void
stap_parse_probe_arguments (struct stap_probe *probe)
{
const char *cur;
- struct gdbarch *gdbarch = get_objfile_arch (probe->p.objfile);
+ struct gdbarch *gdbarch = get_current_arch ();
gdb_assert (!probe->args_parsed);
cur = probe->args_u.text;
@@ -1086,7 +1086,7 @@ static int
stap_can_evaluate_probe_arguments (struct probe *probe_generic)
{
struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
- struct gdbarch *gdbarch = get_objfile_arch (stap_probe->p.objfile);
+ struct gdbarch *gdbarch = get_current_arch ();
/* For SystemTap probes, we have to guarantee that the method
stap_is_single_operand is defined on gdbarch. If it is not, then it
@@ -1337,7 +1337,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
{
bfd *abfd = objfile->obfd;
int size = bfd_get_arch_size (abfd) / 8;
- struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ struct gdbarch *gdbarch = get_current_arch ();
struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr;
CORE_ADDR base_ref;
const char *probe_args = NULL;
@@ -1540,7 +1540,7 @@ stap_gen_info_probes_table_values (struct probe *probe_generic,
gdb_assert (probe_generic->pops == &stap_probe_ops);
- gdbarch = get_objfile_arch (probe->p.objfile);
+ gdbarch = get_current_arch ();
if (probe->sem_addr)
val = print_core_address (gdbarch, probe->sem_addr);
--
1.7.11.7
next reply other threads:[~2013-12-05 6:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 6:34 Sergio Durigan Junior [this message]
2013-12-05 13:04 ` Pedro Alves
2013-12-05 22:12 ` [PATCH] Sanitize gdbarch access on probe/SDT API (was: Re: [PATCH] Use "get_current_arch" instead of...) Sergio Durigan Junior
2013-12-05 23:06 ` [PATCH] Sanitize gdbarch access on probe/SDT API Sergio Durigan Junior
2013-12-05 23:30 ` Tom Tromey
2013-12-06 2:22 ` Sergio Durigan Junior
2013-12-06 13:50 ` Pedro Alves
2013-12-06 15:49 ` Sergio Durigan Junior
2013-12-06 16:00 ` Pedro Alves
2013-12-06 16:04 ` Sergio Durigan Junior
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=1386225226-18549-1-git-send-email-sergiodj@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
/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