public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* RE: command line arguments
@ 2006-02-23 23:41 Stone, Joshua I
  2006-02-24  1:00 ` Frank Ch. Eigler
  0 siblings, 1 reply; 12+ messages in thread
From: Stone, Joshua I @ 2006-02-23 23:41 UTC (permalink / raw)
  To: Frank Ch. Eigler; +Cc: SystemTap

Frank Ch. Eigler wrote:
> Hi -
> 
> I committed a draft of command line argument support as per bug #1304.
> One part (plain substitution into scripts) is usable now.  Another
> part (initializing globals at module init time) is sort of dormant.
> 
> The way the first part works is by making any additional arguments
> passed to "stap" available to the script for substitution as string
> or number literals:
> 
> # stap -e 'probe kernel.function(@1) { print($2) }' sys_open 4

Very cool!
 
> The @ vs $ distinction encodes whether the numbered argument should be
> pasted as a string or number literal.  I considered guessing but
> heuristics don't seem to belong somewhere so critical.
> 
> I'm open to suggestions about better notation than $n and @n.  (#n is
> out because of comments; % and others because of arithmetic
> operators.) 

It would indeed be nice if $N could be dynamically be typed, especially
since the other $target variables are, but I can see how this would be
hard.

The @ is ok, but it doesn't really say "string" to me.  Perhaps a
single-quote or backquote might be better - '1 or `1?

Another option is to allow expansion of $N within string literals - then
if you want a string you use "$N" and for a number use just a plain $N.
Then your toy command-line would be:

# stap -e 'probe kernel.function("$1") { print($2) }' sys_open 4

And you could still do error checking...

# stap -e 'probe kernel.function("$1") { print($2) }' sys_open foo
ERROR: got a string argument where a number was expected (argument 2)


Josh

^ permalink raw reply	[flat|nested] 12+ messages in thread
* command line arguments
@ 2006-02-23 22:42 Frank Ch. Eigler
  2006-02-24  5:52 ` Martin Hunt
  2006-02-24 13:42 ` Daniel P. Berrange
  0 siblings, 2 replies; 12+ messages in thread
From: Frank Ch. Eigler @ 2006-02-23 22:42 UTC (permalink / raw)
  To: systemtap

Hi -

I committed a draft of command line argument support as per bug #1304.
One part (plain substitution into scripts) is usable now.  Another
part (initializing globals at module init time) is sort of dormant.

The way the first part works is by making any additional arguments 
passed to "stap" available to the script for substitution as string
or number literals:

# stap -e 'probe kernel.function(@1) { print($2) }' sys_open 4

The @ vs $ distinction encodes whether the numbered argument should be
pasted as a string or number literal.  I considered guessing but
heuristics don't seem to belong somewhere so critical.

I'm open to suggestions about better notation than $n and @n.  (#n is
out because of comments; % and others because of arithmetic operators.)

- FChE

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

end of thread, other threads:[~2006-02-27 20:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-23 23:41 command line arguments Stone, Joshua I
2006-02-24  1:00 ` Frank Ch. Eigler
  -- strict thread matches above, loose matches on Subject: below --
2006-02-23 22:42 Frank Ch. Eigler
2006-02-24  5:52 ` Martin Hunt
2006-02-24 12:24   ` Frank Ch. Eigler
2006-02-24 18:44     ` Martin Hunt
2006-02-25 21:38       ` Frank Ch. Eigler
2006-02-27 20:34         ` Martin Hunt
2006-02-24 13:42 ` Daniel P. Berrange
2006-02-24 15:51   ` Frank Ch. Eigler
2006-02-24 20:59     ` Roland McGrath
2006-02-24 21:22       ` Frank Ch. Eigler

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