Add directory-reading of debug info to cachegrind.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6839 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in
index 21bc4e8..35f2632 100644
--- a/cachegrind/cg_annotate.in
+++ b/cachegrind/cg_annotate.in
@@ -747,7 +747,9 @@
my $opened_file = "";
my $full_file_name = "";
- foreach my $include_dir (@include_dirs) {
+ # We first try it with the empty include_dir, in case the filename has
+ # the full path.
+ foreach my $include_dir ("", @include_dirs) {
my $try_name = $include_dir . $src_file;
if (open(INPUTFILE, "< $try_name")) {
$opened_file = $try_name;
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index 345a6cb..bd9016b 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -208,10 +208,12 @@
static void get_debug_info(Addr instr_addr, Char file[FILE_LEN],
Char fn[FN_LEN], Int* line)
{
+ Char dir[FILE_LEN];
+ Bool found_dirname;
Bool found_file_line = VG_(get_filename_linenum)(
instr_addr,
file, FILE_LEN,
- NULL, 0, NULL,
+ dir, FILE_LEN, &found_dirname,
line
);
Bool found_fn = VG_(get_fnname)(instr_addr, fn, FN_LEN);
@@ -223,6 +225,15 @@
if (!found_fn) {
VG_(strcpy)(fn, "???");
}
+
+ if (found_dirname) {
+ // +1 for the '/'.
+ tl_assert(VG_(strlen)(dir) + VG_(strlen)(file) + 1 < FILE_LEN);
+ VG_(strcat)(dir, "/"); // Append '/'
+ VG_(strcat)(dir, file); // Append file to dir
+ VG_(strcpy)(file, dir); // Move dir+file to file
+ }
+
if (found_file_line) {
if (found_fn) full_debugs++;
else file_line_debugs++;