Page 1 of 2

cannot debug

Posted: Fri Oct 25, 2013 12:17 pm
by freanux
hi

i wrote a hello world program:

Code: Select all

#include <stdio.h>

int main(int argc, char **argv)
{
	* printf("hello world\n");
	return 0;
}
set the breakpoint on line 1 (marked with the star in code). if i start the program, the gdb quits with following message:
Debugger exited with the following error string:
"During startup program exited normally."
i'm using gnu/linux gentoo, codelite is self compiled.i pulled the newest version of codelite from git: version 5.3
gdb version: GNU gdb (Gentoo 7.5.1 p2) 7.5.1

i have the same installation on my other laptop, which is running/debugging fine, i did check/compare all switches and cannot find any differences.

here is my full debug log:

Code: Select all

Using gdbinit file: /tmp/codelite_gdbinit.txt
Current working dir: /home/flynn/Programming/TestProj1
Launching gdb from : ./Debug
Starting debugger  : gdb --command="/tmp/codelite_gdbinit.txt" --tty=/dev/pts/4 --interpreter=mi "./TestProj1"
DEBUG>>set unwindonsignal on
DEBUG>>set breakpoint pending on
DEBUG>>set width 0
DEBUG>>set height 0
DEBUG>>set print elements 200
DEBUG>>python
DEBUG>>import sys
DEBUG>>sys.path.insert(0, '/home/flynn/.codelite/gdb_printers')
DEBUG>>from libstdcxx.v6.printers import register_libstdcxx_printers
DEBUG>>register_libstdcxx_printers (None)
DEBUG>>from qt4 import register_qt4_printers
DEBUG>>register_qt4_printers (None)
DEBUG>>from wx import register_wx_printers
DEBUG>>register_wx_printers (None)
DEBUG>>end
DEBUG>>00000010-break-insert -f "\"/home/flynn/Programming/TestProj1/main.c:5\""
Debug session started successfully!
DEBUG>>00000011-exec-arguments 
DEBUG>>00000012-exec-run 
DEBUG>>=thread-group-added,id="i1"
=thread-group-added,id="i1"
DEBUG>>~"GNU gdb (Gentoo 7.5.1 p2) 7.5.1\n"
GNU gdb (Gentoo 7.5.1 p2) 7.5.1
DEBUG>>~"Copyright (C) 2012 Free Software Foundation, Inc.\n"
Copyright (C) 2012 Free Software Foundation, Inc.
DEBUG>>~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type "show copying"\nand "show warranty" for details.
DEBUG>>~"This GDB was configured as \"x86_64-pc-linux-gnu\".\nFor bug reporting instructions, please see:\n"
This GDB was configured as "x86_64-pc-linux-gnu".\nFor bug reporting instructions, please see:
DEBUG>>~"<http://bugs.gentoo.org/>...\n"
<http://bugs.gentoo.org/>...
DEBUG>>~"Reading symbols from /home/flynn/Programming/TestProj1/Debug/TestProj1..."
Reading symbols from /home/flynn/Programming/TestProj1/Debug/TestProj1...
DEBUG>>~"done.\n"
done.
DEBUG>>&"set unwindonsignal on\n"
DEBUG>>^done
DEBUG>>&"set breakpoint pending on\n"
DEBUG>>^done
DEBUG>>&"set width 0\n"
DEBUG>>^done
DEBUG>>&"set height 0\n"
DEBUG>>^done
DEBUG>>&"set print elements 200\n"
DEBUG>>^done
DEBUG>>&"python\n"
DEBUG>>&"Traceback (most recent call last):\n"
DEBUG>>&"  File \"<string>\", line 4, in <module>\n"
DEBUG>>&"  File \"/home/flynn/.codelite/gdb_printers/libstdcxx/v6/printers.py\", line 911, in register_libstdcxx_printers\n"
DEBUG>>&"    gdb.printing.register_pretty_printer(obj, libstdcxx_printer)\n"
DEBUG>>&"  File \"/usr/share/gdb/python/gdb/printing.py\", line 141, in register_pretty_printer\n"
DEBUG>>&"    printer.name)\n"
DEBUG>>&"RuntimeError: pretty-printer already registered: libstdc++-v6\n"
DEBUG>>&"Error while executing Python code.\n"
DEBUG>>^error,msg="Error while executing Python code."
^error,msg="Error while executing Python code."
DEBUG>>&"No source file named /home/flynn/Programming/TestProj1/main.c.\n"
DEBUG>>00000010^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="\"/home/flynn/Programming/TestProj1/main.c:5\"",times="0",original-location="\"/home/flynn/Programming/TestProj1/main.c:5\""}
Found the breakpoint ID!
Storing debugger breakpoint Id=1
Successfully set breakpoint 1 at: /home/flynn/Programming/TestProj1/main.c:5
DEBUG>>00000011^done
>> Debuggee process ID: 26213
DEBUG>>=thread-group-started,id="i1",pid="26213"
=thread-group-started,id="i1",pid="26213"
DEBUG>>=thread-created,id="1",group-id="i1"
=thread-created,id="1",group-id="i1"
DEBUG>>=thread-exited,id="1",group-id="i1"
=thread-exited,id="1",group-id="i1"
DEBUG>>=thread-group-exited,id="i1"
=thread-group-exited,id="i1"
DEBUG>>00000012^error,msg="During startup program exited normally."
Debug session ended
During startup program exited normally.
what is wrong?

