User forums > Using Code::Blocks

Debugging with TDM GCC 32bit + CodeBlocks- can't find member variables

<< < (2/3) > >>

TobiasA:
Python seems to be enabled since pretty printing works following the article here:
http://wiki.codeblocks.org/index.php?title=Pretty_Printers

It just won't do on a std::vector<custom_class>.

BlueHazzard:

--- Quote ---Settings->Debugger...->Debugger->Default->Enable Watch Scripts
--- End quote ---
WARNING: This is a pitfall. The scripts you are enabling here are codeblocks internal squirrel scripts. They are outdated and will be removed soon (probably next release). This option has to be turned off!!!
The way to go is to use python scripts from gdb. How to enable them is listed in the wiki article you have found.

The printers for stl are here: https://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python/libstdcxx/v6/printers.py
But they should be included in TDM-GCC-BASE-PATH\share\gcc-6.4.0\python\libstdcxx

The printers for wxWidgets data types: https://github.com/wxWidgets/wxWidgets/blob/master/misc/gdb/print.py

So if you write your gdb init script this should be the paths you are using.


--- Quote ---It just won't do on a std::vector<custom_class>.
--- End quote ---
This is a really bad error description.... At least provide a full gdb debugger log...


--- Quote --- If I disable the watch scripts, GDB doesn't lock up but of course I don't see the elements in my class.
--- End quote ---
You should see the class elements with (codeblocks)scripts disabled. Can you give us a minimal project/ code example you struggle with?

TobiasA:

--- Quote from: BlueHazzard on December 20, 2017, 05:23:02 pm ---
--- Quote ---Settings->Debugger...->Debugger->Default->Enable Watch Scripts
--- End quote ---
WARNING: This is a pitfall. The scripts you are enabling here are codeblocks internal squirrel scripts. They are outdated and will be removed soon (probably next release). This option has to be turned off!!!
The way to go is to use python scripts from gdb. How to enable them is listed in the wiki article you have found.

The printers for stl are here: https://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python/libstdcxx/v6/printers.py
But they should be included in TDM-GCC-BASE-PATH\share\gcc-6.4.0\python\libstdcxx

The printers for wxWidgets data types: https://github.com/wxWidgets/wxWidgets/blob/master/misc/gdb/print.py

So if you write your gdb init script this should be the paths you are using.


--- Quote ---It just won't do on a std::vector<custom_class>.
--- End quote ---
This is a really bad error description.... At least provide a full gdb debugger log...


--- Quote --- If I disable the watch scripts, GDB doesn't lock up but of course I don't see the elements in my class.
--- End quote ---
You should see the class elements with (codeblocks)scripts disabled. Can you give us a minimal project/ code example you struggle with?

--- End quote ---

I think that mentioned pitfall is my problem... Thanks for the advice, I will do so.

The bad thing is that I can't provide a gdb log since code::blocks freezes, making it impossible to copy & paste the log.
Based on what you said about the mentioned pitfall with the watch scripts, I think that this will solve the problem.

BlueHazzard:

--- Quote ---Qt Creator basically adds *this to the watches list. I tried it now, but I'm in a derived class (standard wxWidgets template) from GUIFrame:: and this fails halfway (parsing GDB output failed for "*this"), giving me only one member variable and the base class GUIFrame:: with all its members.
--- End quote ---
Can you give the error output? Or a minimal code example? Or the FULL gdb log? Something to work with and possibly fix it?
Note: You can use any c++ expression in the watches. So you can also cast the this pointer to any other (valid) derived class and it will evaluate. You can also use function calls and so on...
[Edit:]WARNING: But be careful: a invalid memory access will crash your program and it is not for sure you can continue debugging also if you remove the invalid expression from the watches.
Also have a look at this: https://stackoverflow.com/a/8529137 --> https://sourceware.org/gdb/onlinedocs/gdb/Print-Settings.html
You may type the

--- Code: ---set print object on
--- End code ---
in the gdb command line (the text entry field below the debugger log). Or add it to the init commands in the settings

TobiasA:
EDIT: Don't read this wall of text, read my next post. The solution is so simple... Once you know it.

So I disabled the watch script. GDB says it already registered this printer, so this should be OK. The TDM GCC comes with full python support right out of the box as it seems.
Didn't add the wxwidgets printer yet, but I didn't want to bring too much complexity to my problem if STL still doesn't work right.
I also tried adding my own pp.gdb to the startup line for gdb- but the printer for STL is already registered.
The type is recognized now, but the data fields are not.
Well, the good thing is that I've never ever came so far as now. That watch script was the big pitfall, now I'm not so far away of having working. I just need to figure out how to access the elements of a vector.
Also, the "*this" hint was one big step forward.

And a really minimum example that shows it can be found in another thread:
http://forums.codeblocks.org/index.php/topic,21998.15.html
That isn't my problem though since I'm using the python-enabled TDM GCC already setup for GCC.
However, they provide a true minimum sample.

--- Code: ---#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<double> test;
    test.push_back( 22.44 );
    test.push_back( 1.3795933261199322e-306 );

    cout << "Hello world!" << endl;
    return 0;
}

--- End code ---

Which gives me the output of the png attached. I had expected to read at least the size of the vector if the content cannot be parsed because it is some custom class. At least that is how other IDE's (read: GDB implementations) handle it.
The gdb output for this minimum example is:

