From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2533 invoked by alias); 24 Feb 2006 13:42:28 -0000 Received: (qmail 2519 invoked by uid 22791); 24 Feb 2006 13:42:27 -0000 X-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 24 Feb 2006 13:42:25 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id k1ODgNRl007887 for ; Fri, 24 Feb 2006 08:42:23 -0500 Received: from file.surrey.redhat.com (file.surrey.redhat.com [172.16.10.4]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id k1ODgN130036; Fri, 24 Feb 2006 08:42:23 -0500 Received: (from berrange@localhost) by file.surrey.redhat.com (8.13.1/8.13.1/Submit) id k1ODgM96025687; Fri, 24 Feb 2006 13:42:22 GMT Date: Fri, 24 Feb 2006 13:42:00 -0000 From: "Daniel P. Berrange" To: "Frank Ch. Eigler" Cc: systemtap@sources.redhat.com Subject: Re: command line arguments Message-ID: <20060224134222.GA21829@redhat.com> Reply-To: "Daniel P. Berrange" References: <20060223224218.GE20902@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060223224218.GE20902@redhat.com> User-Agent: Mutt/1.4.1i 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/msg00622.txt.bz2 On Thu, Feb 23, 2006 at 05:42:18PM -0500, 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 > > 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.) The scenarios I'd like to use command line args in, are for tweaking aspects of the data capture, say, sampling rate of a timer, or if I was probing 'sys_read', some variable to control how often to log. So I'd think named arguments would be clearer to use, possibly to set global variables. So for example global samplerate = 1000 probe timer.jiffies(samplerate) { ... } One could tweak the rate with # stap --define samplerate=50 stuff.stp Or another exaple, if one wanted to watch all file opens under a particular directory global prefix = "/" probe kernel.function("sys_open") { if ( isinstr(prefix, substr(user_string(filename),0,strlen(prefix)) ) { print("Pid " . pid() . " opens " . user_strin(filename)) } } Then one could restrict it to just files under /etc with # stap -D prefix=/etc watchopen.stp Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|