Problem running debugger for custom makefile project

General questions regarding the usage of CodeLite
mass85
CodeLite Curious
Posts: 8
Joined: Sat Oct 29, 2011 5:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Problem running debugger for custom makefile project

Post by mass85 »

I can not run debugger for Custom Makefile project, whenever I press F5 program exits immediately and there is no sign of my application's activity (nothing in logs etc.). I tried to insert a breakpoint without a result.

However if I run gdb from a command line, it works perfectly.

Here is the output in debug pane:
Using gdbinit file: /home/marcin/.gdbinit
Current working dir: /home/marcin/Codelite_project/workspace
Launching gdb from : /home/marcin/Codelite_project/applications/i686-linux-gnu-m32/MainApp
Starting debugger : gdb --tty=/dev/pts/8 --interpreter=mi "MainApp"
Debug session started successfully!
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
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.
This GDB was configured as "i686-linux-gnu".\nFor bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/marcin/Codelite_project/applications/i686-linux-gnu-m32/MainApp/MainApp...
done.
Successfully set breakpoint 1 at: /home/marcin/Codelite_project/applications/MainApp/MainApp.cpp:181
Continuing...
Program exited normally.
Debug session ended
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem running debugger for custom makefile project

Post by eranif »

Try and change the debuggee process from:
"MainApp"

into

"./MainApp"

From: Project Settings -> General Page (under 'Program to Run/Debug)

Eran
Make sure you have read the HOW TO POST thread
mass85
CodeLite Curious
Posts: 8
Joined: Sat Oct 29, 2011 5:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Problem running debugger for custom makefile project

Post by mass85 »

It didn't help. I got the same result although this command (similar to the one used by CodeLite) run in shell works:
gdb --interpreter=mi "MainApp"

but this one does not work:
gdb --interpreter=mi "./MainApp"

because gdb can not find such file.

So it is strange that I don't get the same output in CodeLite. Moreover if I configure some rubbish commands (i.e. foo) to be passed to the debugger on startup and after attaching to process (in Project settings -> Common settings -> Debugger), I can't see these commands in the debug pane.
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem running debugger for custom makefile project

Post by eranif »

There is a little check box at the top of the debugger output tab ("Enable fill debugger logging"), please tick it - it will give us much more information

Eran
Make sure you have read the HOW TO POST thread
mass85
CodeLite Curious
Posts: 8
Joined: Sat Oct 29, 2011 5:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Problem running debugger for custom makefile project

Post by mass85 »

Here is the new output:

Code: Select all

Using gdbinit file: /home/marcin/.gdbinit
Current working dir: /home/marcin/Codelite_project/workspace
Launching gdb from : /home/marcin/Codelite_project/applications/i686-linux-gnu-m32/MainApp
Starting debugger  : gdb --tty=/dev/pts/8 --interpreter=mi "./MainApp"
DEBUG>>set unwindonsignal on
DEBUG>>set breakpoint pending on
DEBUG>>set width 0
DEBUG>>set height 0
DEBUG>>set print elements 200
DEBUG>>foo
DEBUG>>00000102-break-insert "\"/home/marcin/Codelite_project/applications/MainApp/MainApp.cpp:181\""
Debug session started successfully!
DEBUG>>00000103-exec-arguments 
DEBUG>>00000104-exec-run 
DEBUG>>00000101^done,changelist=[]
DEBUG>>=thread-group-added,id="i1"
=thread-group-added,id="i1"
DEBUG>>~"GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2\n"
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
DEBUG>>~"Copyright (C) 2010 Free Software Foundation, Inc.\n"
Copyright (C) 2010 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 \"i686-linux-gnu\".\nFor bug reporting instructions, please see:\n"
This GDB was configured as "i686-linux-gnu".\nFor bug reporting instructions, please see:
DEBUG>>~"<http://www.gnu.org/software/gdb/bugs/>...\n"
<http://www.gnu.org/software/gdb/bugs/>...
DEBUG>>~"Reading symbols from /home/marcin/Codelite_project/applications/i686-linux-gnu-m32/MainApp/MainApp..."
Reading symbols from /home/marcin/Codelite_project/applications/i686-linux-gnu-m32/MainApp/MainApp...
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>>&"foo\n"
DEBUG>>&"Undefined command: \"foo\".  Try \"help\".\n"
DEBUG>>^error,msg="Undefined command: \"foo\".  Try \"help\"."
^error,msg="Undefined command: \"foo\".  Try \"help\"."
DEBUG>>00000102^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0805d460",func="main(int, char**)",file="MainApp/MainApp.cpp",fullname="/home/marcin/Codelite_project/applications/MainApp/MainApp.cpp",line="181",times="0",original-location="\"/home/marcin/Codelite_project/applications/MainApp/MainApp.cpp:181"}
Found the breakpoint ID!
Storing debugger breakpoint Id=1
Successfully set breakpoint 1 at: /home/marcin/Codelite_project/applications/MainApp/MainApp.cpp:181
DEBUG>>00000103^done
DEBUG>>=thread-group-started,id="i1",pid="27609"
=thread-group-started,id="i1",pid="27609"
DEBUG>>=thread-created,id="1",group-id="i1"
=thread-created,id="1",group-id="i1"
DEBUG>>00000104^running
Continuing...
DEBUG>>*running,thread-id="all"
*running,thread-id="all"
DEBUG>>=library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2",host-name="/lib/ld-linux.so.2",symbols-loaded="0",thread-group="i1"
=library-loaded,id="/lib/ld-linux.so.2",target-name="/lib/ld-linux.so.2",host-name="/lib/ld-linux.so.2",symbols-loaded="0",thread-group="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>>*stopped,reason="exited",exit-code="0177"
Program exited normally.
DEBUG>>00000105-var-update "*" 
Debug session ended
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem running debugger for custom makefile project

