zsh-workers
 help / color / mirror / code / Atom feed
From: "Rocky Bernstein" <rocky.bernstein@gmail.com>
To: "Peter Stephenson" <p.w.stephenson@ntlworld.com>
Cc: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: functrace and funcsourcetrace (was Re: PATCH: trace information for sourced files)
Date: Tue, 12 Aug 2008 20:00:40 -0400	[thread overview]
Message-ID: <6cd6de210808121700kf500ea6p9b3eed0fefadfc8@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2407 bytes --]

I updated today from CVS sources and built. I tried a little test and
alas, I'm sorry to report that I can't use this.

I've attached the little test program called linebug.sh. It doesn't do
any "source"'ing.  rocky-patch.out contains the output given with the
patch I submitted. functrace.out contains output using $functrace and
funcsourcetrace.out contains output using $funcsourcetrace.out.

Right now I can't see how to patch together the output from functrace
and funcsourcetrace. But it really doesn't matter because it shouldn't
be that convoluted either. What we want is an array that contains the
source file name  and absolute line number of the place where we were
called from. If the caller has a caller, then another array entry for
the source file and line number of that location, and so on. This is
the way it works in virtually every other programming language I can
think of. Perl, Python, Ruby, Java, C, C++, bash, ksh, LISP, to name
some that come to mind.

Right now functrace (whose output is shown in functrace.out), seems to
come the closest were it not for this function information getting put
there inside functions instead, and which is sort of duplicated in
funcstack. I am not fussy about what name you want to give this,
whether you want to have several parallel arrays for functions, file
names, line numbers and so on, or fewer with each string encoding more
than one bit of information. However the the filenames and line
numbers have to be there, and match the information as shown in
rocky-patch.out for the run in linebug.sh.

Thanks.


On Tue, Aug 12, 2008 at 4:27 PM, Peter Stephenson
<p.w.stephenson@ntlworld.com> wrote:
> On Tue, 12 Aug 2008 15:58:03 -0400
> "Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
>> > 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.
>
> OK, I've committed it so that the funcsourcetrace element shows up as
> "source:0".
>
> I had a look at providing the text for debug traps but it wasn't as
> trivial as I'd hoped so that may have to wait.
>
> --
> Peter Stephenson <p.w.stephenson@ntlworld.com>
> Web page now at http://homepage.ntlworld.com/p.w.stephenson/
>
>

[-- Attachment #2: linebug.sh --]
[-- Type: application/x-sh, Size: 231 bytes --]

[-- Attachment #3: rocky-patch.out --]
[-- Type: application/octet-stream, Size: 236 bytes --]

$ /usr/local/bin/zsh linebug.sh

linebug.sh:9
====
linebug.sh:13
====
linebug.sh:16
====
linebug.sh:10
linebug.sh:16
====
calling bar 10
linebug.sh:11
linebug.sh:16
====
linebug.sh:14
linebug.sh:11
linebug.sh:16
====
linebug.sh:17
====

[-- Attachment #4: functrace.out --]
[-- Type: application/octet-stream, Size: 277 bytes --]

$ /usr/local/bin/zsh ./linebug.sh

./linebug.sh:9
====
./linebug.sh:13
====
./linebug.sh:16
====
foo:1
./linebug.sh:16
====
calling bar 10
foo:2
./linebug.sh:16
====
bar:1
foo:2
./linebug.sh:16
====
./linebug.sh:17
====
 7:17PM rocky@dr-ferdinand /src/git/zshdb/bug [3 z] 0
$ 

[-- Attachment #5: funcsourcetrace.out --]
[-- Type: application/octet-stream, Size: 251 bytes --]

$ /usr/local/bin/zsh ./linebug.sh

./linebug.sh:1
====
./linebug.sh:1
====
./linebug.sh:1
====
./linebug.sh:1
./linebug.sh:9
====
calling bar 10
./linebug.sh:1
./linebug.sh:9
====
./linebug.sh:1
./linebug.sh:13
./linebug.sh:9
====
./linebug.sh:1
====

             reply	other threads:[~2008-08-13  0:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-13  0:00 Rocky Bernstein [this message]
2008-08-13 19:42 ` Peter Stephenson
2008-08-13 20:43   ` Peter Stephenson
2008-08-13 21:05     ` Peter Stephenson
2008-08-13 22:06       ` Rocky Bernstein
2008-08-18 11:13       ` Mikael Magnusson
2008-08-21 15:31         ` Peter Stephenson
2008-08-21 20:21           ` Mikael Magnusson
2008-08-22 15:33         ` Peter Stephenson
2008-08-22 15:48           ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6cd6de210808121700kf500ea6p9b3eed0fefadfc8@mail.gmail.com \
    --to=rocky.bernstein@gmail.com \
    --cc=p.w.stephenson@ntlworld.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).