From 7e6c2d0bd81af35151167ca75fc1b7d20a9e9a7d Mon Sep 17 00:00:00 2001 From: wcohen Date: Thu, 28 Feb 2008 20:47:11 +0000 Subject: 2008-02-28 Will Cohen PR433780 * errno.stp (returnstr): Handle unified i386/x86_64 reg names. --- tapset/ChangeLog | 5 +++++ tapset/errno.stp | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tapset/ChangeLog b/tapset/ChangeLog index e198b9e5..4c65ccc0 100644 --- a/tapset/ChangeLog +++ b/tapset/ChangeLog @@ -1,3 +1,8 @@ +2008-02-28 Will Cohen + + PR433780 + * errno.stp (returnstr): Handle unified i386/x86_64 reg names. + 2008-02-27 Masami Hiramatsu * x86_64/syscalls.stp (syscall.iopl): Use new_iopl instead of level diff --git a/tapset/errno.stp b/tapset/errno.stp index a6b2c9cf..550e5d4f 100644 --- a/tapset/errno.stp +++ b/tapset/errno.stp @@ -358,7 +358,9 @@ function returnstr:string (returnp:long) %{ /* pure */ /* XXX: unfortunate duplication with return.stp:retval() */ if (CONTEXT->regs) { -#if defined (__i386__) +#if defined (STAPCONF_X86_UNIREGS) && (defined (__x86_64__) || defined (__i386__)) + ret = CONTEXT->regs->ax; +#elif defined (__i386__) ret = CONTEXT->regs->eax; #elif defined (__x86_64__) ret = CONTEXT->regs->rax; -- cgit From 49abf162fa91397b0c65d41f5c9af31ace4e6290 Mon Sep 17 00:00:00 2001 From: fche Date: Thu, 28 Feb 2008 21:34:46 +0000 Subject: PR5045: clean up after interrupts 2008-02-28 Frank Ch. Eigler PR5045 * session.h (pending_interrupts): New global. * main.cxx (handle_interrupts): New fn to handle SIGINT* etc. * elaborate.cxx, translate.cxx, tapsets.cxx, main.cxx (*): Insert pending_interrupts escape hatches inside potentially timetaking loops. * buildrun.cxx: Don't deal with signals. --- ChangeLog | 9 +++++++++ buildrun.cxx | 5 +---- elaborate.cxx | 17 +++++++++++++++++ main.cxx | 47 +++++++++++++++++++++++++++++++++++++---------- session.h | 3 +++ tapsets.cxx | 6 ++++++ translate.cxx | 11 +++++++++-- 7 files changed, 82 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8be45cfc..ecfe4269 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-28 Frank Ch. Eigler + + PR5045 + * session.h (pending_interrupts): New global. + * main.cxx (handle_interrupts): New fn to handle SIGINT* etc. + * elaborate.cxx, translate.cxx, tapsets.cxx, main.cxx (*): Insert + pending_interrupts escape hatches inside potentially timetaking loops. + * buildrun.cxx: Don't deal with signals. + 2008-02-27 Frank Ch. Eigler PR5697 diff --git a/buildrun.cxx b/buildrun.cxx index 67836108..f3f29d49 100644 --- a/buildrun.cxx +++ b/buildrun.cxx @@ -16,7 +16,7 @@ #include extern "C" { -#include "signal.h" +#include #include #include #include @@ -269,9 +269,6 @@ run_pass (systemtap_session& s) if (s.verbose>1) clog << "Running " << staprun_cmd << endl; - signal (SIGHUP, SIG_IGN); - signal (SIGINT, SIG_IGN); rc = system (staprun_cmd.c_str ()); - return rc; } diff --git a/elaborate.cxx b/elaborate.cxx index 7f4ccf35..75714102 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -344,6 +344,8 @@ match_node::find_and_build (systemtap_session& s, const match_key& subkey = i->first; match_node* subnode = i->second; + if (pending_interrupts) break; + if (match.globmatch(subkey)) { if (s.verbose > 2) @@ -627,6 +629,8 @@ derive_probes (systemtap_session& s, { for (unsigned i = 0; i < p->locations.size(); ++i) { + if (pending_interrupts) break; + probe_point *loc = p->locations[i]; try @@ -1070,6 +1074,7 @@ semantic_pass_symbols (systemtap_session& s) s.files.push_back (s.user_file); for (unsigned i = 0; i < s.files.size(); i++) { + if (pending_interrupts) break; stapfile* dome = s.files[i]; // Pass 1: add globals and functions to systemtap-session master list, @@ -1088,6 +1093,7 @@ semantic_pass_symbols (systemtap_session& s) for (unsigned i=0; ifunctions.size(); i++) { + if (pending_interrupts) break; functiondecl* fd = dome->functions[i]; try @@ -1107,6 +1113,7 @@ semantic_pass_symbols (systemtap_session& s) for (unsigned i=0; iprobes.size(); i++) { + if (pending_interrupts) break; probe* p = dome->probes [i]; vector dps; @@ -1116,6 +1123,7 @@ semantic_pass_symbols (systemtap_session& s) for (unsigned j=0; jjoin_group (s); @@ -2025,6 +2033,8 @@ semantic_pass_optimize1 (systemtap_session& s) bool relaxed_p = false; while (! relaxed_p) { + if (pending_interrupts) break; + relaxed_p = true; // until proven otherwise semantic_pass_opt1 (s, relaxed_p); @@ -2052,6 +2062,7 @@ semantic_pass_optimize2 (systemtap_session& s) bool relaxed_p = false; while (! relaxed_p) { + if (pending_interrupts) break; relaxed_p = true; // until proven otherwise semantic_pass_opt5 (s, relaxed_p); @@ -2082,12 +2093,16 @@ semantic_pass_types (systemtap_session& s) // XXX: maybe convert to exception-based error signalling while (1) { + if (pending_interrupts) break; + iterations ++; ti.num_newly_resolved = 0; ti.num_still_unresolved = 0; for (unsigned j=0; j #include +#include #include #include #include @@ -185,6 +186,23 @@ printscript(systemtap_session& s, ostream& o) } } + +int pending_interrupts; + +extern "C" +void handle_interrupt (int /* sig */) +{ + pending_interrupts ++; + if (pending_interrupts > 1) // XXX: should be configurable? time-based? + { + char msg[] = "Too many interrupts received, exiting.\n"; + int rc = write (2, msg, sizeof(msg)-1); + if (rc) /* Do nothing; we don't care if our last gasp went out. */ ; + _exit (1); + } +} + + int main (int argc, char * const argv []) { @@ -541,6 +559,13 @@ main (int argc, char * const argv []) // directory. s.translated_source = string(s.tmpdir) + "/" + s.module_name + ".c"; + // Set up our handler to catch routine signals, to allow clean + // and reasonably timely exit. + signal (SIGHUP, handle_interrupt); + signal (SIGPIPE, handle_interrupt); + signal (SIGINT, handle_interrupt); + signal (SIGTERM, handle_interrupt); + struct tms tms_before; times (& tms_before); struct timeval tv_before; @@ -616,8 +641,10 @@ main (int argc, char * const argv []) for (unsigned j=0; jsize(); i++) { + if (pending_interrupts) return; Dwarf_Die die = v->at(i); int rc = (*callback)(& die, data); if (rc != DWARF_CB_OK) break; @@ -1057,6 +1061,7 @@ struct dwflpp { for (size_t i = 0; i < nsrcs; ++i) { + if (pending_interrupts) return; if (srcsp [i]) // skip over mismatched lines callback (srcsp[i], data); } @@ -3012,6 +3017,7 @@ static int query_cu (Dwarf_Die * cudie, void * arg) { dwarf_query * q = static_cast(arg); + if (pending_interrupts) return DWARF_CB_ABORT; try { diff --git a/translate.cxx b/translate.cxx index fefb0c8f..855a8e93 100644 --- a/translate.cxx +++ b/translate.cxx @@ -4471,18 +4471,21 @@ translate_pass (systemtap_session& s) s.op->newline(1); for (unsigned i=0; iemit_global_init (s.globals[i]); } s.op->newline(-1) << "};"; for (unsigned i=0; inewline(); s.up->emit_functionsig (s.functions[i]); } for (unsigned i=0; inewline(); s.up->emit_function (s.functions[i]); } @@ -4492,12 +4495,16 @@ translate_pass (systemtap_session& s) // emit_locks()/emit_unlocks(). for (unsigned i=0; ineeds_global_locks()) + if (pending_interrupts) return 1; + if (s.probes[i]->needs_global_locks()) s.probes[i]->body->visit (&cup.vcv_needs_global_locks); } for (unsigned i=0; iemit_probe (s.probes[i]); + { + if (pending_interrupts) return 1; + s.up->emit_probe (s.probes[i]); + } s.op->newline(); s.up->emit_module_init (); -- cgit From 9ceec314dfc92c5d69442966dd386aaefee90bea Mon Sep 17 00:00:00 2001 From: wcohen Date: Fri, 29 Feb 2008 14:36:28 +0000 Subject: 2008-02-29 Will Cohen * main.cxx (handle_interrupts): Make compatible with GCC 4.3. --- ChangeLog | 4 ++++ main.cxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ecfe4269..07cee9dc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2008-02-29 Will Cohen + + * main.cxx (handle_interrupts): Make compatible with GCC 4.3. + 2008-02-28 Frank Ch. Eigler PR5045 diff --git a/main.cxx b/main.cxx index 449c1a2a..4364f664 100644 --- a/main.cxx +++ b/main.cxx @@ -197,7 +197,7 @@ void handle_interrupt (int /* sig */) { char msg[] = "Too many interrupts received, exiting.\n"; int rc = write (2, msg, sizeof(msg)-1); - if (rc) /* Do nothing; we don't care if our last gasp went out. */ ; + if (rc) {/* Do nothing; we don't care if our last gasp went out. */ ;} _exit (1); } } -- cgit