* [PATCH] call observer_notify_new_objfile after the attach command
@ 2014-07-09 13:51 Adrian Sendroiu
2014-07-09 14:18 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Adrian Sendroiu @ 2014-07-09 13:51 UTC (permalink / raw)
To: gdb-patches
When debugging a remote bare-metal target which implements the gdb protocol,
using target extended-remote + attach, gdb will not send the qSymbol packet,
even if a file was previously specified using file or symbol-file.
Normally gdb would call remote_check_symbols in several places: the solib
inferior hook, the add_vsyscall_page hook or if the executable file changed
in the time passed between the file and the attach commands. Since none of these
conditions hold in the above scenario (no shared libraries are used and no
vsyscall page is present), gdb won't send a qSymbol packet.
To fix this problem this patch calls observer_notify_new_objfile after the attach
command is completed, if such a symbol file is present.
---
gdb/infcmd.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 14736a5..e491b5d 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2368,11 +2368,15 @@ attach_command_post_wait (char *args, int from_tty, int async_exec)
exec_file_attach (full_exec_path, from_tty);
symbol_file_add_main (full_exec_path, from_tty);
}
+ else if (symfile_objfile)
+ observer_notify_new_objfile(symfile_objfile);
}
else
{
reopen_exec_file ();
reread_symbols ();
+
+ observer_notify_new_objfile(symfile_objfile);
}
/* Take any necessary post-attaching actions for this platform. */
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] call observer_notify_new_objfile after the attach command
2014-07-09 13:51 [PATCH] call observer_notify_new_objfile after the attach command Adrian Sendroiu
@ 2014-07-09 14:18 ` Pedro Alves
2014-07-10 10:57 ` Adrian Sendroiu
0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2014-07-09 14:18 UTC (permalink / raw)
To: Adrian Sendroiu, gdb-patches
On 07/09/2014 02:51 PM, Adrian Sendroiu wrote:
> When debugging a remote bare-metal target which implements the gdb protocol,
> using target extended-remote + attach, gdb will not send the qSymbol packet,
> even if a file was previously specified using file or symbol-file.
>
> Normally gdb would call remote_check_symbols in several places: the solib
> inferior hook, the add_vsyscall_page hook or if the executable file changed
> in the time passed between the file and the attach commands. Since none of these
> conditions hold in the above scenario (no shared libraries are used and no
> vsyscall page is present), gdb won't send a qSymbol packet.
>
> To fix this problem this patch calls observer_notify_new_objfile after the attach
> command is completed, if such a symbol file is present.
But, if no new objfile was (re)loaded, then why call the new_objfile
observer? That's a bit backwards as it makes the core assume
what a particular observer wants to do with the event/subject. If
remote.c is interested in doing something when the attach is complete,
then we can look for such a hook. And it turns out one already
exists -- target_post_attach. So it seems like remote.c should call
remote_check_symbols from its target_post_attach method ?
That's not that different in principle from the remote_check_symbols
call in remote_start_remote.
--
Pedro Alves
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] call observer_notify_new_objfile after the attach command
2014-07-09 14:18 ` Pedro Alves
@ 2014-07-10 10:57 ` Adrian Sendroiu
2014-07-10 13:53 ` Pedro Alves
0 siblings, 1 reply; 4+ messages in thread
From: Adrian Sendroiu @ 2014-07-10 10:57 UTC (permalink / raw)
To: gdb-patches, palves
Thanks, I added a call to remote_check_symbols in the post_attach hook.
Adrian
From 0820f5ab475bd9e261e7be26dabbd30e5df60544 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrian=20=C8=98endroiu?= <adrian.sendroiu@freescale.com>
Date: Thu, 10 Jul 2014 11:16:41 +0300
Subject: [PATCH] call remote_check_symbols after attaching
---
gdb/remote.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/gdb/remote.c b/gdb/remote.c
index 3aa030c..8b438c7 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4484,6 +4484,13 @@ extended_remote_attach (struct target_ops *ops, const char *args, int from_tty)
extended_remote_attach_1 (ops, args, from_tty);
}
+static void
+extended_remote_post_attach (struct target_ops *ops, int pid)
+{
+ if (symfile_objfile)
+ remote_check_symbols();
+}
+
\f
/* Check for the availability of vCont. This function should also check
the response. */
@@ -11530,6 +11537,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;
--
1.7.9.5
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] call observer_notify_new_objfile after the attach command
2014-07-10 10:57 ` Adrian Sendroiu
@ 2014-07-10 13:53 ` Pedro Alves
0 siblings, 0 replies; 4+ messages in thread
From: Pedro Alves @ 2014-07-10 13:53 UTC (permalink / raw)
To: Adrian Sendroiu, gdb-patches
Thanks.
Could you complete the patch according to the instructions
at https://sourceware.org/gdb/wiki/ContributionChecklist, so it
could be git am'ed/pushed? (explain the rationale in the commit
log, ChangeLog, etc.)
Adding a comment in extended_remote_post_attach explaining why
that is done there would be good too. E.g., mention the case
of no libraries and the program not changing.
Please also add something like this above the new function:
/* Implementation of the to_post_attach method. */
And, write an explicit NULL check:
if (symfile_objfile != NULL)
Thanks again,
--
Pedro Alves
On 07/10/2014 11:56 AM, Adrian Sendroiu wrote:
> Thanks, I added a call to remote_check_symbols in the post_attach hook.
>
> Adrian
>
> From 0820f5ab475bd9e261e7be26dabbd30e5df60544 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Adrian=20=C8=98endroiu?= <adrian.sendroiu@freescale.com>
> Date: Thu, 10 Jul 2014 11:16:41 +0300
> Subject: [PATCH] call remote_check_symbols after attaching
>
> ---
> gdb/remote.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/gdb/remote.c b/gdb/remote.c
> index 3aa030c..8b438c7 100644
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -4484,6 +4484,13 @@ extended_remote_attach (struct target_ops *ops, const char *args, int from_tty)
> extended_remote_attach_1 (ops, args, from_tty);
> }
>
> +static void
> +extended_remote_post_attach (struct target_ops *ops, int pid)
> +{
> + if (symfile_objfile)
> + remote_check_symbols();
> +}
> +
> \f
> /* Check for the availability of vCont. This function should also check
> the response. */
> @@ -11530,6 +11537,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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-10 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-09 13:51 [PATCH] call observer_notify_new_objfile after the attach command Adrian Sendroiu
2014-07-09 14:18 ` Pedro Alves
2014-07-10 10:57 ` Adrian Sendroiu
2014-07-10 13:53 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox