Author Topic: Debugging cursor disappearing  (Read 16872 times)

Offline Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Debugging cursor disappearing
« on: November 06, 2011, 05:53:21 pm »
Hello and thank you for reading my post,

My question is about debugging my program from inside Code::Blocks (using "gdb").
When I start debugging and after a few successful steps, the debugging cursor disappears and I have to press the F7 key dozens of times before it reappears.

Nota 1: It happens when I call a method from a library which source code I do not have.
Nota 2: I am using the "-g" option to build my project but maybe this is not enough... ?

Can you help me?
Best regards,
--
Léa

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #1 on: November 06, 2011, 07:05:41 pm »
If you're not using the debugger's branch nightly, please try it. Then if the behaviour is the same, we will dig deeper what is the problem.

Please next time you post about a problem, mention in your post the OS/C::B version/Compiler/Debugger version.
Without them we could hardly help you sometimes.
(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 Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #2 on: November 07, 2011, 12:57:15 am »
@oBFusCATed : Thank you for your answer.

OS: Debian GNU/Linux 6.0.3 (squeeze)
C::B version: 10.05
Compiler version: GNU GCC Compiler
Debugger version: GNU GDB

Quote
If you're not using the debugger's branch nightly, please try it.
I've never done this before. Can you provide some more details/instructions?

I have a given instruction which requires seventeen F7 key presses before I can go to the next instruction (line).

Best regards,
--
Léa

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #3 on: November 07, 2011, 01:11:51 am »
Here is the info how to install the latest nightly build version: http://forums.codeblocks.org/index.php/topic,15440.msg103649.html#msg103649

BTW: Sometimes we are interested in the version numbers, too, GCC and GDB have 20 years of history as projects.
(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 Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #4 on: November 07, 2011, 01:17:29 am »
OS: Debian GNU/Linux 6.0.3 (squeeze)
C::B version: 10.05
Compiler version (> gcc --version): gcc (Debian 4.4.5-8) 4.4.5
Debugger version (> gdb --version): GNU gdb (GDB) 7.0.1-debian

Offline Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #5 on: November 12, 2011, 03:07:10 pm »
Hello oBFusCATed,

I have followed your link: http://forums.codeblocks.org/index.php/topic,15440.msg103649.html#msg103649
Then, in Jens' post, I followed the link: http://apt.jenslody.de/pool/dbg/c/codeblocks/

Here are my questions:

1)What shall I download?
- codeblocks_10.05dbg7549-1_amd64.deb?
- codeblocks-dbg_10.05dbg7549-1_amd64.deb?
- ...?

2) How is it going to impact my current C::B installation?

3) Will I be able to remove this branch properly afterwards (without breaking what already exists)?

Best regards,
--
Léa
Code
-------------------------------------------------------------------------------------------
Config.
-------------------------------------------------------------------------------------------
OS (> uname -a): Linux 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux
C::B version: 10.05
Compiler version (> gcc --version): gcc (Debian 4.4.5-8) 4.4.5
Debugger version (> gdb --version): GNU gdb (GDB) 7.0.1-debian
-------------------------------------------------------------------------------------------

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Debugging cursor disappearing
« Reply #6 on: November 12, 2011, 04:13:33 pm »
- codeblocks_10.05dbg7549-1_amd64.deb?
This one, unless you want to debug C::B itself.

2) How is it going to impact my current C::B installation?
You should uninstall any previous version before. You don't have parallel versions of other programs, too, do you?

3) Will I be able to remove this branch properly afterwards (without breaking what already exists)?
Sure, and you can (later on) re-install any other version.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #7 on: November 12, 2011, 04:36:59 pm »
@MortenMacFly : Hello and thank you for your answer.

Quote from: MortenMacFly
You don't have parallel versions of other programs, too, do you?
What do you mean? On some other computer, I have several different versions of a given program (ex. Apache Tomcat...)... why not with C::B? But maybe this is the notion of "parallel versions of a program"which I do not figure out properly...

