koutheir / libcxx-pretty-printers Goto Github PK
View Code? Open in Web Editor NEWMoved: https://codeberg.org/koutheir/libcxx-pretty-printers
Home Page: https://codeberg.org/koutheir/libcxx-pretty-printers
License: GNU General Public License v3.0
Moved: https://codeberg.org/koutheir/libcxx-pretty-printers
Home Page: https://codeberg.org/koutheir/libcxx-pretty-printers
License: GNU General Public License v3.0
I just tracked down a problem that was causing my gdb to mysteriously abort when it hit a breakpoint early in my program's execution. After a bit of digging through logs & print debugging in the pretty-printers, I discovered that a library I'm using has an object which keeps a vector of std::weak_ptrs to handler objects... one of which is itself. This repo's pretty printer has no guard against this and attempts to resolve it immediately (not in a lazy manner), therefore it prints weak_ptr -> vector -> weak_ptr -> ad infinitum (well, at least until the stack explodes).
I'm going to hack mine so that it doesn't call dereference on weak_ptrs, but I'm sure there is a better solution.
Out of the box, nothing works. If I type info pretty-printers
, gdb lists the printers, but when trying to print variables, it doesn't find the right printer.
After some debugging, I found out that the type names are std::_LIBCPP_ABI_NAMESPACE::...
. The type name lookup regex is '^std::__[a-zA-Z0-9]+::'. I replacing it with '^std::[a-zA-Z0-9_]+::'
, it now finds a types, and can at least print a string. However, when I tried to print a map, I got the following error message:
MapPrinter.to_string
std::map (count=1)Traceback (most recent call last):
File "/home/parallels/workspace/libcxx-pretty-printers/src/libcxx/v1/printers.py", line 736, in __next__
result = ('[%d] %s' % (self.count, str(item['__cc']['first'])),
~~~~^^^^^^^^
gdb.error: There is no member or method named __cc.
I haven't tried any other types yet, but it looks like there is some serious discrepancy with this libc++ version.
I've noticed that I'm getting these errors in the gdb console:
Traceback (most recent call last):
File "/home/andrew/.gdb/libcxx-pretty-printers/src/libcxx/v1/printers.py", line 615, in next
item = self.rbiter.next()
File "/home/andrew/.gdb/libcxx-pretty-printers/src/libcxx/v1/printers.py", line 673, in next
parent_node = parent_node.dereference()['_parent']
gdb.error: There is no member or method named _parent.
(note my line numbers will differ from the head of tree)
I have this error trying to pretty print a shared pointer:
Traceback (most recent call last):
File "/home/coval/libcxx-pretty-printers/src/libcxx/v1/printers.py", line 169, in to_string
usecount = refcounts['__shared_count'] + 1
gdb.error: There is no member named __shared_count.
I have commented the lines 168 to 174 but I think there is a better solution.
I would love to help but not sure how you find the names of the fields?
When displaying or printing std::strings I now get this error (Note executable_name is a std::string)
(gdb) print executable_name
$2 = Python Exception <class 'gdb.error'> There is no member or method named __first_.:
in my .gdbinit file
# libc++ gdb pretty printers
python
import sys
sys.path.insert(0, '/home/rake/src/Tools/libcxx-pretty-printers/src')
from libcxx.v1.printers import register_libcxx_printers
register_libcxx_printers (None)
end
and building with these c/cppflags enabled
-D_LIBCPP_DEBUG=1 -g -O0
Disabling libcxx pretty printers I get
(gdb) print executable_name
$2 = {<std::__1::__basic_string_common<true>> = {<No data fields>}, static __short_mask = 1, static __long_mask = 1,
__r_ = {<std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false>> = {__value_ = {{__l = {__cap_ = 81,
__size_ = 73, __data_ = 0x60f800 "/home/rake/src/Pluralsight/PracticalCppFeatures/build/PractialCppFeatures"}, __s = {{__size_ = 81 'Q', __lx = 81 'Q'},
__data_ = "\000\000\000\000\000\000\000I\000\000\000\000\000\000\000\000\370`\000\000\000\000"}, __r = {__words = {81, 73,
6354944}}}}}, <std::__1::__compressed_pair_elem<std::__1::allocator<char>, 1, true>> = {<std::__1::allocator<char>> = {<No data fields>}, <No data fields>}, <No data fields>}, static npos = 18446744073709551615}
And strangely enough in lldb I get
print executable_name
(std::__1::string) $1 = "/home/rake/src/Pluralsight/PracticalCppFeatures/build/PractialCppFeatures"
They both show the correct data but one is a garbled mess of information.
My platform: Windows 10, Msys2, clang 15.0.5
test code:
int main(int argc, char *argv[])
{
std::string koza{"koza"};
spdlog::info("{}",koza); // break point here
}
GDB>> p koza
Python Exception <class 'gdb.error'>: There is no member or method named __short_mask.
my std::string content without libcxx-pretty-printers
$2 = {
static __endian_factor = 2,
__r_ = {
<std::__1::__compressed_pair_elem<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__rep, 0, false>> = {
__value_ = {
{
__l = {
{
__is_long_ = 0,
__cap_ = 209332974980
},
__size_ = 0,
__data_ = 0x51 <error: Cannot access memory at address 0x51>
},
__s = {
{
__is_long_ = 0 '\000',
__size_ = 4 '\004'
},
__padding_ = 0x14fe79 "koza",
__data_ = "koza", '\000' <repeats 11 times>, "Q\000\000\000\000\000\000"
},
__r = {
__words = {418665949960, 0, 81}
}
}
}
},
<std::__1::__compressed_pair_elem<std::__1::allocator<char>, 1, true>> = {
<std::__1::allocator<char>> = {
<std::__1::__non_trivial_if<true, std::__1::allocator<char> >> = {<No data fields>}, <No data fields>}, <No data fields>}, <No data fields>},
static npos = 18446744073709551615
I'm trying to get this project working on an AAarch64 Ubuntu 18.04 system while remote debugging with CLion 2019.2. Alas it isn't.
From the debugger's log output, the libc++ pretty printers seem to be installed. When trying to view variables that should use them, however, I get just the basic type information. One thing I notice, which I'm not sure if it is a problem, is that the pretty printers info says they are all in the std:: namespace, whereas while trying to view types, all the types are in the std::__1:: namespace. Is this an issue?
Any other suggestions for things to try?
The pretty printing for std::queue
does not work anymore.
When I try to print a vector, I get this strange error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.