From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6898 invoked from network); 12 Aug 2008 19:58:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Aug 2008 19:58:30 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 37633 invoked from network); 12 Aug 2008 19:58:21 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Aug 2008 19:58:21 -0000 Received: (qmail 6440 invoked by alias); 12 Aug 2008 19:58:10 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25444 Received: (qmail 6424 invoked from network); 12 Aug 2008 19:58:08 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 12 Aug 2008 19:58:08 -0000 Received: from mail-gx0-f23.google.com (mail-gx0-f23.google.com [209.85.217.23]) by bifrost.dotsrc.org (Postfix) with ESMTP id 696A780F75A4 for ; Tue, 12 Aug 2008 21:58:04 +0200 (CEST) Received: by gxk4 with SMTP id 4so235489gxk.21 for ; Tue, 12 Aug 2008 12:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=VTPntzQbi2XR7YB7dfJ/ucBKi/wqhs7+35cDzjXTxR8=; b=PbKlBOxdZW8ZplmkxKoN0jgJb9OpCd+B9wFJOGlr75uqdn/5Ihiep1v+zC4wGcRXFt yPfmnMxCStBWtMVt863Cm+VchfMi/pe8XIlNyeobkxFsmxc6hMWHyRyE62oxC/JBdyhR V8dN+wYTR3DYYdicM6IxverqmVOynNA72wVnM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=oEEYdysdkIYMTOVjekIQLkaklICzUuUu3a1CPEK/Wq6dn0qSav48kzjCuSHw5+GZRg 36qYdU/ofgwT2yQYLsZM0h2eJLeCVPsT5InQYj0xRmq2ND89KOPrB/fprc9LXqSaum0u LGMZ7b3o/eW5OMVO91XzmRrI7GFBujmiUPuck= Received: by 10.114.46.11 with SMTP id t11mr5438700wat.211.1218571083072; Tue, 12 Aug 2008 12:58:03 -0700 (PDT) Received: by 10.114.159.2 with HTTP; Tue, 12 Aug 2008 12:58:03 -0700 (PDT) Message-ID: <6cd6de210808121258n5bd7b65fr225ea73e4dbfc0c5@mail.gmail.com> Date: Tue, 12 Aug 2008 15:58:03 -0400 From: "Rocky Bernstein" To: "Peter Stephenson" Subject: Re: PATCH: trace information for sourced files Cc: "Zsh hackers list" In-Reply-To: <8933.1218570362@pws-pc> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8933.1218570362@pws-pc> X-Virus-Scanned: ClamAV 0.92.1/8021/Tue Aug 12 21:27:39 2008 on bifrost X-Virus-Status: Clean Thanks. Comments in line. On Tue, Aug 12, 2008 at 3:46 PM, Peter Stephenson wrote: > This enables the trace information for sourced files. Again, the key is > to make sure the information reflects the calling context. > > I'm not sure what to put in $funcsourcetrace since there is no separate > point of definition from that of the caller in this case. How about "source" or ".". Down the line one may want to record the number of parameters passed, and here I note that zsh allows passing parameters in a source command. As we need > something to keep the array lengths consistent, I've simply put in the > same information as in $functrace. Arguably it should be something > special. > > Note that I will be away for holiday in two parts after tomorrow. Interesting. I'll be out for the next week as well. Lemme know when this is committed to CVS and so I can make the updates to zshdb. Many thanks. > > Index: Doc/Zsh/mod_parameter.yo > =================================================================== > RCS file: /cvsroot/zsh/zsh/Doc/Zsh/mod_parameter.yo,v > retrieving revision 1.9 > diff -u -r1.9 mod_parameter.yo > --- Doc/Zsh/mod_parameter.yo 11 Aug 2008 19:22:54 -0000 1.9 > +++ Doc/Zsh/mod_parameter.yo 12 Aug 2008 19:39:43 -0000 > @@ -173,6 +173,9 @@ > function in native zsh format where only the body of the function occurs > in the file the line number is reported as zero. > The format of each element is var(filename)tt(:)var(lineno). > +Trace information is also shown for files that have been executed > +by the tt(source) or tt(.) builtins; in this case it > +is identical to that provided by the tt(functrace) parameter. > ) > vindex(funcstack) > item(tt(funcstack))( > @@ -185,5 +188,7 @@ > This array contains the names and line numbers of the callers > corresponding to the functions currently being executed. > The format of each element is var(name)tt(:)var(lineno). > +Callers are also shown for sourced files; the caller is the point > +where the tt(source) or tt(.) command was executed. > ) > enditem() > Index: Src/init.c > =================================================================== > RCS file: /cvsroot/zsh/zsh/Src/init.c,v > retrieving revision 1.92 > diff -u -r1.92 init.c > --- Src/init.c 11 Aug 2008 19:22:54 -0000 1.92 > +++ Src/init.c 12 Aug 2008 19:39:43 -0000 > @@ -1100,16 +1100,17 @@ > trap_state = TRAP_STATE_INACTIVE; > > sourcelevel++; > - /* { */ > - /* struct funcstack fstack; */ > - /* fstack.name = dupstring("source"); */ > - /* fstack.caller = dupstring(scriptfilename); */ > - /* fstack.flineno = oldlineno; */ > - /* fstack.lineno = oldlineno; */ > - /* fstack.filename = NULL; */ > - /* fstack.prev = funcstack; */ > - /* funcstack = &fstack; */ > - /* } */ > + { > + struct funcstack fstack; > + fstack.name = dupstring("source"); > + fstack.caller = dupstring(old_scriptfilename ? old_scriptfilename : > + "zsh"); > + fstack.flineno = oldlineno; > + fstack.lineno = oldlineno; > + fstack.filename = fstack.caller; > + fstack.prev = funcstack; > + funcstack = &fstack; > + } > > if (prog) { > pushheap(); > @@ -1118,7 +1119,7 @@ > popheap(); > } else > loop(0, 0); /* loop through the file to be sourced */ > - /* funcstack = funcstack->prev; */ > + funcstack = funcstack->prev; > sourcelevel--; > > trap_state = otrap_state; > Index: Test/V06parameter.ztst > =================================================================== > RCS file: /cvsroot/zsh/zsh/Test/V06parameter.ztst,v > retrieving revision 1.2 > diff -u -r1.2 V06parameter.ztst > --- Test/V06parameter.ztst 11 Aug 2008 19:29:26 -0000 1.2 > +++ Test/V06parameter.ztst 12 Aug 2008 19:39:43 -0000 > @@ -1,5 +1,8 @@ > %test > > + print 'print In sourced file > + print $LINENO + $functrace + $funcsourcetrace > + ' >sourcedfile > print -r -- 'print Started functrace.zsh > module_path=(./Modules) > print $LINENO + $functrace + $funcsourcetrace > @@ -20,7 +23,8 @@ > autoload autofn > : > autofn > - autofn' >functrace.zsh > + autofn > + . ./sourcedfile' >functrace.zsh > $ZTST_testdir/../Src/zsh +Z -f ./functrace.zsh > 0:Function tracing > >Started functrace.zsh > @@ -31,3 +35,5 @@ > >2 + ./functrace.zsh:20 + ./autofn:0 > >Inside autofn > >2 + ./functrace.zsh:21 + ./autofn:0 > +>In sourced file > +>2 + ./functrace.zsh:22 + ./functrace.zsh:22 > > > -- > Peter Stephenson > Web page now at http://homepage.ntlworld.com/p.w.stephenson/ >