109 lines
3.2 KiB
Diff
109 lines
3.2 KiB
Diff
|
From ab0396671d0d5f05573837171e0f2180ab194411 Mon Sep 17 00:00:00 2001
|
|||
|
From: Andrew Burgess <aburgess@redhat.com>
|
|||
|
Date: Tue, 4 Apr 2023 14:50:35 +0100
|
|||
|
Subject: [PATCH 6/7] Add "maint info linux-lwps" command
|
|||
|
|
|||
|
This adds a maintenance command that lets you list all the LWPs under
|
|||
|
control of the linux-nat target.
|
|||
|
|
|||
|
For example:
|
|||
|
|
|||
|
(gdb) maint info linux-lwps
|
|||
|
LWP Ptid Thread ID
|
|||
|
560948.561047.0 None
|
|||
|
560948.560948.0 1.1
|
|||
|
|
|||
|
This shows that "560948.561047.0" LWP doesn't map to any thread_info
|
|||
|
object, which is bogus. We'll be using this in a testcase in a
|
|||
|
following patch.
|
|||
|
|
|||
|
Co-Authored-By: Pedro Alves <pedro@palves.net>
|
|||
|
Change-Id: Ic4e9e123385976e5cd054391990124b7a20fb3f5
|
|||
|
---
|
|||
|
gdb/doc/gdb.texinfo | 4 ++++
|
|||
|
gdb/linux-nat.c | 46 +++++++++++++++++++++++++++++++++++++++++++++
|
|||
|
2 files changed, 50 insertions(+)
|
|||
|
|
|||
|
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
|
|||
|
index c277c16297c..ad9d89796bc 100644
|
|||
|
--- a/gdb/doc/gdb.texinfo
|
|||
|
+++ b/gdb/doc/gdb.texinfo
|
|||
|
@@ -41208,6 +41208,10 @@ module (@pxref{Disassembly In Python}), and will only be present after
|
|||
|
that module has been imported. To force the module to be imported do
|
|||
|
the following:
|
|||
|
|
|||
|
+@kindex maint info linux-lwps
|
|||
|
+@item maint info linux-lwps
|
|||
|
+Print information about LWPs under control of the Linux native target.
|
|||
|
+
|
|||
|
@smallexample
|
|||
|
(@value{GDBP}) python import gdb.disassembler
|
|||
|
@end smallexample
|
|||
|
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
|
|||
|
index 2f89d283acc..a3ff6036e98 100644
|
|||
|
--- a/gdb/linux-nat.c
|
|||
|
+++ b/gdb/linux-nat.c
|
|||
|
@@ -4522,6 +4522,49 @@ current_lwp_ptid (void)
|
|||
|
return inferior_ptid;
|
|||
|
}
|
|||
|
|
|||
|
+/* Implement 'maintenance info linux-lwps'. Displays some basic
|
|||
|
+ information about all the current lwp_info objects. */
|
|||
|
+
|
|||
|
+static void
|
|||
|
+maintenance_info_lwps (const char *arg, int from_tty)
|
|||
|
+{
|
|||
|
+ if (all_lwps ().size () == 0)
|
|||
|
+ {
|
|||
|
+ gdb_printf ("No Linux LWPs\n");
|
|||
|
+ return;
|
|||
|
+ }
|
|||
|
+
|
|||
|
+ /* Start the width at 8 to match the column heading below, then
|
|||
|
+ figure out the widest ptid string. We'll use this to build our
|
|||
|
+ output table below. */
|
|||
|
+ size_t ptid_width = 8;
|
|||
|
+ for (lwp_info *lp : all_lwps ())
|
|||
|
+ ptid_width = std::max (ptid_width, lp->ptid.to_string ().size ());
|
|||
|
+
|
|||
|
+ /* Setup the table headers. */
|
|||
|
+ struct ui_out *uiout = current_uiout;
|
|||
|
+ ui_out_emit_table table_emitter (uiout, 2, -1, "linux-lwps");
|
|||
|
+ uiout->table_header (ptid_width, ui_left, "lwp-ptid", _("LWP Ptid"));
|
|||
|
+ uiout->table_header (9, ui_left, "thread-info", _("Thread ID"));
|
|||
|
+ uiout->table_body ();
|
|||
|
+
|
|||
|
+ /* Display one table row for each lwp_info. */
|
|||
|
+ for (lwp_info *lp : all_lwps ())
|
|||
|
+ {
|
|||
|
+ ui_out_emit_tuple tuple_emitter (uiout, "lwp-entry");
|
|||
|
+
|
|||
|
+ thread_info *th = linux_target->find_thread (lp->ptid);
|
|||
|
+
|
|||
|
+ uiout->field_string ("lwp-ptid", lp->ptid.to_string ().c_str ());
|
|||
|
+ if (th == nullptr)
|
|||
|
+ uiout->field_string ("thread-info", "None");
|
|||
|
+ else
|
|||
|
+ uiout->field_string ("thread-info", print_full_thread_id (th));
|
|||
|
+
|
|||
|
+ uiout->message ("\n");
|
|||
|
+ }
|
|||
|
+}
|
|||
|
+
|
|||
|
void _initialize_linux_nat ();
|
|||
|
void
|
|||
|
_initialize_linux_nat ()
|
|||
|
@@ -4559,6 +4602,9 @@ Enables printf debugging output."),
|
|||
|
sigemptyset (&blocked_mask);
|
|||
|
|
|||
|
lwp_lwpid_htab_create ();
|
|||
|
+
|
|||
|
+ add_cmd ("linux-lwps", class_maintenance, maintenance_info_lwps,
|
|||
|
+ _("List the Linux LWPS."), &maintenanceinfolist);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
--
|
|||
|
2.35.3
|
|||
|
|