From: Nicholas Nethercote Date: Mon, 17 Sep 2007 00:41:07 +0000 (+0000) Subject: Add directory-reading of debug info to cachegrind. X-Git-Tag: svn/VALGRIND_3_3_0~215 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4e68cda863249a597e719c3d7f28a73d7594ff6;p=thirdparty%2Fvalgrind.git Add directory-reading of debug info to cachegrind. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6839 --- diff --git a/cachegrind/cg_annotate.in b/cachegrind/cg_annotate.in index 21bc4e8b31..35f26326d9 100644 --- a/cachegrind/cg_annotate.in +++ b/cachegrind/cg_annotate.in @@ -747,7 +747,9 @@ sub annotate_ann_files($) 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 345a6cb45f..bd9016b748 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -208,10 +208,12 @@ static Char* get_perm_string(Char* s) 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 @@ static void get_debug_info(Addr instr_addr, Char file[FILE_LEN], 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++;