Code::Blocks Forums

User forums => Help => Topic started by: kyokof on July 23, 2010, 04:00:28 pm

Title: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 23, 2010, 04:00:28 pm
I encounterd a problem which is similar to http://forums.codeblocks.org/index.php/topic,8810.0.html (http://forums.codeblocks.org/index.php/topic,8810.0.html).

The demo programme is this
   
    initscr();
    printw("Hello World !!!");     
    refresh(); 
    getch();
    endwin();

I build it with -g and without any other parameters.
I can execute this with "run" and it works fine.
When I use "Debug", the console gives me "warning: GDB: Failed to set controlling terminal:" and no "hello world" appears.
If I use gdb without codeblocks, everything works fine.

My CB version is 10.5.
Fedora core version is 13.
GDB version is 7.1-30.

Thanks a lot..
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: oBFusCATed on July 23, 2010, 04:36:27 pm
Please provide the debugger's debug log (settings -> compiler & debugger -> debugger -> show debuggers debug log)
Do you have xterm or something similar installed and configured (there is a config option for the terminal CB should use)?
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 24, 2010, 06:01:59 am
debug log is here:

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: /tmp/ConsoleTest/
Adding source dir: /tmp/ConsoleTest/
Adding file: bin/Debug/ConsoleTest
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) Fedora (7.1-30.fc13)

Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 24, 2010, 06:04:23 am
I have install xterm, gnome-terminal, terminator.
None of them could work properly under debug mode.

The parameters of "Terminal to launch console programs" is one of there:
gnome-terminal -t $TITLE -x
xterm -T $TITLE -e
terminator -T $TITLE -x
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: oBFusCATed on July 24, 2010, 09:02:30 pm
Please reread my post, I want the other log :)
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 25, 2010, 10:29:50 am
LD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args bin/Debug/ConsoleTest
Working dir : /tmp/ConsoleTest/
Reading symbols from /tmp/ConsoleTest/bin/Debug/ConsoleTest...done.
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: gnome-terminal -t 'Program Console' -x sleep 96110
>>>>>>cb_gdb:
> show version
GNU gdb (GDB) Fedora (7.1-30.fc13)
Copyright (C) 2010 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 "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory /tmp/ConsoleTest/
>>>>>>cb_gdb:
> tty /dev/pts/4
>>>>>>cb_gdb:
Executing: ps x -o tty,pid,command
PS result: ?        16170 ps x -o tty,pid,command
PS result: pts/2    16168 sleep 96110
TTY is[/dev/pts/2]
GetConsoleTTY[/dev/pts/2]ConsolePid[16167]
> tty /dev/pts/2
Queued:[tty /dev/pts/2]
>>>>>>cb_gdb:
> run
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: oBFusCATed on July 25, 2010, 11:01:59 am
Code
LD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args bin/debug/ncurses_app
Working dir : /home/obfuscated/projects/tests/ncurses_app/
Reading symbols from /home/obfuscated/projects/tests/ncurses_app/bin/debug/ncurses_app...done.
(gdb)
> set prompt >>>>>>cb_gdb:
>>>>>>cb_gdb:
> show version
GNU gdb (Gentoo 7.1 p1) 7.1
Copyright (C) 2010 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 "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set print elements -1
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> set print static-members off
source ~/.gdbinit
>>>>>>cb_gdb:>>>>>>cb_gdb:
> directory /home/obfuscated/projects/tests/ncurses_app/
>>>>>>cb_gdb:
> tty /dev/pts/4
Queued:[tty /dev/pts/4]
>>>>>>cb_gdb:
> run
Here is the output from my working example. Looks quite the same.
You'll have to debug C::B in order to find what is wrong, sorry but it works for me.
What is your machine? Is starting of the terminal a slow operation?
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 25, 2010, 01:31:22 pm
My machine?

I am using a VMware virtual machine.
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 25, 2010, 01:33:15 pm
Is starting of the terminal a slow operation?

Yes.
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: oBFusCATed on July 25, 2010, 05:41:42 pm
See here:
http://forums.codeblocks.org/index.php/topic,12678.msg86878.html#msg86878

http://forums.codeblocks.org/index.php/topic,12856.0.html
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 26, 2010, 04:41:23 pm
I solved this problem.

I start CB from console and everything is OK.

debug log is here:

LD_LIBRARY_PATH=.:
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args bin/Debug/ConsoleTest
Working dir : /tmp/ConsoleTest/
Reading symbols from /tmp/ConsoleTest/bin/Debug/ConsoleTest...
done.
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: gnome-terminal -t 'Program Console' -x sleep 96278
>>>>>>cb_gdb:
> show version
GNU gdb (GDB) Fedora (7.1-30.fc13)
Copyright (C) 2010 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 "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory /tmp/ConsoleTest/
>>>>>>cb_gdb:
> tty /dev/pts/4
>>>>>>cb_gdb:
Executing: ps x -o tty,pid,command
PS result: pts/0    16310 ps x -o tty,pid,command
PS result: pts/1    16308 sleep 96278
TTY is[/dev/pts/1]
GetConsoleTTY[/dev/pts/1]ConsolePid[16307]
> tty /dev/pts/1
Queued:[tty /dev/pts/1]
>>>>>>cb_gdb:
> run
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: oBFusCATed on July 26, 2010, 05:13:31 pm
Hm, can you try to specify the full path to xterm in "Terminal to launch console programs" ?

p.s. please use the code tags to surround your logs
Title: Re: Debugging problem in a console application with ncurses library. Old question..
Post by: kyokof on July 27, 2010, 07:24:44 am
I will use code tag next time.

"Hm, can you try to specify the full path to xterm"
I will try it later. 

I used to start CB from double-click CB icon and it didn't work fine.
Yesterday, I start CB from console and everything is OK.