binutils-gdb/gdbsupport
Simon Marchi ffaebc199e gdbsupport: add path_join function
In this review [1], Eli pointed out that we should be careful when
concatenating file names to avoid duplicated slashes.  On Windows, a
double slash at the beginning of a file path has a special meaning.  So
naively concatenating "/"  and "foo/bar" would give "//foo/bar", which
would not give the desired results.  We already have a few spots doing:

  if (first_path ends with a slash)
    path = first_path + second_path
  else
    path = first_path + slash + second_path

In general, I think it's nice to avoid superfluous slashes in file
paths, since they might end up visible to the user and look a bit
unprofessional.

Introduce the path_join function that can be used to join multiple path
components together (along with unit tests).

I initially wanted to make it possible to join two absolute paths, to
support the use case of prepending a sysroot path to a target file path,
or the prepending the debug-file-directory to a target file path.  But
the code in solib_find_1 shows that it is more complex than this anyway
(for example, when the right hand side is a Windows path with a drive
letter).  So I don't think we need to support that case in path_join.
That also keeps the implementation simpler.

Change a few spots to use path_join to show how it can be used.  I
believe that all the spots I changed are guarded by some checks that
ensure the right hand side operand is not an absolute path.

Regression-tested on Ubuntu 18.04.  Built-tested on Windows, and I also
ran the new unit-test there.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187559.html

Change-Id: I0df889f7e3f644e045f42ff429277b732eb6c752
2022-04-21 11:11:21 -04:00
..
.dir-locals.el Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
.gitattributes gdb, gdbserver, gdbsupport: add .gitattributes files 2020-03-05 15:59:22 +01:00
acinclude.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
aclocal.m4 gdb: use AC_PROG_CC_STDC instead of AM_PROG_CC_STDC 2020-10-31 08:30:57 -04:00
agent.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
agent.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
alt-stack.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
array-view.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ax.def Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
block-signals.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
break-common.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
btrace-common.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
btrace-common.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buffer.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buffer.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
buildargv.h Move gdb_argv to gdbsupport 2022-01-18 10:14:42 -07:00
byte-vector.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ChangeLog-2020-2021 gdb: move remaining ChangeLogs to legacy files 2021-07-26 12:20:33 +01:00
check-defines.el Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
cleanups.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
cleanups.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-debug.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-debug.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-defs.h Consolidate definition of current_directory 2022-03-30 09:08:48 -06:00
common-exceptions.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-exceptions.h Specialize std::hash for gdb_exception 2022-04-12 09:31:16 -06:00
common-gdbthread.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-inferior.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-inferior.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-regcache.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-regcache.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-types.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-utils.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
common.m4 Let std::thread check pass even without pthreads 2022-04-14 09:28:56 -06:00
compiler-type.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
config.in Fix build on rhES5 2021-11-09 08:21:18 -07:00
configure Let std::thread check pass even without pthreads 2022-04-14 09:28:56 -06:00
configure.ac gdbsupport: Add an event-pipe class. 2022-02-22 11:22:14 -08:00
create-version.sh Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
def-vector.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
default-init-alloc.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
eintr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
enum-flags.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
environ.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
environ.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
errors.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
errors.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
event-loop.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
event-loop.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
event-pipe.cc Fix typo in last change. 2022-03-03 13:06:50 -08:00
event-pipe.h Avoid conflict with gnulib open/close macros. 2022-03-03 11:21:36 -08:00
fileio.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
fileio.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
filestuff.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
filestuff.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
filtered-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
format.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
format.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
forward-scope-exit.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
function-view.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_assert.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_binary_search.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_file.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_locale.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_obstack.cc Move gdb obstack code to gdbsupport 2022-01-18 10:14:42 -07:00
gdb_obstack.h Move gdb obstack code to gdbsupport 2022-01-18 10:14:42 -07:00
gdb_optional.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_proc_service.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_ref_ptr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_regex.cc gdbsupport/gdb_regex.cc: replace defs.h include with common-defs.h 2022-01-20 22:58:21 -05:00
gdb_regex.h Move gdb_regex to gdbsupport 2022-01-18 10:14:43 -07:00
gdb_select.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_setjmp.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_signals.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_splay_tree.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_string_view.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_string_view.tcc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_sys_time.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_tilde_expand.cc gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search 2022-04-18 15:48:03 -04:00
gdb_tilde_expand.h gdb: use gdb_tilde_expand instead of gdb_tilde_expand_up in source_script_with_search 2022-04-18 15:48:03 -04:00
gdb_unique_ptr.h gdb: add operator+= and operator+ overload for std::string 2022-02-25 17:50:22 +00:00
gdb_unlinker.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_vecs.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_vecs.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_wait.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb_wait.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-dlfcn.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-dlfcn.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-hashtab.cc Introduce gdb-hashtab module in gdbsupport 2022-01-18 10:14:43 -07:00
gdb-hashtab.h Introduce gdb-hashtab module in gdbsupport 2022-01-18 10:14:43 -07:00
gdb-safe-ctype.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-sigmask.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
gdb-xfree.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
hash_enum.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
host-defs.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
intrusive_list.h Make intrusive_list_node's next/prev private 2022-04-13 10:24:38 +01:00
iterator-range.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
job-control.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
job-control.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
Makefile.am gdbsupport: Add an event-pipe class. 2022-02-22 11:22:14 -08:00
Makefile.in gdbsupport: Add an event-pipe class. 2022-02-22 11:22:14 -08:00
netstuff.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
netstuff.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
new-op.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
next-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
observable.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
offset-type.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
parallel-for.h gdbsupport: use result_of_t instead of result_of in parallel-for.h 2022-04-12 14:09:49 -04:00
pathstuff.cc gdbsupport: add path_join function 2022-04-21 11:11:21 -04:00
pathstuff.h gdbsupport: add path_join function 2022-04-21 11:11:21 -04:00
poison.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
preprocessor.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
print-utils.cc Let phex and phex_nz handle sizeof_l==1 2022-03-07 07:52:59 -07:00
print-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptid.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptid.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
ptrace.m4 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
README
refcounted-object.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
reference-to-pointer-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
rsp-low.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
rsp-low.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
run-time-clock.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
run-time-clock.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
safe-iterator.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
safe-strerror.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scope-exit.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_fd.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_ignore_signal.h gdb: don't pass nullptr to sigwait 2022-01-04 10:28:19 +00:00
scoped_ignore_sigttou.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_mmap.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_mmap.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
scoped_restore.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
search.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
search.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
selftest.cc gdbsupport/selftest: Allow lazy registration 2022-04-19 09:12:42 +01:00
selftest.h gdbsupport/selftest: Allow lazy registration 2022-04-19 09:12:42 +01:00
selftest.m4 Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals-state-save-restore.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals-state-save-restore.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
signals.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
symbol.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
tdesc.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
tdesc.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
thread-pool.cc Set the worker thread name on Windows 2022-04-14 12:12:34 -06:00
thread-pool.h gdb: fix build errors in gdbsupport/thread-pool.h used with old gcc 2022-04-14 23:05:00 +08:00
traits.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
underlying.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
valid-expr.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
version.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
warning.m4 gdb: don't use -Wmissing-prototypes with g++ 2022-01-13 10:25:45 +00:00
x86-xstate.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
xml-utils.cc Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04:00
xml-utils.h Automatic Copyright Year update after running gdb/copyright.py 2022-01-01 19:13:23 +04: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.