From: David Grayson <davidegrayson@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH] Apply substitute-path rules to relative filenames
Date: Sat, 25 Feb 2017 05:06:00 -0000 [thread overview]
Message-ID: <58b1109863f72_3d472af4edac70d0358b9@davida2.mail> (raw)
[-- Attachment #1: Type: text/plain, Size: 2268 bytes --]
Hello.
I am attaching a patch to gdb/source.c that makes the substitute-path rules apply to all source filenames, instead of only absolute source filenames and compilation directory names. I hope it will be considered for the next verison of GDB.
==== Motivation for the change ====
I am trying to debug a Windows program that I cross-compiled from Linux and I want GDB to find my source files when I run it. The error message from (unpatched) GDB was:
../samples/hello_triangle/HelloTriangle.cpp: No such file or directory.
Based on my reading of the documentation[1], I expected that I could fix this by adding the following substitute-path rule:
set substitute-path ../samples src/angle/samples
However, that did not change the error message.
When find_and_open_source in gdb/source.c is called, the filename argument is "../samples/hello_triangle/HelloTriangle.cpp" (equal to the filename argument I passed to GCC), while the "dirname" argument is "/home/david/tmp/nix-build-angle_samples-2017-02-17-i686-w64-mingw32.drv-0/build (equal to the CWD when I invoked GCC). Since the "dirname" is long and complicated, I would rather not have to use it in my substitute-path rule. Instead, I would like substitute-path rules to apply to source filenames even if they are relative. After applying this patch, GDB was able to successfully find my source file.
==== Testing ====
I have manually tested that this patch fixes my particular issue.
I ran "make check" on a native Linux GDB built from the current git revision. I am not sure how to make sense of the test suite results, and thought it wasn't too important to learn about that, but please let me know if you want me to do something more to test this patch.
==== Context ====
The code for applying substitute-path rules to absolute source filenames was added on 2008-02-08 and discussed here:
https://sourceware.org/ml/gdb-patches/2008-02/subjects.html#00130
In the discussion, there was no reason given to only apply the substitution rules to absolute filenames.
I also searched the last five years of discussions on this mailing list and I don't think the issue came up (sorry if it did).
Thanks!
--David Grayson
[1]: https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html
[-- Attachment #2: changelog.txt --]
[-- Type: text/plain, Size: 193 bytes --]
2017-02-24 David Grayson <davidegrayson@gmail.com>
* gdb/source.c: Apply substitute-path rules to all source
filenames, not just absolute source filenames and compilation
directory names.
[-- Attachment #3: substitute-path-all-filenames.patch --]
[-- Type: text/plain, Size: 468 bytes --]
diff -ur gdb-7.12.1-orig/gdb/source.c gdb-7.12.1/gdb/source.c
--- gdb-7.12.1-orig/gdb/source.c 2017-02-24 19:33:13.340349333 -0800
+++ gdb-7.12.1/gdb/source.c 2017-02-24 19:34:40.660349333 -0800
@@ -1103,10 +1103,7 @@
}
}
- if (IS_ABSOLUTE_PATH (filename))
{
- /* If filename is absolute path, try the source path
- substitution on it. */
char *rewritten_filename = rewrite_source_path (filename);
if (rewritten_filename != NULL)
reply other threads:[~2017-02-25 5:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58b1109863f72_3d472af4edac70d0358b9@davida2.mail \
--to=davidegrayson@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox