Re: printing std::string in lldb
Re: printing std::string in lldb
- Subject: Re: printing std::string in lldb
- From: Dmitry Markman <email@hidden>
- Date: Fri, 24 Jun 2011 08:47:26 -0400
thanks Allen
s[0] returns error: "(std::string) s" is not an array type
and s.c_str() returns error: "c_str()" is not a member of "(std::string) s"
and of course in 2 cases gdb works just fine:
(gdb) p s[0]
$2 = (reference) @0x100100098: 72 'H'
(gdb) p s.c_str()
$3 = 0x100100098 "Hello, World!"
(gdb)
thanks again
On Jun 24, 2011, at 2:29 AM, Allen Ding wrote:
> "po" is used for Objective-C objects.
>
> s[0] does not return an Objective-C object, operator[] returns a const char&.
>
> Neither does s.c_str(), c_str() returns a const char *.
>
> Try "p s[0]" and "p s.c_str()" instead.
>
> On Jun 24, 2011, at 1:57 PM, Dmitry Markman wrote:
>
>> Hi
>> I'm trying to print std::string in lldb
>>
>> here is a simple program:
>>
>> #include <iostream>
>>
>> int main (int argc, const char * argv[])
>> {
>>
>> std::string s("Hello, World!");
>> std::cout << s << std::endl;
>> return 0;
>> }
>>
>>
>> I set Xcode 4 project to use LLVM 2 compiler and set executable to use lldb
>>
>> I set breakpoint at the line return 0
>>
>>
>> lldb stopped, but when I'm trying to evaluate expression (in console):
>>
>> po s[0]
>> or
>> po s.c_str()
>>
>> lldb errors out:
>> Error [IRForTarget]: Call to a function '_ZNSt18basic_string<char>ixEm' that is not present in the target
>> error: expression can't be interpreted or run
>> for s[0]
>>
>> Error [IRForTarget]: Call to a function '_ZNSt18basic_string<char>5c_strEv' that is not present in the target
>> error: expression can't be interpreted or run
>>
>> for c_str()
>>
>> so what I'm doing wrong?
>>
>> thanks
>>
>>
>>
>>
>>
>> Dmitry Markman
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Xcode-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
Dmitry Markman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden