]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add directory-reading of debug info to cachegrind.
authorNicholas Nethercote <njn@valgrind.org>
Mon, 17 Sep 2007 00:41:07 +0000 (00:41 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Mon, 17 Sep 2007 00:41:07 +0000 (00:41 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6839

cachegrind/cg_annotate.in
cachegrind/cg_main.c

index 21bc4e8b31c0c316c5e82bd66bf92a9f8c6d5417..35f26326d98f35d7b74c37ed82d13b75ce321cec 100644 (file)
@@ -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;
index 345a6cb45f4f4aa542d29af63c99cca4db9d6a5d..bd9016b7486670073a4b783bafabdbc0434817c8 100644 (file)
@@ -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++;