]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r14288 from the BUF_REMOVAL branch to trunk.
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Oct 2014 17:12:12 +0000 (17:12 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Oct 2014 17:12:12 +0000 (17:12 +0000)
What it does it changing cachegrind's get_debug_info function such
that it no longer builds up an absolute pathname. Instead the function
get an additional parameter for the directory name and the absolute
pathname is built when it is needed. This will come in handy soonish
when VG_(get_filename_lineno) will be changed and those buffers will
disappear.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14665

cachegrind/cg_main.c

index 71efdea26bbf25caf02d5a33901c7feb01b1c64f..10e562e4cc5c561d27f50b8afa0eeb0abd6a5c9c 100644 (file)
@@ -211,10 +211,10 @@ static HChar* get_perm_string(const HChar* s)
 /*--- CC table operations                                  ---*/
 /*------------------------------------------------------------*/
 
-static void get_debug_info(Addr instr_addr, HChar file[FILE_LEN],
+static void get_debug_info(Addr instr_addr, HChar dir[FILE_LEN],
+                           HChar file[FILE_LEN],
                            const HChar **fn, UInt* line)
 {
-   HChar dir[FILE_LEN];
    Bool found_dirname;
    Bool found_file_line = VG_(get_filename_linenum)(
                              instr_addr, 
@@ -232,14 +232,6 @@ static void get_debug_info(Addr instr_addr, HChar file[FILE_LEN],
       *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++;
@@ -253,15 +245,24 @@ static void get_debug_info(Addr instr_addr, HChar file[FILE_LEN],
 // Returns a pointer to the line CC, creates a new one if necessary.
 static LineCC* get_lineCC(Addr origAddr)
 {
-   HChar   file[FILE_LEN];
+   HChar   file[FILE_LEN], dir[FILE_LEN];
    const HChar *fn;
    UInt    line;
    CodeLoc loc;
    LineCC* lineCC;
 
-   get_debug_info(origAddr, file, &fn, &line);
+   get_debug_info(origAddr, dir, file, &fn, &line);
+
+   // Form an absolute pathname if a directory is available
+   HChar absfile[VG_(strlen)(dir) + 1 + VG_(strlen)(file) + 1];
+
+   if (dir[0]) {
+      VG_(sprintf)(absfile, "%s/%s", dir, file);
+   } else {
+      VG_(sprintf)(absfile, "%s", file);
+   }
 
-   loc.file = file;
+   loc.file = absfile;
    loc.fn   = fn;
    loc.line = line;