--- Code: ---Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: C:\Users\Adams\Documents\CodeBlocks\consoletestproject\
Adding source dir: C:\Users\Adams\Documents\CodeBlocks\consoletestproject\
Adding file: C:\Users\Adams\Documents\CodeBlocks\consoletestproject\bin\Debug\consoletestproject.exe
Changing directory to: C:/Users/Adams/Documents/CodeBlocks/consoletestproject/.
Set variable: PATH=.;C:\TDM-GCC-32\bin;C:\TDM-GCC-32;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client;C:\Program Files\Intel\iCLS Client;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Skype\Phone;C:\Program Files\TortoiseSVN\bin

[debug]Command-line: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet  -args C:/Users/Adams/Documents/CodeBlocks/consoletestproject/bin/Debug/consoletestproject.exe
[debug]Working dir : C:\Users\Adams\Documents\CodeBlocks\consoletestproject

Starting debugger: C:\TDM-GCC-32\bin\gdb32.exe -nx -fullname -quiet  -args C:/Users/Adams/Documents/CodeBlocks/consoletestproject/bin/Debug/consoletestproject.exe
done

[debug]> set prompt >>>>>>cb_gdb:
[debug]Skip initializing the scripting!

Setting breakpoints

[debug]Reading symbols from C:/Users/Adams/Documents/CodeBlocks/consoletestproject/bin/Debug/consoletestproject.exe...done.
[debug](gdb) >>>>>>cb_gdb:
[debug]> show version
[debug]GNU gdb (GDB) 7.9.1
[debug]Copyright (C) 2015 Free Software Foundation, Inc.
[debug]License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
[debug]This is free software: you are free to change and redistribute it.
[debug]There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
[debug]and "show warranty" for details.
[debug]This GDB was configured as "mingw32".
[debug]Type "show configuration" for configuration details.
[debug]For bug reporting instructions, please see:
[debug]<http://www.gnu.org/software/gdb/bugs/>.
[debug]Find the GDB manual and other documentation resources online at:
[debug]<http://www.gnu.org/software/gdb/documentation/>.
[debug]For help, type "help".
[debug]Type "apropos word" to search for commands related to "word".
[debug]>>>>>>cb_gdb:
[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 7.9.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 0
[debug]>>>>>>cb_gdb:
[debug]> set new-console on
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor att
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory C:/Users/Adams/Documents/CodeBlocks/consoletestproject/
[debug]Source directories searched: C:/Users/Adams/Documents/CodeBlocks/consoletestproject;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "C:/Users/Adams/Documents/CodeBlocks/consoletestproject/main.cpp:15"
[debug]Breakpoint 2 at 0x40140a: file C:\Users\Adams\Documents\CodeBlocks\consoletestproject\main.cpp, line 15.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: C:\Users\Adams\Documents\CodeBlocks\consoletestproject\bin\Debug\consoletestproject.exe

Child process PID: 6408

[debug][New Thread 6408.0x1124]
[debug]Breakpoint 2, main () at C:\Users\Adams\Documents\CodeBlocks\consoletestproject\main.cpp:15
[debug]C:\Users\Adams\Documents\CodeBlocks\consoletestproject\main.cpp:15:248:beg:0x40140a
[debug]>>>>>>cb_gdb:

At C:\Users\Adams\Documents\CodeBlocks\consoletestproject\main.cpp:15

[debug]> info locals
[debug]test = {<std::_Vector_base<double, std::allocator<double> >> = {_M_impl = {<std::allocator<double>> = {<__gnu_cxx::new_allocator<double>> = {<No data fields>}, <No data fields>}, _M_start = 0x711650, _M_finish = 0x711660, _M_end_of_storage = 0x711660}}, <No data fields>}
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]No arguments.
[debug]>>>>>>cb_gdb:
[debug]> whatis foldingvector
[debug]No symbol "foldingvector" in current context.
[debug]>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  main () at C:\Users\Adams\Documents\CodeBlocks\consoletestproject\main.cpp:15
[debug]>>>>>>cb_gdb:

--- End code ---
You should however ignore that foldingvector entry, this was still written in my watchlist.

However, what is interesting is that in the other thread, someone commanded "whatis test[0]" but this gives me the following log:

--- Code: ---[debug]> whatis test[0]
[debug]Could not find operator[].
[debug]>>>>>>cb_gdb:

Could not find operator[].

--- End code ---

And "output test" gives:

--- Code: ---[debug]> output test
[debug]{<std::_Vector_base<double, std::allocator<double> >> = {_M_impl = {<std::allocator<double>> = {<__gnu_cxx::new_allocator<double>> = {<No data fields>}, <No data fields>}, _M_start = 0x711650, _M_finish = 0x711660, _M_end_of_storage = 0x711660}}, <No data fields>}>>>>>>cb_gdb:

{<std::_Vector_base<double, std::allocator<double> >> = {_M_impl = {<std::allocator<double>> = {<__gnu_cxx::new_allocator<double>> = {<No data fields>}, <No data fields>}, _M_start = 0x711650, _M_finish = 0x711660, _M_end_of_storage = 0x711660}}, <No data fields>}

--- End code ---

I think this is the root of the problem..?
To be honest I am lost completely why this seems to work on some systems and on others, it doesn't.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version