www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Problem with debugging in Linux

reply Qian Xu <quian.xu stud.tu-ilmenau.de> writes:
Hi All,

I try to debug my application with gdb. 
However the callstack information is incomplete. 

Workground looks as follows:

1. Create a test file

---- My code -----
module mymodule;
class Foo {}
void main()
{
   Foo foo;
   if (foo == foo) {} // segfault
}
---- My code -----

2. Compile it:
dmd -version=Posix -w -g -debug -O test.d -c
dmd test.o -oftarget

3. Type "ulimit -c unlimited" in terminal (in order to generate core dump)

4. Run "target" (a core dump will be generated)

5. gdb target /var/coredump/the_core_dump

6. type "bt" to see the callstack information.
#0  0x0804956a in _Dmain ()
#1  0xb7ceafc0 in ?? ()
#2  0xbfdc79c0 in ?? ()
#3  0x0804a090 in _D2rt6dmain24mainUiPPaZi7runMainMFZv ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)




Does anybody know, why gdb says "corrupt stack"?

Best regards
Qian Xu
Jul 15 2009
parent reply grauzone <none example.net> writes:
It works with dmd 1.046 on Linux. The backtrace I'm getting is:

#0  0x0804916a in _Dmain ()
#1  0x08049450 in _D2rt6dmain24mainUiPPaZi7runMainMFZv ()
#2  0x080493b5 in _D2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#3  0x0804948d in _D2rt6dmain24mainUiPPaZi6runAllMFZv ()
#4  0x080493b5 in _D2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
#5  0x08049364 in main ()

Maybe that bug got fixed. Could it have to do with the changelog entry 
"Fix instruction scheduler bug on Linux"?
Jul 15 2009
parent reply Qian Xu <quian.xu stud.tu-ilmenau.de> writes:
grauzone wrote:

 It works with dmd 1.046 on Linux. The backtrace I'm getting is:
 
 #0  0x0804916a in _Dmain ()
 #1  0x08049450 in _D2rt6dmain24mainUiPPaZi7runMainMFZv ()
 #2  0x080493b5 in _D2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
 #3  0x0804948d in _D2rt6dmain24mainUiPPaZi6runAllMFZv ()
 #4  0x080493b5 in _D2rt6dmain24mainUiPPaZi7tryExecMFDFZvZv ()
 #5  0x08049364 in main ()
 
 Maybe that bug got fixed. Could it have to do with the changelog entry
 "Fix instruction scheduler bug on Linux"?

Thanks. It works with dmd 1.046. However I have another questiont to the new dmd compiler. I try to compile my app using "dmd myapp.d -c", but dmd says "object.d: Error: module object cannot read file 'object.d'". The new dmd seems tow work with phobos only? My project is based on tango. It could be a problem .... Qian
Jul 15 2009
parent Piotrek <starpit tlen.pl> writes:
Qian Xu pisze:
 grauzone wrote:
 
 It works with dmd 1.046 on Linux. The backtrace I'm getting is:

 Maybe that bug got fixed. Could it have to do with the changelog entry
 "Fix instruction scheduler bug on Linux"?

Thanks. It works with dmd 1.046. Qian

So, does gdb 6.8 work with dmd 1.046 binaries? I've tried it on ubuntu with the out-of-the-box gdb installation but no success (Using -g or -gc switch) piotrek yeti:~/Pulpit/dmd/linux/bin$ ./dmd -g test.d piotrek yeti:~/Pulpit/dmd/linux/bin$ gdb test GNU gdb 6.8-debian Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i486-linux-gnu"... (gdb) break test.d:9 Breakpoint 1 at 0x8049b19: file test.d, line 9. (gdb) run Starting program: /home/piotrek/Pulpit/dmd/linux/bin/test [Thread debugging using libthread_db enabled] Hello World, Reloaded [New Thread 0xb7ec76d0 (LWP 8479)] [Switching to Thread 0xb7ec76d0 (LWP 8479)] Breakpoint 1, 0x08049b19 in _Dmain () Current language: auto; currently asm (gdb) list 1 import std.stdio; 2 3 4 void main(string[] args) 5 { 6 writefln("Hello World, Reloaded"); 7 8 int d = 1; 9 d++; 10 d--; (gdb) print d No symbol "a" in current context. (gdb) Cheers Piotrek
Jul 15 2009