[PATCH 26/46] gdb: revise the pid_to_exec_file target op

Tankut Baris Aktemur tankut.baris.aktemur@intel.com
Tue Jul 2 11:42:57 GMT 2024


Some targets, such as Intel GT, do not have the notion of an exec
file.  These targets may leave the pid_to_exec_file target op
unimplemented, but from GDB's point of view, this means the exec file
could not be determined, and GDB issues a warning.

Extend the meaning of the pid_to_exec_file target op, so that if the
exec file path is empty, it means that the target does not have exec
files at all.  This way, GDB can omit checking the exec file while
also not issuing the warning.
---
 gdb/exec.c   | 6 ++++++
 gdb/target.h | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/gdb/exec.c b/gdb/exec.c
index 63eee4297bc..1b43d9ea976 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -328,6 +328,12 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
       return;
     }
 
+  if (*exec_file_target == '\0')
+    {
+      /* The target does not have the notion of an exec file.  */
+      return;
+    }
+
   gdb::unique_xmalloc_ptr<char> exec_file_host
     = exec_file_find (exec_file_target, NULL);
 
diff --git a/gdb/target.h b/gdb/target.h
index b840ea05ac2..ea484ca4065 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1996,6 +1996,9 @@ extern gdb::array_view<const gdb_byte> target_thread_info_to_thread_handle
 
    If the executable file cannot be determined, NULL is returned.
 
+   If the target does not have the notion of executable files,
+   empty string is returned.
+
    Else, a pointer to a character string containing the pathname
    is returned.  This string should be copied into a buffer by
    the client if the string will not be immediately used, or if
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928



More information about the Gdb-patches mailing list