binutils-gdb/gdbsupport
Andrew Burgess ea4c968ce5 gdb: avoid '//' in filenames when searching for debuginfo
I spotted that the gdb.base/sysroot-debug-lookup.exp test that I added
recently actually had a KPASS when run with the
native-extended-gdbserver board.  This was an oversight when adding
the test.

The failures in this test, when using the 'unix' board, are logged as
bug PR gdb/31804.  The problem appears to be caused by the use of the
child_path function in find_separate_debug_file.

What happens on the 'unix' board is that the file is specified to GDB
with a target: prefix, however GDB spots that the target filesystem is
local to GDB and so opens the file without a target: prefix.  When we
call into find_separate_debug_file the DIR and CANON_DIR arguments,
which are computed from the objfile_name() no longer have a target:
prefix.

However, in this test if the file was opened with a target: prefix,
then the sysroot also has a target: prefix.  When child_path is called
it looks for a common prefix between CANON_DIR (from the objfile_name)
and the sysroot.  However, the sysroot still has the target: prefix,
which means the child_path() call fails and returns nullptr.

What happens in the native-extended-gdbserver case is that GDB doesn't
see the target filesystem as local.  Now the filename retains the
target: prefix, which means that in the child_path() call both the
sysroot and the CANON_DIR have a target: prefix, and so the
child_path() call succeeds.  This allows GDB to progress, try some
additional paths, and then find the debug information.

So, this commit changes gdb.base/sysroot-debug-lookup.exp to expect
the test to succeed when using the native-extended-gdbserver protocol.

This leaves one KFAIL when using the native-extended-gdbserver board,
we find the debug information but (apparently) find it in the wrong
file.  What's happening is that when GDB builds the filename for the
debug information we end up with a '//' string as a directory
separator, the test regexp only expects a single separator.

Instead of just fixing the test regexp, I've updated the path_join
function in gdbsupport/pathstuff.{cc,h} to allow for absolute paths to
appear in the argument list after the first argument.  This means it's
now possible to do this:

  auto result = path_join ("/a/b/c", "/d/e/f");
  gdb_assert (result == "/a/b/c/d/e/f");

Additionally I've changed path_join so that it avoids adding
unnecessary directory separators.  In the above case when the two
paths were joined GDB only added a single separator between 'c' and
'd'.  But additionally, if we did this:

  auto result = path_join ("/a/b/c/", "/d/e/f");
  gdb_assert (result == "/a/b/c/d/e/f");

We'd still only get a single separator.

With these changes to path_join I can now make use of this function in
find_separate_debug_file.  With this done I now have no KFAIL when
using the native-extended-gdbserver board.

After this commit we still have 2 KFAIL when not using the
native-gdbserver and unix boards, these will be addressed in the next
commit.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31804

