Author Topic: Showing vector elements in debugger  (Read 1779 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 4910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Showing vector elements in debugger
« Reply #45 on: June 25, 2017, 03:51:37 pm »
@ollydbg:
does it make sense to provide the python dll within your gdb download? Are there dependencies to other dlls (from python27.dll to other) too?
What if there is a python27.dll in the bin folder and one in the system folder? What version gets picked?
I see the frustration of the OP and i would like to do something against it...
Copying only a dll file is not enough, you have to copy all the folders(such as the folder named "Lib" under python installed folder) to your GDB's bin folder. This will make the distribution a lot bigger, my personally python have a lot of non-standard packages installed in the "Lib" folder, so I don't want to to distribute the python, installing python is quite simple under Windows, just download the official python installer.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Online stahta01

  • Lives here!
  • ****
  • Posts: 5846
    • My Best Post
Re: Showing vector elements in debugger
« Reply #46 on: June 25, 2017, 05:50:32 pm »
Banned?  :-\

Will you come with me?



Usually I don't explain my points ...
But for you I will do an exception:
Yes, I will take you for serious ...
... as soon as you do mature.
I always tried to explain/ to give reason for what I wrote above.
I can't imagine of anything more revealing weakness than the threat of a bann.
Oh man ...

If you do NOT consider it worth your time to look at the FAQs; then, I think you never read the rules!

Reading the rules after you are banned is NOT very useful.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Showing vector elements in debugger
« Reply #47 on: June 25, 2017, 06:00:39 pm »
@stahta01:
I couldn't have expressed it better.  :)

Copying only a dll file is not enough, you have to copy all the folders(such as the folder named "Lib" under python installed folder) to your GDB's bin folder. This will make the distribution a lot bigger, my personally python have a lot of non-standard packages installed in the "Lib" folder, so I don't want to to distribute the python, installing python is quite simple under Windows, just download the official python installer.

Does this mean that using the gdb binaries (v.7.9.1) from http://tdm-gcc.tdragon.net/download (at the bottom) will never be sufficient (although "includes Python support")?
I took this and copied everything into the existing structure ... and it works ... nearly (see description above).
« Last Edit: June 25, 2017, 06:23:46 pm by nji »

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1372
Re: Showing vector elements in debugger
« Reply #48 on: June 26, 2017, 10:27:37 am »
i tested now with the gdb from the tdm site and here are my results:
Code: [Select]
Active debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: ****rerreer\
Adding source dir: ****rerreer\
Adding file: ****rerreer\bin\Debug\rerreer.exe
Changing directory to: ****rerreer/.
Set variable: PATH=.####

[debug]Command-line: TDM-GCC-32\bin\gdb.exe -fullname -quiet -nx -args ****rerreer/bin/Debug/rerreer.exe
[debug]Working dir : ****rerreer

Starting debugger: TDM-GCC-32\bin\gdb.exe -fullname -quiet -nx -args ****rerreer/bin/Debug/rerreer.exe
done

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

Setting breakpoints

[debug]Reading symbols from ****rerreer/bin/Debug/rerreer.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 200
[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]> source TDM-GCC-32\bin\stl.gdb
source TDM-GCC-32\share\gcc-4.9.2\python\wx\wx_print.py
[debug]>>>>>>cb_gdb:register wxWudgets printer
[debug]> directory ****rerreer/
[debug]>>>>>>cb_gdb:
[debug]> break "****rerreer/main.cpp:10"
[debug]Source directories searched: ****rerreer;$cdir;$cwd
[debug]>>>>>>cb_gdb:Breakpoint 2 at 0x4013b2: file ****rerreer\main.cpp, line 10.

Source directories searched: ****rerreer;$cdir;$cwd

[debug]> run
[debug]>>>>>>cb_gdb:
[debug]> info frame
[debug]Starting program: ****rerreer\bin\Debug\rerreer.exe

Child process PID: 7072

[debug][New Thread 7072.0x11a0]
[debug]Breakpoint 2, main () at ****rerreer\main.cpp:10
[debug]****rerreer\main.cpp:10:137:beg:0x4013b2
[debug]>>>>>>cb_gdb:Stack level 0, frame at 0x28ff30:

At ****rerreer\main.cpp:10

[debug]> bt 30
[debug] eip = 0x4013b2 in main (****rerreer\main.cpp:10); saved eip = 0x4010fd
[debug] source language c++.
[debug] Arglist at 0x28ff18, args:
[debug] Locals at 0x28ff18, Previous frame's sp is 0x28ff30
[debug] Saved registers:
[debug]  ebx at 0x28ff0c, ebp at 0x28ff18, esi at 0x28ff10, edi at 0x28ff14, eip at 0x28ff2c
[debug]>>>>>>cb_gdb:#0  main () at ****rerreer\main.cpp:10
[debug]>>>>>>cb_gdb:
[debug]> whatis test
[debug]type = std::vector<double>
[debug]>>>>>>cb_gdb:
[debug]> output test
[debug]std::vector of length 1, capacity 1 = {22.440000000000001}>>>>>>cb_gdb:
[debug]> next
[debug]****rerreer\main.cpp:12:187:beg:0x4013ce
[debug]>>>>>>cb_gdb:

At ****rerreer\main.cpp:12

[debug]> whatis test
[debug]type = std::vector<double>
[debug]>>>>>>cb_gdb:
[debug]> output test
[debug]std::vector of length 2, capacity 2 = {22.440000000000001, 1.3795933261199322e-306}>>>>>>cb_gdb:
[debug]> bt 30
[debug]#0  main () at ****rerreer\main.cpp:12
[debug]>>>>>>cb_gdb:
[debug]> whatis test[0]
[debug]type = double
[debug]>>>>>>cb_gdb:
[debug]> output test[0]
[debug]22.440000000000001>>>>>>cb_gdb:
[debug]> whatis test[1]
[debug]type = double
[debug]>>>>>>cb_gdb:
[debug]> output test[1]
[debug]1.3795933261199322e-306>>>>>>cb_gdb:
so all is working for me... I don't understand why it is not working for you...
Can you try do redo all my steps i posted above but use the tdm gdb?
Also can you create a new project and try my sample code i posted above?

Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Showing vector elements in debugger
« Reply #49 on: June 26, 2017, 11:33:17 am »
Maybe there is a kind of confusion beginning to creep in now.

I already tested both versions of gdb:

The one from TDM
https://sourceforge.net/projects/tdm-gcc/files/GDB/gdb32-7.9.1-tdm-1.zip/download
works ("humbling") for me too, as I posted here
http://forums.codeblocks.org/index.php/topic,21998.msg149717.html#msg149717

And the one from ollydbg
http://sourceforge.net/projects/gdbmingw/files/gdb2016-01-30.zip/download
lets miss the python27.dll
see
http://forums.codeblocks.org/index.php/topic,21998.msg149741.html#msg149741

The reason why TDM gdb works for you (as the one from ollydbg) probably is
because you installed python separately.

[Edit:
If you would de-install your python distr, maybe (... maybe) you would have the same effect than I.]

BTW:
As TDM gdb (python-enabled) works (more or less) for me (without having
installed python anywhere) I do doubt that it is necessary to install python separately.
For me it looks like a kind of "cooperation problem" (IDE, gdb, ...?).
And the way I did now (just copying the binaries into the existing structure)
for sure is no good.
« Last Edit: June 26, 2017, 11:39:42 am by nji »

Offline BlueHazzard

  • Lives here!
  • ****
  • Posts: 1372
Re: Showing vector elements in debugger
« Reply #50 on: June 26, 2017, 11:57:11 am »
Quote
As TDM gdb (python-enabled) works (more or less) for me (without having
installed python anywhere) I do doubt that it is necessary to install python separately.
For me it looks like a kind of "cooperation problem" (IDE, gdb, ...?).
i think it has something to do with your code (you never mentioned that you tested my code) or something with the python scripts.
the things what baffle me is the output of your debugger..
Code: [Select]
[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:
As you can see it is different from my output:
Code: [Select]
[debug]> whatis test[0]
[debug]type = double
vs
Code: [Select]
whatis diffVector [2]
[debug]type = std::vector<double, std::allocator<double> >::reference

Also what does show the watches window for this:
Code: [Select]
[debug](__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type &) @0x147f660: 1.3795933261199322e-306>>>>>>cb_gdb:?


Offline nji

  • Multiple posting newcomer
  • *
  • Posts: 24
Re: Showing vector elements in debugger
« Reply #51 on: June 26, 2017, 12:28:14 pm »
Actually I used exactly your code
Code: [Select]
    vector<double> test;
    test.push_back( 22.44 );
    test.push_back( 1.3795933261199322e-306 );
    test[1];
And then the debugger's output is
Code: [Select]
[debug]> whatis test
[debug]type = std::vector<double, std::allocator<double> >
[debug]>>>>>>cb_gdb:
[debug]> output test
[debug]std::vector of length 2, capacity 2 = {22.440000000000001, 1.3795933261199322e-306}>>>>>>cb_gdb:
[debug]> whatis test[1]
[debug]type = std::vector<double, std::allocator<double> >::reference
[debug]>>>>>>cb_gdb:
[debug]> output test[1]
[debug](__gnu_cxx::__alloc_traits<std::allocator<double> >::value_type &) @0x1bee910: <error reading variable>>>>>>>cb_gdb:

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 10062
Re: Showing vector elements in debugger
« Reply #52 on: June 29, 2017, 03:00:35 pm »
I also sometimes get lost with the "enable scripts" versus do not enable the scripts but have a gdb-python pair.

These are going away, soon. I'll just remove them as soon as I find some free time. They are useless anyway.

For gdb troubles: if we ship python enabled gdb then we'll need to ship our own version of python or modify the installer to start an installation of python itself.
BTW one of the gdb windows builds had some stub gdb.exe which was modifying env variables and then the only thing it did was to start the real executable. This version doesn't work too well (the pausing command doesn't work)!

p.s. unfortunately I don't have time nor desire to work on c::b on windows.
<debugger plugin maintainer>
(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 BlueHazzard

  • Lives here!
  • ****
  • Posts: 1372
Re: Showing vector elements in debugger
« Reply #53 on: July 09, 2017, 11:27:17 pm »
@nji
any news on this?
I honestly have no idea what is going on on your system... I don't think this has anything to do with codeblocks and its configuration, but something with gdb and compiler combination?