Bug 6445 - extend utrace probes with "system-wide" and target-process syntax
Summary: extend utrace probes with "system-wide" and target-process syntax
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: David Smith
URL:
Keywords:
: 5898 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-04-22 12:01 UTC by Frank Ch. Eigler
Modified: 2008-09-30 19:22 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Ch. Eigler 2008-04-22 12:01:28 UTC
We now have some process(PID).* and process("NAME").* probes.  This could be
extended to join the existing "stap -c CMD" / "stap -x PID" process targeting
facility:

* extend the task-finder logic to restrict its scanning of tasks to the
  staprun-given target-pid (and its descendants) only
* permit process.* utrace probes (i.e., not parametrized with "NAME" or PID,
  implicitly referring to the target-pid (and its descendants)

The "and its descendants" qualifier may need to be an option rather than
be hard-coded.
Comment 1 Frank Ch. Eigler 2008-04-30 21:12:55 UTC
*** Bug 5898 has been marked as a duplicate of this bug. ***
Comment 2 Frank Ch. Eigler 2008-07-19 18:23:41 UTC
In addition,

  probe process("*").{begin,syscall,...} 

should constitute utrace-based probes on all processes systemwide.
Comment 3 Frank Ch. Eigler 2008-07-30 15:20:45 UTC
For purposes of this, it would be sufficient to have two
extensions:

- process("*") syntax
  that maps to the task_finder's unrestricted pathname/pid

- target-process syntax
  that maps to another task_finder option that restricts its
  monitoring to the target() (stap -c/-x) hierarchy

Maybe these two could be the same -- i.e., if someone runs "stap -c/-x",
then process("*").foo (or simpler, process.foo) probes would automagically
be restricted to the target process hierarchy.

Finally, bug #6456 could be a followup to support finer-grained
wildcards as in process("/bin/*").
Comment 4 David Smith 2008-08-12 15:21:07 UTC
Commit 6cdf288 implements system-wide utrace probes.
Comment 5 Mark Wielaard 2008-08-20 12:23:17 UTC
For reference this is what I was using so that you can do something simple like
: stap -e 'probe timer.ms(50) {t = tid(); if (t != 0) { printf("%s:%d.%d 0x%xd
%s\n", execname(), pid(), tid(), uaddr(), umap_name(uaddr())); } }' to see where
 exe/library the system is busy in.

# Returns the address in userspace that the current task was at when the
# probe occured.
function uaddr:long () %{ /* pure */
        #include <asm/processor.h>
        struct pt_regs *uregs;
        uregs = task_pt_regs(current);

        THIS->__retvalue = (int64_t) REG_IP(uregs);
%}

# Returns the name of the map in userspace of the give address in the
# current task. XXX - figure out locking issues.
function umap_name:string(uaddr:long) %{ /* pure */
        #include <linux/mm.h>
        #include <linux/dcache.h>
        struct mm_struct *mm;
        struct vm_area_struct *vma;
        char *buf = NULL;
        mm = get_task_mm (current);
        if (mm)
          {
            vma = mm->mmap;
            while (vma && (uint64_t) vma->vm_start < (uint64_t) THIS->uaddr)
              vma = vma->vm_next;
            if (vma && vma->vm_file)
              {
                buf = _stp_kmalloc(PATH_MAX);
                buf = d_path (&(vma->vm_file->f_path), buf, PATH_MAX);
              }
          }
        if (buf)
          strlcpy(THIS->__retvalue, buf, MAXSTRINGLEN);
        else
          strlcpy(THIS->__retvalue, "<unknown>", MAXSTRINGLEN);
%}
Comment 6 Mark Wielaard 2008-08-20 12:40:11 UTC
(In reply to comment #5)
> For reference [...]

Ignore that. I added this to the wrong bug. It was in reference to bug #5951
comment #3. Sorry for the bugzilla spam.
Comment 7 Frank Ch. Eigler 2008-09-06 14:25:59 UTC
I believe commit cec7293 puts the finishing touches on this;
could you please review?
Comment 8 David Smith 2008-09-16 19:32:45 UTC
(In reply to comment #7)
> I believe commit cec7293 puts the finishing touches on this;
> could you please review?

The task_finder.c changes look reasonable, but this new code doesn't work for
me.  When I run "stap -c /bin/ls ...", _stp_target is 0.
Comment 9 David Smith 2008-09-30 19:22:36 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > I believe commit cec7293 puts the finishing touches on this;
> > could you please review?
> 
> The task_finder.c changes look reasonable, but this new code doesn't work for
> me.  When I run "stap -c /bin/ls ...", _stp_target is 0.

This works for me now.  I'm not sure what the problem was earlier.