]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r14289 from the BUF_REMOVAL branch to trunk.
authorFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Oct 2014 19:16:14 +0000 (19:16 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sun, 26 Oct 2014 19:16:14 +0000 (19:16 +0000)
Change CLG_(get_debug_info) to not build up an absolute pathname in its
'file' parameter. Instead give it an additional parameter to hold the
directory name. Callers can then build up the absolute pathname if needed.
This change will come in handy soonish when VG_(get_filename_lineno) will be
changed and those buffers will disappear.
The change has a bit of ripple to get_fn_node_inseg and CLG_(get_file_node).

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

callgrind/debug.c
callgrind/dump.c
callgrind/fn.c
callgrind/global.h

index 53dd7fa005ee43cd6d92ab5f159030767bab119c..2acdd6f9543389c91470659b54580e19c7c51d2a 100644 (file)
@@ -374,6 +374,7 @@ void CLG_(print_bbcc_cost)(int s, BBCC* bbcc)
 void CLG_(print_addr)(Addr addr)
 {
     HChar fl_buf[FILENAME_LEN];
+    HChar dir_buf[FILENAME_LEN];
     const HChar *fn_buf;
     const HChar* obj_name;
     DebugInfo* di;
@@ -384,7 +385,7 @@ void CLG_(print_addr)(Addr addr)
        return;
     }
 
-    CLG_(get_debug_info)(addr, fl_buf, &fn_buf, &ln, &di);
+    CLG_(get_debug_info)(addr, dir_buf, fl_buf, &fn_buf, &ln, &di);
 
     if (VG_(strcmp)(fn_buf,"???")==0)
        VG_(printf)("%#lx", addr);
@@ -403,8 +404,12 @@ void CLG_(print_addr)(Addr addr)
       }
     }
 
-    if (ln>0)
-       VG_(printf)(" (%s:%u)", fl_buf,ln);
+    if (ln>0) {
+       if (dir_buf[0])
+          VG_(printf)(" (%s/%s:%u)", dir_buf, fl_buf, ln);
+       else
+          VG_(printf)(" (%s:%u)", fl_buf, ln);
+    }
 }
 
 void CLG_(print_addr_ln)(Addr addr)
index 5e73a9f4598dc71ef9c14f2af322f4daeef4be0c..0f750afee3092d31b51e306e19e262c472d1d49e 100644 (file)
@@ -448,14 +448,7 @@ Bool get_debug_pos(BBCC* bbcc, Addr addr, AddrPos* p)
            VG_(strcpy)(file, "???");
            p->line = 0;
        }
-       if (found_dirname) {
-           // +1 for the '/'.
-           CLG_ASSERT(VG_(strlen)(dir) + VG_(strlen)(file) + 1 < FILENAME_LEN);
-           VG_(strcat)(dir, "/");     // Append '/'
-           VG_(strcat)(dir, file);    // Append file to dir
-           VG_(strcpy)(file, dir);    // Move dir+file to file
-       }
-       p->file    = CLG_(get_file_node)(bbcc->bb->obj, file);
+       p->file    = CLG_(get_file_node)(bbcc->bb->obj, dir, file);
 
        debug_cache_info[cachepos] = found_file_line;
        debug_cache_addr[cachepos] = addr;
index 3102b526b59a5e60bdfa6c21538b093cc4f47888..fe3342ffcd5ee9446bd0e97b680019be80ad1581 100644 (file)
@@ -286,7 +286,7 @@ obj_node* CLG_(get_obj_node)(DebugInfo* di)
 
 
 static __inline__ 