Post by eranif »

A quick questions:

can you post the snippet of code where you place your breakpoint?
Is it placed at the first line of code?

Eran
Make sure you have read the HOW TO POST thread
mass85
CodeLite Curious
Posts: 8
Joined: Sat Oct 29, 2011 5:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Problem running debugger for custom makefile project

Post by mass85 »

Code: Select all

int main(int argc, char *argv[]) {
     check_ver_arg(argc, argv);   // breakpoint
...
/* 
Initialisation of program. Start of threads
*/
}
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem running debugger for custom makefile project

Post by eranif »

Ok, here is your problem:
codelite places a breakpoint at the first line in the main function, however you set one too...
so when this breakpoint hits, codelite applies the user breakpoints and hit the 'Continue'.. so since you probably don't have other breakpoints - your programs runs until it exits.

To disable this functionality, go to the menu:
Settings | Debugger Settings | GNU gdb debugger | General

and disable the option
'Apply breakpoints after main function is hit'

It should fix your problem
Eran
Make sure you have read the HOW TO POST thread
mass85
CodeLite Curious
Posts: 8
Joined: Sat Oct 29, 2011 5:43 pm
Genuine User: Yes
IDE Question: c++
Contact:

Re: Problem running debugger for custom makefile project

Post by mass85 »

Unfortunately it does not fix my problem. I had played with breakpoints and they never stopped the program. Moreover my program does not exit without logging anything. It all looks like program didn't even start.

I've googled "exit code 0177" and I found this:
Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) b main
Breakpoint 1 at 0x8048a78: file helloworld.cpp, line 17.
(gdb) start
Breakpoint 2 at 0x8048a78: file helloworld.cpp, line 17.
Starting program: /home/tcmichals/examples/helloworld
/home/tcmichals/examples/helloworld: error while loading shared libraries: libb
ost_thread-gcc41-mt-d-1_35.so.1.35.0: cannot open shared object file: No such f
le or directory

Program exited with code 0177.
It is just an example but usually (or always) when 0177 is returned the problem was that some library was not found at start of application. Maybe in my case environment variables are not passed in the right way? How/where should I set them? Anyway it's strange that I don't get any error regarding file that was not found...
User avatar
eranif
CodeLite Plugin
Posts: 6372
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Problem running debugger for custom makefile project

Post by eranif »

mass85 wrote:It is just an example but usually (or always) when 0177 is returned the problem was that some library was not found at start of application. Maybe in my case environment variables are not passed in the right way? How/where should I set them? Anyway it's strange that I don't get any error regarding file that was not found...
How did you start codelite?

Did you try starting it from the shell? (simply: codelite &)
It should inherit the shell environment

Eran
Make sure you have read the HOW TO POST thread
Post Reply