Implement "info proc exe" for NetBSD

Message ID 20200412153653.6277-1-n54@gmx.com
State New
Headers show
Series
  • Implement "info proc exe" for NetBSD
Related show

Commit Message

Kamil Rytarowski April 12, 2020, 3:36 p.m.
Use pid_to_exec_file() to query the program.

gdb/ChangeLog:

	* nbsd-nat.c (nbsd_nat_target::info_proc): Add do_exe.
---
 gdb/nbsd-nat.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

--
2.25.0

Comments

Simon Marchi April 12, 2020, 5:13 p.m. | #1
On 2020-04-12 11:36 a.m., Kamil Rytarowski wrote:
> Use pid_to_exec_file() to query the program.

> 

> gdb/ChangeLog:

> 

> 	* nbsd-nat.c (nbsd_nat_target::info_proc): Add do_exe.


Thanks, this is ok.

Simon
Kamil Rytarowski April 12, 2020, 5:22 p.m. | #2
On 12.04.2020 19:13, Simon Marchi wrote:
> On 2020-04-12 11:36 a.m., Kamil Rytarowski wrote:

>> Use pid_to_exec_file() to query the program.

>>

>> gdb/ChangeLog:

>>

>> 	* nbsd-nat.c (nbsd_nat_target::info_proc): Add do_exe.

>

> Thanks, this is ok.

>

> Simon

>


Thanks.

I will just reorder "if (do_exe)" and "if (do_mappings)" to follow the
FreeBSD order and push it.

Patch

diff --git a/gdb/nbsd-nat.c b/gdb/nbsd-nat.c
index 2420153c7bc..828bbb57c82 100644
--- a/gdb/nbsd-nat.c
+++ b/gdb/nbsd-nat.c
@@ -299,6 +299,7 @@  bool
 nbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
 {
   pid_t pid;
+  bool do_exe = false;
   bool do_mappings = false;

   switch (what)
@@ -306,6 +307,9 @@  nbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
     case IP_MAPPINGS:
       do_mappings = true;
       break;
+    case IP_EXE:
+      do_exe = true;
+      break;
     default:
       error (_("Not supported on this target."));
     }
@@ -345,6 +349,14 @@  nbsd_nat_target::info_proc (const char *args, enum info_proc_what what)
       else
 	warning (_("unable to fetch virtual memory map"));
     }
+  if (do_exe)
+    {
+      const char *exe = pid_to_exec_file (pid);
+      if (exe != nullptr)
+	printf_filtered ("exe = '%s'\n", exe);
+      else
+	warning (_("unable to fetch executable path name"));
+    }

   return true;
 }