mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2026-08-27 00:26:02 -04:00
Currently, on native Windows, GDB presents a mix of backslashes and
forward slashes to users, like e.g.:
...
attach 15044
Attaching to program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.base\attach\attach.exe, process 15044
...
[Switching to thread 1 (Thread 15044.0x1294)]
main () at C:/rocgdb/src/gdb/testsuite/gdb.base/attach.c:19
19 while (! should_exit)
(gdb) FAIL: gdb.base/attach.exp: do_attach_failure_tests: first attach
...
Note how above, the "attach" command uses backslashes, and the source
path uses forward slashes.
Most annoyingly, depending on compiler, you can end up with mixed
slash styles in the same path:
Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp, line 33.
^
A while ago, in commit a63213cd37 ("MSYS2+MinGW testing: Unix <->
Windows path conversion"), I had made the testsuite normalize
backslashes to forward slashes, among other things. I had said in the
commit log there:
"It's arguable whether GDB itself should do this sanitization. I
suspect it should. I personally dislike seeing backward slashes in
e.g., "info shared" output, or worse, mixed backward and forward
slashes. Still, I propose starting with a testsuite adjustment that
moves us forward, and handle that separately. I won't be surprised if
we need the new routine for some cases even if we adjust GDB."
After running into some other tests that would need backslash
adjustment, and also because this is something user-visible, not just
a testsuite issue, I decided to bite the bullet and make GDB itself do
the slashes normalization.
This patch fixes all the cases of backslashes that I could find:
- source files and compilation directory
- executable name, and shared library names
- cd/pwd commands
It does this by normalizing slashes at some strategic places. The
conversion is only attempted if needed -- i.e., if debugging on
Windows, or cross-debugging Windows programs from a non-Windows host.
For executable/shared library names, this is doing the backslash ->
forward slash conversion completely on the host side in common code,
without touching the target backend files in either GDB or GDBserver,
by design, so that this is all completely a client side decision, and
works the same against any Windows GDBserver version, against remote
servers other than ours (e.g., Wine's), so we can change it later if
we want, etc.
I did tweak the gdb and gdbserver backends for the other way around
(forward slash => backslash), to make sure that they pass backslashes
to CreateProcess, so that inferiors see native backslashes in their
own argv[0]. For GDBserver, it would already have been possible to
launch an executable with forward slashes before (e.g., when debugging
from a Linux or Cygwin client), so this makes Windows gdbserver
behavior more consistent, independently of client, too.
I did not add an option to make this configurable at runtime on
purpose. I don't see the point, it'd just add more complication and
testing surface. Always normalizing keeps it simple.
For the source paths, I considered doing the normalization earlier in
the DWARF reader, but decided against it, because that would force
extra copying of strings -- the DWARF reader works mostly by passing
around const char pointers. Also, the places I picked in principle
will automatically handle PDB if/when we get to it.
The buildsym.c change takes care of compilation directory paths.
The allocate_symtab change takes care of source paths. That one
required a (temporary) copy, but I think that that's acceptable there.
The gdb_realpath change is needed because just before the touched code
there's a GetFullPathName call, which itself normalizes to
backslashes.
The exec.c and solib.c changes take care of executable and shared
libraries.
The change to testsuite/lib/gdb.exp, to adjust to forward-slash style
for DOS full names, are necessary otherwise MI tests break. E.g.:
*stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x00007ff780461508",
func="main",args=[],file="C:/rocgdb/src/gdb/testsuite/gdb.mi/basics.c",
fullname="C:/rocgdb/src/gdb/testsuite/gdb.mi/basics.c",line="64",arch="i386:x86-64"},
thread-id="1",stopped-threads="all"
FAIL: gdb.mi/gdb2549.exp: mi runto main (unknown output after running)
gdb.base/set-cwd.exp was the only test I found (so far at least) that
required adjustment, but note that without this patch that testcase
fails and throws TCL errors, like:
...
FAIL: gdb.base/set-cwd.exp: test_cwd_reset: inferior cwd is correctly set
ERROR: couldn't compile regular expression pattern: invalid escape \ sequence
...
It passes cleanly with the patch.
Below's the before / after comparison of different commands / output.
Before:
Reading symbols from ./outputs/gdb.rocm/simple/simple...
(gdb)
start
Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp, line 33.
Starting program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple
Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp:33
33 hipError_t error = hipMalloc (&result_ptr, sizeof (int));
Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp:33
33 hipError_t error = hipMalloc (&result_ptr, sizeof (int));
(gdb)
(gdb) info inferiors
Num Description Connection Executable
* 1 process 15620 1 (native) C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple
(gdb) info sharedlibrary
From To Syms Read Shared Object Library
0x00007ffd22f91000 0x00007ffd231a69a8 Yes (*) C:\Windows\SYSTEM32\ntdll.dll
0x00007ffd21af1000 0x00007ffd21bb2520 Yes (*) C:\Windows\System32\kernel32.dll
0x00007ffd20091000 0x00007ffd20432548 Yes (*) C:\Windows\System32\KernelBase.dll
0x00007ffcc89c1000 0x00007ffcc9b145bc Yes (*) C:\Windows\SYSTEM32\amdhip64_7.dll
0x00007ffd22911000 0x00007ffd22d829b0 Yes (*) C:\Windows\System32\setupapi.dll
0x00007ffd216c1000 0x00007ffd217653f0 Yes (*) C:\Windows\System32\msvcrt.dll
0x00007ffd22431000 0x00007ffd224de5c8 Yes (*) C:\Windows\System32\advapi32.dll
0x00007ffd21a41000 0x00007ffd21ae52b8 Yes (*) C:\Windows\System32\sechost.dll
0x00007ffd20651000 0x00007ffd20676af0 Yes (*) C:\Windows\System32\bcrypt.dll
0x00007ffd21f31000 0x00007ffd22045860 Yes (*) C:\Windows\System32\rpcrt4.dll
0x00007ffd22d91000 0x00007ffd22f40e50 Yes (*) C:\Windows\System32\user32.dll
0x00007ffd20781000 0x00007ffd207a43d8 Yes (*) C:\Windows\System32\win32u.dll
0x00007ffd228d1000 0x00007ffd228f73d8 Yes (*) C:\Windows\System32\gdi32.dll
0x00007ffd207b1000 0x00007ffd208d09c8 Yes (*) C:\Windows\System32\gdi32full.dll
0x00007ffd20b91000 0x00007ffd20c28410 Yes (*) C:\Windows\System32\msvcp_win.dll
0x00007ffd20471000 0x00007ffd2057f410 Yes (*) C:\Windows\System32\ucrtbase.dll
0x00007ffd21541000 0x00007ffd215afbc8 Yes (*) C:\Windows\System32\ws2_32.dll
0x00007ffd223f1000 0x00007ffd2241fc40 Yes (*) C:\Windows\System32\imm32.dll
(gdb) info source
Current source file is C:/rocgdb/src/gdb/testsuite/gdb.rocm\simple.cpp
Compilation directory is C:\msys2\home\alves\gdb\build-testsuite
Located in C:\rocgdb\src\gdb\testsuite\gdb.rocm\simple.cpp
(gdb) info sources
C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple:
C:\rocgdb\src\gdb\testsuite\gdb.rocm\simple.cpp, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_stdio_config.h,
C:\Program Files\AMD\ROCm\7.1\include\hip\hip_runtime_api.h, C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\stdint.h,
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdio.h, C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__stddef_nullptr_t.h,
C:\Program Files\AMD\ROCm\7.1\lib\clang\21\include\__stddef_size_t.h, C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\cstdlib,
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\stdlib.h, C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_search.h,
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt\corecrt_malloc.h,
...
(gdb) detach
Detaching from program: C:\msys2\home\alves\gdb\build-testsuite\outputs\gdb.rocm\simple\simple, process 20800
[Inferior 1 (process 20800) detached]
(gdb) cd /tmp
Working directory C:\tmp.
(gdb) pwd
Working directory C:\tmp.
After:
Reading symbols from ./outputs/gdb.rocm/simple/simple...
(gdb) start
Temporary breakpoint 1 at 0x1400010ec: file C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp, line 33.
Starting program: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple
Thread 1 hit Temporary breakpoint 1, main () at C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp:33
33 hipError_t error = hipMalloc (&result_ptr, sizeof (int));
(gdb) info sources
C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple:
C:/rocgdb/src/gdb/testsuite/gdb.rocm/simple.cpp, C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_stdio_config.h,
C:/Program Files/AMD/ROCm/7.1/include/hip/hip_runtime_api.h, C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include/stdint.h,
C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/stdio.h, C:/Program Files/AMD/ROCm/7.1/lib/clang/21/include/__stddef_nullptr_t.h,
C:/Program Files/AMD/ROCm/7.1/lib/clang/21/include/__stddef_size_t.h, C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/include/cstdlib,
C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/stdlib.h, C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_search.h,
C:/Program Files (x86)/Windows Kits/10/Include/10.0.22621.0/ucrt/corecrt_malloc.h,
...
(gdb) info inferiors
Num Description Connection Executable
* 1 process 19920 1 (native) C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple
(gdb) info shared
From To Syms Read Shared Object Library
0x00007ffd22f91000 0x00007ffd231a69a8 Yes (*) C:/Windows/SYSTEM32/ntdll.dll
0x00007ffd21af1000 0x00007ffd21bb2520 Yes (*) C:/Windows/System32/kernel32.dll
0x00007ffd20091000 0x00007ffd20432548 Yes (*) C:/Windows/System32/KernelBase.dll
0x00007ffcc89c1000 0x00007ffcc9b145bc Yes (*) C:/Windows/SYSTEM32/amdhip64_7.dll
0x00007ffd22911000 0x00007ffd22d829b0 Yes (*) C:/Windows/System32/setupapi.dll
0x00007ffd216c1000 0x00007ffd217653f0 Yes (*) C:/Windows/System32/msvcrt.dll
0x00007ffd22431000 0x00007ffd224de5c8 Yes (*) C:/Windows/System32/advapi32.dll
0x00007ffd21a41000 0x00007ffd21ae52b8 Yes (*) C:/Windows/System32/sechost.dll
0x00007ffd20651000 0x00007ffd20676af0 Yes (*) C:/Windows/System32/bcrypt.dll
0x00007ffd21f31000 0x00007ffd22045860 Yes (*) C:/Windows/System32/rpcrt4.dll
0x00007ffd22d91000 0x00007ffd22f40e50 Yes (*) C:/Windows/System32/user32.dll
0x00007ffd20781000 0x00007ffd207a43d8 Yes (*) C:/Windows/System32/win32u.dll
0x00007ffd228d1000 0x00007ffd228f73d8 Yes (*) C:/Windows/System32/gdi32.dll
0x00007ffd207b1000 0x00007ffd208d09c8 Yes (*) C:/Windows/System32/gdi32full.dll
0x00007ffd20b91000 0x00007ffd20c28410 Yes (*) C:/Windows/System32/msvcp_win.dll
0x00007ffd20471000 0x00007ffd2057f410 Yes (*) C:/Windows/System32/ucrtbase.dll
0x00007ffd21541000 0x00007ffd215afbc8 Yes (*) C:/Windows/System32/ws2_32.dll
0x00007ffd223f1000 0x00007ffd2241fc40 Yes (*) C:/Windows/System32/imm32.dll
(*): Shared library is missing debugging information.
(gdb) detach
Detaching from program: C:/msys2/home/alves/gdb/build-testsuite/outputs/gdb.rocm/simple/simple, process 7816
[Inferior 1 (process 7816) detached]
(gdb) cd /tmp
Working directory C:/tmp.
(gdb) pwd
Working directory C:/tmp.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Reviewed-By: Andrew Burgess <aburgess@redhat.com>
Change-Id: I6366c41d200938259330e60bc1e98b576f787518
410 lines
15 KiB
C++
410 lines
15 KiB
C++
/* Shared library declarations for GDB, the GNU Debugger.
|
|
|
|
Copyright (C) 1992-2026 Free Software Foundation, Inc.
|
|
|
|
This file is part of GDB.
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef GDB_SOLIB_H
|
|
#define GDB_SOLIB_H
|
|
|
|
#include "gdb_bfd.h"
|
|
#include "gdbsupport/function-view.h"
|
|
#include "gdbsupport/intrusive_list.h"
|
|
#include "gdbsupport/owning_intrusive_list.h"
|
|
#include "symfile-add-flags.h"
|
|
#include "target-section.h"
|
|
|
|
struct program_space;
|
|
|
|
/* Value of the 'set debug solib' configuration variable. */
|
|
|
|
extern bool debug_solib;
|
|
|
|
/* Print an "solib" debug statement. */
|
|
|
|
#define solib_debug_printf(fmt, ...) \
|
|
debug_prefixed_printf_cond (debug_solib, "solib", fmt, ##__VA_ARGS__)
|
|
|
|
#define SOLIB_SCOPED_DEBUG_START_END(fmt, ...) \
|
|
scoped_debug_start_end (debug_solib, "solib", fmt, ##__VA_ARGS__)
|
|
|
|
#define SO_NAME_MAX_PATH_SIZE 512 /* FIXME: Should be dynamic */
|
|
|
|
/* Base class for target-specific link map information. */
|
|
|
|
struct lm_info
|
|
{
|
|
lm_info () = default;
|
|
lm_info (const lm_info &) = default;
|
|
virtual ~lm_info () = 0;
|
|
};
|
|
|
|
using lm_info_up = std::unique_ptr<lm_info>;
|
|
|
|
struct solib_ops;
|
|
|
|
struct solib : intrusive_list_node<solib>
|
|
{
|
|
/* Constructor
|
|
|
|
OPS is the solib_ops implementation providing this solib. */
|
|
explicit solib (lm_info_up lm_info, std::string original_name,
|
|
std::string name, const solib_ops &ops);
|
|
|
|
/* Return the solib_ops implementation providing this solib. */
|
|
const solib_ops &ops () const
|
|
{ return *m_ops; }
|
|
|
|
/* Free symbol-file related contents of SO and reset for possible reloading
|
|
of SO. If we have opened a BFD for SO, close it. If we have placed SO's
|
|
sections in some target's section table, the caller is responsible for
|
|
removing them.
|
|
|
|
This function doesn't mess with objfiles at all. If there is an
|
|
objfile associated with SO that needs to be removed, the caller is
|
|
responsible for taking care of that. */
|
|
void clear () ;
|
|
|
|
/* The following fields of the structure come directly from the
|
|
dynamic linker's tables in the inferior, and are initialized by
|
|
current_sos. */
|
|
|
|
/* A pointer to target specific link map information. Often this
|
|
will be a copy of struct link_map from the user process, but
|
|
it need not be; it can be any collection of data needed to
|
|
traverse the dynamic linker's data structures. */
|
|
lm_info_up lm_info;
|
|
|
|
/* Shared object file name, exactly as it appears in the
|
|
inferior's link map. This may be a relative path, or something
|
|
which needs to be looked up in LD_LIBRARY_PATH, etc. We use it
|
|
to tell which entries in the inferior's dynamic linker's link
|
|
map we've already loaded. */
|
|
std::string original_name;
|
|
|
|
/* Shared object file name, expanded to something GDB can open. */
|
|
std::string name;
|
|
|
|
/* The following fields of the structure are built from
|
|
information gathered from the shared object file itself, and
|
|
are set when we actually add it to our symbol tables.
|
|
|
|
current_sos must initialize these fields to 0. */
|
|
|
|
gdb_bfd_ref_ptr abfd;
|
|
|
|
/* True if symbols have been read in. */
|
|
bool symbols_loaded = false;
|
|
|
|
/* objfile with symbols for a loaded library. Target memory is read from
|
|
ABFD. OBJFILE may be NULL either before symbols have been loaded, if
|
|
the file cannot be found or after the command "nosharedlibrary". */
|
|
struct objfile *objfile = nullptr;
|
|
|
|
std::vector<target_section> sections;
|
|
|
|
/* Record the range of addresses belonging to this shared library.
|
|
There may not be just one (e.g. if two segments are relocated
|
|
differently). This is used for "info sharedlibrary" and
|
|
the MI command "-file-list-shared-libraries". The latter has a format
|
|
that supports outputting multiple segments once the related code
|
|
supports them. */
|
|
CORE_ADDR addr_low = 0, addr_high = 0;
|
|
|
|
private:
|
|
/* The solib_ops responsible for this solib. */
|
|
const solib_ops *m_ops;
|
|
};
|
|
|
|
/* A unique pointer to an solib. */
|
|
using solib_up = std::unique_ptr<solib>;
|
|
|
|
/* Callback type for the 'iterate_over_objfiles_in_search_order'
|
|
methods. */
|
|
|
|
using iterate_over_objfiles_in_search_order_cb_ftype
|
|
= gdb::function_view<bool (objfile *)>;
|
|
|
|
struct solib_ops
|
|
{
|
|
explicit solib_ops (program_space *pspace)
|
|
: m_pspace (pspace)
|
|
{}
|
|
|
|
virtual ~solib_ops () = default;
|
|
|
|
/* Adjust the section binding addresses by the base address at
|
|
which the object was actually mapped. */
|
|
virtual void relocate_section_addresses (solib &so, target_section *) const
|
|
= 0;
|
|
|
|
/* Reset private data structures associated with SO.
|
|
This is called when SO is about to be reloaded.
|
|
It is also called when SO is about to be freed.
|
|
|
|
Defaults to no-op. */
|
|
virtual void clear_so (const solib &so) const {}
|
|
|
|
/* Free private data structures associated to PSPACE. This method
|
|
should not free resources associated to individual solib entries,
|
|
those are cleared by the clear_so method.
|
|
|
|
Defaults to no-op. */
|
|
virtual void clear_solib (program_space *pspace) const {}
|
|
|
|
/* Target dependent code to run after child process fork.
|
|
|
|
Defaults to no-op. */
|
|
virtual void create_inferior_hook (int from_tty) const {};
|
|
|
|
/* Construct a list of the currently loaded shared objects. This
|
|
list does not include an entry for the main executable file.
|
|
|
|
Note that we only gather information directly available from the
|
|
inferior --- we don't examine any of the shared library files
|
|
themselves. The declaration of `struct solib' says which fields
|
|
we provide values for. */
|
|
virtual owning_intrusive_list<solib> current_sos () const = 0;
|
|
|
|
/* Find, open, and read the symbols for the main executable. If
|
|
FROM_TTY is non-zero, allow messages to be printed.
|
|
|
|
Return true if this was done successfully. Defaults to false. */
|
|
virtual bool open_symbol_file_object (int from_tty) const { return false; }
|
|
|
|
/* Determine if PC lies in the dynamic symbol resolution code of
|
|
the run time loader.
|
|
|
|
Defaults to false. */
|
|
virtual bool in_dynsym_resolve_code (CORE_ADDR pc) const
|
|
{ return false; };
|
|
|
|
/* Find and open shared library binary file. */
|
|
virtual gdb_bfd_ref_ptr bfd_open (const char *pathname) const;
|
|
|
|
/* Given two solib objects, GDB from the GDB thread list and INFERIOR from the
|
|
list returned by current_sos, return true if they represent the same library.
|
|
|
|
Defaults to comparing the solib original names using filename_cmp. */
|
|
virtual bool same (const solib &gdb, const solib &inferior) const;
|
|
|
|
/* Return whether a region of memory must be kept in a core file
|
|
for shared libraries loaded before "gcore" is used to be
|
|
handled correctly when the core file is loaded. This only
|
|
applies when the section would otherwise not be kept in the
|
|
core file (in particular, for readonly sections).
|
|
|
|
Defaults to false. */
|
|
virtual bool keep_data_in_core (CORE_ADDR vaddr, unsigned long size) const
|
|
{ return false; };
|
|
|
|
/* Enable or disable optional solib event breakpoints as appropriate. This
|
|
should be called whenever stop_on_solib_events is changed.
|
|
|
|
Defaults to no-op. */
|
|
virtual void update_breakpoints () const {};
|
|
|
|
/* Target-specific processing of solib events that will be performed before
|
|
solib_add is called.
|
|
|
|
Defaults to no-op. */
|
|
virtual void handle_event () const {};
|
|
|
|
/* Return an address within the inferior's address space which is known
|
|
to be part of SO. If there is no such address, or GDB doesn't know
|
|
how to figure out such an address then an empty optional is
|
|
returned.
|
|
|
|
The returned address can be used when loading the shared libraries
|
|
for a core file. GDB knows the build-ids for (some) files mapped
|
|
into the inferior's address space, and knows the address ranges which
|
|
those mapped files cover. If GDB can figure out a representative
|
|
address for the library then this can be used to match a library to a
|
|
mapped file, and thus to a build-id. GDB can then use this
|
|
information to help locate the shared library objfile, if the objfile
|
|
is not in the expected place (as defined by the shared libraries file
|
|
name).
|
|
|
|
The default implementation of returns an empty option, indicating GDB is
|
|
unable to find an address within the library SO. */
|
|
virtual std::optional<CORE_ADDR> find_solib_addr (solib &so) const
|
|
{ return {}; };
|
|
|
|
/* Return true if the linker or libc supports linkage namespaces.
|
|
|
|
Defaults to false. */
|
|
virtual bool supports_namespaces () const { return false; }
|
|
|
|
/* Return which linker namespace contains SO.
|
|
|
|
The supports_namespaces method must return true for this to be
|
|
called.
|
|
|
|
Throw an error if the namespace can not be determined (such as when we're
|
|
stepping though the dynamic linker). */
|
|
virtual int find_solib_ns (const solib &so) const
|
|
{ gdb_assert_not_reached ("namespaces not supported"); }
|
|
|
|
/* Returns the number of active namespaces in the inferior.
|
|
|
|
The supports_namespaces method must return true for this to be called. */
|
|
virtual int num_active_namespaces () const
|
|
{ gdb_assert_not_reached ("namespaces not supported"); }
|
|
|
|
/* Returns all solibs for a given namespace. If the namespace is not
|
|
active, returns an empty vector.
|
|
|
|
The supports_namespaces method must return true for this to be called. */
|
|
virtual std::vector<const solib *> get_solibs_in_ns (int ns) const
|
|
{ gdb_assert_not_reached ("namespaces not supported"); }
|
|
|
|
/* Iterate over all objfiles of the program space in the order that makes the
|
|
most sense for the architecture to make global symbol searches.
|
|
|
|
CB is a callback function passed an objfile to be searched. The iteration
|
|
stops if this function returns true.
|
|
|
|
If not nullptr, CURRENT_OBJFILE corresponds to the objfile being inspected
|
|
when the symbol search was requested. */
|
|
virtual void iterate_over_objfiles_in_search_order
|
|
(iterate_over_objfiles_in_search_order_cb_ftype cb,
|
|
objfile *current_objfile) const;
|
|
|
|
protected:
|
|
/* The program space for which this solib_ops was created. */
|
|
program_space *m_pspace;
|
|
};
|
|
|
|
/* A unique pointer to an solib_ops. */
|
|
using solib_ops_up = std::unique_ptr<solib_ops>;
|
|
|
|
/* Find main executable binary file. */
|
|
extern gdb::unique_xmalloc_ptr<char> exec_file_find (const char *in_pathname);
|
|
|
|
/* Find shared library binary file. */
|
|
extern gdb::unique_xmalloc_ptr<char> solib_find (const char *in_pathname,
|
|
int *fd);
|
|
|
|
/* Open BFD for shared library file. */
|
|
extern gdb_bfd_ref_ptr solib_bfd_fopen (const char *pathname, int fd);
|
|
|
|
/* Find solib binary file and open it. */
|
|
extern gdb_bfd_ref_ptr solib_bfd_open (const char *in_pathname);
|
|
|
|
/* Called when we free all symtabs of PSPACE, to free the shared library
|
|
information as well. */
|
|
|
|
extern void clear_solib (program_space *pspace);
|
|
|
|
/* Called to add symbols from a shared library to gdb's symbol table. */
|
|
|
|
extern void solib_add (const char *, int, int);
|
|
|
|
/* Read in symbols for shared object SO. If SYMFILE_VERBOSE is set in FLAGS,
|
|
be chatty about it. Return true if any symbols were actually loaded. */
|
|
|
|
extern bool solib_read_symbols (solib &so, symfile_add_flags flags);
|
|
|
|
/* Function to be called when the inferior starts up, to discover the
|
|
names of shared libraries that are dynamically linked, the base
|
|
addresses to which they are linked, and sufficient information to
|
|
read in their symbols at a later time. */
|
|
|
|
extern void solib_create_inferior_hook (int from_tty);
|
|
|
|
/* If ADDR lies in a shared library, return its name. */
|
|
|
|
extern const char *solib_name_from_address (struct program_space *, CORE_ADDR);
|
|
|
|
/* Return true if ADDR lies within SOLIB. */
|
|
|
|
extern bool solib_contains_address_p (const solib &, CORE_ADDR);
|
|
|
|
/* Return whether the data starting at VADDR, size SIZE, must be kept
|
|
in a core file for shared libraries loaded before "gcore" is used
|
|
to be handled correctly when the core file is loaded. This only
|
|
applies when the section would otherwise not be kept in the core
|
|
file (in particular, for readonly sections). */
|
|
|
|
extern bool solib_keep_data_in_core (CORE_ADDR vaddr, unsigned long size);
|
|
|
|
/* Return true if PC lies in the dynamic symbol resolution code of the
|
|
run time loader. */
|
|
|
|
extern bool in_solib_dynsym_resolve_code (CORE_ADDR);
|
|
|
|
/* Discard symbols that were auto-loaded from shared libraries in PSPACE. */
|
|
|
|
extern void no_shared_libraries (program_space *pspace);
|
|
|
|
/* Synchronize GDB's shared object list with inferior's.
|
|
|
|
Extract the list of currently loaded shared objects from the
|
|
inferior, and compare it with the list of shared objects in the
|
|
current program space's list of shared libraries. Edit
|
|
the current program space's solib list to bring it in sync with the
|
|
inferior's new list.
|
|
|
|
If we notice that the inferior has unloaded some shared objects,
|
|
free any symbolic info GDB had read about those shared objects.
|
|
|
|
Don't load symbolic info for any new shared objects; just add them
|
|
to the list, and leave their symbols_loaded flag clear.
|
|
|
|
If FROM_TTY is non-null, feel free to print messages about what
|
|
we're doing. */
|
|
|
|
extern void update_solib_list (int from_tty);
|
|
|
|
/* Return true if NAME is the libpthread shared library. */
|
|
|
|
extern bool libpthread_name_p (const char *name);
|
|
|
|
/* Look up symbol from both symbol table and dynamic string table. */
|
|
|
|
extern CORE_ADDR gdb_bfd_lookup_symbol
|
|
(bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym);
|
|
|
|
/* Look up symbol from symbol table. */
|
|
|
|
extern CORE_ADDR gdb_bfd_lookup_symbol_from_symtab
|
|
(bfd *abfd, gdb::function_view<bool (const asymbol *)> match_sym);
|
|
|
|
/* Scan for DESIRED_DYNTAG in .dynamic section of ABFD. If DESIRED_DYNTAG is
|
|
found, 1 is returned and the corresponding PTR and PTR_ADDR are set. */
|
|
|
|
extern int gdb_bfd_scan_elf_dyntag (const int desired_dyntag, bfd *abfd,
|
|
CORE_ADDR *ptr, CORE_ADDR *ptr_addr);
|
|
|
|
/* If FILENAME refers to an ELF shared object then attempt to return the
|
|
string referred to by its DT_SONAME tag. */
|
|
|
|
extern gdb::unique_xmalloc_ptr<char> gdb_bfd_read_elf_soname
|
|
(const char *filename);
|
|
|
|
/* Enable or disable optional solib event breakpoints as appropriate. */
|
|
|
|
extern void update_solib_breakpoints (void);
|
|
|
|
/* Handle an solib event by calling solib_add. */
|
|
|
|
extern void handle_solib_event (void);
|
|
|
|
/* Calculate the number of linker namespaces active in PSPACE. */
|
|
|
|
extern int solib_linker_namespace_count (program_space *pspace);
|
|
|
|
#endif /* GDB_SOLIB_H */
|