From a21d81ec8b00571cb5987fe04ce74a3fe873351c Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 23 Jun 2008 12:41:45 -0500 Subject: Major update to memory map change notification code. 2008-06-23 David Smith * tapsets.cxx (utrace_derived_probe_group::emit_probe_decl): Handles UDPF_NONE value. (utrace_derived_probe_group::emit_vm_callback_probe_decl): New function. (utrace_derived_probe_group::emit_module_decls): Calls emit_vm_callback_probe_decl() to set up vm_callbacks. 2008-06-23 David Smith * task_finder.c (__stp_tf_vm_cb): New function. (stap_register_task_finder_target): Sets up syscall entry and syscall exit handlers. (__stp_find_file_based_vma): New function. (__stp_utrace_task_finder_target_syscall_entry): New function. Saves vma information off at syscall entry. (__stp_target_call_vm_callback): New function. (__stp_utrace_task_finder_target_syscall_exit): New function. Handles changes to memory maps based on information saved at syscall entry. * syscall.h: New file containing syscall function. * task_finder_vma.c: New file containing saved vma information handling functions. --- tapsets.cxx | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'tapsets.cxx') diff --git a/tapsets.cxx b/tapsets.cxx index 3f9291f2..5b66d186 100644 --- a/tapsets.cxx +++ b/tapsets.cxx @@ -5225,6 +5225,9 @@ private: bool flags_seen[UDPF_NFLAGS]; void emit_probe_decl (systemtap_session& s, utrace_derived_probe *p); + void emit_vm_callback_probe_decl (systemtap_session& s, bool has_path, + string path, int64_t pid, + string vm_callback); public: utrace_derived_probe_group(): num_probes(0), flags_seen() { } @@ -5484,6 +5487,11 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, 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)),"; break; + case UDPF_NONE: + s.op->line() << " .flags=(UDPF_NONE),"; + s.op->line() << " .ops={ },"; + s.op->line() << " .events=0,"; + break; default: throw semantic_error ("bad utrace probe flag"); break; @@ -5493,6 +5501,40 @@ utrace_derived_probe_group::emit_probe_decl (systemtap_session& s, } +void +utrace_derived_probe_group::emit_vm_callback_probe_decl (systemtap_session& s, + bool has_path, + string path, + int64_t pid, + string vm_callback) +{ + s.op->newline() << "{"; + s.op->line() << " .tgt={"; + + if (has_path) + { + s.op->line() << " .pathname=\"" << path << "\","; + s.op->line() << " .pid=0,"; + } + else + { + s.op->line() << " .pathname=NULL,"; + s.op->line() << " .pid=" << pid << ","; + } + + s.op->line() << " .callback=NULL,"; + s.op->line() << " .vm_callback=&" << vm_callback << ","; + s.op->line() << " },"; + s.op->line() << " .pp=\"internal\","; + s.op->line() << " .ph=NULL,"; + s.op->line() << " .flags=(UDPF_NONE),"; + s.op->line() << " .ops={ NULL },"; + s.op->line() << " .events=0,"; + s.op->line() << " .engine_attached=0,"; + s.op->line() << " },"; +} + + void utrace_derived_probe_group::emit_module_decls (systemtap_session& s) { @@ -5737,6 +5779,14 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) for (p_b_path_iterator it = probes_by_path.begin(); it != probes_by_path.end(); it++) { + // Emit a "fake" probe decl that is really a hook for to get + // our vm_callback called. + string path = it->first; + s.op->newline() << "#ifdef DEBUG_TASK_FINDER_VMA"; + emit_vm_callback_probe_decl (s, true, path, (int64_t)0, + "__stp_tf_vm_cb"); + s.op->newline() << "#endif"; + for (unsigned i = 0; i < it->second.size(); i++) { utrace_derived_probe *p = it->second[i]; @@ -5751,6 +5801,13 @@ utrace_derived_probe_group::emit_module_decls (systemtap_session& s) for (p_b_pid_iterator it = probes_by_pid.begin(); it != probes_by_pid.end(); it++) { + // Emit a "fake" probe decl that is really a hook for to get + // our vm_callback called. + s.op->newline() << "#ifdef DEBUG_TASK_FINDER_VMA"; + emit_vm_callback_probe_decl (s, false, NULL, it->first, + "__stp_tf_vm_cb"); + s.op->newline() << "#endif"; + for (unsigned i = 0; i < it->second.size(); i++) { utrace_derived_probe *p = it->second[i]; -- cgit