Howto:Debug your own PBX voicemail script

From innovaphone wiki
Jump to navigation Jump to search

The <dbg> statement allows to intersperse textual landmarks into the trace output alike "hello world", "my script is now here", "my script's now there", "..elswhere". This article is going beyond that approach.

The configured URL of a voicemail object allows to specify the $_trace Variable, which actually is a bitmap of 8 trace flags. This article recommends the value 123. To be configured..:

  • Activate the trace checkmark
  • Configure the trace 123 value alike:
http://127.0.0.1/drive/CF0/berlin/sammelnummer/DE/berlin-sammelnummer.xml?$_pbxfwd=true&$_trace=123

The value 123 constitutes 64: <debug> statements, which will dump the internal representation of a voicemail script into the trace output. Such a trace output is going to look as follows.

84:3398:173:1 - vm.0(T):setup vm='VM-Bln-sammel' call=-1 cdpn=827 cgpn=173 dest='' sc=false chan=-1 leg2=false mwi=false ct=false
...
84:3398:174:3 - iprt.3.0(T): dumping code..
84:3398:174:3 - 0xf633ac:addr=0 voicemail .unknown=http://www.innovaphone.com/xsd/voicemail6.xsd
84:3398:174:3 - 0xf62fc8:addr=1   function define=Silence
84:3398:174:3 - 0xf62d04:addr=2     store-get root= name=silence.g711a out-url=$ctrl
84:3398:174:3 - 0xf62d48:addr=3     pbx-prompt url=$ctrl sec=2 repeat=true
84:3398:174:3 - 0xf636b8:addr=4   return
84:3398:174:3 - 0xf63744:addr=5   function define=Main
84:3398:174:3 - 0xf64584:addr=90     store-get root=$sub name=de_greeting_berlin_sammelnummer.g711a out-url=$ctrl
84:3398:174:3 - 0xf63c04:addr=91     pbx-prompt url=$ctrl
84:3398:174:3 - 0xf64610:addr=92     store-get root= name=silence.g711a out-url=$ctrl
84:3398:174:3 - 0xf64108:addr=93     pbx-prompt url=$ctrl sec=1 repeat=true
84:3398:174:3 - 0xf63010:addr=94     while cond=true [false=>0xf6309c]
84:3398:174:3 - 0xf63db4:addr=95       store-get root= name=de_menu_berlin_sammelnummer.g711a out-url=$ctrl
84:3398:174:3 - 0xf64728:addr=96       pbx-prompt url=$ctrl
84:3398:174:3 - 0xf64770:addr=97       store-get root= name=silence.g711a out-url=$ctrl
84:3398:174:3 - 0xf647b4:addr=98       pbx-prompt url=$ctrl sec=2 repeat=true
84:3398:174:3 - 0xf62e10:addr=99       .jump 0xf63010
84:3398:174:3 - 0xf6309c:addr=100     .label
84:3398:174:3 - 0xf648c4:addr=101   return
...and so on

The actual interpretation is going to take place on that internal representation and will look similar to the following trace excerpt:

84:3398:174:5 - iprt.3.0(T):running file='http://127.0.0.1/drive/CF0/berlin/sammelnummer/DE/berlin-sammelnummer.xml' ver=''
84:3398:174:5 - iprt.3.0(T):0xf63744:addr=5 function
84:3398:174:5 - iprt.3.0(T):0xf64584:addr=90 store-get
84:3398:174:5 - iprt.3.0(T):assign name='$ctrl' val='http://127.0.0.1/drive/CF0/berlin/sammelnummer/DE/de_greeting_berlin_sammelnummer.g711a' type=string
84:3398:174:5 - iprt.3.0(T):0xf63c04:addr=91 pbx-prompt
84:3398:174:5 - vm.3(T):prompt vmstate=0 url=http://127.0.0.1/drive/CF0/berlin/sammelnummer/DE/de_greeting_berlin_sammelnummer.g711a?coder=g711a
84:3398:175:0 - iprt.3.0(T):lookup attr=sec as failed
84:3398:175:1 - vm.3(T):tx=SIG_CONN call=3 state=SETUP dir=inc vmstate=1 
84:3398:176:2 - vm.3(T):rx=SIG_CHANNELS call=3 state=CONN dir=inc vmstate=1 
84:3398:176:3 - vm.3(T):rx=SIG_CONN_ACK call=3 state=CONN dir=inc vmstate=1 
84:3399:229:0 - vm.3(T):rx=SIG_FACILITY call=3 state=CONN dir=inc vmstate=1 

Most notably are the lines

..
84:3398:174:5 - iprt.3.0(T):0xf63744:addr=5 function
..
84:3398:174:5 - iprt.3.0(T):0xf64584:addr=90 store-get
..
84:3398:174:5 - iprt.3.0(T):0xf63c04:addr=91 pbx-prompt

Those lines document which statement the interpreter is currently executing. They correlate 1:1 to the internal representation from above.

Summary

If one is unsure what a script is doing, activate the voicemail trace flag 64. The voicemail parser will then ouput the internal representation of the script in a human-readable form. The voicemail interpreter will document the corresponding statements it is currently executing.