Vocal debugging

This is the probably useless but nevertheless cool: using Apple's text to speech system to speak out values for variables as they enter a function's scope in the debugger.

Given the C program below, we want the system to speak the values of the integer pointed to by "var" as we enter the "increment" function:


cristi:~ diciu$ cat Programming/test/vocal.c

void increment(int *var)
{
(*var)++;
}

int main()
{
int a=1;

while(1)
{
increment(&a);
sleep(1);
}
}

cristi:~/Programming/test diciu$ gcc vocal.c



Here's the GDB session:


cristi:~/Programming/test diciu$ gdb ./a.out
[..]
(gdb) b increment
Breakpoint 3 at 0x1f5c
(gdb) comm
Type commands for when breakpoint 3 is hit, one per line.
End with a line saying just "end".
>set $start=(*(int *)($ebp + 8))
>set $end=$start + 4
>dump memory /tmp/myfilename $start $end
>shell od -tx /tmp/myfilename | awk -F ' ' '{print $2}' | grep -v "^$" | xargs say
>cont
>end
(gdb) r


The awk mess is required because memory dumping from gdb is not very smart - it does not allow you to control the formatting when dumping.