diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | parse.cxx | 14 | ||||
-rw-r--r-- | parse.h | 1 | ||||
-rw-r--r-- | translate.cxx | 9 |
4 files changed, 26 insertions, 5 deletions
@@ -1,3 +1,10 @@ +2006-05-09 Will Cohen <wcohen@redhat.com> + + 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 <guanglei@cn.ibm.com> PR 2520 * main.cxx: add -M option to stop merge per-cpu files in bulk mode @@ -77,6 +77,16 @@ tt2str(token_type tt) } ostream& +operator << (ostream& o, const source_loc& loc) +{ + o << loc.file << ":" + << loc.line << ":" + << loc.column; + + return o; +} + +ostream& operator << (ostream& o, const token& t) { o << tt2str(t.type); @@ -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; } @@ -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"; |