Quote from: MortenMacFly
You should uninstall any previous version before.
Ok.
So, I totally don't know how to be sure that I'm going to properly uninstall C::B.
I installed C::B from the sources ("codeblocks-10.05-1debian-src.tar") and I ran the usual commands triplet (./configure, make, make install).
Can you tell me how to uninstall C::B properly now?
P.S. I'm quasi sure you're thinking this is not a C::B relevant question... not specific enough.
I am conscious of the fact that this is a general question.
But the fact is that it is with C::B I have this problem for the first time.

Thank you for helping.
Best regards,
--
Léa

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #8 on: November 12, 2011, 05:17:54 pm »
If you have the files of C::B in the state after the make install command, you can try with make uninstall.
Otherwise you should delete the files manually.

Then you just add Jens' repo to the source list, apt-get update; apt-get install codeblocks codeblock-contrib and you're done.
(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 Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #9 on: November 12, 2011, 11:17:04 pm »
Hello,
Thank you for your answer.

==================================================
C::B uninstall and install
==================================================
FYI, here is what I had to do (after the "make uninstall"):

In "/etc/apt/sources.list", I added the following lines:
Code
deb http://apt.jenslody.de/ any dbg
deb-src http://apt.jenslody.de/ any dbg
deb http://apt.wxwidgets.org/ lenny-wx main

Then I ran:
Code
> apt-get install jens-lody-debian-keyring
> wget -q http://apt.wxwidgets.org/key.asc -O-  | sudo apt-key add -

And finally:
Code
> apt-get update
> apt-get install codeblocks codeblocks-contrib

Cf. instructions in: http://apt.jenslody.de/
+ some literature: http://wiki.debian.org/SecureApt
==================================================

Now I can run the new C::B properly.

If I put a breakpoint in front of my target instruction and start debugging, here is what I get:
- the debug cursor stops in front of the bp (ok),
- I press F7 seventeen times (the cursor is not moving, apart from a slight blink),
- here is what is printed in the "Debugger" view:
Code
[...]
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.0.1-debian
At /path/to/my/cb/project/main.cpp:40
In __cxa_throw () (/usr/lib/libstdc++.so.6)
#8  0x0000000000402b92 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
/path/to/my/cb/project/src/AClass.cpp:71:1299:beg:0x402b92
At /path/to/my/cb/project/src/AClass.cpp:71
#8  0x0000000000402b92 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
/path/to/my/cb/project/src/AClass.cpp:71:1299:beg:0x402b92
[...] sixteen times.
Program exited normally.
Debugger finished with status 0

Here it is.
Best regards,
--
Léa

Code
-------------------------------------------------------------------------------------------
Config.
-------------------------------------------------------------------------------------------
OS (> uname -a): Linux 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux
C::B version: svn build rev 7549 - SDK version: 1.12.10
Compiler version (> gcc --version): gcc (Debian 4.4.5-8) 4.4.5
Debugger version (> gdb --version): GNU gdb (GDB) 7.0.1-debian
-------------------------------------------------------------------------------------------

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #10 on: November 12, 2011, 11:43:02 pm »
Can you paste the debugger's debug log? You should enable it in Settings->Debugger->Common.
(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 Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #11 on: November 13, 2011, 12:11:13 am »
Here it is...

Code
LD_LIBRARY_PATH=.:/usr/local/dbxml-2.5.16/install/lib:/usr/local/lib/
Command-line: /usr/bin/gdb -nx -fullname  -quiet -args /path/to/my/cb/project/bin/Debug/my_cb_project
Working dir : /my/working/dir/my_cb_project
Reading symbols from /path/to/my/cb/project/bin/Debug/my_cb_project...done.
(gdb)
> set prompt >>>>>>cb_gdb:
>>>>>>cb_gdb:
> show version
GNU gdb (GDB) 7.0.1-debian
Copyright (C) 2009 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-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 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:
> directory /path/to/my/cb/project/
>>>>>>cb_gdb:
> run
[Thread debugging using libthread_db enabled]
Catchpoint 1 (exception thrown), 0x00007ffff6678230 in __cxa_throw () from /usr/lib/libstdc++.so.6
>>>>>>cb_gdb:
> bt 30
#0  0x00007ffff6678230 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1  0x00007ffff6e9a234 in DbXml::SyntaxDatabase::SyntaxDatabase(DbXml::Syntax const*, __db_env*, DbXml::Transaction*, std::string const&, bool, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#2  0x00007ffff6e405ae in DbXml::Container::openIndexDbs(DbXml::Transaction*, DbXml::ContainerConfig const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#3  0x00007ffff6e45dc0 in DbXml::Container::openInternal(DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#4  0x00007ffff6e47d7a in DbXml::Container::Container(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#5  0x00007ffff6e80fdb in DbXml::Manager::ContainerStore::findContainer(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#6  0x00007ffff6e81183 in DbXml::Manager::openContainer(std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#7  0x00007ffff6eabf48 in DbXml::XmlManager::createContainer(std::string const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
#9  0x00000000004022d2 in main (argc=1, argv=0x7fffffffe308) at /path/to/my/cb/project/main.cpp:40
>>>>>>cb_gdb:
> frame 8
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
/path/to/my/cb/project/src/AClass.cpp:71:1299:beg:0x402af2
>>>>>>cb_gdb:
> next
Single stepping until exit from function __cxa_throw,
which has no line number information.
Catchpoint 1 (exception thrown), 0x00007ffff6678230 in __cxa_throw () from /usr/lib/libstdc++.so.6
>>>>>>cb_gdb:
> bt 30
#0  0x00007ffff6678230 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1  0x00007ffff6e9a234 in DbXml::SyntaxDatabase::SyntaxDatabase(DbXml::Syntax const*, __db_env*, DbXml::Transaction*, std::string const&, bool, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#2  0x00007ffff6e405ae in DbXml::Container::openIndexDbs(DbXml::Transaction*, DbXml::ContainerConfig const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#3  0x00007ffff6e45dc0 in DbXml::Container::openInternal(DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#4  0x00007ffff6e47d7a in DbXml::Container::Container(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#5  0x00007ffff6e80fdb in DbXml::Manager::ContainerStore::findContainer(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#6  0x00007ffff6e81183 in DbXml::Manager::openContainer(std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#7  0x00007ffff6eabf48 in DbXml::XmlManager::createContainer(std::string const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
#9  0x00000000004022d2 in main (argc=1, argv=0x7fffffffe308) at /path/to/my/cb/project/main.cpp:40
>>>>>>cb_gdb:
> frame 8
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
/path/to/my/cb/project/src/AClass.cpp:71:1299:beg:0x402af2
>>>>>>cb_gdb:
> bt 30
#0  0x00007ffff6678230 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1  0x00007ffff6e9a234 in DbXml::SyntaxDatabase::SyntaxDatabase(DbXml::Syntax const*, __db_env*, DbXml::Transaction*, std::string const&, bool, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#2  0x00007ffff6e405ae in DbXml::Container::openIndexDbs(DbXml::Transaction*, DbXml::ContainerConfig const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#3  0x00007ffff6e45dc0 in DbXml::Container::openInternal(DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#4  0x00007ffff6e47d7a in DbXml::Container::Container(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#5  0x00007ffff6e80fdb in DbXml::Manager::ContainerStore::findContainer(DbXml::Manager&, std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#6  0x00007ffff6e81183 in DbXml::Manager::openContainer(std::string const&, DbXml::Transaction*, DbXml::ContainerConfig const&, bool) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#7  0x00007ffff6eabf48 in DbXml::XmlManager::createContainer(std::string const&) () from /usr/local/dbxml-2.5.16/install/lib/libdbxml-2.5.so
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
#9  0x00000000004022d2 in main (argc=1, argv=0x7fffffffe308) at /path/to/my/cb/project/main.cpp:40
>>>>>>cb_gdb:
> frame 8
#8  0x0000000000402af2 in AClass::aMethod (this=0x60bd60) at /path/to/my/cb/project/src/AClass.cpp:71
/path/to/my/cb/project/src/AClass.cpp:71:1299:beg:0x402af2
>>>>>>cb_gdb:
> next
Single stepping until exit from function __cxa_throw,
which has no line number information.
[...] (sixteen times)
END OF aMethod()
END
Program exited normally.
>>>>>>cb_gdb:
> quit

It's not clear to me what's wrong...
Thanks and best regards,
--
Léa

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #12 on: November 13, 2011, 12:27:57 am »
You've hit an exception and C::B is catching it. Then it switches to the first valid frame.
But if you use the step command it doesn't continue to to the next line, but to the next line in the frame0, which is up in the stack, but you don't have sources for it.
You have two solutions here:
1. disable the catch c++ exceptions option
2. disable the option to switch to the first valid frame
(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 Léa Massiot

  • Multiple posting newcomer
  • *
  • Posts: 39
Re: Debugging cursor disappearing
« Reply #13 on: November 13, 2011, 01:07:34 pm »
Hello,
Thank you for your answer.

Quote from: oBFusCATed
You've hit an exception and C::B is catching it. Then it switches to the first valid frame. But if you use the step command it doesn't continue to the next line, but to the next line in the frame0, which is up in the stack, but you don't have sources for it.
Ok. I see. Thank you for this explanation.



Can you please have a look at the code below?
This is the "createContainer()" method which throws an exception.
Code
void AClass::aMethod()
{
        std::string s_wholeFileName = "";
        s_wholeFileName.append(ms_containerPathName);
        s_wholeFileName.append(ms_containerName);

        try
        {
                XmlManager   xmlManager;
                XmlContainer xmlContainer = xmlManager.createContainer(s_wholeFileName);
        }
        catch(XmlException &xe)
        {
                std::cout << "XmlException: "
                          << xe.what()
                          << std::endl;
        }
        catch(...)
        {
                std::cout << "Something went wrong."
                          << std::endl;
        }

        std::cout << "END OF aMethod()"
                  << std::endl;
}
Question 1: As an exception is being thrown (and since it's not a "XmlException"), shouldn't "we" go inside the "catch(...)" block (which is not what happens)?
Question 2: As you can see, I am outputing to "std::cout" but I can't see anything in the "Debugger" view. Where can I check for these outputs?

Quote from: oBFusCATed
You have two solutions here:
1. disable the catch c++ exceptions option
2. disable the option to switch to the first valid frame
Well, I'm concerned about this exception being thrown.
What I do not understand is that an exception is being thrown and yet the program "exits normally" and it doesn't even go through the "catch(...)" block...
This is confusing to me.

1. I disabled the catch C++ exceptions option.
Code
Settings -> Debugger -> GDB debugger -> Default
Uncheck the "Catch C++ exceptions" check box.
And indeed the problem disappears.

2. I re-enabled the "Catch C++ exceptions" option and disabled the option to switch to the first valid frame.
Code
Settings -> Debugger
Uncheck the "When stopping, auto-switch to the first frame with valid source info" check box.
It is telling me:
Code
Unknown file: /usr/lib/libstdc++.so.6
In __cxa_throw () (/usr/lib/libstdc++.so.6)
But the file  "/usr/lib/libstdc++.so.6" exists.

Can you help?
Best regards,
--
Léa

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Debugging cursor disappearing
« Reply #14 on: November 13, 2011, 01:14:23 pm »
/usr/lib/libstdc++.so.6 is shared library and there is no source for it...
(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!]