This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Apply substitute-path to relative filenames as well


The patch is attached.

The change itself is similar to
https://www.sourceware.org/ml/gdb-patches/2017-02/msg00693.html , but the code
is slightly cleaner (at the cost of making the patch larger).

Also, as the patch is trivial, so i would expect it to not to require copyright
assignment (i do have one, but David Grayson might not have).

Here's the copy of the commit message:

When source file path is relative to the build directory (which
is considered a good practice and is enforced in certain buildsystems,
such as meson), gdb only applies substitute-path to the build directory
path. Then gdb appends the source file path to the rewritten build
directory path, and tries to access that.

This fails if either two of the following conditions are true:
a) The user didn't specify substitute-path for the build directory.
   This is highly likely, since path substitution for build directories
   is not documented anywhere, and since gdb does not tell[0] the user
   the path to the build directory, just the source file path.
b) The source file path changed.
   This can also easily happen, since a source path that is relative
   to the build directory can include any number of directory names
   that are not part of the program source tree (starting with the
   name of the root directory of the source tree). Gdb will not apply
   substitute-path to that relative path, thus there is no way for
   the user to tell gdb about these changes.

This commit changes the code to apply substitute-path to all filenames,
both relative and absolute. This way it is possible to do things like:

set substitute-path ../foobar-1.0 /src/my/foobar-1.0

which is completely in line with the user expectations.

This might break unusual cases where build directory path is also
relative (is that even possible?) and happens to match the path
to the source directory (i.e. happens to match a substitution rule).

[0]: There's a "maintenance info symtabs" command that does show the names
     of the build directories, but normal users are not required to
     know or use that.
---
 gdb/source.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

gdb/ChangeLog:

2019-02-28 Руслан Ижбулатов  <lrn1986@gmail.com>

       * source.c (find_and_open_source): Apply substitute-path to all
       filenames, both absolute and relative


Attachment: 0001-Apply-substitute-path-to-relative-filenames-as-well.patch
Description: Text document

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]