From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] mi: Restore original thread/frame when specifying --thread or --thread-group
Date: Wed, 03 Aug 2016 13:41:00 -0000 [thread overview]
Message-ID: <83adec9c-d7a1-3165-eac7-236372e994ef@redhat.com> (raw)
In-Reply-To: <a53f780e-0163-5257-e670-c373e8a1cdf1@ericsson.com>
On 08/02/2016 11:14 PM, Simon Marchi wrote:
> On 16-08-02 01:38 PM, Simon Marchi wrote:
>> Ok, I kinda had the same design idea, but it was blurry. Now that you explain it
>> (I didn't know what previous_inferior_ptid was), it's clear. I'll try to prototype it
>> quickly to see if it's viable.
>
> I started to prototype what you described, but it's definitely not a small job. It would
> also be too big of a change to put in 7.12. I'd be really interested to work on that for
> the next development cycle though.
>
> In the mean time, here is a new version of the patch that implements what I had described
> (with the global flag), which I think is less risky.
I think you need to consider infcalls, and canned sequence of commands
Python/Scheme, etc., basically any place that sets ui->async = 0 ...
guile/guile.c:169: current_ui->async = 0;
guile/guile.c:202: current_ui->async = 0;
guile/guile.c:332: current_ui->async = 0;
guile/scm-ports.c:521: current_ui->async = 0;
top.c:700: current_ui->async = 0;
compile/compile.c:95: current_ui->async = 0;
compile/compile.c:137: current_ui->async = 0;
compile/compile.c:191: current_ui->async = 0;
infcall.c:586: current_ui->async = 0;
python/python.c:326: current_ui->async = 0;
python/python.c:471: current_ui->async = 0;
python/python.c:655: current_ui->async = 0;
cli/cli-script.c:384: current_ui->async = 0;
cli/cli-script.c:666: current_ui->async = 0;
cli/cli-script.c:690: current_ui->async = 0;
cli/cli-script.c:1697: current_ui->async = 0;
... because these will only return when execution next stops,
so the cleanup runs after, and undoes the thread change.
E.g., this infcall stops due to a breakpoint on another
thread, but MI still reverts back to the "--thread" thread:
(gdb)
b usleep
[...]
^done
(gdb)
thread 1
[...]
^done
=thread-selected,id="1"
(gdb)
-interpreter-exec --thread 1 console "print sleep (10)"
[...]
~"[Switching to Thread 0x7ffff6ffb700 (LWP 7818)]\n"
~"\n"
~"Thread 3 \"threads\" hit Breakpoint 2, usleep (useconds=1) at ../sysdeps/posix/usleep.c:26\n"
~"26\t struct timespec ts = { .tv_sec = (long int) (useconds / 1000000),\n"
*stopped,reason="breakpoint-hit",disp="keep",bkptno="2",frame={addr="0x00007ffff78f6030",func="usleep",args=[{name="useconds",value="1"}],file="../sysdeps/posix/usleep.c",fullname="/usr/src/debug/glibc-2.22/sysdeps/posix/usleep.c",line="26"},thread-id="3",stopped-threads="all",core="2"
&"The program stopped in another thread while making a function call from GDB.\n"
&"Evaluation of the expression containing the function\n"
&"(__sleep) will be abandoned.\n"
&"When the function is done executing, GDB will silently stop.\n"
^error,msg="The program stopped in another thread while making a function call from GDB.\nEvaluation of the expression containing the function\n(__sleep) will be abandoned.\nWhen the function is done executing, GDB will silently stop."
(gdb)
thread
[...]
~"[Current thread is 1 (Thread 0x7ffff7fc8700 (LWP 7813))]\n"
^done
(gdb)
Above should have been 3.
E.g., this user-defined command starts the program and stops in
thread 2.1, but MI still reverts back to the "--thread" thread:
(gdb) define foo
~">" inferior 2
~">" start
~">" end
(gdb)
info inferiors
~" Num Description Executable \n"
~"* 1 process 8216 /home/pedro/brno/pedro/gdb/tests/threads \n"
~" 2 <null> /home/pedro/brno/pedro/gdb/tests/threads \n"
^done
(gdb)
info threads
~" Id Target Id Frame \n"
~"* 1.1 Thread 0x7ffff7fc8700 (LWP 8216) \"threads\" main () at threads.c:54\n"
^done
(gdb)
-interpreter-exec --thread 1 console "foo"
~"[Switching to inferior 2 [<null>] (/home/pedro/brno/pedro/gdb/tests/threads)]\n"
[...]
~"\n"
~"Thread 2.1 \"threads\" hit Temporary breakpoint 3, main () at threads.c:54\n"
~"54\t long i = 0;\n"
*stopped,reason="breakpoint-hit",disp="del",bkptno="3",frame={addr="0x000000000040076e",func="main",args=[],file="threads.c",fullname="/home/pedro/brno/pedro/gdb/tests/threads.c",line="54"},thread-id="3",stopped-threads="all",core="7"
=breakpoint-deleted,id="3"
(gdb)
thread
&"thread\n"
~"[Current thread is 1.1 (Thread 0x7ffff7fc8700 (LWP 8216))]\n"
^done
(gdb)
While at it, "inferior 2" is a command that explicitly changes
the thread, but misses setting the new flag:
-interpreter-exec --thread 1 console "inferior 2"
~"[Switching to inferior 2 [process 8603] (/home/pedro/brno/pedro/gdb/tests/threads)]\n"
~"[Switching to thread 2.1 (Thread 0x7ffff7fc8700 (LWP 8603))] \n"
~"#0 main () at threads.c:54\n"
~"54\t long i = 0;\n"
^done
(gdb)
thread
&"thread \n"
~"[Current thread is 1.1 (Thread 0x7ffff7fc8700 (LWP 8599))]\n"
^done
(gdb)
It may be this requires setting the flag in most of the places
that we'd set the user-selected thread in the other approach,
not sure.
Thanks,
Pedro Alves
next prev parent reply other threads:[~2016-08-03 13:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-01 21:14 [PATCH 0/2] Two MI changes related to separate UIs Simon Marchi
2016-08-01 21:15 ` [PATCH 1/2] mi: Restore original thread/frame when specifying --thread or --thread-group Simon Marchi
2016-08-02 14:49 ` Pedro Alves
2016-08-02 17:45 ` Simon Marchi
2016-08-02 22:32 ` Simon Marchi
2016-08-03 13:41 ` Pedro Alves [this message]
2016-08-03 22:24 ` Simon Marchi
2016-08-05 17:26 ` Pedro Alves
2016-08-05 21:01 ` Simon Marchi
2016-08-17 20:24 ` Simon Marchi
2016-08-01 21:15 ` [PATCH 2/2] mi: Add launch-type={run,attach} in =thread-group-started Simon Marchi
2016-08-02 14:49 ` Eli Zaretskii
2016-08-02 15:55 ` Simon Marchi
2016-08-17 20:17 ` Simon Marchi
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=83adec9c-d7a1-3165-eac7-236372e994ef@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@ericsson.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