Reviewed-By: Keith Seitz <keiths@redhat.com>
2024-08-19 15:02:56 +01:00
..
.dir-locals.el Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
.gitattributes gdb, gdbserver, gdbsupport: add .gitattributes files 2020-03-05 15:59:22 +01:00
acinclude.m4 gdb: move libiberty.m4 to gdbsupport 2024-01-10 19:52:52 -05:00
aclocal.m4 Finalized intl-update patches 2023-11-15 12:53:04 +00:00
agent.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
agent.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
alt-stack.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
array-view.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
ax.def Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
block-signals.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
break-common.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
btrace-common.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
btrace-common.h btrace, gdbserver: Add ptwrite to btrace_config_pt. 2024-08-14 11:20:56 +02:00
buildargv.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
byte-vector.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
ChangeLog-2020-2021 gdb: move remaining ChangeLogs to legacy files 2021-07-26 12:20:33 +01:00
check-defines.el gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} 2024-02-21 13:30:19 -05:00
cleanups.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
cleanups.h Rewrite final cleanups 2024-02-27 10:30:29 -07:00
common-debug.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
common-debug.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
common-defs.h gdb: remove some GCC version checks 2024-02-21 13:30:17 -05:00
common-exceptions.cc gdb, gdbserver, gdbsupport: use [[noreturn]] instead of ATTRIBUTE_NORETURN 2024-07-16 18:30:45 -04:00
common-exceptions.h gdb, gdbserver, gdbsupport: use [[noreturn]] instead of ATTRIBUTE_NORETURN 2024-07-16 18:30:45 -04:00
common-gdbthread.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
common-inferior.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
common-inferior.h gdb: remove get_exec_file 2024-06-07 23:09:03 -04:00
common-regcache.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
common-regcache.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
common-types.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
common-utils.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
common-utils.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
common.m4 btrace, python: Enable ptwrite filter registration. 2024-08-14 11:20:57 +02:00
compiler-type.m4 Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
config.in btrace, python: Enable ptwrite filter registration. 2024-08-14 11:20:57 +02:00
configure btrace, python: Enable ptwrite filter registration. 2024-08-14 11:20:57 +02:00
configure.ac autoupdate: add square brackets around arguments of AC_INIT 2024-06-10 08:25:56 +09:30
create-version.sh Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
def-vector.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
default-init-alloc.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
eintr.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
enum-flags.h gdb, gdbsupport: use using in enum flags code 2024-08-12 10:58:49 -04:00
environ.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
environ.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
errors.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
errors.h gdb, gdbserver, gdbsupport: use [[noreturn]] instead of ATTRIBUTE_NORETURN 2024-07-16 18:30:45 -04:00
event-loop.cc Use std::vector in event-loop.cc 2024-04-21 19:54:27 -06:00
event-loop.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
event-pipe.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
event-pipe.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
fileio.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
fileio.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
filestuff.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
filestuff.h Introduce read_remainder_of_file 2024-02-27 09:46:31 -07:00
filtered-iterator.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
format.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
format.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
forward-scope-exit.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
function-view.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_assert.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_binary_search.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_file.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_locale.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_obstack.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb_obstack.h Require trivial destructor in allocate_on_obstack 2024-03-21 12:21:24 -06:00
gdb_proc_service.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_ref_ptr.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_regex.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb_regex.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_select.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_setjmp.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_signals.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_splay_tree.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_sys_time.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_tilde_expand.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb_tilde_expand.h gdb: add overloads of gdb_tilde_expand 2024-06-27 15:15:26 +01:00
gdb_unique_ptr.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_unlinker.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_vecs.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb_vecs.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb_wait.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb_wait.h [gdb/build] Fix build on postmarketos 2024-03-14 21:28:44 +01:00
gdb-checked-static-cast.h gdbsupport: rename include guard in gdb-checked-static-cast.h 2024-03-19 14:41:51 +00:00
gdb-dlfcn.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
gdb-dlfcn.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb-hashtab.h Remove hashtab_obstack_allocate 2024-06-24 09:11:30 -06:00
gdb-safe-ctype.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb-sigmask.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
gdb-xfree.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
hash_enum.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
host-defs.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
intrusive_list.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
iterator-range.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
job-control.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
job-control.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
libiberty.m4 Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
Makefile.am Remove hashtab_obstack_allocate 2024-06-24 09:11:30 -06:00
Makefile.in Remove hashtab_obstack_allocate 2024-06-24 09:11:30 -06:00
netstuff.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
netstuff.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
new-op.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
next-iterator.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
observable.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
offset-type.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
packed.h gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} 2024-02-21 13:30:19 -05:00
parallel-for.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
pathstuff.cc gdb: avoid '//' in filenames when searching for debuginfo 2024-08-19 15:02:56 +01:00
pathstuff.h gdb: avoid '//' in filenames when searching for debuginfo 2024-08-19 15:02:56 +01:00
poison.h gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable} 2024-02-21 13:30:19 -05:00
preprocessor.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
print-utils.cc gdbsupport: constify some return values in print-utils.{h,cc} 2024-04-18 10:31:54 -04:00
print-utils.h gdbsupport: constify some return values in print-utils.{h,cc} 2024-04-18 10:31:54 -04:00
ptid.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
ptid.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
ptrace.m4 Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
range-chain.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
README
refcounted-object.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
reference-to-pointer-iterator.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
rsp-low.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
rsp-low.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
run-time-clock.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
run-time-clock.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
safe-iterator.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
safe-strerror.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
scope-exit.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
scoped_fd.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
scoped_ignore_signal.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
scoped_ignore_sigttou.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
scoped_mmap.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
scoped_mmap.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
scoped_restore.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
search.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
search.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
selftest.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
selftest.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
selftest.m4 Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
signals-state-save-restore.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
signals-state-save-restore.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
signals.cc gdbsupport: remove #ifndef REALTIME_LO in signals.cc 2024-08-12 10:21:15 -04:00
symbol.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
task-group.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
task-group.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
tdesc.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
tdesc.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
thread-pool.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
thread-pool.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
traits.h gdb: move RequireLongest to gdbsupport/traits.h 2024-04-22 21:34:19 -04:00
underlying.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
valid-expr.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
version.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00
warning.m4 gdb, gdbserver, gdbsupport: remove -Wno-vla-cxx-extension 2024-08-02 16:54:52 -04:00
x86-xstate.h gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition 2024-06-14 09:08:44 +01:00
xml-utils.cc gdb, gdbserver, gdbsupport: remove includes of early headers 2024-03-26 21:13:22 -04:00
xml-utils.h Update copyright year range in header of all files managed by GDB 2024-01-12 15:49:57 +00:00

This is a helper library that is used by gdb and gdbserver.

To send patches, follow the gdb patch submission instructions in
../gdb/CONTRIBUTE.  For maintainers, see ../gdb/MAINTAINERS.