Search code examples
c++stringdebugginglldb

How set std::string type on lldb?


I have the following code:

#include <iostream>
#include <string>

int main() {
    std::string name = "Foo";
    return 0;
}

When i will debug with lldb i want set a std::string like i set this int:

expr int $num = 4

I try:

expr std::string $name = "Foo"

And i got:

error: no type named 'string' in namespace 'std'

Does anyone understand what is going on? How can i create a std::string on lldb?

Obs:

When i print name, lldb give me this type std::__1::string for std::string:

p foo
(std::__1::string) $2 = "foo"

Solution

  • You can use alternatively:

    • expr const char * $foo
    • expr const char $foo[]
    • expr const char $foo[4]

    Obviously the last one can be used only if you know the dimension of the char-array