yichun

Untitled

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