From: Josef Weidendorfer Date: Mon, 17 Oct 2011 18:12:48 +0000 (+0000) Subject: Fix callgrind part of bug 280757. X-Git-Tag: svn/VALGRIND_3_7_0~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d08c246e3fae166fc1f6a515ea81050b3c6452b1;p=thirdparty%2Fvalgrind.git Fix callgrind part of bug 280757. For this, we make VG_(tmpdir) available to tools. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12163 --- diff --git a/callgrind/command.c b/callgrind/command.c index 674fd0fa69..400fbbdc76 100644 --- a/callgrind/command.c +++ b/callgrind/command.c @@ -2,7 +2,7 @@ This file is part of Callgrind, a Valgrind tool for call graph profiling programs. - Copyright (C) 2002-2010, Josef Weidendorfer (Josef.Weidendorfer@gmx.de) + Copyright (C) 2002-2011, Josef Weidendorfer (Josef.Weidendorfer@gmx.de) This tool is derived from and contains lot of code from Cachegrind Copyright (C) 2002 Nicholas Nethercote (njn@valgrind.org) @@ -58,6 +58,7 @@ static void setup_control(void) Int fd, size; SysRes res; Char* dir; + const HChar *tmpdir; CLG_ASSERT(thisPID != 0); @@ -95,10 +96,12 @@ static void setup_control(void) VG_(sprintf)(result_file2, "%s/%s", dir, DEFAULT_RESULTNAME); + tmpdir = VG_(tmpdir)(); info_file = (char*) CLG_MALLOC("cl.command.sc.5", + VG_(strlen)(tmpdir) + VG_(strlen)(DEFAULT_INFONAME) + 10); CLG_ASSERT(info_file != 0); - VG_(sprintf)(info_file, "%s.%d", DEFAULT_INFONAME, thisPID); + VG_(sprintf)(info_file, "%s/%s.%d", tmpdir, DEFAULT_INFONAME, thisPID); CLG_DEBUG(1, "Setup for interactive control (PID: %d):\n", thisPID); CLG_DEBUG(1, " output file: '%s'\n", out_file); diff --git a/callgrind/global.h b/callgrind/global.h index c56b11fad7..19065daaa6 100644 --- a/callgrind/global.h +++ b/callgrind/global.h @@ -53,7 +53,7 @@ #define DEFAULT_OUTFORMAT "callgrind.out.%p" #define DEFAULT_COMMANDNAME "callgrind.cmd" #define DEFAULT_RESULTNAME "callgrind.res" -#define DEFAULT_INFONAME "/tmp/callgrind.info" +#define DEFAULT_INFONAME "callgrind.info" typedef struct _CommandLineOptions CommandLineOptions; struct _CommandLineOptions { diff --git a/coregrind/pub_core_libcfile.h b/coregrind/pub_core_libcfile.h index 9a5bc5477b..9cfaab20d5 100644 --- a/coregrind/pub_core_libcfile.h +++ b/coregrind/pub_core_libcfile.h @@ -90,9 +90,6 @@ extern SysRes VG_(pread) ( Int fd, void* buf, Int count, OffT offset ); written is guaranteed not to exceed 64+strlen(part_of_name). */ extern Int VG_(mkstemp) ( HChar* part_of_name, /*OUT*/HChar* fullname ); -/* Return the name of a directory for temporary files. */ -extern const HChar* VG_(tmpdir)(void); - /* Record the process' working directory at startup. Is intended to be called exactly once, at startup, before the working directory changes. Return True for success, False for failure, so that the diff --git a/include/pub_tool_libcfile.h b/include/pub_tool_libcfile.h index 8a1766600c..700f50de9e 100644 --- a/include/pub_tool_libcfile.h +++ b/include/pub_tool_libcfile.h @@ -94,6 +94,9 @@ extern Int VG_(getdents)( Int fd, struct vki_dirent *dirp, UInt count ); extern Char* VG_(basename)( const Char* path ); extern Char* VG_(dirname) ( const Char* path ); +/* Return the name of a directory for temporary files. */ +extern const HChar* VG_(tmpdir)(void); + /* Copy the working directory at startup into buf[0 .. size-1], or return False if buf is too small. */ extern Bool VG_(get_startup_wd) ( Char* buf, SizeT size );