How do you debug AGIs?

Way too many moons ago (17 years!), I started working with Asterisk. While I knew nothin’ about nothin’, my client had confidence in me and, after an on-site visit with Jared Smith in Utah, had confidence in Asterisk.

I designed my first application (an adult chat service) as a series of AGIs. Since, at the time, my sharpest tool was C, I wrote the AGIs in C. I didn’t find any ‘AGI in C’ library so I wrote one.

I was used to developing in C and using GDB (in Emacs) for debugging. Initally, I felt lost and out of control debugging by peppering my code with printfs and syslogs.

Then one day I had an epiphany that I could capture the console output with AGI debugging enabled, massage it with a shell script, and feed the dialog back into my code (in GDB, in Emacs) so I could step through my bugs much more effectively. Setting breakpoints, examining variables, and setting variables beats the hell out of printf/syslog.

I’ve used the same technique with AGIs written in Perl (in perldb, in Emacs).

It occurs to me that I have never seen this technique ‘in print.’

Is this a commonly known technique that everybody uses or does everybody pepper with printf/syslog, grip it, and rip it?

use a command agi set debug on to get the detailed agi logs in in CLI

I’m sorry, your comment isn’t clear.

Are you suggesting that I use ‘agi set debug on’ (I do as I stated above) or that your debugging technique is to enable AGI debugging and watch the CLI to figure out what went wrong?

Also, what languages do you write AGIs in?

Hi @sedwards

Actually I use PHP language and to debug more I can only use the ‘echo’ command to print out my query and values in variables to get the idea if the values are setting and getting correct so similarly, you can use ‘printf’ if your language is C

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.