thanks
freanux

Re: cannot debug

Posted: Sun Oct 27, 2013 12:09 am
by freanux
the problem still exists. i really can't figure out, what the problem is.
btw, the gcc version is: gcc (Gentoo 4.7.3-r1 p1.3, pie-0.5.5) 4.7.3

no ideas?

Re: cannot debug

Posted: Sun Oct 27, 2013 12:13 am
by eranif
Have you tried to disable the python pretty printing ?

Uncheck this option:
Settings -> GDB Settings -> Enable Pretty Printing

Also, make sure you remove the content of the 'GDB Start up commands' field from:
Settings -> GDB Settings -> Start up commands

Eran

Re: cannot debug

Posted: Sun Oct 27, 2013 12:35 am
by freanux
hi

pretty printing is unchecked. i removed the content of the startup commands. same result :-(

Re: cannot debug

Posted: Sun Oct 27, 2013 12:42 am
by freanux
here is the debugger's log output:

Code: Select all

Using gdbinit file: /tmp/codelite_gdbinit.txt
Current working dir: /home/flynn/Programming/TestProj2
Launching gdb from : ./Debug
Starting debugger  : gdb --command="/tmp/codelite_gdbinit.txt" --tty=/dev/pts/4 --interpreter=mi "./TestProj2"
DEBUG>>set unwindonsignal on
DEBUG>>set breakpoint pending on
DEBUG>>set width 0
DEBUG>>set height 0
DEBUG>>set print elements 200
DEBUG>>00000013-break-insert -f "\"/home/flynn/Programming/TestProj1/main.c:9\""
DEBUG>>00000014-break-insert -f "\"/home/flynn/Programming/TestProj2/main.c:5\""
Debug session started successfully!
DEBUG>>00000015-exec-arguments 
DEBUG>>00000016-exec-run 
DEBUG>>=thread-group-added,id="i1"
=thread-group-added,id="i1"
DEBUG>>~"GNU gdb (Gentoo 7.5.1 p2) 7.5.1\n"
GNU gdb (Gentoo 7.5.1 p2) 7.5.1
DEBUG>>~"Copyright (C) 2012 Free Software Foundation, Inc.\n"
Copyright (C) 2012 Free Software Foundation, Inc.
DEBUG>>~"License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type \"show copying\"\nand \"show warranty\" for details.\n"
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type "show copying"\nand "show warranty" for details.
DEBUG>>~"This GDB was configured as \"x86_64-pc-linux-gnu\".\nFor bug reporting instructions, please see:\n"
This GDB was configured as "x86_64-pc-linux-gnu".\nFor bug reporting instructions, please see:
DEBUG>>~"<http://bugs.gentoo.org/>...\n"
<http://bugs.gentoo.org/>...
DEBUG>>~"Reading symbols from /home/flynn/Programming/TestProj2/Debug/TestProj2..."
Reading symbols from /home/flynn/Programming/TestProj2/Debug/TestProj2...
DEBUG>>~"done.\n"
done.
DEBUG>>&"set unwindonsignal on\n"
DEBUG>>^done
DEBUG>>&"set breakpoint pending on\n"
DEBUG>>^done
DEBUG>>&"set width 0\n"
DEBUG>>^done
DEBUG>>&"set height 0\n"
DEBUG>>^done
DEBUG>>&"set print elements 200\n"
DEBUG>>^done
DEBUG>>&"No source file named /home/flynn/Programming/TestProj1/main.c.\n"
DEBUG>>00000013^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="<PENDING>",pending="\"/home/flynn/Programming/TestProj1/main.c:9\"",times="0",original-location="\"/home/flynn/Programming/TestProj1/main.c:9\""}
Found the breakpoint ID!
Storing debugger breakpoint Id=1
Successfully set breakpoint 1 at: /home/flynn/Programming/TestProj1/main.c:9
DEBUG>>00000014^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x000000000040056b",func="main",file="/home/flynn/Programming/TestProj2/main.c",fullname="/home/flynn/Programming/TestProj2/main.c",line="5",times="0",original-location="/home/flynn/Programming/TestProj2/main.c:5"}
Found the breakpoint ID!
Storing debugger breakpoint Id=2
Successfully set breakpoint 2 at: /home/flynn/Programming/TestProj2/main.c:5
DEBUG>>00000015^done
>> Debuggee process ID: 17532
DEBUG>>=thread-group-started,id="i1",pid="17532"
=thread-group-started,id="i1",pid="17532"
DEBUG>>=thread-created,id="1",group-id="i1"
=thread-created,id="1",group-id="i1"
DEBUG>>=thread-exited,id="1",group-id="i1"
=thread-exited,id="1",group-id="i1"
DEBUG>>=thread-group-exited,id="i1"
=thread-group-exited,id="i1"
DEBUG>>00000016^error,msg="During startup program exited normally."
Debug session ended
During startup program exited normally.

