public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* Setting values in library tapsets from user tapscript?
@ 2019-10-28  7:41 Craig Ringer
  2019-10-30 22:34 ` Frank Ch. Eigler
  0 siblings, 1 reply; 3+ messages in thread
From: Craig Ringer @ 2019-10-28  7:41 UTC (permalink / raw)
  To: systemtap

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting values in library tapsets from user tapscript?
  2019-10-28  7:41 Setting values in library tapsets from user tapscript? Craig Ringer
@ 2019-10-30 22:34 ` Frank Ch. Eigler
  2020-01-13  6:42   ` Craig Ringer
  0 siblings, 1 reply; 3+ messages in thread
From: Frank Ch. Eigler @ 2019-10-30 22:34 UTC (permalink / raw)
  To: Craig Ringer; +Cc: systemtap


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Setting values in library tapsets from user tapscript?
  2019-10-30 22:34 ` Frank Ch. Eigler
@ 2020-01-13  6:42   ` Craig Ringer
  0 siblings, 0 replies; 3+ messages in thread
From: Craig Ringer @ 2020-01-13  6:42 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: systemtap

On Thu, 31 Oct 2019 at 06:34, Frank Ch. Eigler <fche@redhat.com> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-13  6:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28  7:41 Setting values in library tapsets from user tapscript? Craig Ringer
2019-10-30 22:34 ` Frank Ch. Eigler
2020-01-13  6:42   ` Craig Ringer

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).