why_bird
12-09-2008, 12:20 PM
Hi all,
I have a Tcl script as a wrapper for some C code (lets call it program A). The Tcl script runs constantly, and sets up a socket so that another C program (program \B) can send commands to it. The Tcl wrapper then interprets these commands and calls the appropriate C functions. Before anyone goes 'why would you do that like that...?', well, the short answer is firstly, it's simulating something, secondly, not down to me!
So my question: I can debug program B, that's simple. But how would I debug the Tcl script/program A? Or see what its doing? (I suppose it would be possible to add lots of print statements, which I will do if there's no other way to do it) I have managed to make it segfault, and I don't know why!
I have tried running it through valgrind: nothing.. valgrind just seems to ignore it, even when it segfaults. I have also tried running the Tcl interpreter through gdb, and calling the Tcl script through that. but then it just 'takes over' gdb, and I can't print anything or exert any control over it.
I have some experience of C, little to none of Tcl, and little to none of running networked code/sockets/all that kind of stuff, so any pointers would be welcomed.
I am running Red Hat Enterprise Linux ES release 4, and won't necessarily be able to install things, though I might. I have heard of smartgdb which a page on the tcl wiki suggested for debugging c/tcl code.. could that be of use?
many thanks,
why_bird
I have a Tcl script as a wrapper for some C code (lets call it program A). The Tcl script runs constantly, and sets up a socket so that another C program (program \B) can send commands to it. The Tcl wrapper then interprets these commands and calls the appropriate C functions. Before anyone goes 'why would you do that like that...?', well, the short answer is firstly, it's simulating something, secondly, not down to me!
So my question: I can debug program B, that's simple. But how would I debug the Tcl script/program A? Or see what its doing? (I suppose it would be possible to add lots of print statements, which I will do if there's no other way to do it) I have managed to make it segfault, and I don't know why!
I have tried running it through valgrind: nothing.. valgrind just seems to ignore it, even when it segfaults. I have also tried running the Tcl interpreter through gdb, and calling the Tcl script through that. but then it just 'takes over' gdb, and I can't print anything or exert any control over it.
I have some experience of C, little to none of Tcl, and little to none of running networked code/sockets/all that kind of stuff, so any pointers would be welcomed.
I am running Red Hat Enterprise Linux ES release 4, and won't necessarily be able to install things, though I might. I have heard of smartgdb which a page on the tcl wiki suggested for debugging c/tcl code.. could that be of use?
many thanks,
why_bird