From 1472a4e17771f9076a7aa83c8cd2f4a1364a9a94 Mon Sep 17 00:00:00 2001 From: fche Date: Fri, 4 Nov 2005 21:46:14 +0000 Subject: [PATCH] 2005-11-04 Frank Ch. Eigler * tapsets.cxx (dwarf_derived_probe::emit_registrations): Add possible kprobe address prechecking logic. Set kretprobes maxactive to zero. * translate.cxx (emit_module_init): Set a more helpful default probe_point value for use in registration errors. Exit properly after registration failure of probe #0. --- ChangeLog | 9 +++++++++ tapsets.cxx | 17 ++++++++++++++--- translate.cxx | 10 ++++++++-- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46621e750..490c14eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-11-04 Frank Ch. Eigler + + * tapsets.cxx (dwarf_derived_probe::emit_registrations): Add + possible kprobe address prechecking logic. Set kretprobes + maxactive to zero. + * translate.cxx (emit_module_init): Set a more helpful default + probe_point value for use in registration errors. Exit properly + after registration failure of probe #0. + 2005-11-04 Roland McGrath * tapsets.cxx (add_probe_point): Use dwfl_module_relocation_info to diff --git a/tapsets.cxx b/tapsets.cxx index 8345c7972..0e4357e75 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -2601,14 +2601,25 @@ dwarf_derived_probe::emit_registrations (translator_output* o, o->indent(1); string probe_name = struct_kprobe_array_name(probenum) + "[i]"; +#if 0 + // XXX: triggers false negatives on RHEL4U2 kernel + // emit address verification code + o->newline() << "void *addr = " << probe_name; + if (has_return) + o->line() << ".kp.addr;"; + else + o->line() << ".addr;"; + o->newline() << "rc = ! virt_addr_valid (addr);"; +#endif + if (has_return) { o->newline() << "#ifdef ARCH_SUPPORTS_KRETPROBES"; o->newline() << probe_name << ".handler = &" << func_name << ";"; - o->newline() << probe_name << ".maxactive = 1;"; + o->newline() << probe_name << ".maxactive = 0;"; // request default // XXX: pending PR 1289 // o->newline() << probe_name << ".kp_fault_handler = &stap_kprobe_fault_handler;"; - o->newline() << "rc = register_kretprobe (&(" << probe_name << "));"; + o->newline() << "rc = rc || register_kretprobe (&(" << probe_name << "));"; o->newline() << "#else"; o->newline() << "rc = 1;"; o->newline() << "#endif"; @@ -2618,7 +2629,7 @@ dwarf_derived_probe::emit_registrations (translator_output* o, o->newline() << probe_name << ".pre_handler = &" << func_name << ";"; // XXX: pending PR 1289 // o->newline() << probe_name << ".kp_fault_handler = &stap_kprobe_fault_handler;"; - o->newline() << "rc = register_kprobe (&(" << probe_name << "));"; + o->newline() << "rc = rc || register_kprobe (&(" << probe_name << "));"; } o->newline() << "if (unlikely (rc)) {"; diff --git a/translate.cxx b/translate.cxx index bdacdccab..0c1ce84fc 100644 --- a/translate.cxx +++ b/translate.cxx @@ -825,9 +825,13 @@ c_unparser::emit_module_init () { o->newline() << "/* register probe #" << i << ", "; o->line() << session->probes[i]->locations.size() << " location(s) */"; - // default + + // By default, mark the first location as the site of possible + // registration failure. This is helpful since non-dwarf + // derived_probes tend to have only a single location. + assert (session->probes[i]->locations.size() > 0); o->newline() << "probe_point = " << - lex_cast_qstring (*session->probes[i]->tok) << ";"; + lex_cast_qstring (*session->probes[i]->locations[0]) << ";"; session->probes[i]->emit_registrations (o, i); o->newline() << "if (unlikely (rc)) {"; @@ -843,6 +847,8 @@ c_unparser::emit_module_init () // essential for kprobes. if (i > 0) o->newline() << "goto unregister_" << (i-1) << ";"; + else + o->newline() << "goto out;"; o->newline(-1) << "}"; } -- 2.43.5