From: Pedro Alves <palves@redhat.com>
To: Patrick Palka <patrick@parcs.ath.cx>, Yao Qi <qiyaoltc@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Unset attach_flag when running a new process
Date: Thu, 13 Aug 2015 16:30:00 -0000 [thread overview]
Message-ID: <55CCC619.3040207@redhat.com> (raw)
In-Reply-To: <CA+C-WL9DD9GgNqQkB5N1Qv7OAGRTtn2z7N0KNt9dqhMmaNgT_A@mail.gmail.com>
On 08/02/2015 09:20 PM, Patrick Palka wrote:
> On Thu, Jul 30, 2015 at 12:24 PM, Yao Qi <qiyaoltc@gmail.com> wrote:
>> On 30/07/15 16:28, Patrick Palka wrote:
>>>
>>> + /* Unset attach_flag, it may be set if the previous process associated
>>> with
>>> + the inferior was attached to. */
>>> + current_inferior ()->attach_flag = 0;
>>
>>
>> It is better to do such reset in target.c:target_pre_inferior, which
>> is created for such purpose, as far as I know.
>
> That makes sense, although I am a bit hesitant about such a change,
> since target_pre_inferior has a lot of callers.
You mean, the whole lot of 3 callers. :-)
infcmd.c:542: target_pre_inferior (from_tty);
infcmd.c:2603: target_pre_inferior (from_tty);
target.c:2191: target_pre_inferior (from_tty);
> Is it OK, for
> instance, to assume that current_inferior points to the right inferior
> when target_pre_inferior gets called? Currently current_inferior is
> not called directly or indirectly from target_pre_inferior.
Should be. It's called from the run command, and from the
attach command. Those assume that the current inferior is
the inferior that we're about to run/attach.
The call in target_preopen is more dubious. That should probably
be iterating over all inferiors and calling target_pre_inferior
on each. For the case where you have multiple inferiors, and then
connect to a remote target with "target remote".
> +set test "kill process"
> +send_gdb "kill\n"
> +gdb_expect {
> + -re ".y or n. $" {
> + send_gdb "y\n"
> + exp_continue
> + }
> + -re "$gdb_prompt $" {
> + pass $test
> + }
> + default {
> + fail $test
> + }
> +}
Avoid raw gdb_expect. You can write:
gdb_test "kill" \
"" \
"kill process" \
"Kill the program being debugged.*y or n. $" \
"y"
> +
> +set test "restart process"
> +gdb_test "start" "Starting program.*Temporary breakpoint .*" $test
> +
> +set test "attempt kill via quit"
> +send_gdb "quit\n"
> +set ok 0
> +# The quit prompt should warn about killing the process, not about detaching the
> +# process, since this process was not attached to.
> +gdb_expect {
Please use gdb_test_multiple. That catches internal errors and such.
> + -re "will be killed.*.y or n. $" {
> + set ok 1
> + send_gdb "n\n"
> + exp_continue
> + }
> + -re "will be detached.*.y or n. $" {
> + send_gdb "n\n"
> + exp_continue
> + }
> + -re "$gdb_prompt $" {
> + if $ok {
> + pass $test
> + } else {
> + fail $test
> + }
gdb_assert $ok $test
> + }
> + default {
> + fail $test
> + }
> +}
> +
> +remote_exec host "kill $testpid"
>
Thanks,
Pedro Alves
next prev parent reply other threads:[~2015-08-13 16:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-30 1:24 Patrick Palka
2015-07-30 15:28 ` Patrick Palka
2015-07-30 16:24 ` Yao Qi
2015-08-02 20:20 ` Patrick Palka
2015-08-13 16:30 ` Pedro Alves [this message]
2015-08-13 17:19 ` Patrick Palka
2015-08-17 13:01 ` Patrick Palka
2015-08-26 16:05 ` Patrick Palka
2015-08-26 17:06 ` Pedro Alves
2015-08-27 0:56 ` Patrick Palka
2015-09-16 16:34 ` Doug Evans
2015-08-13 15:12 ` Patrick Palka
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=55CCC619.3040207@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=patrick@parcs.ath.cx \
--cc=qiyaoltc@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).