|
From: <sv...@va...> - 2014-08-15 15:04:40
|
Author: florian
Date: Fri Aug 15 15:04:31 2014
New Revision: 14289
Log:
Change CLG_(get_debug_info) such that it does not build up an absolute
path name. Instead add a function parameter to hold the directory
name, if one was found. Build up the path name when it is needed.
That will come in handy soonish.
This change has some ripple and a few other functions need to be changed
and now take in an additional parameter for the directory as well.
For clarity, change some function parameter types from
HChar [FILENAME_LEN] to const HChar * if the parameter is an
input parameter.
Modified:
branches/BUF_REMOVAL/callgrind/debug.c
branches/BUF_REMOVAL/callgrind/dump.c
branches/BUF_REMOVAL/callgrind/fn.c
branches/BUF_REMOVAL/callgrind/global.h
Modified: branches/BUF_REMOVAL/callgrind/debug.c
==============================================================================
--- branches/BUF_REMOVAL/callgrind/debug.c (original)
+++ branches/BUF_REMOVAL/callgrind/debug.c Fri Aug 15 15:04:31 2014
@@ -373,7 +373,7 @@
/* dump out an address with source info if available */
void CLG_(print_addr)(Addr addr)
{
- HChar fl_buf[FILENAME_LEN];
+ HChar fl_buf[FILENAME_LEN], dir_buf[FILENAME_LEN];
HChar *fn_buf;
const HChar* obj_name;
DebugInfo* di;
@@ -384,7 +384,7 @@
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 +403,12 @@
}
}
- 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)
Modified: branches/BUF_REMOVAL/callgrind/dump.c
==============================================================================
--- branches/BUF_REMOVAL/callgrind/dump.c (original)
+++ branches/BUF_REMOVAL/callgrind/dump.c Fri Aug 15 15:04:31 2014
@@ -461,14 +461,10 @@
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
+ if (! found_dirname) {
+ dir[0] = '\0';
}
- 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;
Modified: branches/BUF_REMOVAL/callgrind/fn.c
==============================================================================
--- branches/BUF_REMOVAL/callgrind/fn.c (original)
+++ branches/BUF_REMOVAL/callgrind/fn.c Fri Aug 15 15:04:31 2014
@@ -286,7 +286,7 @@
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* 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 @@
*/
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 @@
Bool CLG_(get_debug_info)(Addr instr_addr,
+ HChar dir[FILENAME_LEN],
HChar file[FILENAME_LEN],
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);
@@ -439,12 +448,8 @@
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_dirname) {
+ dir[0] = '\0';
}
if (!found_file_line && !found_fn) {
@@ -488,7 +493,7 @@
*/
fn_node* CLG_(get_fn_node)(BB* bb)
{
- HChar filename[FILENAME_LEN], *fnname;
+ HChar filename[FILENAME_LEN], dirname[FILENAME_LEN], *fnname;
DebugInfo* di;
UInt line_num;
fn_node* fn;
@@ -502,7 +507,7 @@
* 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 +538,7 @@
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 +553,7 @@
}
/* 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,9 +594,13 @@
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/%s:%u)\n",
+ bb_addr(bb), fnname, dirname, filename, line_num);
+ } else {
+ CLG_DEBUG(3,"- get_fn_node(BB %#lx): %s (in %s:%u)\n",
+ bb_addr(bb), fnname, filename, line_num);
+ }
return fn;
}
Modified: branches/BUF_REMOVAL/callgrind/global.h
==============================================================================
--- branches/BUF_REMOVAL/callgrind/global.h (original)
+++ branches/BUF_REMOVAL/callgrind/global.h Fri Aug 15 15:04:31 2014
@@ -721,8 +721,9 @@
void CLG_(init_eventsets)(void);
/* from main.c */
-Bool CLG_(get_debug_info)(Addr, HChar filename[FILENAME_LEN],
- HChar **fn_name, UInt*, DebugInfo**);
+Bool CLG_(get_debug_info)(Addr, HChar dirname[FILENAME_LEN],
+ HChar filename[FILENAME_LEN],
+ 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);
@@ -751,7 +752,8 @@
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 */
|