Advertisement
yichun

Untitled

Dec 20th, 2019
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 22.12 KB | None | 0 0
  1. diff --git a/NEWS b/NEWS
  2. index 303a1075e..c927c0f69 100644
  3. --- a/NEWS
  4. +++ b/NEWS
  5. @@ -2,6 +2,9 @@
  6.  
  7.  * What's new in version 4.2, 2019-11-18
  8.  
  9. +- The process(EXE).begin probe handlers are now always triggered for
  10. +  already-running target processes.
  11. +
  12.  - Initial support for multi-dimensional supports has been added to
  13.    the stapbpf backend. Note that these arrays cannot be iterated upon
  14.    with a foreach loop.
  15. diff --git a/runtime/linux/debug.h b/runtime/linux/debug.h
  16. index e23ee96e7..dbe1d4397 100644
  17. --- a/runtime/linux/debug.h
  18. +++ b/runtime/linux/debug.h
  19. @@ -73,6 +73,17 @@
  20.  #define dbug_unwind(level, args...) ;
  21.  #endif
  22.  
  23. +
  24. +#ifdef DEBUG_TASK_FINDER
  25. +#define dbug_task(level, args...) do {                  \
  26. +       if ((level) <= DEBUG_TASK_FINDER)               \
  27. +           _stp_dbug(__FUNCTION__, __LINE__, args);    \
  28. +   } while (0)
  29. +#else
  30. +#define dbug_task(level, args...) ;
  31. +#endif
  32. +
  33. +
  34.  #if defined(DEBUG_TASK_FINDER_VMA)
  35.  #define dbug_task_vma(level, args...) do {                                     \
  36.                 if ((level) <= DEBUG_TASK_FINDER_VMA)                               \
  37. diff --git a/runtime/linux/task_finder2.c b/runtime/linux/task_finder2.c
  38. index 6f5d637da..9297c2b02 100644
  39. --- a/runtime/linux/task_finder2.c
  40. +++ b/runtime/linux/task_finder2.c
  41. @@ -35,10 +35,10 @@ static atomic_t __stp_attach_count = ATOMIC_INIT (0);
  42.  
  43.  #define debug_task_finder_attach() (atomic_inc(&__stp_attach_count))
  44.  #define debug_task_finder_detach() (atomic_dec(&__stp_attach_count))
  45. -#define debug_task_finder_report()                 \
  46. -    (printk(KERN_ERR "%s:%d - attach count: %d, inuse count: %d\n",    \
  47. -       __FUNCTION__, __LINE__, atomic_read(&__stp_attach_count),   \
  48. -       atomic_read(&__stp_inuse_count)))
  49. +#define debug_task_finder_report()                      \
  50. +    dbug_task(1, "attach count: %d, inuse count: %d\n",    \
  51. +       atomic_read(&__stp_attach_count),           \
  52. +       atomic_read(&__stp_inuse_count))
  53.  #else
  54.  #define debug_task_finder_attach() /* empty */
  55.  #define debug_task_finder_detach() /* empty */
  56. @@ -532,6 +532,7 @@ __stp_utrace_attach(struct task_struct *tsk,
  57.     }
  58.     else {
  59.         rc = utrace_set_events(tsk, engine, event_flags);
  60. +       dbug_task(2, "utrace_set_events returned %d", rc);
  61.         if (rc == -EINPROGRESS) {
  62.             /*
  63.              * It's running our callback, so we have to
  64. @@ -553,6 +554,7 @@ __stp_utrace_attach(struct task_struct *tsk,
  65.  
  66.             if (action != UTRACE_RESUME) {
  67.                 rc = utrace_control(tsk, engine, action);
  68. +               dbug_task(2, "utrace_control returned %d", rc);
  69.                 /* If utrace_control() returns
  70.                  * EINPROGRESS when we're trying to
  71.                  * stop/interrupt, that means the task
  72. @@ -588,6 +590,8 @@ __stp_call_callbacks(struct stap_task_finder_target *tgt,
  73.     struct list_head *cb_node;
  74.     int rc;
  75.  
  76. +   dbug_task(2, "entering tgt=%p tsk=%p pid=%d", tgt, tsk, tsk ? tsk->tgid : -1);
  77. +
  78.     if (tgt == NULL || tsk == NULL)
  79.         return;
  80.  
  81. @@ -599,7 +603,16 @@ __stp_call_callbacks(struct stap_task_finder_target *tgt,
  82.         if (cb_tgt == NULL || cb_tgt->callback == NULL)
  83.             continue;
  84.  
  85. +       dbug_task(2, "calling %s callback %p (proc=%s pid=%d, pathlen=%d, "
  86. +             "engine-attached=%d)",
  87. +             (cb_tgt->purpose?:""), cb_tgt->callback, cb_tgt->procname,
  88. +              cb_tgt->pid,
  89. +             (int) cb_tgt->pathlen, cb_tgt->engine_attached);
  90. +
  91.         rc = cb_tgt->callback(cb_tgt, tsk, register_p, process_p);
  92. +
  93. +       dbug_task(2, "tgt callback returned %d", rc);
  94. +
  95.         if (rc != 0) {
  96.             _stp_warn("task_finder %s%scallback for task %d failed: %d",
  97.                                    (cb_tgt->purpose?:""), (cb_tgt->purpose?" ":""),
  98. @@ -835,7 +848,11 @@ __stp_utrace_attach_match_filename(struct task_struct *tsk,
  99.         else if (tgt->pathlen > 0
  100.              && (tgt->pathlen != filelen
  101.                  || strcmp(tgt->procname, filename) != 0))
  102. +       {
  103. +           dbug_task(2, "target path NOT matched: [%s] != [%s]",
  104. +                     tgt->procname, filename);
  105.             continue;
  106. +       }
  107.         /* Ignore pid-based target, they were handled at startup. */
  108.         else if (tgt->pid != 0)
  109.             continue;
  110. @@ -1660,6 +1677,10 @@ stap_start_task_finder(void)
  111.         rc = __stp_utrace_attach(tsk, &__stp_utrace_task_finder_ops, 0,
  112.                      __STP_TASK_FINDER_EVENTS,
  113.                      UTRACE_RESUME);
  114. +
  115. +       dbug_task(2, "__stp_utrace_attach() for pid %d returned %d",
  116. +                 tsk->tgid, rc);
  117. +
  118.         if (rc == EPERM) {
  119.             /* Ignore EPERM errors, which mean this wasn't
  120.              * a thread we can attach to. */
  121. @@ -1724,7 +1745,11 @@ stap_start_task_finder(void)
  122.             else if (tgt->pathlen > 0
  123.                  && (tgt->pathlen != mmpathlen
  124.                      || strcmp(tgt->procname, mmpath) != 0))
  125. +           {
  126. +               dbug_task(2, "target path not matched: [%s] != [%s]",
  127. +                     tgt->procname, mmpath);
  128.                 continue;
  129. +           }
  130.             /* pid-based target */
  131.             else if (tgt->pid != 0 && tgt->pid != tsk->pid)
  132.                 continue;
  133. @@ -1747,6 +1772,10 @@ stap_start_task_finder(void)
  134.             rc = __stp_utrace_attach(tsk, &tgt->ops, tgt,
  135.                          __STP_ATTACHED_TASK_EVENTS,
  136.                          UTRACE_STOP);
  137. +
  138. +           dbug_task(2, "__stp_utrace_attach() for %d returned %d", tsk->tgid,
  139. +                 rc);
  140. +
  141.             if (rc != 0 && rc != EPERM)
  142.                 goto stf_err;
  143.             rc = 0;     /* ignore EPERM */
  144. @@ -1771,18 +1800,13 @@ stap_task_finder_post_init(void)
  145.         return;
  146.     }
  147.  
  148. -#ifdef DEBUG_TASK_FINDER
  149. -   printk(KERN_ERR "%s:%d - entry.\n", __FUNCTION__, __LINE__);
  150. -#endif
  151. +   dbug_task(2, "entry.");
  152.     rcu_read_lock();
  153.     do_each_thread(grp, tsk) {
  154.         struct list_head *tgt_node;
  155.  
  156.         if (atomic_read(&__stp_task_finder_state) != __STP_TF_RUNNING) {
  157. -#ifdef DEBUG_TASK_FINDER
  158. -           printk(KERN_ERR "%s:%d - exiting early...\n",
  159. -                  __FUNCTION__, __LINE__);
  160. -#endif
  161. +           dbug_task(2, "exiting early...");
  162.             break;
  163.         }
  164.  
  165. @@ -1824,6 +1848,10 @@ stap_task_finder_post_init(void)
  166.                     _stp_error("utrace_control returned error %d on pid %d",
  167.                            rc, (int)tsk->pid);
  168.                 }
  169. +
  170. +               dbug_task(2, "utrace_control(UTRACE_INTERRUPT) for pid %d "
  171. +                     "returned %d (%d)", tsk->pid, rc, -EINPROGRESS);
  172. +
  173.                 utrace_engine_put(engine);
  174.  
  175.                 /* Since we only need to interrupt
  176. @@ -1835,9 +1863,7 @@ stap_task_finder_post_init(void)
  177.     } while_each_thread(grp, tsk);
  178.     rcu_read_unlock();
  179.     atomic_set(&__stp_task_finder_complete, 1);
  180. -#ifdef DEBUG_TASK_FINDER
  181. -   printk(KERN_ERR "%s:%d - exit.\n", __FUNCTION__, __LINE__);
  182. -#endif
  183. +   dbug_task(2, "exit.");
  184.     return;
  185.  }
  186.  
  187. diff --git a/tapset-been.cxx b/tapset-been.cxx
  188. index 61b3b18a3..1107d3e76 100644
  189. --- a/tapset-been.cxx
  190. +++ b/tapset-been.cxx
  191. @@ -149,7 +149,7 @@ be_derived_probe_group::emit_module_decls (systemtap_session& s)
  192.  
  193.    s.op->newline() << "static void enter_be_probe (struct stap_be_probe *stp) {";
  194.    s.op->indent(1);
  195. -  common_probe_entryfn_prologue (s, "stp->state", "stp->probe",
  196. +  common_probe_entryfn_prologue (s, "stp->state", "", "stp->probe",
  197.                  "stp_probe_type_been", false);
  198.    s.op->newline() << "(*stp->probe->ph) (c);";
  199.    common_probe_entryfn_epilogue (s, false, otf_safe_context(s));
  200. diff --git a/tapset-itrace.cxx b/tapset-itrace.cxx
  201. index 4682e7674..0a262076c 100644
  202. --- a/tapset-itrace.cxx
  203. +++ b/tapset-itrace.cxx
  204. @@ -199,7 +199,7 @@ itrace_derived_probe_group::emit_module_decls (systemtap_session& s)
  205.    s.op->newline() << "static void enter_itrace_probe(struct stap_itrace_probe *p, struct pt_regs *regs, void *data) {";
  206.    s.op->indent(1);
  207.  
  208. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "p->probe",
  209. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "p->probe",
  210.                  "stp_probe_type_itrace");
  211.    s.op->newline() << "c->uregs = regs;";
  212.    s.op->newline() << "c->user_mode_p = 1;";
  213. diff --git a/tapset-mark.cxx b/tapset-mark.cxx
  214. index 2dec501c8..5a48eaa76 100644
  215. --- a/tapset-mark.cxx
  216. +++ b/tapset-mark.cxx
  217. @@ -509,7 +509,7 @@ mark_derived_probe_group::emit_module_decls (systemtap_session& s)
  218.    s.op->newline();
  219.    s.op->newline() << "static void enter_marker_probe (void *probe_data, void *call_data, const char *fmt, va_list *args) {";
  220.    s.op->newline(1) << "struct stap_marker_probe *smp = (struct stap_marker_probe *)probe_data;";
  221. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "smp->probe",
  222. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "smp->probe",
  223.                  "stp_probe_type_marker");
  224.    s.op->newline() << "c->ips.kmark.marker_name = smp->name;";
  225.    s.op->newline() << "c->ips.kmark.marker_format = smp->format;";
  226. diff --git a/tapset-netfilter.cxx b/tapset-netfilter.cxx
  227. index 1c6952e1f..a6ae5909d 100644
  228. --- a/tapset-netfilter.cxx
  229. +++ b/tapset-netfilter.cxx
  230. @@ -313,7 +313,7 @@ netfilter_derived_probe_group::emit_module_decls (systemtap_session& s)
  231.        s.op->newline() << "#elif defined(STAPCONF_NETFILTER_V41)";
  232.        s.op->newline() << "int (*nf_okfn)(struct sock *, struct sk_buff *) = nf_state->okfn;";
  233.        s.op->newline() << "#endif";
  234. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp",
  235. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "stp",
  236.                                       "stp_probe_type_netfilter",
  237.                                       false);
  238.  
  239. diff --git a/tapset-perfmon.cxx b/tapset-perfmon.cxx
  240. index 11dbbd32b..2b9f5ad42 100644
  241. --- a/tapset-perfmon.cxx
  242. +++ b/tapset-perfmon.cxx
  243. @@ -235,7 +235,7 @@ perf_derived_probe_group::emit_module_decls (systemtap_session& s)
  244.    s.op->newline() << "static void handle_perf_probe (unsigned i, struct pt_regs *regs)";
  245.    s.op->newline() << "{";
  246.    s.op->newline(1) << "struct stap_perf_probe* stp = & stap_perf_probes [i];";
  247. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe",
  248. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "stp->probe",
  249.                  "stp_probe_type_perf");
  250.    s.op->newline() << "if (user_mode(regs)) {";
  251.    s.op->newline(1)<< "c->user_mode_p = 1;";
  252. diff --git a/tapset-procfs.cxx b/tapset-procfs.cxx
  253. index c39f20fcb..c5087afcb 100644
  254. --- a/tapset-procfs.cxx
  255. +++ b/tapset-procfs.cxx
  256. @@ -366,7 +366,7 @@ procfs_derived_probe_group::emit_module_decls (systemtap_session& s)
  257.      {
  258.        s.op->newline() << "struct _stp_procfs_data pdata;";
  259.  
  260. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING",
  261. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "",
  262.                      "spp->read_probe",
  263.                      "stp_probe_type_procfs");
  264.  
  265. @@ -412,7 +412,7 @@ procfs_derived_probe_group::emit_module_decls (systemtap_session& s)
  266.      {
  267.        s.op->newline() << "struct _stp_procfs_data pdata;";
  268.  
  269. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING",
  270. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "",
  271.                      "spp->write_probes[0]",
  272.                      "stp_probe_type_procfs");
  273.  
  274. diff --git a/tapset-timers.cxx b/tapset-timers.cxx
  275. index 8dd00a1b9..4949b6e14 100644
  276. --- a/tapset-timers.cxx
  277. +++ b/tapset-timers.cxx
  278. @@ -136,7 +136,7 @@ timer_derived_probe_group::emit_module_decls (systemtap_session& s)
  279.    s.op->line() << ");";
  280.    s.op->newline(-1) << "{";
  281.    s.op->indent(1);
  282. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe",
  283. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "stp->probe",
  284.                  "stp_probe_type_timer");
  285.    s.op->newline() << "(*stp->probe->ph) (c);";
  286.    common_probe_entryfn_epilogue (s, true, otf_safe_context(s));
  287. @@ -293,7 +293,7 @@ hrtimer_derived_probe_group::emit_module_decls (systemtap_session& s)
  288.  
  289.        s.op->newline() << "{";
  290.        s.op->indent(1);
  291. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe",
  292. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "stp->probe",
  293.                      "stp_probe_type_hrtimer");
  294.        s.op->newline() << "(*stp->probe->ph) (c);";
  295.        common_probe_entryfn_epilogue (s, true, otf_safe_context(s));
  296. @@ -315,7 +315,8 @@ hrtimer_derived_probe_group::emit_module_decls (systemtap_session& s)
  297.  
  298.        s.op->newline() << "{";
  299.        s.op->indent(1);
  300. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "stp->probe",
  301. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "",
  302. +                                     "stp->probe",
  303.                      "stp_probe_type_hrtimer");
  304.        s.op->newline() << "(*stp->probe->ph) (c);";
  305.        common_probe_entryfn_epilogue (s, true, otf_safe_context(s));
  306. @@ -483,7 +484,7 @@ profile_derived_probe_group::emit_module_decls (systemtap_session& s)
  307.    s.op->newline() << "static void enter_all_profile_probes (struct pt_regs *regs) {";
  308.    s.op->newline(1) << "const struct stap_probe * probe = "
  309.                     << common_probe_init (probes[0]) << ";";
  310. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "probe",
  311. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "probe",
  312.                  "stp_probe_type_profile_timer");
  313.    // Timer interrupts save all registers, so if the interrupt happened
  314.    // in user space we can rely on it being the full user pt_regs.
  315. diff --git a/tapset-utrace.cxx b/tapset-utrace.cxx
  316. index 2b644843a..f85607398 100644
  317. --- a/tapset-utrace.cxx
  318. +++ b/tapset-utrace.cxx
  319. @@ -862,10 +862,13 @@ utrace_derived_probe_group::emit_module_linux_decls (systemtap_session& s)
  320.        s.op->newline() << "static void stap_utrace_probe_handler(struct task_struct *tsk, struct stap_utrace_probe *p) {";
  321.        s.op->indent(1);
  322.  
  323. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "p->probe",
  324. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING",
  325. +                                     "STAP_SESSION_STARTING",
  326. +                                     "p->probe",
  327.                      "stp_probe_type_utrace");
  328.  
  329.        // call probe function
  330. +      s.op->newline() << "dbug_task(2, \"calling UDPF probe function\");";
  331.        s.op->newline() << "(*p->probe->ph) (c);";
  332.        common_probe_entryfn_epilogue (s, true, otf_safe_context(s));
  333.  
  334. @@ -889,7 +892,7 @@ utrace_derived_probe_group::emit_module_linux_decls (systemtap_session& s)
  335.        s.op->indent(1);
  336.        s.op->newline() << "struct stap_utrace_probe *p = (struct stap_utrace_probe *)engine->data;";
  337.  
  338. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "p->probe",
  339. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "p->probe",
  340.                      "stp_probe_type_utrace_syscall");
  341.        s.op->newline() << "c->uregs = regs;";
  342.        s.op->newline() << "c->user_mode_p = 1;";
  343. @@ -914,6 +917,10 @@ utrace_derived_probe_group::emit_module_linux_decls (systemtap_session& s)
  344.    s.op->newline() << "int rc = 0;";
  345.    s.op->newline() << "struct stap_utrace_probe *p = container_of(tgt, struct stap_utrace_probe, tgt);";
  346.    s.op->newline() << "struct utrace_engine *engine;";
  347. +  s.op->newline() << "dbug_task(2, \"utrace probe cb: register_p=%d "
  348. +    "process_p=%d, p->flags=%x (begin: %d, thr begin: %d)\", "
  349. +    "register_p, process_p, (unsigned) p->flags, UDPF_BEGIN, "
  350. +    "UDPF_THREAD_BEGIN);";
  351.  
  352.    s.op->newline() << "if (register_p) {";
  353.    s.op->indent(1);
  354. @@ -1176,7 +1183,7 @@ utrace_derived_probe_group::emit_module_dyninst_decls (systemtap_session& s)
  355.                    << "(uint64_t index, struct pt_regs *regs) {";
  356.    s.op->newline(1) << "struct stapdu_probe *sup = &stapdu_probes[index];";
  357.  
  358. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sup->probe",
  359. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sup->probe",
  360.                                   "stp_probe_type_utrace");
  361.    s.op->newline() << "c->uregs = regs ?: &stapdu_dummy_uregs;";
  362.    s.op->newline() << "c->user_mode_p = 1;";
  363. diff --git a/tapsets.cxx b/tapsets.cxx
  364. index b83960a2e..68ec74b43 100644
  365. --- a/tapsets.cxx
  366. +++ b/tapsets.cxx
  367. @@ -91,7 +91,7 @@ common_probe_init (derived_probe* p)
  368.  
  369.  void
  370.  common_probe_entryfn_prologue (systemtap_session& s,
  371. -                  string statestr, string probe,
  372. +                  string statestr, string statestr2, string probe,
  373.                    string probe_type, bool overload_processing,
  374.                    void (*declaration_callback)(systemtap_session& s, void *data),
  375.                    void (*pre_context_callback)(systemtap_session& s, void *data),
  376. @@ -159,9 +159,20 @@ common_probe_entryfn_prologue (systemtap_session& s,
  377.        s.op->newline(-1) << "}";
  378.      }
  379.  
  380. -  s.op->newline() << "if (atomic_read (session_state()) != " << statestr << ")";
  381. -  s.op->newline(1) << "goto probe_epilogue;";
  382. -  s.op->indent(-1);
  383. +  s.op->newline() << "{";
  384. +  s.op->newline(1) << "unsigned sess_state = atomic_read (session_state());";
  385. +  s.op->newline() << "#ifdef DEBUG_PROBES";
  386. +  s.op->newline() << "_stp_dbug(__FUNCTION__, __LINE__, \"session state: %d, "
  387. +    "expecting " << statestr << " (%d)"
  388. +    << (statestr2.empty() ? "" : string(" or ") + statestr2 + " (%d)")
  389. +    << "\", sess_state, " << statestr
  390. +    << (statestr2.empty() ? "" : string(", ") + statestr2)  << ");";
  391. +  s.op->newline() << "#endif";
  392. +  s.op->newline() << "if (sess_state != " << statestr
  393. +    << (statestr2.empty() ? "" : string(" && sess_state != ") + statestr2)
  394. +    << ")";
  395. +  s.op->newline() << "goto probe_epilogue;";
  396. +  s.op->newline(-1) << "}";
  397.  
  398.    if (pre_context_callback)
  399.      {
  400. @@ -6079,7 +6090,7 @@ generic_kprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
  401.    s.op->line() << "kprobe_idx:0)"; // NB: at least we avoid memory corruption
  402.    // XXX: it would be nice to give a more verbose error though; BUG_ON later?
  403.    s.op->line() << "];";
  404. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "skp->probe",
  405. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "skp->probe",
  406.                  "stp_probe_type_kprobe");
  407.    s.op->newline() << "c->kregs = regs;";
  408.  
  409. @@ -6116,7 +6127,7 @@ generic_kprobe_derived_probe_group::emit_module_decls (systemtap_session& s)
  410.    s.op->newline() << "const struct stap_probe *sp = entry ? skp->entry_probe : skp->probe;";
  411.    s.op->newline() << "if (sp) {";
  412.    s.op->indent(1);
  413. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sp",
  414. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sp",
  415.                  "stp_probe_type_kretprobe");
  416.    s.op->newline() << "c->kregs = regs;";
  417.  
  418. @@ -9465,7 +9476,7 @@ uprobe_derived_probe_group::emit_module_utrace_decls (systemtap_session& s)
  419.    s.op->newline() << "static void enter_uprobe_probe (struct uprobe *inst, struct pt_regs *regs) {";
  420.    s.op->newline(1) << "struct stap_uprobe *sup = container_of(inst, struct stap_uprobe, up);";
  421.    s.op->newline() << "const struct stap_uprobe_spec *sups = &stap_uprobe_specs [sup->spec_index];";
  422. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sups->probe",
  423. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sups->probe",
  424.                  "stp_probe_type_uprobe", true,
  425.                  udpg_entryfn_prologue_declaration_callback,
  426.                  udpg_entryfn_prologue_pre_context_callback,
  427. @@ -9500,7 +9511,7 @@ uprobe_derived_probe_group::emit_module_utrace_decls (systemtap_session& s)
  428.    s.op->newline() << "static void enter_uretprobe_probe (struct uretprobe_instance *inst, struct pt_regs *regs) {";
  429.    s.op->newline(1) << "struct stap_uprobe *sup = container_of(inst->rp, struct stap_uprobe, urp);";
  430.    s.op->newline() << "const struct stap_uprobe_spec *sups = &stap_uprobe_specs [sup->spec_index];";
  431. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sups->probe",
  432. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sups->probe",
  433.                  "stp_probe_type_uretprobe", true,
  434.                  udpg_entryfn_prologue_declaration_callback,
  435.                  udpg_entryfn_prologue_pre_context_callback,
  436. @@ -9664,7 +9675,7 @@ uprobe_derived_probe_group::emit_module_inode_decls (systemtap_session& s)
  437.  
  438.    // Since we're sharing the entry function, we have to dynamically choose the probe_type
  439.    string probe_type = "(sup->return_p ? stp_probe_type_uretprobe : stp_probe_type_uprobe)";
  440. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sup->probe",
  441. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sup->probe",
  442.                                   probe_type, true,
  443.                  udpg_entryfn_prologue_declaration_callback,
  444.                  udpg_entryfn_prologue_pre_context_callback,
  445. @@ -9857,7 +9868,7 @@ uprobe_derived_probe_group::emit_module_dyninst_decls (systemtap_session& s)
  446.    // Since we're sharing the entry function, we have to dynamically choose the probe_type
  447.    string probe_type = "((sup->flags & STAPDYN_PROBE_FLAG_RETURN) ?"
  448.                        " stp_probe_type_uretprobe : stp_probe_type_uprobe)";
  449. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "sup->probe",
  450. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "sup->probe",
  451.                                   probe_type);
  452.  
  453.    s.op->newline() << "c->uregs = regs ?: &stapdu_dummy_uregs;";
  454. @@ -10546,7 +10557,7 @@ hwbkpt_derived_probe_group::emit_module_decls (systemtap_session& s)
  455.    // XXX: why not match stap_hwbkpt_ret_array[i] against bp instead?
  456.    s.op->newline() << "if (bp->attr.bp_addr==hp->bp_addr && bp->attr.bp_type==hp->bp_type && bp->attr.bp_len==hp->bp_len) {";
  457.    s.op->newline(1) << "struct stap_hwbkpt_probe *skp = &stap_hwbkpt_probes[i];";
  458. -  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "skp->probe",
  459. +  common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "skp->probe",
  460.                  "stp_probe_type_hwbkpt");
  461.    s.op->newline() << "if (user_mode(regs)) {";
  462.    s.op->newline(1)<< "c->user_mode_p = 1;";
  463. @@ -11866,7 +11877,7 @@ tracepoint_derived_probe_group::emit_module_decls (systemtap_session& s)
  464.        s.op->newline() << "{";
  465.        s.op->newline(1) << "const struct stap_probe * const probe = "
  466.                         << common_probe_init (p) << ";";
  467. -      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "probe",
  468. +      common_probe_entryfn_prologue (s, "STAP_SESSION_RUNNING", "", "probe",
  469.                      "stp_probe_type_tracepoint");
  470.        s.op->newline() << "c->ips.tp.tracepoint_system = "
  471.                        << lex_cast_qstring (p->tracepoint_system)
  472. diff --git a/tapsets.h b/tapsets.h
  473. index b52c35c21..2a11ebd6f 100644
  474. --- a/tapsets.h
  475. +++ b/tapsets.h
  476. @@ -21,6 +21,7 @@ void register_standard_tapsets(systemtap_session& sess);
  477.  std::vector<derived_probe_group*> all_session_groups(systemtap_session& s);
  478.  std::string common_probe_init (derived_probe* p);
  479.  void common_probe_entryfn_prologue (systemtap_session& s, std::string statestr,
  480. +                                    std::string statestr2,
  481.                     std::string probe, std::string probe_type,
  482.                     bool overload_processing = true,
  483.                     void (*declaration_callback)(systemtap_session& s, void* data) = NULL,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement