1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-06 21:11:11 +02:00

25443 (tweaked): allow $functrace to show sourced files

This commit is contained in:
Peter Stephenson 2008-08-12 20:25:14 +00:00
parent b2e70921b0
commit 01f5d0a274
4 changed files with 30 additions and 12 deletions

View file

@ -1,3 +1,9 @@
2008-08-12 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 25443 (tweaked): Doc/Zsh/mod_parameter.yo,
Src/Modules/parameter.c, Test/V06parameter.ztst: allow
$functrace to show sourced files.
2008-08-12 Peter Stephenson <pws@csr.com>
* unposted: Completion/Solaris/Command/.distfiles,

View file

@ -173,6 +173,9 @@ or `var(name) tt(LPAR()RPAR())' started. In the case of an autoloaded
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).
For files that have been executed by the tt(source) or tt(.) builtins
(in which case there is no separate definition) the trace information is
shown as tt(source:0).
)
vindex(funcstack)
item(tt(funcstack))(
@ -185,5 +188,7 @@ item(tt(functrace))(
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()

View file

@ -1100,16 +1100,17 @@ source(char *s)
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 = 0;
fstack.lineno = oldlineno;
fstack.filename = fstack.name;
fstack.prev = funcstack;
funcstack = &fstack;
}
if (prog) {
pushheap();
@ -1118,7 +1119,7 @@ source(char *s)
popheap();
} else
loop(0, 0); /* loop through the file to be sourced */
/* funcstack = funcstack->prev; */
funcstack = funcstack->prev;
sourcelevel--;
trap_state = otrap_state;

View file

@ -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 + source:0