www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Debugging

reply Mike Swieton <mike swieton.net> writes:
Has anyone here been debugging code with GDB? Is there any trick or anything
to it? I've been trying and I've been seeing some very strange stack traces
(things in impossible orders, etc). Anyone else seen this? Suggestions?

Mike Swieton
__
About the use of language: it is impossible to sharpen a pencil with a blunt
axe. It is equally vain to try to do it with ten blunt axes instead.
	- Edsger Dijkstra
May 31 2004
parent reply hellcatv hotmail.com writes:
well you can set breakpoints at anywhere in the file
you can print local vars using the var name and class or struct vars by
prefixing things with this.

the function names contain the gem that is the actual function name about 1/3
the way down the name of the function-- a keen eye should be able to spot it
amidst all the module-sounding garbage :-)

I haven't figured out how to call functions but I suspect if I mangled them
correctly (i.e. with all the module garbage around them) then it would properly
work...
good luck

In article <pan.2004.06.01.03.59.58.423280 swieton.net>, Mike Swieton says...
Has anyone here been debugging code with GDB? Is there any trick or anything
to it? I've been trying and I've been seeing some very strange stack traces
(things in impossible orders, etc). Anyone else seen this? Suggestions?

Mike Swieton
__
About the use of language: it is impossible to sharpen a pencil with a blunt
axe. It is equally vain to try to do it with ten blunt axes instead.
	- Edsger Dijkstra

May 31 2004
parent Mike Swieton <mike swieton.net> writes:
On Tue, 01 Jun 2004 05:00:17 +0000, hellcatv wrote:

 well you can set breakpoints at anywhere in the file
 you can print local vars using the var name and class or struct vars by
 prefixing things with this.
 
 the function names contain the gem that is the actual function name about 1/3
 the way down the name of the function-- a keen eye should be able to spot it
 amidst all the module-sounding garbage :-)
 
 I haven't figured out how to call functions but I suspect if I mangled them
 correctly (i.e. with all the module garbage around them) then it would properly
 work...
 good luck

Thanks, but I'm afraid that's not quite the problem: I'm seeing stack traces that show function calls that can't be there. Example (probably should have posted this initially, even though it is relatively useless w/o context): #0 0x400c0bf1 in do_sigsuspend () from /lib/libc.so.6 #1 0x400c0cb9 in sigsuspend () from /lib/libc.so.6 #2 0x4002a278 in __pthread_wait_for_restart_signal () from /lib/libpthread.so.0 #3 0x40026d18 in pthread_cond_wait GLIBC_2.0 () from /lib/libpthread.so.0 Regarding 0-3: All reasonable through here. #4 0x0804b003 in _D10concurrent10waitnotify14WaitNotifyImpl4waitFC6ObjectZv () #5 0x0804b1eb in _D10concurrent10waitnotify17WaitNotifyAllImpl4waitFC6ObjectZv () Re 4-5: WaitNotifyAllImpl.wait() does not call WaitNotifyImpl.wait(). #6 0x0804eb8a in _D10concurrent6fjtask17FJTaskRunnerGroup15InvokableFJTask017 nitWaitNotifyAllFZv () Re 6: initWaitNotifyAll doesn't call #6, wait(). #7 0x0804ece1 in _D10concurrent6fjtask17FJTaskRunnerGroup15InvokableFJTask1 awaitTerminationFZv () Re 7: awaitTermination only calls #4, WaitNotifyAll.wait(), directly. I shouldn't see 5-6 in between. #8 0x0804e615 in _D10concurrent6fjtask17FJTaskRunnerGroup7executeFC10concur ent6fjtask6FJTaskZv () #9 0x0804e63a in _D10concurrent6fjtask17FJTaskRunnerGroup6invokeFC10concur ent6fjtask6FJTaskZv () #10 0x080498df in _Dmain () Re 8-10: Reasonable. #11 0x08053834 in _D9invariant12_d_invariantFC6ObjectZv () Re 11: what's this invariant stuff? Why would Object's invariants (which it doesn't have, btw) run before _Dmain? #12 0x400acd06 in __libc_start_main () from /lib/libc.so.6 The name mangling is a pain in the ass, but not a problem really. What gets me is that I don't understand what the program's doing. This is simply not a possible call sequence at all. I'm hoping I'm just using the debugger wrong, and there's something obvious I can fix here. Mike Swieton __ What would you attempt to do if you knew you would not fail? - Dr. Robert Schuller
Jun 01 2004