From: Nick Roberts <nickrob@snap.net.nz>
To: gdb-patches@sourceware.org
Subject: [RFC] Using bt command in async mode
Date: Tue, 01 Apr 2008 02:08:00 -0000 [thread overview]
Message-ID: <18417.38670.195071.81191@kahikatea.snap.net.nz> (raw)
This patch allows the bt to be executed in async mode while the inferior is
executing. The idea being that the frontend can get a snapshot of what the
inferior is doing and update the UI. It's just a proof of concept, so I've
used linux_nat_async_events and my_waitpid directly but eventually these could
be made into target methods, of course.
If the general idea is agreeable, I would like to extend it to other commands
like "info locals", "info threads" etc.
An example session looks like this:
(gdb) maintenance set linux-async on
(gdb) r&
Starting program: /home/nickrob/donowt
(gdb) bt
#0 0x080483c9 in mysub1 () at donowt.c:12
#1 0x080483f7 in mysub () at donowt.c:22
#2 0x0804840f in main () at donowt.c:28
(gdb) interrupt
(gdb)
Program received signal SIGINT, Interrupt.
0x080483c9 in mysub1 () at donowt.c:12
12 if (i == 5)
(gdb) quit
The program is running. Quit anyway (and kill it)? (y or n) y
nickrob@kahikatea:~$
--
Nick http://www.inet.net.nz/~nickrob
2008-04-01 Nick Roberts <nickrob@snap.net.nz>
* stack.c (backtrace_command): Make it work in async mode when
the target is executing.
* top.c (execute_command): Enable bt command in async mode.
* inferior.h: New externs
* linux-nat.c (linux_nat_async_events, my_waitpid): Make
non-static.
*** stack.c 18 Mar 2008 08:32:24 +1200 1.164
--- stack.c 01 Apr 2008 12:58:57 +1200
*************** static void
*** 1285,1293 ****
backtrace_command (char *arg, int from_tty)
{
struct cleanup *old_chain = NULL;
! int fulltrace_arg = -1, arglen = 0, argc = 0;
struct backtrace_command_args btargs;
if (arg)
{
char **argv;
--- 1285,1306 ----
backtrace_command (char *arg, int from_tty)
{
struct cleanup *old_chain = NULL;
! int fulltrace_arg = -1, arglen = 0, argc = 0, restart = 0;
struct backtrace_command_args btargs;
+ if (target_executing)
+ {
+ int status, options, async_events_were_enabled;
+
+ /* Must be async to get here. */
+ async_events_were_enabled = linux_nat_async_events (0);
+ target_stop ();
+ my_waitpid (PIDGET (inferior_ptid), &status, 0);
+ if (async_events_were_enabled)
+ linux_nat_async_events (1);
+ restart = 1;
+ }
+
if (arg)
{
char **argv;
*************** backtrace_command (char *arg, int from_t
*** 1342,1347 ****
--- 1355,1363 ----
if (old_chain)
do_cleanups (old_chain);
+
+ if (restart)
+ continue_command ("&", 0);
}
static void
*** top.c 01 Apr 2008 13:47:11 +1200 1.137
--- top.c 01 Apr 2008 13:35:00 +1200
*************** execute_command (char *p, int from_tty)
*** 463,469 ****
&& strcmp (c->name, "pwd") != 0
&& strcmp (c->name, "show") != 0
&& strcmp (c->name, "info") != 0
! && strcmp (c->name, "interrupt") != 0)
error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
--- 463,470 ----
&& strcmp (c->name, "pwd") != 0
&& strcmp (c->name, "show") != 0
&& strcmp (c->name, "info") != 0
! && strcmp (c->name, "interrupt") != 0
! && strcmp (c->name, "bt") != 0)
error (_("Cannot execute this command while the target is running."));
/* Pass null arg rather than an empty one. */
*** inferior.h 30 Jan 2008 11:18:32 +1300 1.87
--- inferior.h 01 Apr 2008 09:24:04 +1200
*************** struct regcache;
*** 49,54 ****
--- 49,57 ----
struct inferior_status;
+ extern int my_waitpid (int pid, int *status, int flags);
+ extern int linux_nat_async_events (int enable);
+
extern struct inferior_status *save_inferior_status (int);
extern void restore_inferior_status (struct inferior_status *);
*** linux-nat.c 26 Mar 2008 08:51:33 +1200 1.80
--- linux-nat.c 01 Apr 2008 13:10:00 +1200
*************** static volatile int linux_nat_num_queued
*** 176,182 ****
target events are blocked. */
static int linux_nat_async_events_enabled;
- static int linux_nat_async_events (int enable);
static void pipe_to_local_event_queue (void);
static void local_event_queue_to_pipe (void);
static void linux_nat_event_pipe_push (int pid, int status, int options);
--- 176,181 ----
*************** linux_tracefork_child (void)
*** 350,356 ****
/* Wrapper function for waitpid which handles EINTR, and checks for
locally queued events. */
! static int
my_waitpid (int pid, int *status, int flags)
{
int ret;
--- 349,355 ----
/* Wrapper function for waitpid which handles EINTR, and checks for
locally queued events. */
! int
my_waitpid (int pid, int *status, int flags)
{
int ret;
*************** async_sigchld_handler (int signo)
*** 3820,3826 ****
/* Enable or disable async SIGCHLD handling. */
! static int
linux_nat_async_events (int enable)
{
int current_state = linux_nat_async_events_enabled;
--- 3819,3825 ----
/* Enable or disable async SIGCHLD handling. */
! int
linux_nat_async_events (int enable)
{
int current_state = linux_nat_async_events_enabled;
next reply other threads:[~2008-04-01 2:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-01 2:08 Nick Roberts [this message]
2008-04-01 19:55 ` Tom Tromey
2008-04-01 22:30 ` Nick Roberts
2008-04-10 16:05 ` Vladimir Prus
2008-04-11 22:55 ` Nick Roberts
2008-04-10 15:22 ` Daniel Jacobowitz
2008-04-10 15:36 ` Tom Tromey
2008-04-10 15:39 ` Pedro Alves
2008-04-17 2:58 ` Tom Tromey
2008-04-10 15:53 ` Daniel Jacobowitz
2008-04-17 2:47 ` Tom Tromey
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=18417.38670.195071.81191@kahikatea.snap.net.nz \
--to=nickrob@snap.net.nz \
--cc=gdb-patches@sourceware.org \
/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