This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC]: Improvement of TUI status line to display pid and thread instead of target name
- From: Stephane Carrez <stephane dot carrez at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Sat, 10 Nov 2012 18:53:47 +0100
- Subject: [RFC]: Improvement of TUI status line to display pid and thread instead of target name
Hi!
While debugging a multi-thread application, the TUI status line looks
as follows:
multi-thre Thread 0xb7175 In:
system__tasking__rendezvous__timed_task_entry_call
Line: ?? PC: 0xb7d49787
The target name and thread information are not useful at all.
I've worked on a better status line which displays the process id, the
current thread id
and the number of threads. The new status line looks as follows:
Pid 25932 Tid 1 on 7 In:
system__tasking__rendezvous__timed_task_entry_call
Line: ?? PC: 0xb7d49787
I've also used the thread observer to be notified when a thread is
created or exited
so the status line is refreshed while threads are created/exited.
Attached is the patch for the above changes.
Before committing it, I would like your feedback.
Stephane
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/gdb/ChangeLog,v
retrieving revision 1.14812
diff -u -p -r1.14812 ChangeLog
--- ChangeLog 10 Nov 2012 13:12:17 -0000 1.14812
+++ ChangeLog 10 Nov 2012 17:41:48 -0000
@@ -1,5 +1,15 @@
2012-11-10 Stephane Carrez <Stephane.Carrez@gmail.com>
+ * tui/tui-data.h (MAX_PID_WIDTH): Increase to 24.
+ * tui/tui-stack.c (tui_make_status_line): Display the
+ current process and thread id instead of target name.
+ * tui/tui-hooks.c (tui_thread_exit): New function.
+ (tui_new_thread): Likewise.
+ (tui_install_hooks): Install the thread observers.
+ (tui_remove_hooks): And remove them here.
+
+2012-11-10 Stephane Carrez <Stephane.Carrez@gmail.com>
+
* tui/tui.c (tui_rl_command_key): Switch to TUI_ONE_COMMAND_MODE
while executing the gdb command.
(tui_rl_startup_hook): Do not switch back to TUI_SINGLE_KEY_MODE if we
Index: tui/tui-data.h
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-data.h,v
retrieving revision 1.29
diff -u -p -r1.29 tui-data.h
--- tui/tui-data.h 1 Mar 2012 21:08:07 -0000 1.29
+++ tui/tui-data.h 10 Nov 2012 17:41:48 -0000
@@ -86,7 +86,7 @@ struct tui_gen_win_info
numbers. */
#define MIN_PROC_WIDTH 12
#define MAX_TARGET_WIDTH 10
-#define MAX_PID_WIDTH 14
+#define MAX_PID_WIDTH 24
#define TUI_FLOAT_REGS_NAME "$FREGS"
#define TUI_FLOAT_REGS_NAME_LOWER "$fregs"
Index: tui/tui-hooks.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-hooks.c,v
retrieving revision 1.50
diff -u -p -r1.50 tui-hooks.c
--- tui/tui-hooks.c 8 Nov 2012 22:54:11 -0000 1.50
+++ tui/tui-hooks.c 10 Nov 2012 17:41:48 -0000
@@ -181,6 +181,22 @@ tui_about_to_proceed (void)
tui_target_has_run = 1;
}
+/* Handle thread exit. Refresh the status line. */
+
+static void
+tui_thread_exit (struct thread_info *tp, int silent)
+{
+ tui_show_locator_content ();
+}
+
+/* Handle thread creation. Refresh the status line. */
+
+static void
+tui_new_thread (struct thread_info *tp)
+{
+ tui_show_locator_content ();
+}
+
/* The selected frame has changed. This is happens after a target
stop or when the user explicitly changes the frame
(up/down/thread/...). */
@@ -253,6 +269,8 @@ static struct observer *tui_bp_deleted_o
static struct observer *tui_bp_modified_observer;
static struct observer *tui_inferior_exit_observer;
static struct observer *tui_about_to_proceed_observer;
+static struct observer *tui_thread_exit_observer;
+static struct observer *tui_new_thread_observer;
/* Install the TUI specific hooks. */
void
@@ -276,6 +294,10 @@ tui_install_hooks (void)
= observer_attach_inferior_exit (tui_inferior_exit);
tui_about_to_proceed_observer
= observer_attach_about_to_proceed (tui_about_to_proceed);
+ tui_thread_exit_observer
+ = observer_attach_thread_exit (tui_thread_exit);
+ tui_new_thread_observer
+ = observer_attach_new_thread (tui_new_thread);
deprecated_register_changed_hook = tui_register_changed_hook;
}
@@ -300,6 +322,10 @@ tui_remove_hooks (void)
tui_inferior_exit_observer = NULL;
observer_detach_about_to_proceed (tui_about_to_proceed_observer);
tui_about_to_proceed_observer = NULL;
+ observer_detach_thread_exit (tui_thread_exit_observer);
+ tui_thread_exit_observer = NULL;
+ observer_detach_new_thread (tui_new_thread_observer);
+ tui_new_thread_observer = NULL;
}
void _initialize_tui_hooks (void);
Index: tui/tui-stack.c
===================================================================
RCS file: /cvs/src/src/gdb/tui/tui-stack.c,v
retrieving revision 1.46
diff -u -p -r1.46 tui-stack.c
--- tui/tui-stack.c 25 Apr 2012 08:16:43 -0000 1.46
+++ tui/tui-stack.c 10 Nov 2012 17:41:48 -0000
@@ -29,6 +29,7 @@
#include "top.h"
#include "gdb-demangle.h"
#include "gdb_string.h"
+#include "gdbthread.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
#include "tui/tui-stack.h"
@@ -57,8 +58,8 @@ static void tui_update_command (char *,
/* Create the status line to display as much information as we can on
- this single line: target name, process number, current function,
- current line, current PC, SingleKey mode. */
+ this single line: target name, process number, thread id, thread count,
+ current function, current line, current PC, SingleKey mode. */
static char*
tui_make_status_line (struct tui_locator_element *loc)
{
@@ -74,16 +75,31 @@ tui_make_status_line (struct tui_locator
int line_width;
int pc_width;
struct ui_file *pc_out;
+ char proc_info[40];
+
+ target_width = strlen (target_shortname);
+ if (target_width > MAX_TARGET_WIDTH)
+ target_width = MAX_TARGET_WIDTH;
if (ptid_equal (inferior_ptid, null_ptid))
pid_name = "No process";
else
- pid_name = target_pid_to_str (inferior_ptid);
+ {
+ int nr_threads = thread_count ();
- target_width = strlen (target_shortname);
- if (target_width > MAX_TARGET_WIDTH)
- target_width = MAX_TARGET_WIDTH;
+ if (nr_threads > 1)
+ xsnprintf (proc_info, sizeof (proc_info), "Pid %d Tid %d on %d",
+ ptid_get_pid (inferior_ptid),
+ pid_to_thread_id (inferior_ptid),
+ nr_threads);
+ else
+ xsnprintf (proc_info, sizeof (proc_info), "Pid %d",
+ ptid_get_pid (inferior_ptid));
+ target_width = 0;
+ pid_name = proc_info;
+ }
+
pid_width = strlen (pid_name);
if (pid_width > MAX_PID_WIDTH)
pid_width = MAX_PID_WIDTH;