This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Use "get_current_arch" instead of "get_objfile_arch" on SystemTap SDT code (and fix ARM bug)
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Thu, 5 Dec 2013 04:33:46 -0200
- Subject: [PATCH] Use "get_current_arch" instead of "get_objfile_arch" on SystemTap SDT code (and fix ARM bug)
- Authentication-results: sourceware.org; auth=none
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