From: Tilman Sauerbeck Date: 2005-01-27T06:14:22+09:00 Subject: Re: Debugging C Extensions and [A bit OT] general C Questions Brian Schr�der [2005-01-27 04:11]: > Right now I'm using printf to output things to the console, but I'd rather like to debug the process in somethink like ddd. Is this possible? > I tried to connect to the running process, but it said to me that the process was "no program". gdb ruby b Init_my_ext r gdb will tell you that it couldn't resolve the breakpoint because your extension isn't loaded yet, but it will do so as soon as you require/load your extension. If the GC is troubling you, get Valgrind (and a suppression file for Ruby, e.g. http://code-monkey.de/files/ruby.supp) and give it a go. There will be a lot of false positives though, so it's not that easy to get the useful information out of Valgrind's output ;) > And now the OT question: > > anybody knows of a compact C manual on the web, where I can for example learn how in this code: > > [snip] > > the result data data is returned? I'd think that there is no copying of large amounts of data involved, but I'm not 100% shure because I haven't found a good manual explaining this yet. Umm. All it copies is sizeof(SRVolume) bytes. It will only copy the pointer to the result data, not the contents itself. > Additionally I get under special circumstances (Creating a volume, setting a value and using p(volume)) the message that it tries to free a wrong pointer. If i change p(volume) to puts volume.inspect it works. This is shurely not enough description, but maybe you could point me to some more information on the GC and other things that can bring forth this error message. Check that your mark callbacks are set up correctly, i.e. make sure you're not forgetting to mark some of your objects. btw, your lines are a bit too long ;) Usually it's set to 74 characters. -- Regards, Tilman