From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4250 invoked by alias); 1 Apr 2008 02:00:21 -0000 Received: (qmail 4016 invoked by uid 22791); 1 Apr 2008 02:00:15 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.25) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 01 Apr 2008 01:59:49 +0000 Received: from kahikatea.snap.net.nz (30.31.255.123.static.snap.net.nz [123.255.31.30]) by viper.snap.net.nz (Postfix) with ESMTP id 716C33D9F00 for ; Tue, 1 Apr 2008 14:59:46 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 1000) id BEFB18FC6D; Tue, 1 Apr 2008 13:59:42 +1200 (NZST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18417.38670.195071.81191@kahikatea.snap.net.nz> Date: Tue, 01 Apr 2008 02:08:00 -0000 To: gdb-patches@sourceware.org Subject: [RFC] Using bt command in async mode X-Mailer: VM 7.19 under Emacs 22.1.92.3 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-04/txt/msg00002.txt.bz2 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 * 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;