Author Topic: Change the format in the debugger  (Read 5672 times)

Offline lordkrotos

  • Multiple posting newcomer
  • *
  • Posts: 11
Change the format in the debugger
« on: March 15, 2006, 07:40:24 pm »
Hi every body,

I am what we call a "noob" in c++ developpment, and also in english... So, please be indulgent!  :lol:

I've juste discover code::Blocks last week, and I'm afraid I can't do anything with it, because the format of watches in debugger mode in unreadable for me. Is there a way to change it in a more "human comprehensive" way?

Thanks

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Change the format in the debugger
« Reply #1 on: March 15, 2006, 08:10:36 pm »
can you give an example of your project and what you consider unreadable ??

Offline lordkrotos

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Change the format in the debugger
« Reply #2 on: March 15, 2006, 08:20:08 pm »
I wanted to say: un-understandable.
Here is the part of the code I want to watch:
//
  QTextStream in(&file);
        QString str;
        int i=0;
        while (!in.atEnd())
        {
           str =in.readLine();//
            i++;
        }
//

The debbuger tell me that str=0X11d9048 instead of d="a string".
Thank you

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5490
Re: Change the format in the debugger
« Reply #3 on: March 15, 2006, 08:25:19 pm »
yep ,those things are not completely possible, though you can do stuff things with scripting to have such things visible. I have looked very briefly at it, not enough on telling you how to do it, sorry.
I think in the (nightly) installation of CB there are some example scripts (fo example one fot std::string and wxstring), those might help you on creating one yourself.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Change the format in the debugger
« Reply #4 on: March 15, 2006, 08:26:42 pm »
(you did not state which version you use, but I assume a recent build)

Well... QString is some class, you cannot expect the debugger to know how to handle it. So what it does is, it shows a pointer to it.

In fact, the debugger in Code::Blocks is by default already being extremely nice because it decodes wxString as well as std::string and a couple of other STL classes. Most debuggers don't do that! :)

You should do a forum search, there is a thread describing how to add debugger scripts (I don't remember where). You can write a watch script to decode *any* kind of class, be it QString or RString or SString  :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline yop

  • Regular
  • ***
  • Posts: 387
Re: Change the format in the debugger
« Reply #5 on: March 15, 2006, 08:30:47 pm »
The debugger can only show you POD values (int char long etc.), you can't use it with QStrings. Take a look in my answers in http://www.qtcentre.org/forum/showthread.php?p=1965#post1965 to see a workaround that I haven't used with C::B but illustrates that you need to take some extra steps to show non POD values using gdb. mandrav has added support for wxStrings and other containers in the debugger using angelscript. It should be possible to add support for more. I'm used to ddd as a debugger frontend so I must admit I haven't used the C::B debugging capabilities that much, but who knows maybe I'll take a look at QString and some other Qt containers (QValueList, QMap etc.)
Life would be so much easier if we could just look at the source code.

Offline lordkrotos

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: Change the format in the debugger
« Reply #6 on: March 15, 2006, 08:49:05 pm »
Ok, thanks every body  , I will look at the debuggers scripts.

leandro

  • Guest
Re: Change the format in the debugger
« Reply #7 on: April 23, 2006, 07:53:07 pm »
Hi everybody... I have the following problem... I'm developing an application in C++ using Code::Blocks and QT Framework libraries... I have also read that in Code::Blocks there is the possibility to write scripts (I'm trying modifing the "gdb_types.script" file)... Super! Since I discovered this information I put my old IDE away and started to use only Code::Blocks... But I have a common problem... I would like to watch QString types variables as real strings and not as pointers like it was done with wxStrings. So I tried without success to adapt the original script file to support QString classes but I never used GDB from the command line(I always use frontends for GDB or another compiler/debug combination), and I didn't uderstand the logic implemented in the original script file for wxStrings, STL Vectors and so on... Is there some documentation explaining (a tutorial or an API) how to improve this script and solve this kind of question?

Thank you very much in advance