From: Florian Krohm Date: Sun, 26 Oct 2014 17:12:12 +0000 (+0000) Subject: Merge r14288 from the BUF_REMOVAL branch to trunk. X-Git-Tag: svn/VALGRIND_3_11_0~883 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08e13c218dcd7db4504fde9e4a4b7ac90ed78e81;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14665 --- diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c index 71efdea26b..10e562e4cc 100644 --- a/cachegrind/cg_main.c +++ b/cachegrind/cg_main.c @@ -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;