-file_node* new_file_node(HChar filename[FILENAME_LEN],
+file_node* new_file_node(const HChar *filename,
                         obj_node* obj, file_node* next)
 {
   Int i;
@@ -305,11 +305,19 @@ file_node* new_file_node(HChar filename[FILENAME_LEN],
 
  
 file_node* CLG_(get_file_node)(obj_node* curr_obj_node,
-                               HChar filename[FILENAME_LEN])
+                               const HChar *dir, const HChar *file)
 {
     file_node* curr_file_node;
     UInt       filename_hash;
 
+    /* Build up an absolute pathname, if there is a directory available */
+    HChar filename[VG_(strlen)(dir) + 1 + VG_(strlen)(file) + 1];
+    VG_(strcpy)(filename, dir);
+    if (filename[0] != '\0') {
+       VG_(strcat)(filename, "/");
+    }
+    VG_(strcat)(filename, file);
+
     /* lookup in file hash */
     filename_hash = str_hash(filename, N_FILE_ENTRIES);
     curr_file_node = curr_obj_node->files[filename_hash];
@@ -403,11 +411,12 @@ fn_node* get_fn_node_infile(file_node* curr_file_node,
  */
 static __inline__
 fn_node* get_fn_node_inseg(DebugInfo* di,
-                          HChar filename[FILENAME_LEN],
+                          const HChar *dirname,
+                          const HChar *filename,
                           const HChar *fnname)
 {
   obj_node  *obj  = CLG_(get_obj_node)(di);
-  file_node *file = CLG_(get_file_node)(obj, filename);
+  file_node *file = CLG_(get_file_node)(obj, dirname, filename);
   fn_node   *fn   = get_fn_node_infile(file, fnname);
 
   return fn;
@@ -415,12 +424,12 @@ fn_node* get_fn_node_inseg(DebugInfo* di,
 
 
 Bool CLG_(get_debug_info)(Addr instr_addr,
-                        HChar file[FILENAME_LEN],
-                        const HChar **fn_name, UInt* line_num,
-                        DebugInfo** pDebugInfo)
+                          HChar dir[FILENAME_LEN],
+                          HChar file[FILENAME_LEN],
+                          const HChar **fn_name, UInt* line_num,
+                          DebugInfo** pDebugInfo)
 {
   Bool found_file_line, found_fn, found_dirname, result = True;
-  HChar dir[FILENAME_LEN];
   UInt line;
   
   CLG_DEBUG(6, "  + get_debug_info(%#lx)\n", instr_addr);
@@ -438,14 +447,6 @@ Bool CLG_(get_debug_info)(Addr instr_addr,
                                               &line);
    found_fn = VG_(get_fnname)(instr_addr, fn_name);
 
-   if (found_dirname) {
-       // +1 for the '/'.
-       CLG_ASSERT(VG_(strlen)(dir) + VG_(strlen)(file) + 1 < FILENAME_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 && !found_fn) {
      CLG_(stat).no_debug_BBs++;
      VG_(strcpy)(file, "???");
@@ -488,6 +489,7 @@ static BB* exit_bb = 0;
 fn_node* CLG_(get_fn_node)(BB* bb)
 {
     HChar      filename[FILENAME_LEN];
+    HChar      dirname[FILENAME_LEN];
     const HChar *fnname;
     DebugInfo* di;
     UInt       line_num;
@@ -502,7 +504,7 @@ fn_node* CLG_(get_fn_node)(BB* bb)
      * the BB according to debug information
      */
     CLG_(get_debug_info)(bb_addr(bb),
-                       filename, &fnname, &line_num, &di);
+                         dirname, filename, &fnname, &line_num, &di);
 
     if (0 == VG_(strcmp)(fnname, "???")) {
        int p;
@@ -533,7 +535,7 @@ fn_node* CLG_(get_fn_node)(BB* bb)
     if (0 == VG_(strcmp)(fnname, "vgPlain___libc_freeres_wrapper")
        && exit_bb) {
       CLG_(get_debug_info)(bb_addr(exit_bb),
-                         filename, &fnname, &line_num, &di);
+                           dirname, filename, &fnname, &line_num, &di);
        
        CLG_DEBUG(1, "__libc_freeres_wrapper renamed to _exit\n");
     }
@@ -548,7 +550,7 @@ fn_node* CLG_(get_fn_node)(BB* bb)
     }
 
     /* get fn_node struct for this function */
-    fn = get_fn_node_inseg( di, filename, fnname);
+    fn = get_fn_node_inseg( di, dirname, filename, fnname);
 
     /* if this is the 1st time the function is seen,
      * some attributes are set */
@@ -589,8 +591,12 @@ fn_node* CLG_(get_fn_node)(BB* bb)
     bb->fn   = fn;
     bb->line = line_num;
 
-    CLG_DEBUG(3,"- get_fn_node(BB %#lx): %s (in %s:%u)\n",
-            bb_addr(bb), fnname, filename, line_num);
+    if (dirname[0]) {
+       CLG_DEBUG(3,"- get_fn_node(BB %#lx): %s (in %s:%u)\n",
+                 bb_addr(bb), fnname, filename, line_num);
+    } else
+       CLG_DEBUG(3,"- get_fn_node(BB %#lx): %s (in %s/%s:%u)\n",
+                 bb_addr(bb), fnname, dirname, filename, line_num);
 
     return fn;
 }
index a32ba557482d74bf17283d22e91b17fcbdf1a790..cf4b201cd54f1162f8a4db6251ff5affa20439d9 100644 (file)
@@ -690,8 +690,9 @@ void CLG_(print_debug_usage)(void);
 void CLG_(init_eventsets)(void);
 
 /* from main.c */
-Bool CLG_(get_debug_info)(Addr, HChar filename[FILENAME_LEN],
-                        const HChar **fn_name, UInt*, DebugInfo**);
+Bool CLG_(get_debug_info)(Addr, HChar dirname[FILENAME_LEN],
+                          HChar filename[FILENAME_LEN],
+                          const HChar **fn_name, UInt*, DebugInfo**);
 void CLG_(collectBlockInfo)(IRSB* bbIn, UInt*, UInt*, Bool*);
 void CLG_(set_instrument_state)(const HChar*,Bool);
 void CLG_(dump_profile)(const HChar* trigger,Bool only_current_thread);
@@ -720,7 +721,8 @@ UInt* CLG_(get_fn_entry)(Int n);
 
 void      CLG_(init_obj_table)(void);
 obj_node* CLG_(get_obj_node)(DebugInfo* si);
-file_node* CLG_(get_file_node)(obj_node*, HChar* filename);
+file_node* CLG_(get_file_node)(obj_node*, const HChar *dirname,
+                               const HChar* filename);
 fn_node*  CLG_(get_fn_node)(BB* bb);
 
 /* from bbcc.c */