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][RFC] symfile.c:find_separate_debug_file: additional path


Recently I added a directory with debug symbols to the "debug-file-directory" variable in .gdbinit, expecting that gdb would search for the debug file mentioned in the ".gnu_debuglink" section in this directory. That is not the case.

If the binary is "/very/big/path/binary", gdb searchs for symbols in "/dir/with/symbols/very/big/path/[.gnu_debuglink]", which is fine, as this is a traditional path. But gdb never checks "/dir/with/symbols/[.gnu_debuglink]". I found this behaviour counter-intuitive. And furthermore I really needed to get gdb to find the symbols automatically without changing the location of any file, and without creating symlinks.

So in order to get gdb to find the debug symbols on the root of the debugfile directory (i.e. "/dir/with/symbols/[.gnu_debuglink]"), I created the patch presented bellow, it simply adds the root of the debugfile directories as an extra search path. And it works fine.

Is there an easier way to obtain the desirable behaviour? (note that I cannot change the location of binaries or debug symbols. I can only change .gdbinit, the .gnu_debuglink section of the binaries and gdb)

Is this patch suitable for the main repo?


Best Regards,
Tiago Queiroz

2013-11-01  Tiago Queiroz <tiagofaq@gmail.com>
    * symfile.c:find_separate_debug_file: Add an extra search path.
---
 gdb/symfile.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/symfile.c b/gdb/symfile.c
index 5ed2591..49940c9 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1546,6 +1546,15 @@ find_separate_debug_file (const char *dir,
          if (separate_debug_file_exists (debugfile, crc32, objfile))
            return debugfile;
        }
+
+      /* Try the root of the global debugfile directory.  */
+      strcpy (debugfile, debugdir);
+      strcat (debugfile, "/");
+      strcat (debugfile, debuglink);
+
+      if (separate_debug_file_exists (debugfile, crc32, objfile))
+        return debugfile;
+
     }

   do_cleanups (back_to);
--
1.7.9.5


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