This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] symfile debug file additional search in sysroot
- From: CÃdric Buissart <cedric dot buissart at gmail dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 10 Jun 2015 09:44:19 +0200
- Subject: [PATCH] symfile debug file additional search in sysroot
- Authentication-results: sourceware.org; auth=none
Hi all,
This patch allows coredump analysis taken from foreign machines in an
easy way using the sysroot option. e.g. :
- extract the necessary binaries and debuginfo in
/coredump/<coredump-ID>/ (e.g. : via rpm2cpio if RPM is used)
- in gdb, set sysroot to /coredump/<coredump-ID>/
- and your good to go : the sym files will also be searched relative
to /coredump/<coredump-ID>/
In practice, you'll still also want to add that folder to your
auto-load safe-path, and another patch will be required for source
access (e.g. : the list command), but I have found this patch very
useful in my daily work and to set up scripts to automatically build a
coredump analysis environment
Basically, when searching for a separate debug file, if it is not
found, the patch kicks in and set an additional search in
<sysroot>/<debugdir>.
Benefits :
- no need for recreating a full OS or a container to open a coredump.
- you can use a modern GDB, with your own plugins and scripts, to
diagnose a coredump created on an old OS
- you can export the recreated OS sample and let other people mount
and use their own gdb to look at the coredump.
There is no drawback : old style search will still be fully functional.
I am unsure this was sufficiently clearly explained, but I hope I will
trigger your interest.
:) If you have a better way of easy opening coredump without building
a whole OS/container and without that patch, please let me know
Cedric
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 84858dc..0f68885 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1533,6 +1533,18 @@ find_separate_debug_file (const char *dir,
do_cleanups (back_to);
return debugfile;
}
+
+ /* or we can try to inject debugdir between sysroot and
normal path */
+ strcpy (debugfile, gdb_sysroot);
+ strcat (debugfile, debugdir);
+ strcat (debugfile, canon_dir + strlen (gdb_sysroot));
+ strcat (debugfile, "/");
+ strcat (debugfile, debuglink);
+ if (separate_debug_file_exists (debugfile, crc32, objfile))
+ {
+ do_cleanups (back_to);
+ return debugfile;
+ }
}
}