User forums > Using Code::Blocks

Showing vector elements in debugger

(1/11) > >>

nji:
I'm using codeblocks in its actual release (16.01) with tdm mingw 4.9.2 @ Win7Prof64.
When debugging I need to see the contents of a std::vector<double>.
For example: myVector [2].
No matter if I add myVector to the watches ... or then "properties" ("watch as array"),
or if I watch myVector [2] directly ... no success in showing the value,
only quite useless internal information.
Of course I found some threads about that in the forum, but all seem quite old,
some quite arrogant, pointing to nowhere, and very confusing for a newbie like me.
Looks like codeblock is not able to show the info from gdb (Although vector etc.
are c++ standard since years!)
And therefore a python script is needed. And for that python has to be "activated"
while building gdb itself (which is not the case for the windows binaries).
While the latter one seems refused by mingw developers because python project
doesn't cooperate. A cul-de-sac.
And even if all this would work, one would have to do further
steps to build and include gdb-command scripts etc.
If I get it right.
CAN THIS BE POSSIBLE?
Or is it a joke?
In the year 2017 you have to printf to debug a c++ standard element, when using
codeblock/ gcc?
It would be nice if someone could lighten the matter up.
Are there simple steps ... for all the ones who want to change from M$.
Or will the next release of codeblocks do it all by itself?
The situation as it presents now (and not only this example) is quite deterrent.
Which is a pity.
Thank you for hints.

BlueHazzard:
What i have done and it seems to work:
1) Use a python enabled gdb. I don't know but i think the tdm gcc has python enabled
2) In Settings->Debugger->GDB/CDB debugger->Default->Debugger initilization commands:
 
--- Code: ---python
import sys
sys.path.insert(0, 'PATH_TO_TDM\share\gcc-4.9.2\python')
from libstdcxx.v6.printers import register_libstdcxx_printers
end
--- End code ---
3) make sure you have deactivated "Enable watch scripts"

If you have trouble:
Activate full debugger logging: In Settings->Debugger->GDB/CDB debugger->Common->Full (Debug) log
and post the log here inside code tags (the # symbol in the new post editor)


--- Quote ---CAN THIS BE POSSIBLE?
Or is it a joke?
In the year 2017 you have to printf to debug a c++ standard element, when using
codeblock/ gcc?
--- End quote ---
See it as learning.. If you know the things behind all this you will get a better programmer


--- Quote ---Or will the next release of codeblocks do it all by itself?
--- End quote ---
Don't know... The team abandoned the internal scripting and decided to use the gdb internal python scripting. If you use a compiler that has no python support cb could not do anything about this... In general this are gdb problems and not really codeblocks problems ;)

nji:

--- Quote from: BlueHazzard on June 22, 2017, 11:25:51 am ---What i have done and it seems to work:
1) Use a python enabled gdb. I don't know but i think the tdm gcc has python enabled

--- End quote ---
No unfortunately NOT.
If I do the test from http://wiki.codeblocks.org/index.php?title=Pretty_Printers
my gdb says that python scripting is deactivated.
And if I search deeper for a python activated gdb I get lost. More and more problems arise.
(Install special versions of mingw etc.)
As I said already - a cul de sac this way.

BlueHazzard:
From this side, it tells me that tdm gcc has python enabled gdb

http://tdm-gcc.tdragon.net/index.php/

This should be the download link
http://sourceforge.net/projects/tdm-gcc/files/GDB/gdb32-7.9.1-tdm-1.zip/download
it should be possible to simply copy this version over your installed version..

nji:
In the actual codeblock package (v. 16.01) there is gdb v. 7.6.1, and there python is NOT enabled.
Due to your hint to the tdm site, (up from?) v. 7.9.1. python is enabled.

OK ... I copied the new version of gdb over the installed version und entered the new name gdb(server)32.exe instead of gdb(server).exe into cb's setting. Then startet the db and added "diffVector [2]" to the watch window. The output:
(__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type &) @0x147f660: <error reading variable>

diffVector shows same as before.


--- Code: ---Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: D:\Guido\develop\TestMovieIn\
Adding source dir: D:\Guido\develop\TestMovieIn\
Adding file: D:\Guido\develop\TestMovieIn\bin\Debug\TestMovieIn.exe
Changing directory to: D:/Guido/develop/TestMovieIn/.
Set variable: PATH=.;D:\Guido\develop\opencv\build_codeblocks\install\x86\mingw\lib;C:\Program Files (x86)\CodeBlocks\MinGW\bin;C:\Program Files (x86)\CodeBlocks\MinGW;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\Windows Live\Shared

[debug]Command-line: C:\Program Files (x86)\CodeBlocks\MinGW\bin\gdb32.exe -nx -fullname -quiet  -args D:/Guido/develop/TestMovieIn/bin/Debug/TestMovieIn.exe
[debug]Working dir : D:\Guido\develop\TestMovieIn

