|
From: <sv...@va...> - 2014-10-26 17:12:20
|
Author: florian
Date: Sun Oct 26 17:12:12 2014
New Revision: 14665
Log:
Merge r14288 from the BUF_REMOVAL branch to trunk.
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.
Modified:
trunk/ (props changed)
trunk/cachegrind/cg_main.c
Modified: trunk/cachegrind/cg_main.c
==============================================================================
--- trunk/cachegrind/cg_main.c (original)
+++ trunk/cachegrind/cg_main.c Sun Oct 26 17:12:12 2014
@@ -211,10 +211,10 @@
/*--- 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 @@
*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 @@
// 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;
|