From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3788 invoked by alias); 23 Feb 2006 23:41:17 -0000 Received: (qmail 3781 invoked by uid 22791); 23 Feb 2006 23:41:17 -0000 X-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from fmr23.intel.com (HELO scsfmr003.sc.intel.com) (143.183.121.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 23 Feb 2006 23:41:16 +0000 Received: from scsfmr101.sc.intel.com (scsfmr101.sc.intel.com [10.3.253.10]) by scsfmr003.sc.intel.com (8.12.10/8.12.10/d: major-outer.mc,v 1.1 2004/09/17 17:50:56 root Exp $) with ESMTP id k1NNf8me023989; Thu, 23 Feb 2006 23:41:08 GMT Received: from scsmsxvs040.sc.intel.com (scsmsxvs040.sc.intel.com [10.3.90.8]) by scsfmr101.sc.intel.com (8.12.10/8.12.10/d: major-inner.mc,v 1.2 2004/09/17 18:05:01 root Exp $) with SMTP id k1NNZtZh022988; Thu, 23 Feb 2006 23:35:57 GMT Received: from scsmsx332.amr.corp.intel.com ([10.3.90.6]) by scsmsxvs040.sc.intel.com (SAVSMTP 3.1.7.47) with SMTP id M2006022315410819677 ; Thu, 23 Feb 2006 15:41:08 -0800 Received: from scsmsx403.amr.corp.intel.com ([10.3.90.18]) by scsmsx332.amr.corp.intel.com with Microsoft SMTPSVC(6.0.3790.211); Thu, 23 Feb 2006 15:41:08 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: command line arguments Date: Thu, 23 Feb 2006 23:41:00 -0000 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: command line arguments Thread-Index: AcY4yn+f7xUd/CWdQTyWsJzmtfB7owABbPiQ From: "Stone, Joshua I" To: "Frank Ch. Eigler" Cc: "SystemTap" X-OriginalArrivalTime: 23 Feb 2006 23:41:08.0192 (UTC) FILETIME=[9E9B8E00:01C638D2] X-Scanned-By: MIMEDefang 2.52 on 10.3.253.10 X-IsSubscribed: yes Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org X-SW-Source: 2006-q1/txt/msg00608.txt.bz2 Frank Ch. Eigler wrote: > Hi - >=20 > 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. >=20 > 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: >=20 > # stap -e 'probe kernel.function(@1) { print($2) }' sys_open 4 Very cool! =20 > 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. >=20 > I'm open to suggestions about better notation than $n and @n. (#n is > out because of comments; % and others because of arithmetic > operators.)=20 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