Starting debugger: C:\Program Files (x86)\CodeBlocks\MinGW\bin\gdb32.exe -nx -fullname -quiet  -args D:/Guido/develop/TestMovieIn/bin/Debug/TestMovieIn.exe
done

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

Setting breakpoints

[debug]Reading symbols from D:/Guido/develop/TestMovieIn/bin/Debug/TestMovieIn.exe...
[debug]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]> python
import sys
sys.path.insert(0, 'C:\Program Files (x86)\CodeBlocks\MinGW\share\gcc-4.9.2\python')
from libstdcxx.v6.printers import register_libstdcxx_printers
end
[debug]>>>>>>>>>>cb_gdb:
[debug]> directory D:/Guido/develop/TestMovieIn/
[debug]Source directories searched: D:/Guido/develop/TestMovieIn;$cdir;$cwd
[debug]>>>>>>cb_gdb:
[debug]> break "D:/Guido/develop/TestMovieIn/main.cpp:38"
[debug]Breakpoint 2 at 0x401579: file D:\Guido\develop\TestMovieIn\main.cpp, line 38.
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]Starting program: D:\Guido\develop\TestMovieIn\bin\Debug\TestMovieIn.exe

Child process PID: 4544

[debug][New Thread 4544.0x114c]
[debug][New Thread 4544.0x13dc]
[debug][Switching to Thread 4544.0x13dc]
[debug]Breakpoint 2, ComputePart (source=..., diffVector=..., nLap=@0x55f2ce: 20, nThreads=@0x4d1fe48: 1, nThreadNo=@0x55f2c8: 0) at D:\Guido\develop\TestMovieIn\main.cpp:38
[debug]D:\Guido\develop\TestMovieIn\main.cpp:38:1231:beg:0x401579
[debug]>>>>>>cb_gdb:

At D:\Guido\develop\TestMovieIn\main.cpp:38

[debug]> info locals
[debug]capt = <incomplete type>
[debug]refS = {width = 1280, height = 720}
[debug]frame = {flags = 1124007936, dims = 0, rows = 0, cols = 0, data = 0x0, datastart = 0x0, dataend = 0x0, datalimit = 0x0, allocator = 0x0, u = 0x0, size = {p = 0x4d1fcb0}, step = {p = 0x4d1fcd8, buf = {0, 0}}}
[debug]s = {<cv::Vec<double, 4>> = {<cv::Matx<double, 4, 1>> = {val = {0, 0, 0, 0}}, <No data fields>}, <No data fields>}
[debug]frameRes = {flags = 1124007936, dims = 0, rows = 0, cols = 0, data = 0x0, datastart = 0x0, dataend = 0x0, datalimit = 0x0, allocator = 0x0, u = 0x0, size = {p = 0x4d1fce8}, step = {p = 0x4d1fd10, buf = {0, 0}}}
[debug]frameDuo = {_M_elems = {{flags = 1124007936, dims = 0, rows = 0, cols = 0, data = 0x0, datastart = 0x0, dataend = 0x0, datalimit = 0x0, allocator = 0x0, u = 0x0, size = {p = 0x4d1fd20}, step = {p = 0x4d1fd48, buf = {0, 0}}}, {flags = 1124007936, dims = 0, rows = 0, cols = 0, data = 0x0, datastart = 0x0, dataend = 0x0, datalimit = 0x0, allocator = 0x0, u = 0x0, size = {p = 0x4d1fd58}, step = {p = 0x4d1fd80, buf = {0, 0}}}}}
[debug]frameNum = 0
[debug]>>>>>>cb_gdb:
[debug]> info args
[debug]source = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x55f27c "26229.wmv"}}
[debug]diffVector = @0x28fecc: {<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 = 0x1c19678, _M_finish = 0x1c19678, _M_end_of_storage = 0x1c80850}}, <No data fields>}
[debug]nLap = @0x55f2ce: 20
[debug]nThreads = @0x4d1fe48: 1
[debug]nThreadNo = @0x55f2c8: 0
[debug]>>>>>>cb_gdb:
[debug]> whatis diffVector
[debug]type = std::vector<double, std::allocator<double> > &
[debug]>>>>>>cb_gdb:
[debug]> output diffVector
[debug](std::vector<double, std::allocator<double> > &) @0x28fecc: {<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 = 0x1c19678, _M_finish = 0x1c19678, _M_end_of_storage = 0x1c80850}}, <No data fields>}>>>>>>cb_gdb:
[debug]> whatis diffVector [2]
[debug]type = std::vector<double, std::allocator<double> >::reference
[debug]>>>>>>cb_gdb:
[debug]> output diffVector [2]
[debug](__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type &) @0x147f660: 1.3795933261199322e-306>>>>>>cb_gdb:

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version