Setting values in library tapsets from user tapscript?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting values in library tapsets from user tapscript?

Craig Ringer
Hi folks

Related to my earlier post, is there any way to supply macro values to
referenced tapsets?

Say I need to define @EXECPATH in "myexec.stp" so I can use @var and
@cast etc for references to the executable that "myexec.stp" targets.

Is there any way to do that from the main user tapscript, or the commandline?

Library tapsets don't seem to see @define'd macros from user
tapscripts, which is sensible. But I didn't find a way to define them
on the commandline either; -D macros don't appear to be visible to the
tapscripts, just the generated C code.

Using -G doesn't help since you can't write @var("sym@CU",$someglobal)

I'm struggling to find any way to create a tapset that can probe
globals in postgres :( and I just cannot understand why it's this hard
in a tool that's so smooth and simple in most ways.



--
 Craig Ringer                   http://www.2ndQuadrant.com/
 2ndQuadrant - PostgreSQL Solutions for the Enterprise
Reply | Threaded
Open this post in threaded view
|

Re: Setting values in library tapsets from user tapscript?

Frank Ch. Eigler

craig wrote:

> Related to my earlier post, is there any way to supply macro values to
> referenced tapsets?  [...]

Yeah, indirectly.  You correctly surmise that you're stuck with macros
and/or command line parameters to do this kind of thing, because for the
purpose you need them, they need to be compile-time literals (instead of
variables).  So, this works:

- create a new  foo.stpm  file in a new directory /zoo
- add into it:
   @define foo %( @1 %)
  or
   @define foo %( "/some/literal" %)
- create your probe.stp file that uses this macro:
- add into it:
   probe process(@foo "/bar").function("*"){}
- note the @foo reference
- run stap thusly:

   % stap -I/zoo probe.stp "/path/prefix"   # in the @1 case
or % stap -I/zoo probe.stp                  # in the hardcoded case

and bob is your uncle.  This works because "*.stpm" files located
in -any- tapset directory are parsed early and macro definitions
inside them is accessible to other files.


- FChE

Reply | Threaded
Open this post in threaded view
|

Re: Setting values in library tapsets from user tapscript?

Craig Ringer
On Thu, 31 Oct 2019 at 06:34, Frank Ch. Eigler <[hidden email]> wrote:

>
> craig wrote:
>
> > Related to my earlier post, is there any way to supply macro values to
> > referenced tapsets?  [...]
>
> Yeah, indirectly. [...]



- create a new  foo.stpm  file in a new directory /zoo
>
>
Apologies for the late reply. That did the trick. The Makefile for the
relevant programs now generates a templated .stpm that defines appropriate
macros. Then a regular tapset uses those macros in a probe alias. So the
tapscripts using the tapset don't have to care. The invoker supplies the
correct include path and it works.

It'd be good to be able to resolve @var etc against userspace modules as
discussed before, but it can be worked around this way at least.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 2ndQuadrant - PostgreSQL Solutions for the Enterprise