Ejemplo n.º 1
0
static void
stapkp_unregister_probe(struct stap_dwarf_probe *sdp)
{
   struct stap_dwarf_kprobe *sdk = sdp->kprobe;

   if (!sdp->registered_p)
      return;

   if (sdp->return_p) {
      unregister_kretprobe (&sdk->u.krp);
      dbug_stapkp("-kretprobe %p\n", sdk->u.krp.kp.addr);
   } else {
      unregister_kprobe (&sdk->u.kp);
      dbug_stapkp("-kprobe %p\n", sdk->u.kp.addr);
   }

#if defined(__ia64__)
   unregister_kprobe (&sdk->dummy);
   dbug_stapkp("-kprobe %p\n", sdk->dummy.addr);
#endif

   sdp->registered_p = 0;

   stapkp_add_missed(sdp);

   // PR16861: kprobes may have left some things in the k[ret]probe struct.
   // Let's reset it to be sure it's safe for re-use.
   memset(sdk, 0, sizeof(struct stap_dwarf_kprobe));
}
Ejemplo n.º 2
0
static void
stapkp_batch_unregister_probes(struct stap_kprobe_probe *probes,
                               size_t nprobes)
{
    size_t i, n;

    n = stapkp_collect_registered_probes(probes,
                                         nprobes, COLLECT_KPROBES);
    unregister_kprobes((struct kprobe **)stap_unreg_kprobes, n);
    dbug_stapkp_cond(n > 0, "-kprobe * %zd\n", n);

    n = stapkp_collect_registered_probes(probes,
                                         nprobes, COLLECT_KRETPROBES);
    unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes, n);
    dbug_stapkp_cond(n > 0, "-kretprobe * %zd\n", n);

#ifdef __ia64__
    n = stapkp_collect_registered_probes(probes,
                                         nprobes, COLLECT_DUMMYS);
    unregister_kprobes((struct kprobe **)stap_unreg_kprobes, n);
    dbug_stapkp_cond(n > 0, "-kprobe * %zd\n", n);
#endif

    // Now for all of those we just unregistered, we need to update registered_p
    // and account for (and possibly report) missed hits.
    for (i = 0; i < nprobes; i++) {

        struct stap_kprobe_probe *skp = &probes[i];

        if (!skp->registered_p)
            continue;

        skp->registered_p = 0;

        stapkp_add_missed(skp);

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
        if (skp->symbol_name != NULL) {
            if (skp->return_p) {
                if (skp->kprobe->u.krp.kp.symbol_name != NULL)
                    kfree(skp->kprobe->u.krp.kp.symbol_name);
            }
            else {
                if (skp->kprobe->u.kp.symbol_name != NULL)
                    kfree(skp->kprobe->u.kp.symbol_name);
            }
        }
#endif

        // PR16861: kprobes may have left some things in the k[ret]probe struct.
        // Let's reset it to be sure it's safe for re-use.
        memset(skp->kprobe, 0, sizeof(struct stap_kprobe));
    }
}
Ejemplo n.º 3
0
static void
stapkp_unregister_probe(struct stap_kprobe_probe *skp)
{
    struct stap_kprobe *sk = skp->kprobe;

    if (!skp->registered_p)
        return;

    if (skp->return_p) {
        unregister_kretprobe (&sk->u.krp);
        if (skp->symbol_name)
            dbug_stapkp("-kretprobe %s:%d\n", sk->u.krp.kp.symbol_name,
                        sk->u.krp.kp.offset);
        else
            dbug_stapkp("-kretprobe %p\n", sk->u.krp.kp.addr);
    } else {
        unregister_kprobe (&sk->u.kp);
        if (skp->symbol_name)
            dbug_stapkp("-kprobe %s:%u\n", sk->u.kp.symbol_name,
                        sk->u.kp.offset);
        else
            dbug_stapkp("-kprobe %p\n", sk->u.kp.addr);
    }

#if defined(__ia64__)
    unregister_kprobe (&sk->dummy);
    dbug_stapkp("-kprobe %p\n", sk->dummy.addr);
#endif

    skp->registered_p = 0;

    stapkp_add_missed(skp);

#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
    if (skp->symbol_name != NULL) {
        if (skp->return_p) {
            if (sk->u.krp.kp.symbol_name != NULL)
                kfree(sk->u.krp.kp.symbol_name);
        }
        else {
            if (sk->u.kp.symbol_name != NULL)
                kfree(sk->u.kp.symbol_name);
        }
    }
#endif

    // PR16861: kprobes may have left some things in the k[ret]probe struct.
    // Let's reset it to be sure it's safe for re-use.
    memset(sk, 0, sizeof(struct stap_kprobe));
}
Ejemplo n.º 4
0
static void
stapkp_batch_unregister_probes(struct stap_dwarf_probe *probes,
                               size_t nprobes)
{
   size_t i, n;

   n = stapkp_collect_registered_probes(probes,
                                        nprobes, COLLECT_KPROBES);
   unregister_kprobes((struct kprobe **)stap_unreg_kprobes, n);
   dbug_stapkp_cond(n > 0, "-kprobe * %zd\n", n);

   n = stapkp_collect_registered_probes(probes,
                                        nprobes, COLLECT_KRETPROBES);
   unregister_kretprobes((struct kretprobe **)stap_unreg_kprobes, n);
   dbug_stapkp_cond(n > 0, "-kretprobe * %zd\n", n);

#ifdef __ia64__
   n = stapkp_collect_registered_probes(probes,
                                        nprobes, COLLECT_DUMMYS);
   unregister_kprobes((struct kprobe **)stap_unreg_kprobes, n);
   dbug_stapkp_cond(n > 0, "-kprobe * %zd\n", n);
#endif

   // Now for all of those we just unregistered, we need to update registered_p
   // and account for (and possibly report) missed hits.
   for (i = 0; i < nprobes; i++) {

      struct stap_dwarf_probe *sdp = &probes[i];

      if (!sdp->registered_p)
         continue;

      sdp->registered_p = 0;

      stapkp_add_missed(sdp);

      // PR16861: kprobes may have left some things in the k[ret]probe struct.
      // Let's reset it to be sure it's safe for re-use.
      memset(sdp->kprobe, 0, sizeof(struct stap_dwarf_kprobe));
   }
}