-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Labels
lldbquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
Hello, I'm trying to write my own variable printer for std::unordered_map for debugging GCC compiled program under LLDB (because the standard one always shows size=0). I've found an example in the repository and but it seems like its self.count is always None.
I tried to set up some debug printing in the extract_type and got the following:
def extract_type(self):
type = self.valobj.GetType()
template_arg_num = 4 if self.kind == "map" else 3
allocator_type = type.GetTemplateArgumentType(template_arg_num)
data_type = allocator_type.GetTemplateArgumentType(0)
print("allocator_type:", allocator_type) # Debug output
print("data_type:", data_type) # Debug output
print("allocator_type arguments count:", allocator_type.GetNumberOfTemplateArguments()) # Debug output
return data_typeIt successfully fetches the allocator_type as:
(lldb) p someMap
allocator_type: class allocator<std::pair<char const, long unsigned int> > : public std::__new_allocator<std::pair<const char, unsigned long> > {
template <class _Tp1> struct rebind;
template<> struct rebind<std::__detail::_Hash_node<std::pair<const char, unsigned long>, false>> {
typedef std::allocator<std::__detail::_Hash_node<std::pair<char const, long unsigned int>, false> > other;
};
public:
void allocator();
void allocator(const std::allocator<std::pair<char const, long unsigned int> > &);
std::allocator<std::pair<char const, long unsigned int> > &operator=(const std::allocator<std::pair<char const, long unsigned int> > &);
~allocator<std::pair<char const, long unsigned int> >();
}
data_type: No value
allocator_type arguments count: 0
But allocator_type.GetNumberOfTemplateArguments() always returns 0 and data_type is "No value".
Here are some details to reproduce the issue:
Code to reproduce
LLDB version
❯ lldb --version
lldb version 19.1.7GCC version
❯ g++ --version
g++ (GCC) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.C++ code
#include <bits/stdc++.h>
int main() {
std::unordered_map<char, size_t> someMap;
someMap.emplace('a', 2);
std::cout << someMap.size() << std::endl;
return 0;
}Compilation command
g++ -g -O0 main.cpp
LLDB_DEBUGSERVER_PATH=/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver lldb a.outOS and env
MacBook Air M1, 16GB, MacOS Sequoia Version 15.6 (24G84)
Metadata
Metadata
Assignees
Labels
lldbquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!