diff mbox

call remote_check_symbols after attaching

Message ID 1405070240-11462-1-git-send-email-adrian.sendroiu@freescale.com
State Committed
Headers show

Commit Message

Adrian Sendroiu July 11, 2014, 9:17 a.m. UTC
When debugging a remote bare-metal target with
"target extended-remote" + attach, gdb won't send a qSymbol packet to initiate
symbol lookup. This happens because all the previous places in which gdb might
have done this are guarded by conditions that don't hold in the said scenario:
there are no shared libraries, no vsyscall page and the binary file didn't
change in the time passed between the "file" and the "attach" commands.

To solve this problem remote_check_symbols is called in the post_attach hook.

gdb:

2014-07-11  Adrian Sendroiu  <adrian.sendroiu@freescale.com>

	* remote.c: call remote_check_symbols after attaching
---
 gdb/remote.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Tom Tromey July 11, 2014, 3:25 p.m. UTC | #1
>>>>> "Adrian" == Adrian Sendroiu <adrian.sendroiu@freescale.com> writes:

One little nit here --

Adrian> +  if (symfile_objfile != NULL)
Adrian> +    remote_check_symbols();

GNU style puts a space before the "(".

Tom
diff mbox

Patch

diff --git a/gdb/remote.c b/gdb/remote.c
index 3aa030c..2c97b5d 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4484,6 +4484,19 @@  extended_remote_attach (struct target_ops *ops, const char *args, int from_tty)
   extended_remote_attach_1 (ops, args, from_tty);
 }
 
+/* Implementation of the to_post_attach method */
+
+static void
+extended_remote_post_attach (struct target_ops *ops, int pid)
+{
+  /* In certain cases gdb might not have had the chance to start symbol lookup
+     up until now. This could happen if the debugged binary is not using
+     shared libraries, the vsyscall page is not present and the binary itself
+     hadn't changed since the debugging process was started */
+  if (symfile_objfile != NULL)
+    remote_check_symbols();
+}
+
 
 /* Check for the availability of vCont.  This function should also check
    the response.  */
@@ -11530,6 +11543,7 @@  Specify the serial device it is connected to (e.g. /dev/ttya).";
   extended_remote_ops.to_mourn_inferior = extended_remote_mourn;
   extended_remote_ops.to_detach = extended_remote_detach;
   extended_remote_ops.to_attach = extended_remote_attach;
+  extended_remote_ops.to_post_attach = extended_remote_post_attach;
   extended_remote_ops.to_kill = extended_remote_kill;
   extended_remote_ops.to_supports_disable_randomization
     = extended_remote_supports_disable_randomization;