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>
Calls of `get_exec_file (0)` are equivalent to just getting the exec
filename from the current program space. I'm looking to remove
`get_exec_file`, so replace these uses with
`current_program_space->exec_filename ()`.
Remove the `err` parameter of `get_exec_wrapper` since all the calls
that remain pass 1, meaning to error out if no executable is specified.
Change-Id: I7729ea4c7f03dbb046211cc5aa3858ab3a551965
Approved-By: Tom Tromey <tom@tromey.com>
This commit is the result of the following actions:
- Running gdb/copyright.py to update all of the copyright headers to
include 2024,
- Manually updating a few files the copyright.py script told me to
update, these files had copyright headers embedded within the
file,
- Regenerating gdbsupport/Makefile.in to refresh it's copyright
date,
- Using grep to find other files that still mentioned 2023. If
these files were updated last year from 2022 to 2023 then I've
updated them this year to 2024.
I'm sure I've probably missed some dates. Feel free to fix them up as
you spot them.
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
Same idea as the previous patch, but for m_cwd.
To keep things consistent across the board, change get_inferior_cwd as
well, which is shared with GDBserver. So update the related GDBserver
code too.
Change-Id: Ia2c047fda738d45f3d18bc999eb67ceb8400ce4e
The declaration of set_inferior_cwd is currently shared between gdb and
gdbserver, in gdbsupport/common-inferior.h. It doesn't need to be, as
set_inferior_cwd is not called from common code. Only get_inferior_cwd
needs to.
The motivation for this is that a future patch will change the prototype
of set_inferior_cwd in gdb, and I don't want to change it for gdbserver
unnecessarily. I see this as a good cleanup in any case, to reduce to
just the essential what is shared between GDB and GDBserver.
Change-Id: I3127d27d078f0503ebf5ccc6fddf14f212426a73
This commits the result of running gdb/copyright.py as per our Start
of New Year procedure...
gdb/ChangeLog
Update copyright year range in copyright header of all GDB files.
Adapt the construct_inferior_arguments function to
take a gdb::array_view<char * const> parameter instead
of a char * array and an int indicating the length
and adapt the only call site.
This will allow calling it more simply in a follow-up
patch introducing more uses of the function.
gdbsupport/ChangeLog:
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to take a gdb::array_view<char * const> parameter.
Adapt call site.
Change-Id: I1c6496c8c0b0eb3ef3fda96e9e3bd64c5e6cac3c
Allow construct_inferior_arguments to handle zero args
and have it return a std::string, similar to how
stringify_argv in gdbsupport/common-utils does.
Also, add a const qualifier for the second parameter,
since it is only read, not written to.
The intention is to replace existing uses of
stringify_argv by construct_inferior_arguments
in a subsequent step, since construct_inferior_arguments
properly handles special characters, while stringify_argv
doesn't.
gdbsupport/ChangeLog:
* common-inferior.cc, common-inferior.h (construct_inferior_arguments):
Adapt to handle zero args and return a std::string.
Adapt call site.
Change-Id: I126c4390a1018c7527b0b8fd545252ab8a5a7adc
This moves the function construct_inferior_arguments from
gdb/inferior.h and gdb/infcmd.c to gdbsupport/common-inferior.{h,cc}.
While at it, also move the function's comment to the header file
to align with current standards.
The intention is to use it from gdbserver in a follow-up commit.
gdb/ChangeLog:
* infcmd.c, inferior.h: (construct_inferior_arguments):
Moved function from here to gdbsupport/common-inferior.{h,cc}
gdbsupport/ChangeLog:
* common-inferior.h, common-inferior.cc: (construct_inferior_arguments):
Move function here from gdb/infcmd.c, gdb/inferior.h
Change-Id: Ib9290464ce8c0872f605d8829f88352d064c30d6
This patch moves the gdbsupport directory to the top level. This is
the next step in the ongoing project to move gdbserver to the top
level.
The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport".
This patch then adds a build system to gdbsupport and wires it into
the top level. Then it changes gdb to use the top-level build.
gdbserver, on the other hand, is not yet changed. It still does its
own build of gdbsupport.
ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport.
* MAINTAINERS: Add gdbsupport.
* configure: Rebuild.
* configure.ac (configdirs): Add gdbsupport.
* gdbsupport: New directory, move from gdb/gdbsupport.
* Makefile.def (host_modules, dependencies): Add gnulib.
* Makefile.in: Rebuild.
gdb/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* nat/x86-linux-dregs.c: Include configh.h.
* nat/linux-ptrace.c: Include configh.h.
* nat/linux-btrace.c: Include configh.h.
* defs.h: Include config.h, bfd.h.
* configure.ac: Don't source common.host.
(CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files.
* configure: Rebuild.
* acinclude.m4: Update path.
* Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables.
(CONFIG_SRC_SUBDIR): Remove gdbsupport.
(INTERNAL_CFLAGS_BASE): Add INCSUPPORT.
(CLIBS): Add LIBSUPPORT.
(CDEPS): Likewise.
(COMMON_SFILES): Remove gdbsupport files.
(HFILES_NO_SRCDIR): Likewise.
(stamp-version): Update path to create-version.sh.
(ALLDEPFILES): Remove gdbsupport files.
gdb/gdbserver/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* server.h: Include config.h.
* gdbreplay.c: Include config.h.
* configure: Rebuild.
* configure.ac: Don't source common.host.
* acinclude.m4: Update path.
* Makefile.in (INCSUPPORT): New variable.
(INCLUDE_CFLAGS): Add INCSUPPORT.
(SFILES): Update paths.
(version-generated.c): Update path to create-version.sh.
(gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths.
gdbsupport/ChangeLog
2020-01-14 Tom Tromey <tom@tromey.com>
* common-defs.h: Add GDBSERVER case. Update includes.
* acinclude.m4, aclocal.m4, config.in, configure, configure.ac,
Makefile.am, Makefile.in, README: New files.
* Moved from ../gdb/gdbsupport/
Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78