binutils-gdb/gdb/nat
Simon Marchi 7831bc9185 gdb: remove get_exec_file
I believe that the get_exec_file function is unnecessary, and the code
can be simplified if we remove it.

Consider for instance when you "run" a program on Linux with native
debugging.

 1. run_command_1 obtains the executable file from
    `current_program_space->exec_filename ()`
 2. it passes it to `run_target->create_inferior()`, which is
    `inf_ptrace_target::create_inferior()` in this case, which then
    passes it to `fork_inferior()`
 3. `fork_inferior()` then has a fallback, where if the passed exec file
    is nullptr, it gets its from `get_exec_file()`.
 4. `get_exec_file()` returns `current_program_space->exec_filename ()`
    - just like the things we started with - or errors out if the
    current program space doesn't have a specified executable.

If there's no exec filename passed in step 1, there's not going to be
any in step 4, so it seems pointless to call `get_exec_file()`, we could
just error out when `exec_file` is nullptr.  But we can't error out
directly in `fork_inferior()`, since the error is GDB-specific, and that
function is shared with GDBserver.

Speaking of GDBserver, all code paths that lead to `fork_inferior()`
provide a non-nullptr exec file.

Therefore, to simplify things:

 - Make `fork_inferior()` assume that the passed exec file is not
   nullptr, don't call `get_exec_file()`
 - Change some targets (darwin-nat, go32-nat, gnu-nat, inf-ptrace,
   nto-procfs, procfs) to error out when the exec file passed to their
   create_inferior method is nullptr.  Some targets are fine with a
   nullptr exec file, so we can't check that in `run_command_1()`.
 - Add the `no_executable_specified_error()` function, which re-uses the
   error message that `get_exec_file()` had.
 - Change some targets (go32-nat, nto-procfs) to not call
   `get_exec_file()`, since it's pointless for the same reason as in the
   example above, if it returns, it's going the be the same value as the
   `exec_file` parameter.  Just rely on `exec_file`.
 - Remove the final use of `get_exec_file()`, in `load_command()`.
 - Remove the `get_exec_file()` implementations in GDB and GDBserver and
   remove the shared declaration.

Change-Id: I601c16498e455f7baa1f111a179da2f6c913baa3
Approved-By: Tom Tromey <tom@tromey.com>
2024-06-07 23:09:03 -04:00
..
aarch64-hw-point.c Fix regression on aarch64-linux gdbserver 2024-05-02 10:04:14 -06:00
aarch64-hw-point.h Fix regression on aarch64-linux gdbserver 2024-05-02 10:04:14 -06:00
aarch64-linux-hw-point.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
aarch64-linux-hw-point.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
aarch64-linux.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
aarch64-linux.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
aarch64-mte-linux-ptrace.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
aarch64-mte-linux-ptrace.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
aarch64-scalable-linux-ptrace.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
aarch64-scalable-linux-ptrace.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
aarch64-scalable-linux-sigcontext.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
amd64-linux-siginfo.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
amd64-linux-siginfo.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
fork-inferior.c gdb: remove get_exec_file 2024-06-07 23:09:03 -04:00
fork-inferior.h gdb: define type aliases for fork_inferior() callbacks 2024-05-16 15:09:48 -04:00
gdb_ptrace.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_thread_db.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
glibc_thread_db.h
linux-btrace.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
linux-btrace.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
linux-namespaces.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
linux-namespaces.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
linux-nat.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
linux-osdata.c gdb/nat: Factor linux_proc_get_stat_field out of linux_common_core_of_thread 2024-04-29 23:14:06 -03:00
linux-osdata.h gdb/nat: Factor linux_proc_get_stat_field out of linux_common_core_of_thread 2024-04-29 23:14:06 -03:00
linux-personality.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
linux-personality.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
linux-procfs.c gdb/nat/linux: Fix attaching to process when it has zombie threads 2024-04-29 23:14:11 -03:00
linux-procfs.h gdb/nat/linux: Fix attaching to process when it has zombie threads 2024-04-29 23:14:11 -03:00
linux-ptrace.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
linux-ptrace.h gdb+gdbserver/Linux: Remove USE_SIGTRAP_SIGINFO fallback 2024-04-17 18:21:30 +01:00
linux-waitpid.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
linux-waitpid.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
mips-linux-watch.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
mips-linux-watch.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
netbsd-nat.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
netbsd-nat.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
ppc-linux.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
ppc-linux.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
riscv-linux-tdesc.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
riscv-linux-tdesc.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
windows-nat.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
windows-nat.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
x86-cpuid.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
x86-dregs.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
x86-dregs.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
x86-gcc-cpuid.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
x86-linux-dregs.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
x86-linux-dregs.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
x86-linux.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
x86-linux.h Revert "gdb/x86: move reading of cs and ds state into gdb/nat directory" 2024-03-26 18:53:17 +00:00
x86-xstate.c gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
x86-xstate.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00