With GDB I want to watch std::shared_ptr<T>::get() result.
To do that i have try to setup the pretty printers.
I have follow some links:
http://forums.codeblocks.org/index.php?topic=23590.0http://wiki.codeblocks.org/index.php/Pretty_PrintersAnd to do that i have quiclky copy past the python command from codelite (it's work with codelite)
python
import sys
sys.path.insert(0, '/home/gandi/.codelite/gdb_printers')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
from qt4 import register_qt4_printers
register_qt4_printers (None)
from wx import register_wx_printers
register_wx_printers (None)
end
It doesn't work CB report an error from python code.
I have modify the ${HOME}/.gdbinit file:
python
import sys
sys.path.append('blabla/.config/Epic/GDBPrinters/')
from UE4Printers import register_ue4_printers
register_ue4_printers(None)
print("Registered pretty printers for UE4 classes")
# sys.path.append('/blabla/gcc/libstdc++-v3/python')
import libstdcxx
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
print("Enregistrement des «belles écritures» pour libstdc++.")
end
In a terminal i test the gdb app and the python code work:
$ gdb
GNU gdb (GDB) 10.1-5.mga8 (Mageia release 8)
Copyright (C) 2020 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-mageia-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
Registered pretty printers for UE4 classes
Enregistrement des «belles écritures» pour libstdc++.
(gdb)
I try this new python code inside codeblocks (Debugger settings)
Same result:
Debugger name and version: GNU gdb (GDB) 10.1-5.mga8 (Mageia release 8)
Error while executing Python code.
Here my small code to test the GDB watcher.
#include <iostream>
#include <string>
#include <memory>
struct Node
{
std::string m_Toto;
};
typedef std::shared_ptr<Node> NodePtr;
int main()
{
printf("Hello World");
NodePtr toto{new Node{"Toto"}};
std::cout << toto->m_Toto << std::endl;
return 0;
}
Here my CB build information:
Name : Code::Blocks
Version : svn-r12302
SDK Version : 2.6.0
Scintilla Version: 3.7.5
Author : The Code::Blocks Team
E-mail : info@codeblocks.org
Website : http://www.codeblocks.org
wxWidgets Library (wxGTK port)
Version 3.1.4 (Unicode: wchar_t, debug level: 0),
compiled at Mar 11 2021 22:48:45
Runtime version of toolkit used is 3.24.
Compile-time GTK+ version is 3.24.24.
My linux:
Mageia8 gcc10