Author Topic: Debugging problem in a console application with ncurses library. Old question..  (Read 7058 times)

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
I encounterd a problem which is similar to 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..

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
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)?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
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)


Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Please reread my post, I want the other log :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
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?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
My machine?

I am using a VMware virtual machine.

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
Is starting of the terminal a slow operation?

Yes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
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
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline kyokof

  • Single posting newcomer
  • *
  • Posts: 8
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.