Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: functrace and funcsourcetrace (was Re: PATCH: trace information for sourced files)
- X-seq: zsh-workers 25447
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Subject: Re: functrace and funcsourcetrace (was Re: PATCH: trace information for sourced files)
- Date: Wed, 13 Aug 2008 20:42:12 +0100
- In-reply-to: <6cd6de210808121700kf500ea6p9b3eed0fefadfc8@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <6cd6de210808121700kf500ea6p9b3eed0fefadfc8@xxxxxxxxxxxxxx>
On Tue, 12 Aug 2008 20:00:40 -0400
"Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> wrote:
> 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.
As I said, deciding what's in the calling context and what's in the
current context is difficult. We've got something that consistently
tracks only the calling context; it seems what we need to end up with is
a mixture with the next level up.
Let's analyse the differences in one of the key bits, in a function call;
here they are in parallel:
functrace funcsourcetrace rocky where we are
foo:1 ./linebug.sh:1 linebug.sh:10 print_stack
./linebug.sh:16 ./linebug.sh:9 linebug.sh:16 foo
In the first line,
- foo:1 means "we (print_stack) were called from the first line in the
function foo"
- ./linebug.sh:1 means "the definition of print_stack is at line 1 in
linebug.sh"
- linebug.sh:10 means "the caller of print_stack is at line 10
in linebug.sh, regardless of where the line in the function is".
In the second line,
- ./linebug.sh:16 means "our own caller (foo) was called here"; this
is a script, not a function, so it's a filename, not a function name.
- ./linebug.sh:9 means "foo was defined starting here"
- ./linebug.sh:16 means "our own caller was run at this line in this file"
So the number Rocky wants for the function context is actually the first
line from functrace plus the second line from funcsourcetrace (which is
the point at which line number 0 of foo occurs). So to do this
consistently for functions, it looks like we need an array that keeps
the file from the next level up in funcsourcetrace (the function might
be defined in a different file, and that's what we need to get the right
line number) and adds that line number to the line number in the
immediately calling context.
This should be doable (without too much additional help, anyway)
entirely within a new function (corresponding to a new array) in the
parameter module. The major decision is whether the immediate caller is
a function, in which case do the addition as above, or not, in which
case just report the current functrace output. The functrace output
should be fine for source'd files, too.
I'll have a look at this when I get back (unless I get bored on holiday).
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author