This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb/gdb-7.11-branch] Fix PR gdb/19858: GDB doesn't register the JIT libraries on attach
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 31 Mar 2016 18:38:21 -0000
- Subject: [binutils-gdb/gdb-7.11-branch] Fix PR gdb/19858: GDB doesn't register the JIT libraries on attach
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd64cabb8c66a5565fc33bf66a07c08bc767e413
commit cd64cabb8c66a5565fc33bf66a07c08bc767e413
Author: Yichao Yu <yyc1992@gmail.com>
Date: Thu Mar 31 19:28:47 2016 +0100
Fix PR gdb/19858: GDB doesn't register the JIT libraries on attach
Ref: https://sourceware.org/ml/gdb/2016-03/msg00023.html
GDB currently fails to fetch the list of already-registered JIT
modules on attach.
Nothing is calling jit_inferior_init, which is what is responsible for
walking the JIT object list at init time.
Despite the misleading naming, jit_inferior_created_hook ->
jit_inferior_init is only called when the inferior execs.
This regressed with the fix for PR gdb/13431 (03bef283c2d3):
https://sourceware.org/ml/gdb-patches/2012-02/msg00023.html which
removed the inferior_created (jit_inferior_created_observer)
observer.
Adding an inferior_created observer back fixes the issue.
In turn, this exposes a bug in jit_breakpoint_re_set_internal as well,
which is returning the wrong result when we already have the
breakpoint at the right address.
gdb/ChangeLog:
2016-03-31 Yichao Yu <yyc1992@gmail.com>
PR gdb/19858
* jit.c (jit_breakpoint_re_set_internal): Return 0 if we already
got the breakpoint at the right address.
(jit_inferior_created): New function.
(_initialize_jit): Install jit_inferior_created as
inferior_created observer.
Signed-off-by: Pedro Alves <palves@redhat.com>
Diff:
---
gdb/ChangeLog | 9 +++++++++
gdb/jit.c | 13 +++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 77e3275..068adc5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2016-03-31 Yichao Yu <yyc1992@gmail.com>
+
+ PR gdb/19858
+ * jit.c (jit_breakpoint_re_set_internal): Return 0 if we already
+ got the breakpoint at the right address.
+ (jit_inferior_created): New function.
+ (_initialize_jit): Install jit_inferior_created as
+ inferior_created observer.
+
2016-03-17 Markus Metzger <markus.t.metzger@intel.com>
PR gdb/19829
diff --git a/gdb/jit.c b/gdb/jit.c
index afc1c51..9fd5ae6 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -1026,7 +1026,7 @@ jit_breakpoint_deleted (struct breakpoint *b)
}
/* (Re-)Initialize the jit breakpoint if necessary.
- Return 0 on success. */
+ Return 0 if the jit breakpoint has been successfully initialized. */
static int
jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
@@ -1070,7 +1070,7 @@ jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
paddress (gdbarch, addr));
if (ps_data->cached_code_address == addr)
- return 1;
+ return 0;
/* Delete the old breakpoint. */
if (ps_data->jit_breakpoint != NULL)
@@ -1367,6 +1367,14 @@ jit_inferior_init (struct gdbarch *gdbarch)
}
}
+/* inferior_created observer. */
+
+static void
+jit_inferior_created (struct target_ops *ops, int from_tty)
+{
+ jit_inferior_created_hook ();
+}
+
/* Exported routine to call when an inferior has been created. */
void
@@ -1496,6 +1504,7 @@ _initialize_jit (void)
show_jit_debug,
&setdebuglist, &showdebuglist);
+ observer_attach_inferior_created (jit_inferior_created);
observer_attach_inferior_exit (jit_inferior_exit_hook);
observer_attach_breakpoint_deleted (jit_breakpoint_deleted);