From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: GDB Patches <gdb-patches@sourceware.org>,
Jan Kratochvil <jan.kratochvil@redhat.com>
Subject: Re: [PATCH v6] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages
Date: Tue, 17 Apr 2018 20:07:00 -0000 [thread overview]
Message-ID: <87fu3tfvfu.fsf@redhat.com> (raw)
In-Reply-To: <ea2c0a62-a250-5120-6aeb-58bc1b5a646b@redhat.com> (Pedro Alves's message of "Tue, 17 Apr 2018 16:56:52 +0100")
On Tuesday, April 17 2018, Pedro Alves wrote:
> On 04/16/2018 09:04 PM, Sergio Durigan Junior wrote:
>> Changes from v5:
>>
>> - Save result from 'target_pid_to_str' using std::string instead of
>> 'const char *', avoiding a possible race condition.
>
> Sorry Sergio, we're getting there, but this will need more work.
I'm the one who apologizes.
>> Built and regtested on BuildBot, without regressions.
>>
>
>> * gdb.threads/process-dies-while-detaching.c
>> (parent_function): Use 'usleep' in order to avoid
>> race-conditions.
>
> This is stale. There's no 'usleep' any more.
Removed.
>> @@ -121,9 +120,11 @@ struct inferior *
>> add_inferior (int pid)
>> {
>> struct inferior *inf = add_inferior_silent (pid);
>> + std::string infpid = target_pid_to_str (pid_to_ptid (pid));
>>
>> if (print_inferior_events)
>> - printf_unfiltered (_("[New inferior %d]\n"), pid);
>> + printf_unfiltered (_("[New inferior %d (%s)]\n"),
>> + inf->num, infpid.c_str ());
>
> Let's call target_pid_to_str directly here without the
> deep copy.
>
> You needed to call target_pid_to_str early in kill_command
> because there first kill the target, and print the
> string _afterwards_. "target_kill" may pop the target from the
> target stack, so we can't use target_pid_to_str after the
> target is gone already.
>
> But here, we're not messing with the target stack.
>
> (Nor are we calling target_pid_to_str twice in a row in
> the same expression.)
I confess I knew this, but decided to do a deep copy anyway because I
was aiming for consistency. But no problem at all, I'll simplify this
part.
>
>> void
>> @@ -261,12 +259,13 @@ void
>> detach_inferior (inferior *inf)
>> {
>> /* Save the pid, since exit_inferior_1 will reset it. */
>> - int pid = inf->pid;
>> + std::string infpid = target_pid_to_str (pid_to_ptid (inf->pid));
>>
>> exit_inferior_1 (inf, 0);
>>
>> if (print_inferior_events)
>> - printf_unfiltered (_("[Inferior %d detached]\n"), pid);
>> + printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
>> + inf->num, infpid.c_str ());
>
> Same here.
Fixed.
>> diff --git a/gdb/remote.c b/gdb/remote.c
>> index f54a38833b..be118c5d97 100644
>> --- a/gdb/remote.c
>> +++ b/gdb/remote.c
>> @@ -5137,7 +5137,12 @@ remote_detach_1 (int from_tty, inferior *inf)
>> /* If doing detach-on-fork, we don't mourn, because that will delete
>> breakpoints that should be available for the followed inferior. */
>> if (!is_fork_parent)
>> - target_mourn_inferior (inferior_ptid);
>> + {
>> + target_mourn_inferior (inferior_ptid);
>> + if (print_inferior_events)
>> + printf_unfiltered (_("[Inferior %d (process %d) detached]\n"),
>> + inf->num, pid);
>
> This is still using "(process %d)", which is incorrect
> for target remote.
You're right, sorry about this.
> Also, here, if debugging in "target remote" mode, and this is
> the last live process, that target_mourn_inferior call will
> unpush the remote target from the target stack. So this is another
> case where you need to call target_pid_to_str _before_ calling
> target_mourn_inferior.
Good point. This is fixed.
> As mentioned before, not all targets print "process $decimal" in
> their target_pid_to_str implementation. So your testsuite changes
> will need to adapt too.
>
> Please try this: hack away gdbserver/server.c's support for
> the RSP multi-process extensions (look for "multiprocess+"), and
> test with "target remote". That hack will emulate older gdbservers and
> other stubs that don't support telling gdb the process's pid.
> Manually confirm that you get "Remote target" instead of
> "process $pid" -- see remote.c's implementation of
> target_pid_to_str. Then run the testsuite against that gdbserver.
[ After a quick chat to clarify things... ]
I will make sure to adjust all regexps and take into account the many
outputs that can happen here.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
next prev parent reply other threads:[~2018-04-17 20:07 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-24 19:47 [PATCH] Always print "Detaching after fork from child..." Sergio Durigan Junior
2018-01-24 20:43 ` Jan Kratochvil
2018-01-24 20:56 ` Sergio Durigan Junior
2018-01-25 15:59 ` Pedro Alves
2018-01-25 20:21 ` Sergio Durigan Junior
2018-01-25 22:39 ` Pedro Alves
2018-01-31 16:57 ` [PATCH v2] Enable 'set print inferior-events' and cleanup attach/detach messages Sergio Durigan Junior
2018-02-01 17:17 ` Pedro Alves
2018-03-06 1:44 ` Sergio Durigan Junior
2018-03-09 21:56 ` [PATCH v3] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages Sergio Durigan Junior
[not found] ` <a036d7a8-cf74-d3a3-6763-14c77217e533@redhat.com>
2018-03-26 11:43 ` Pedro Alves
2018-04-03 0:15 ` Sergio Durigan Junior
2018-04-02 21:51 ` Sergio Durigan Junior
2018-04-05 18:47 ` [PATCH v4] " Sergio Durigan Junior
2018-04-05 21:32 ` Sergio Durigan Junior
2018-04-06 15:39 ` Pedro Alves
2018-04-06 15:56 ` Sergio Durigan Junior
2018-04-06 16:41 ` Pedro Alves
2018-04-10 16:22 ` Sergio Durigan Junior
2018-04-11 18:46 ` [PATCH v5] " Sergio Durigan Junior
2018-04-11 19:05 ` Pedro Alves
2018-04-11 19:08 ` Sergio Durigan Junior
2018-04-16 20:04 ` [PATCH v6] " Sergio Durigan Junior
2018-04-17 15:57 ` Pedro Alves
2018-04-17 20:07 ` Sergio Durigan Junior [this message]
2018-04-19 19:54 ` [PATCH v7] " Sergio Durigan Junior
2018-04-24 13:33 ` Pedro Alves
2018-04-24 19:49 ` Sergio Durigan Junior
2018-04-25 17:41 ` [PATCH] Fix new inferior events output (Re: [PATCH v7] Enable 'set print inferior-events' and improve detach/fork/kill/exit messages) Pedro Alves
2018-04-25 17:53 ` Sergio Durigan Junior
2018-04-25 18:07 ` Pedro Alves
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=87fu3tfvfu.fsf@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jan.kratochvil@redhat.com \
--cc=palves@redhat.com \
/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