From 0323ed4d37fee4f84251a74dce04271160d2d1f1 Mon Sep 17 00:00:00 2001 From: wcohen Date: Tue, 9 May 2006 12:55:56 +0000 Subject: Print out information to make it easier to determine which probe in script associated with timing information. --- ChangeLog | 7 +++++++ parse.cxx | 14 +++++++++++--- parse.h | 1 + translate.cxx | 9 +++++++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index de5881cc..71733211 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-05-09 Will Cohen + + PR 2228 + * parse.h: + * parse.cxx: Add << operator for struct source_loc. + * translate.cxx (emit_module_init): Print location of probe in script. + 2006-05-09 Li Guanglei PR 2520 * main.cxx: add -M option to stop merge per-cpu files in bulk mode diff --git a/parse.cxx b/parse.cxx index 96d9a5d4..0eba81bb 100644 --- a/parse.cxx +++ b/parse.cxx @@ -76,6 +76,16 @@ tt2str(token_type tt) return "unknown token"; } +ostream& +operator << (ostream& o, const source_loc& loc) +{ + o << loc.file << ":" + << loc.line << ":" + << loc.column; + + return o; +} + ostream& operator << (ostream& o, const token& t) { @@ -93,9 +103,7 @@ operator << (ostream& o, const token& t) } o << " at " - << t.location.file << ":" - << t.location.line << ":" - << t.location.column; + << t.location; return o; } diff --git a/parse.h b/parse.h index b9d56152..8648bc52 100644 --- a/parse.h +++ b/parse.h @@ -24,6 +24,7 @@ struct source_loc unsigned column; }; +std::ostream& operator << (std::ostream& o, const source_loc& loc); enum token_type { diff --git a/translate.cxx b/translate.cxx index 30601cf2..f4f00f65 100644 --- a/translate.cxx +++ b/translate.cxx @@ -1023,13 +1023,18 @@ c_unparser::emit_module_init () session->probes[i]->emit_deregistrations (o); o->newline() << "#ifdef STP_TIMING"; o->newline(1) << "{"; + o->newline() << "const char *probe_point = " << + lex_cast_qstring (*session->probes[i]->locations[0]) << ";"; o->newline() << "struct stat_data *stats = _stp_stat_get (time_" << session->probes[i]->name << ", 0);"; o->newline() << "int64_t avg = 0;"; o->newline() << "const char *error;"; o->newline() << "if (stats->count) avg = _stp_div64(&error, stats->sum, stats->count);"; - o->newline() << "_stp_printf (\"time_" << session->probes[i]->name - << " %lld@%lld\\n\"," << "stats->count, avg);"; + o->newline() << "_stp_printf ("; + o->newline() << "\"probe at " << session->probes[i]->tok->location + << " (%s)\"" ; + o->newline() << "\" %lld@%lld (%lld <= t <= %lld)\\n\","; + o->newline() << "probe_point, stats->count, avg, stats->min, stats->max);"; o->newline() << "_stp_print_flush();"; o->newline(-1) << "}"; o->newline() << "#endif"; -- cgit