0

I have compiled a very simple file with the command

clang++ main.cpp -g -o test

then

lldb ./test
b main , r, gui, n n n n n …

and as you can see in the upper part of the following screenshot, the variable named “unordered” which is an unordered set, has a size of zero, though it doesn't …

the code prints out “1” for unordered.size()

in GDB there is no problem with the same binary, can someone point me in the right direction?

I don't know how to do this in cmd lldb but through vscodium debugging panel the variable inspector allows me to see the “raw” content of “unordered” which has something like “m_element_count” so there is the information…

enter image description here

here the source file in plain text.

int main() {

char c;

std::unordered_set<char*> unordered;

unordered.insert(&c); 

std::set<char*> ordered;

ordered.insert(&c);

std::cout <<unordered.size() << " " << ordered.size() << std::endl;

}

.

(gdb) info locals
c = 46 ‘.’
unordered = std::unordered_set with 1 element = {[0] = 0x7fffffffde67 “.@\343VUUU”}
ordered = std::set with 1 element = {[0] = 0x7fffffffde67 “.@\343VUUU”}

thank you in advance

1
  • Both gdb & lldb have to understand the layout of these std types in order to extract information like size. In lldb's case, these are called type summary formatters. They have to be matched to the version of the STL library you are building against, since they have to inspect the internal layout of the objects. It looks like either there's a bug in this unordered formatter, or there's a mismatch between the installed formatters and your version of the STL. To help you with that we'd have to know the version of lldb and the version of the STL you were using. Commented Jan 21 at 21:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.