From 480f38d3275c87ac5b58a95dd127633babfc7374 Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 18 Aug 2008 15:54:39 -0500 Subject: Add missing 'process' bindings. 2008-08-18 David Smith * tapsets.cxx (register_standard_tapsets): Add missing 'process.syscall' and 'process.syscall.return' bindings. --- tapsets.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 9dcb4290..39fc0074 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -8916,21 +8916,24 @@ register_standard_tapsets(systemtap_session & s) ->bind(new utrace_builder ()); s.pattern_root->bind(TOK_PROCESS)->bind(TOK_THREAD)->bind(TOK_END) ->bind(new utrace_builder ()); - - // itrace user-space probes - s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") - ->bind(new itrace_builder ()); - s.pattern_root->bind_num(TOK_PROCESS)->bind("itrace") - ->bind(new itrace_builder ()); - s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_SYSCALL) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_SYSCALL) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_SYSCALL) + ->bind(new utrace_builder ()); s.pattern_root->bind_str(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) ->bind(new utrace_builder ()); s.pattern_root->bind_num(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) ->bind(new utrace_builder ()); + s.pattern_root->bind(TOK_PROCESS)->bind(TOK_SYSCALL)->bind(TOK_RETURN) + ->bind(new utrace_builder ()); + + // itrace user-space probes + s.pattern_root->bind_str(TOK_PROCESS)->bind("itrace") + ->bind(new itrace_builder ()); + s.pattern_root->bind_num(TOK_PROCESS)->bind("itrace") + ->bind(new itrace_builder ()); // marker-based parts s.pattern_root->bind(TOK_KERNEL)->bind_str(TOK_MARK) -- cgit From 930a1798154b9c1caf27009825b2b165ef577a1e Mon Sep 17 00:00:00 2001 From: David Smith Date: Tue, 19 Aug 2008 12:12:06 -0500 Subject: PR 6841 fix. 2008-08-19 David Smith PR 6841 * tapsets.cxx (utrace_derived_probe_group::emit_probe_decl): Workaround utrace bug by quiescing threads before attaching a utrace syscall engine to them. (utrace_derived_probe_group::emit_module_decls): Emit quiesce handler. 2008-08-19 David Smith PR 6841 * task_finder.c (__stp_utrace_task_finder_target_quiesce): Quiesces thread before turning on syscall tracing. --- tapsets.cxx | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 39fc0074..36601b01 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6096,17 +6096,19 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, // For UDPF_SYSCALL/UDPF_SYSCALL_RETURN probes, the .report_death // handler isn't strictly necessary. However, it helps to keep - // our attaches/detaches symmetrical. + // our attaches/detaches symmetrical. Notice we're using quiesce + // as a workaround for bug 6841. case UDPF_SYSCALL: s.op->line() << " .flags=(UDPF_SYSCALL),"; - s.op->line() << " .ops={ .report_syscall_entry=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death },"; - s.op->line() << " .events=(UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .ops={ .report_syscall_entry=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; + s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; case UDPF_SYSCALL_RETURN: s.op->line() << " .flags=(UDPF_SYSCALL_RETURN),"; - s.op->line() << " .ops={ .report_syscall_exit=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death },"; - s.op->line() << " .events=(UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .ops={ .report_syscall_exit=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; + s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; + case UDPF_NONE: s.op->line() << " .flags=(UDPF_NONE),"; s.op->line() << " .ops={ },"; @@ -6228,6 +6230,24 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output handler function for SYSCALL_ENTRY and SYSCALL_EXIT events if (flags_seen[UDPF_SYSCALL] || flags_seen[UDPF_SYSCALL_RETURN]) { + s.op->newline() << "static u32 stap_utrace_probe_syscall_quiesce(struct utrace_attached_engine *engine, struct task_struct *tsk) {"; + s.op->indent(1); + s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; + + // Turn off quiesce handling and turn on either syscall entry + // or exit events. + s.op->newline() << "if (p->flags == UDPF_SYSCALL)"; + s.op->indent(1); + s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH));"; + s.op->indent(-1); + s.op->newline() << "else if (p->flags == UDPF_SYSCALL_RETURN)"; + s.op->indent(1); + s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH));"; + s.op->indent(-1); + + s.op->newline() << "return (UTRACE_ACTION_NEWSTATE | UTRACE_ACTION_RESUME);"; + s.op->newline(-1) << "}"; + s.op->newline() << "static u32 stap_utrace_probe_syscall(struct utrace_attached_engine *engine, struct task_struct *tsk, struct pt_regs *regs) {"; s.op->indent(1); s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; -- cgit From 4550733ebf24fb067f9a2350e0ab86d44fea932e Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 20 Aug 2008 15:05:57 -0500 Subject: Supports original and new utrace interfaces. 2008-08-20 David Smith * tapsets.cxx (utrace_derived_probe_group::emit_probe_decl): Supports original and new utrace interfaces. (utrace_derived_probe_group::emit_module_decls): Ditto. 2008-08-20 David Smith * task_finder.c: Supports original and new utrace interfaces. * utrace_compatibility.h (utrace_attach_task): Compatibility layer for original utrace interface. --- tapsets.cxx | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 36601b01..d2e5bdba 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -6076,12 +6076,12 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, case UDPF_BEGIN: // process begin s.op->line() << " .flags=(UDPF_BEGIN),"; s.op->line() << " .ops={ .report_quiesce=stap_utrace_probe_quiesce },"; - s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)),"; + s.op->line() << " .events=(UTRACE_STOP|UTRACE_EVENT(QUIESCE)),"; break; case UDPF_THREAD_BEGIN: // thread begin s.op->line() << " .flags=(UDPF_THREAD_BEGIN),"; s.op->line() << " .ops={ .report_quiesce=stap_utrace_probe_quiesce },"; - s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)),"; + s.op->line() << " .events=(UTRACE_STOP|UTRACE_EVENT(QUIESCE)),"; break; // Notice we're not setting up a .ops/.report_death handler for @@ -6101,12 +6101,12 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, case UDPF_SYSCALL: s.op->line() << " .flags=(UDPF_SYSCALL),"; s.op->line() << " .ops={ .report_syscall_entry=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; - s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .events=(UTRACE_STOP|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; case UDPF_SYSCALL_RETURN: s.op->line() << " .flags=(UDPF_SYSCALL_RETURN),"; s.op->line() << " .ops={ .report_syscall_exit=stap_utrace_probe_syscall, .report_death=stap_utrace_task_finder_report_death, .report_quiesce=stap_utrace_probe_syscall_quiesce },"; - s.op->line() << " .events=(UTRACE_ACTION_QUIESCE|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; + s.op->line() << " .events=(UTRACE_STOP|UTRACE_EVENT(QUIESCE)|UTRACE_EVENT(DEATH)),"; break; case UDPF_NONE: @@ -6192,7 +6192,11 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output handler function for UDPF_BEGIN and UDPF_THREAD_BEGIN if (flags_seen[UDPF_BEGIN] || flags_seen[UDPF_THREAD_BEGIN]) { + s.op->newline() << "#ifdef UTRACE_ORIG_VERSION"; s.op->newline() << "static u32 stap_utrace_probe_quiesce(struct utrace_attached_engine *engine, struct task_struct *tsk) {"; + s.op->newline() << "#else"; + s.op->newline() << "static u32 stap_utrace_probe_quiesce(enum utrace_resume_action action, struct utrace_attached_engine *engine, struct task_struct *tsk, unsigned long event) {"; + s.op->newline() << "#endif"; s.op->indent(1); s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; @@ -6203,10 +6207,9 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*p->ph) (c);"; common_probe_entryfn_epilogue (s.op); - // UTRACE_ACTION_NEWSTATE not needed here to clear quiesce since - // we're detaching - utrace automatically restarts the thread. + // we're detaching, so utrace automatically restarts the thread. s.op->newline() << "debug_task_finder_detach();"; - s.op->newline() << "return UTRACE_ACTION_DETACH;"; + s.op->newline() << "return UTRACE_DETACH;"; s.op->newline(-1) << "}"; } @@ -6230,25 +6233,39 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output handler function for SYSCALL_ENTRY and SYSCALL_EXIT events if (flags_seen[UDPF_SYSCALL] || flags_seen[UDPF_SYSCALL_RETURN]) { + s.op->newline() << "#ifdef UTRACE_ORIG_VERSION"; s.op->newline() << "static u32 stap_utrace_probe_syscall_quiesce(struct utrace_attached_engine *engine, struct task_struct *tsk) {"; + s.op->newline() << "#else"; + s.op->newline() << "static u32 stap_utrace_probe_syscall_quiesce(enum utrace_resume_action action, struct utrace_attached_engine *engine, struct task_struct *tsk, unsigned long event) {"; + s.op->newline() << "#endif"; s.op->indent(1); s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; + s.op->newline() << "int rc = 0;"; // Turn off quiesce handling and turn on either syscall entry // or exit events. s.op->newline() << "if (p->flags == UDPF_SYSCALL)"; s.op->indent(1); - s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH));"; + s.op->newline() << "rc = utrace_set_events(tsk, engine, UTRACE_EVENT(SYSCALL_ENTRY)|UTRACE_EVENT(DEATH));"; s.op->indent(-1); s.op->newline() << "else if (p->flags == UDPF_SYSCALL_RETURN)"; s.op->indent(1); - s.op->newline() << "utrace_set_flags(tsk, engine, UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH));"; + s.op->newline() << "rc = utrace_set_events(tsk, engine, UTRACE_EVENT(SYSCALL_EXIT)|UTRACE_EVENT(DEATH));"; + s.op->indent(-1); + s.op->newline() << "if (rc != 0)"; + s.op->indent(1); + s.op->newline() << "_stp_error(\"utrace_set_events returned error %d on pid %d\", rc, (int)tsk->pid);"; s.op->indent(-1); - s.op->newline() << "return (UTRACE_ACTION_NEWSTATE | UTRACE_ACTION_RESUME);"; + s.op->newline() << "return UTRACE_RESUME;"; s.op->newline(-1) << "}"; + s.op->newline() << "#ifdef UTRACE_ORIG_VERSION"; s.op->newline() << "static u32 stap_utrace_probe_syscall(struct utrace_attached_engine *engine, struct task_struct *tsk, struct pt_regs *regs) {"; + s.op->newline() << "#else"; + s.op->newline() << "static u32 stap_utrace_probe_syscall(enum utrace_resume_action action, struct utrace_attached_engine *engine, struct task_struct *tsk, struct pt_regs *regs) {"; + s.op->newline() << "#endif"; + s.op->indent(1); s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;"; @@ -6260,7 +6277,7 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) s.op->newline() << "(*p->ph) (c);"; common_probe_entryfn_epilogue (s.op); - s.op->newline() << "return UTRACE_ACTION_RESUME;"; + s.op->newline() << "return UTRACE_RESUME;"; s.op->newline(-1) << "}"; } -- cgit From 46b3c6cd16e7aba1a5a26b310ee128bfdc7897fa Mon Sep 17 00:00:00 2001 From: David Smith Date: Thu, 21 Aug 2008 12:22:35 -0500 Subject: Added task finder target parameter to vm_callback functions. 2008-08-21 David Smith * tapsets.cxx (itrace_derived_probe_group::emit_module_decls): Updated task finder callback function signature. (utrace_derived_probe_group::emit_module_decls): Ditto. 2008-08-21 David Smith * task_finder.c (__stp_tf_vm_cb): Added task finder target parameter. (__stp_utrace_attach_match_filename): Updated task finder callback call. (__stp_utrace_task_finder_target_death): Ditto. (__stp_utrace_task_finder_target_quiesce): Ditto. (__stp_target_call_vm_callback): Ditto. (__stp_utrace_task_finder_target_syscall_exit): Ditto. (stap_start_task_finder): Ditto. --- tapsets.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index d2e5bdba..ce8862cf 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5684,7 +5684,7 @@ itrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output task finder callback routine that gets called for all // itrace probe types. - s.op->newline() << "static int _stp_itrace_probe_cb(struct task_struct *tsk, int register_p, int process_p, struct stap_task_finder_target *tgt) {"; + s.op->newline() << "static int _stp_itrace_probe_cb(struct stap_task_finder_target *tgt, struct task_struct *tsk, int register_p, int process_p) {"; s.op->indent(1); s.op->newline() << "int rc = 0;"; s.op->newline() << "struct stap_itrace_probe *p = container_of(tgt, struct stap_itrace_probe, tgt);"; @@ -6283,7 +6283,7 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) // Output task_finder callback routine that gets called for all // utrace probe types. - s.op->newline() << "static int _stp_utrace_probe_cb(struct task_struct *tsk, int register_p, int process_p, struct stap_task_finder_target *tgt) {"; + s.op->newline() << "static int _stp_utrace_probe_cb(struct stap_task_finder_target *tgt, struct task_struct *tsk, int register_p, int process_p) {"; s.op->indent(1); s.op->newline() << "int rc = 0;"; s.op->newline() << "struct stap_utrace_probe *p = container_of(tgt, struct stap_utrace_probe, tgt);"; -- cgit