Re: cannot debug

Posted: Sun Oct 27, 2013 1:14 am
by eranif
Do you have this option enabled: Settings -> GDB Settings -> General -> Apply breakpoints after main function is hit
Try disable it

Its a long shot, but maybe this intermediate breakpoint is conflicting with your breakpoint (which is also set on the first line of the program)

Eran

Re: cannot debug

Posted: Sun Oct 27, 2013 1:22 am
by freanux
no, this option is not enabled. see screenshot.

Re: cannot debug

Posted: Sun Oct 27, 2013 1:31 am
by eranif
I compared your log to my own log - and it seems like your GDB crashed...
I am missing these lines:

Code: Select all

DEBUG>>00000051-exec-continue
DEBUG>>00000051^running
Which is the equivalent of the command line to "run"

Can you debug this from the command line? Myabe its a bug in gdb with the MI enabled (Machine Interface)
Try debugging it like this:

Code: Select all

gdb <exe> -i=mi
Eran

Re: cannot debug

Posted: Sun Oct 27, 2013 3:03 pm
by freanux
if i debug in a console session, it works as expected.
it seems, that gdb is no longer able to execute your "run" command. hmm, it's really strange.

Re: cannot debug

Posted: Sun Oct 27, 2013 3:16 pm
by eranif
Try following codelite's flow ( you are using CLI commands, while codelite is using MI commands), for example:

- codelite does not use 'run' but rather -exec-run
- Try placing the breakpoint as codelite does (-break-insert)

You could also try and enable the option in codelite, Settings -> GDB Settings -> Misc -> Use file name only for breakpoints (NO full paths)
This helps in various cases.

BTW, try adding some more code to your sample main and place the breakpoints not only on the first line, does it helps?

Eran