public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "dsmith at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug translator/20394] New: inconsistency in exe/library paths searching between @cast() and process.library.function probes
Date: Thu, 21 Jul 2016 14:55:00 -0000	[thread overview]
Message-ID: <bug-20394-6586@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=20394

            Bug ID: 20394
           Summary: inconsistency in exe/library paths searching between
                    @cast() and process.library.function probes
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
          Assignee: systemtap at sourceware dot org
          Reporter: dsmith at redhat dot com
  Target Milestone: ---

When writing probes, you can do the following:

====
probe
  process("python").library("libpython2.7.so*").function("PyEval_EvalFrameEx")
{
  # ... probe contents here ...
}
====

Notice that I'm just probing "python" as the "process" argument, a non-absolute
path. The translator will look up "python" in my PATH and find it. Notice I'm
using a wildcarded and non-absolute path for the "library" argument.

The above works fine and is very user friendly.

So, when using @cast(), I'd like to specify the symbol search path the same
way:

====
# cat pytest1.stp
function foo:long(object:long)
{
  printf("%d\n",
         @cast(object, "PyFrameObject", "python:libpython2.7.so*")->f_lineno)
}

probe 
  process("python").library("libpython2.7.so*").function("PyEval_EvalFrameEx")
{
  foo($f)
  exit()
}
# stap -v ./pytest1.stp -c "python -c 'import sys; sys.exit(0)'"
Pass 1: parsed user script and 117 library scripts using
242808virt/39472res/7568shr/32212data kb, in 190usr/30sys/234real ms.
semantic error: while processing function foo

semantic error: type definition 'PyFrameObject' not found in
'python:libpython2.7.so*': operator '@cast' at ./pytest1.stp:4:3
        source:          @cast(object, "PyFrameObject",
"python:libpython2.7.so*")->f_lineno)
                         ^

Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using
250612virt/48776res/8880shr/40016data kb, in 120usr/380sys/498real ms.
Pass 2: analysis failed.  [man error::pass2]
====

So, that didn't work. Let's try without the wildcard:

====
# cat pytest2.stp
function foo:long(object:long)
{
  printf("%d\n",
         @cast(object, "PyFrameObject", "python:libpython2.7.so")->f_lineno)
}

probe 
  process("python").library("libpython2.7.so*").function("PyEval_EvalFrameEx")
{
  foo($f)
  exit()
}
# stap -v ./pytest2.stp -c "python -c 'import sys; sys.exit(0)'"
Pass 1: parsed user script and 117 library scripts using
242808virt/39644res/7740shr/32212data kb, in 200usr/40sys/240real ms.
semantic error: while processing function foo

semantic error: type definition 'PyFrameObject' not found in
'python:libpython2.7.so': operator '@cast' at ./pytest2.stp:4:3
        source:          @cast(object, "PyFrameObject",
"python:libpython2.7.so")->f_lineno)
                         ^

Pass 2: analyzed script: 1 probe, 3 functions, 0 embeds, 0 globals using
250608virt/48792res/8892shr/40012data kb, in 100usr/400sys/511real ms.
Pass 2: analysis failed.  [man error::pass2]
====

OK, on this system /usr/lib64/libpython2.7.so is a symbolic link to
/usr/lib64/libpython2.7.so.1.0. Let's give that a shot:

====
# cat pytest3.stp
function foo:long(object:long)
{
  printf("%d\n",
         @cast(object, "PyFrameObject",
"python:libpython2.7.so.1.0")->f_lineno)
}

probe 
  process("python").library("libpython2.7.so*").function("PyEval_EvalFrameEx")
{
  foo($f)
  exit()
}
# stap -v ./pytest3.stp -c "python -c 'import sys; sys.exit(0)'"
Pass 1: parsed user script and 117 library scripts using
242804virt/39504res/7604shr/32208data kb, in 210usr/30sys/242real ms.
semantic error: while processing function foo

semantic error: type definition 'PyFrameObject' not found in
'python:libpython2.7.so.1.0': operator '@cast' at ./pytest3.stp:4:3
        source:          @cast(object, "PyFrameObject",
"python:libpython2.7.so.1.0")->f_lineno)
                         ^

Pass 2: analyzed script: 1 probe, 1 function, 0 embeds, 0 globals using
250608virt/48804res/8912shr/40012data kb, in 100usr/370sys/492real ms.
Pass 2: analysis failed.  [man error::pass2]
====

Nope.

The only thing I can seem to get to work for @cast() is a full absolute path to
the library. One reason why this is annoying is that to handle both 32-bit
distros and 64-bit distros, I'll have to specify the library in both /usr/lib/
and /usr/lib64:

====
# cat pytest4.stp
function foo:long(object:long)
{
  printf("%d\n",
         @cast(object, "PyFrameObject",
"python:/usr/lib64/libpython2.7.so:/usr/lib/libpython2.7.so")->f_lineno)
}

probe 
  process("python").library("libpython2.7.so*").function("PyEval_EvalFrameEx")
{
  foo($f)
  exit()
}
# stap -v ./pytest4.stp -c "python -c 'import sys; sys.exit(0)'"
Pass 1: parsed user script and 117 library scripts using
242808virt/39712res/7812shr/32212data kb, in 210usr/30sys/238real ms.
Pass 2: analyzed script: 1 probe, 4 functions, 0 embeds, 0 globals using
251388virt/49532res/8828shr/40792data kb, in 120usr/190sys/317real ms.
Pass 3: translated to C into
"/tmp/stapYGfpK4/stap_d4c98f72a2d5b7cef816271d6bd3e397_3084_src.c" using
251388virt/49724res/9020shr/40792data kb, in 20usr/190sys/206real ms.
Pass 4: compiled C into "stap_d4c98f72a2d5b7cef816271d6bd3e397_3084.ko" in
4730usr/1000sys/5459real ms.
Pass 5: starting run.
59
Pass 5: run completed in 30usr/70sys/392real ms.
====

-- 
You are receiving this mail because:
You are the assignee for the bug.

             reply	other threads:[~2016-07-21 14:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-21 14:55 dsmith at redhat dot com [this message]
2016-07-21 15:06 ` [Bug translator/20394] " fche at redhat dot com
2016-07-21 15:50 ` dsmith at redhat dot com
2020-04-24 20:26 ` fche at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-20394-6586@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).