Headless debugging - stack info
How do you collect stack info when debugging non-interactive jobs?
I cobbled this together today from the docs, but maybe there's something pre-built? LOG^%ETN()?
set stack = ""for loop=0:1:$STACK(-1) {
set stack = stack _ "Context level:" _ loop _ " Context type: " _ $STACK(loop) _ $c(10,13) _
" Current place: " _ $STACK(loop,"PLACE") _ $c(10,13) _
" Current source: " _$STACK(loop,"MCODE") _ $c(10,13)
}Log meth
Discussion (0)0
Comments
I use the same code and as well as use $ZU(41,-2) to get stack information .
I wish I could see the code in $$macroERROR^%occMsgXML() (used by $$$ERROR() macro and other) to store the stack in a Status.
Status already includes stack-trace. It is not printed by default. You can enable including stack-trace information into status text representation.
Status already includes stack-trace
I know, that is the very reason why I'm curious to see how it's implemented there!
My guess is that is using $ZU(41,-2).
Take a look at class %SYS.ProcessQuery
USER>set q=##class(%SYS.ProcessQuery).ExamStackByPid($J,1)
USER>zw ^mtemp(q)
^mtemp(4,"*FORMAT")=1
^mtemp(4,"*LEVEL",1)=1
^mtemp(4,"*LEVEL",2)=2
^mtemp(4,"*STACK")=2
^mtemp(4,"*STACK",0,"V","$D")=""
...
^mtemp(4,"*STACK",1,"I")="1^S^^^0^"
^mtemp(4,"*STACK",1,"L")=" 1 SIGN ON "
^mtemp(4,"*STACK",1,"S")=""
^mtemp(4,"*STACK",1,"T")="SIGN ON "
^mtemp(4,"*STACK",2,"I")="2^e^^^0^S q=##CLASS(%SYS.ProcessQuery).ExamStackByPid($J,1)"
^mtemp(4,"*STACK",2,"L")=" 2 $$EXTFUNC ~S q=##CLASS(%SYS.ProcessQuery).ExamStackByPid($J,1)"
^mtemp(4,"*STACK",2,"S")="~S q=##CLASS(%SYS.ProcessQuery).ExamStackByPid($J,1)"
^mtemp(4,"*STACK",2,"T")="$$EXTFUNC "
^mtemp(4,"*VARS")=1
That's convenient!