aboutsummaryrefslogtreecommitdiff
path: root/cachegrind/cg_main.c
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2007-11-23 01:41:32 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2007-11-23 01:41:32 +0000
commit374a36dbfb6d08ed8d77c31a88e198a861ffadf0 (patch)
tree70b56afcf1a57ad8cafb5e769e7354342f4fe847 /cachegrind/cg_main.c
parentf36ae99840c45960187073d140934e45daa6b066 (diff)
downloadvalgrind-374a36dbfb6d08ed8d77c31a88e198a861ffadf0.tar.gz
Fixed up the log file mess throughout, including the docs. This killed
--log-file-qualifier and --log-file-exactly. Updated NEWS some in preparation for 3.3.0. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7202 a5019735-40e9-0310-863c-91ae7b9d1cf9
Diffstat (limited to 'cachegrind/cg_main.c')
-rw-r--r--cachegrind/cg_main.c62
1 files changed, 9 insertions, 53 deletions
diff --git a/cachegrind/cg_main.c b/cachegrind/cg_main.c
index d8627fb86..9fae9de57 100644
--- a/cachegrind/cg_main.c
+++ b/cachegrind/cg_main.c
@@ -65,8 +65,9 @@
/*--- Options ---*/
/*------------------------------------------------------------*/
-static Bool clo_cache_sim = True; /* do cache simulation? */
-static Bool clo_branch_sim = False; /* do branch simulation? */
+static Bool clo_cache_sim = True; /* do cache simulation? */
+static Bool clo_branch_sim = False; /* do branch simulation? */
+static Char* clo_cachegrind_out_file = "cachegrind.out.%p";
/*------------------------------------------------------------*/
/*--- Types and Data Structures ---*/
@@ -1255,17 +1256,9 @@ static CacheCC Dw_total;
static BranchCC Bc_total;
static BranchCC Bi_total;
-// The output file base name specified by the user using the
-// --cachegrind-out-file switch. This is combined with the
-// process ID and optional user-supplied qualifier (from
-// --log-file-qualifier) to produce the name stored in
-// cachegrind_out_file.
-static Char* cachegrind_out_file_basename = "cachegrind.out";
-
-// The final, completed name for the output file.
+// The output file name. Controlled by --cachegrind-out-file.
static Char* cachegrind_out_file = NULL;
-
static void fprint_CC_table_and_calc_totals(void)
{
Int i, fd;
@@ -1691,7 +1684,7 @@ static Bool cg_process_cmd_line_option(Char* arg)
else if (VG_CLO_STREQN(5, arg, "--L2="))
parse_cache_opt(&clo_L2_cache, &arg[5]);
else if (VG_CLO_STREQN(22, arg, "--cachegrind-out-file=")) {
- cachegrind_out_file_basename = &arg[22];
+ clo_cachegrind_out_file = &arg[22];
}
else VG_BOOL_CLO(arg, "--cache-sim", clo_cache_sim)
else VG_BOOL_CLO(arg, "--branch-sim", clo_branch_sim)
@@ -1709,8 +1702,7 @@ static void cg_print_usage(void)
" --L2=<size>,<assoc>,<line_size> set L2 cache manually\n"
" --cache-sim=yes|no [yes] collect cache stats?\n"
" --branch-sim=yes|no [no] collect branch prediction stats?\n"
-" --cachegrind-out-file=<file> write profile data to <file>.<pid>\n"
-" [cachegrind.out.<pid>]\n"
+" --cachegrind-out-file=<file> output file name [cachegrind.out.%%p]\n"
);
}
@@ -1725,8 +1717,6 @@ static void cg_print_debug_usage(void)
/*--- Setup ---*/
/*--------------------------------------------------------------------*/
-static Char base_dir[VKI_PATH_MAX];
-
static void cg_post_clo_init(void); /* just below */
static void cg_pre_clo_init(void)
@@ -1751,9 +1741,7 @@ static void cg_pre_clo_init(void)
static void cg_post_clo_init(void)
{
- HChar* qual = NULL;
cache_t I1c, D1c, L2c;
- Int filename_szB;
/* Can't disable both cache and branch profiling */
if ((!clo_cache_sim) && (!clo_branch_sim)) {
@@ -1764,41 +1752,9 @@ static void cg_post_clo_init(void)
VG_(exit)(2);
}
- /* Get working directory */
- tl_assert( VG_(get_startup_wd)(base_dir, VKI_PATH_MAX) );
-
- /* Do we have a --log-file-qualifier= to consider? */
- if (VG_(clo_log_file_qualifier)) {
- qual = VG_(getenv)(VG_(clo_log_file_qualifier));
- }
-
- /* Block is big enough for
- dir name ++ cachegrind_out_file_basename
- ++ ".<pid>"
- ++ the log file qualifier, if in use */
- filename_szB
- = VG_(strlen)(base_dir)
- + 1 /* "/" */
- + VG_(strlen)(cachegrind_out_file_basename)
- + 11 /* "." <pid>, assuming sizeof(pid) <= 4 */
- + (qual ? (10 + VG_(strlen)(qual)) : 0)
- + 1; /* to guarantee checkable zero at the end */
-
- tl_assert(filename_szB > 0);
- cachegrind_out_file
- = VG_(calloc)( sizeof(Char), filename_szB );
-
- if (qual) {
- VG_(sprintf)(cachegrind_out_file, "%s/%s.%d.lfq.%s",
- base_dir, cachegrind_out_file_basename,
- VG_(getpid)(), qual);
- } else {
- VG_(sprintf)(cachegrind_out_file, "%s/%s.%d",
- base_dir, cachegrind_out_file_basename,
- VG_(getpid)());
- }
-
- tl_assert( cachegrind_out_file[filename_szB-1] == 0 );
+ // Setup output filename.
+ cachegrind_out_file =
+ VG_(expand_file_name)("--cachegrind-out-file", clo_cachegrind_out_file);
CC_table =
VG_(OSetGen_Create)(offsetof(LineCC, loc),