Re: [Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Tim Hammerquist via lldb-commits
Thanks, Sean!

On Thu, Dec 1, 2016 at 11:25 AM, Sean Callanan  wrote:

> $ svn commit
> Sendingsource/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> Transmitting file data .done
> Committing transaction...
> Committed revision 288403.
>
> Sorry for the noise, folks.
>
> Sean
>
> On Dec 1, 2016, at 11:21 AM, Sean Callanan  wrote:
>
> It'll be a fix.  ETA 10 minutes.
>
> On Dec 1, 2016, at 11:16 AM, Sean Callanan via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
> It's definitely this one.  I'll have a fix or a revert in the next 30
> minutes.
>
> On Dec 1, 2016, at 10:58 AM, Tim Hammerquist  wrote:
>
> Builds with this patch have been failing due to a segfaulting testcase.
> See:
>
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/
>
> At first glance, it's possible the failure was introduced by either this
> commit (r288386) or possibly r288372.
>
> -Tim
>
>
> On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits <
> lldb-commits@lists.llvm.org> wrote:
>
>> Author: spyffe
>> Date: Thu Dec  1 11:46:51 2016
>> New Revision: 288386
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev
>> Log:
>> Handle UTF-16 and UTF-32 constant CFStrings
>>
>> We have a longstanding issue where the expression parser does not handle
>> wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message
>>
>> Internal error [IRForTarget]: An Objective-C constant string's string
>> initializer is not an array
>> error: warning: expression result unused
>> error: The expression could not be prepared to run in the target
>>
>> This is just a side effect of the fact that we don't handle wide string
>> constants when converting these to CFStringCreateWithBytes. That function
>> takes the string's encoding as an argument, so I made it work and added a
>> testcase.
>>
>> https://reviews.llvm.org/D27291
>> 
>>
>> Added:
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-
>> string/TestUnicodeString.py
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-
>> string/main.m
>> Modified:
>> lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>>
>> Added: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-
>> string/TestUnicodeString.py
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Pyth
>> on/lldbsuite/test/lang/objc/unicode-string/TestUnicodeStri
>> ng.py?rev=288386&view=auto
>> 
>> ==
>> --- 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>> (added)
>> +++ 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>> Thu Dec  1 11:46:51 2016
>> @@ -0,0 +1,6 @@
>> +from lldbsuite.test import lldbinline
>> +from lldbsuite.test import decorators
>> +
>> +lldbinline.MakeInlineTest(
>> +__file__, globals(), [
>> +decorators.skipUnlessDarwin])
>>
>> Added: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-
>> string/main.m
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Pyth
>> on/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
>> 
>> ==
>> --- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>> (added)
>> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>> Thu Dec  1 11:46:51 2016
>> @@ -0,0 +1,5 @@
>> +#import 
>> +
>> +int main() {
>> +  NSLog(@"凸"); //% self.expect("po @\"凹\"",
>> DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
>> +}
>>
>> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget
>> .cpp
>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugin
>> s/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=
>> 288385&r2=288386&view=diff
>> 
>> ==
>> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>> (original)
>> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu
>> Dec  1 11:46:51 2016
>> @@ -498,42 +498,60 @@ bool IRForTarget::RewriteObjCConstString
>>Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
>>   : Constant::getNullValue(i8_ptr_ty);
>>Constant *numBytes_arg = ConstantInt::get(
>> -  m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);
>> -  Constant *encoding_arg = ConstantInt::get(
>> -  i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
>> -  Constant *isExternal_arg =
>> -  ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
>> -
>> -  Value *argument_array[5];
>> -
>> -  argument_array[0] = alloc_arg;
>> -  argument_array[1] = bytes_arg;
>> -  argument

Re: [Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Sean Callanan via lldb-commits
$ svn commit
Sendingsource/Plugins/ExpressionParser/Clang/IRForTarget.cpp
Transmitting file data .done
Committing transaction...
Committed revision 288403.

Sorry for the noise, folks.

Sean

> On Dec 1, 2016, at 11:21 AM, Sean Callanan  wrote:
> 
> It'll be a fix.  ETA 10 minutes.
> 
>> On Dec 1, 2016, at 11:16 AM, Sean Callanan via lldb-commits 
>> mailto:lldb-commits@lists.llvm.org>> wrote:
>> 
>> It's definitely this one.  I'll have a fix or a revert in the next 30 
>> minutes.
>>> On Dec 1, 2016, at 10:58 AM, Tim Hammerquist >> > wrote:
>>> 
>>> Builds with this patch have been failing due to a segfaulting testcase. See:
>>> 
>>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/ 
>>> 
>>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/ 
>>> 
>>> 
>>> At first glance, it's possible the failure was introduced by either this 
>>> commit (r288386) or possibly r288372.
>>> 
>>> -Tim
>>> 
>>> 
>>> On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits 
>>> mailto:lldb-commits@lists.llvm.org>> wrote:
>>> Author: spyffe
>>> Date: Thu Dec  1 11:46:51 2016
>>> New Revision: 288386
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev 
>>> 
>>> Log:
>>> Handle UTF-16 and UTF-32 constant CFStrings
>>> 
>>> We have a longstanding issue where the expression parser does not handle 
>>> wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message
>>> 
>>> Internal error [IRForTarget]: An Objective-C constant string's string 
>>> initializer is not an array
>>> error: warning: expression result unused
>>> error: The expression could not be prepared to run in the target
>>> 
>>> This is just a side effect of the fact that we don't handle wide string 
>>> constants when converting these to CFStringCreateWithBytes. That function 
>>> takes the string's encoding as an argument, so I made it work and added a 
>>> testcase.
>>> 
>>> https://reviews.llvm.org/D27291 
>>> >
>>> 
>>> Added:
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
>>> 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>> 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>>> Modified:
>>> lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>>> 
>>> Added: 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=288386&view=auto
>>>  
>>> 
>>> ==
>>> --- 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>>  (added)
>>> +++ 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>>  Thu Dec  1 11:46:51 2016
>>> @@ -0,0 +1,6 @@
>>> +from lldbsuite.test import lldbinline
>>> +from lldbsuite.test import decorators
>>> +
>>> +lldbinline.MakeInlineTest(
>>> +__file__, globals(), [
>>> +decorators.skipUnlessDarwin])
>>> 
>>> Added: 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
>>>  
>>> 
>>> ==
>>> --- 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
>>> (added)
>>> +++ 
>>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
>>> Thu Dec  1 11:46:51 2016
>>> @@ -0,0 +1,5 @@
>>> +#import 
>>> +
>>> +int main() {
>>> +  NSLog(@"凸"); //% self.expect("po @\"凹\"", 
>>> DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
>>> +}
>>> 
>>> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=288385&r2=288386&view=diff
>>>  
>>> 
>>> ==
>>> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
>>> (original)
>>> +++ lldb/

Re: [Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Sean Callanan via lldb-commits
It'll be a fix.  ETA 10 minutes.

> On Dec 1, 2016, at 11:16 AM, Sean Callanan via lldb-commits 
>  wrote:
> 
> It's definitely this one.  I'll have a fix or a revert in the next 30 minutes.
>> On Dec 1, 2016, at 10:58 AM, Tim Hammerquist > > wrote:
>> 
>> Builds with this patch have been failing due to a segfaulting testcase. See:
>> 
>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/ 
>> 
>> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/ 
>> 
>> 
>> At first glance, it's possible the failure was introduced by either this 
>> commit (r288386) or possibly r288372.
>> 
>> -Tim
>> 
>> 
>> On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits 
>> mailto:lldb-commits@lists.llvm.org>> wrote:
>> Author: spyffe
>> Date: Thu Dec  1 11:46:51 2016
>> New Revision: 288386
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev 
>> 
>> Log:
>> Handle UTF-16 and UTF-32 constant CFStrings
>> 
>> We have a longstanding issue where the expression parser does not handle 
>> wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message
>> 
>> Internal error [IRForTarget]: An Objective-C constant string's string 
>> initializer is not an array
>> error: warning: expression result unused
>> error: The expression could not be prepared to run in the target
>> 
>> This is just a side effect of the fact that we don't handle wide string 
>> constants when converting these to CFStringCreateWithBytes. That function 
>> takes the string's encoding as an argument, so I made it work and added a 
>> testcase.
>> 
>> https://reviews.llvm.org/D27291 
>> >
>> 
>> Added:
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
>> 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>> Modified:
>> lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>> 
>> Added: 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=288386&view=auto
>>  
>> 
>> ==
>> --- 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>  (added)
>> +++ 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>>  Thu Dec  1 11:46:51 2016
>> @@ -0,0 +1,6 @@
>> +from lldbsuite.test import lldbinline
>> +from lldbsuite.test import decorators
>> +
>> +lldbinline.MakeInlineTest(
>> +__file__, globals(), [
>> +decorators.skipUnlessDarwin])
>> 
>> Added: 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
>>  
>> 
>> ==
>> --- 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
>> (added)
>> +++ 
>> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
>> Thu Dec  1 11:46:51 2016
>> @@ -0,0 +1,5 @@
>> +#import 
>> +
>> +int main() {
>> +  NSLog(@"凸"); //% self.expect("po @\"凹\"", 
>> DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
>> +}
>> 
>> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=288385&r2=288386&view=diff
>>  
>> 
>> ==
>> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
>> (original)
>> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Dec 
>>  1 11:46:51 2016
>> @@ -498,42 +498,60 @@ bool IRForTarget::RewriteObjCConstString
>>Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
>>   : Constant::getNullValue(i8_ptr_ty);
>>Constant *numBytes_arg = ConstantInt::get(
>> -  m_intptr_ty, cstr ? string_array->getNumElements()

Re: [Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Sean Callanan via lldb-commits
It's definitely this one.  I'll have a fix or a revert in the next 30 minutes.
> On Dec 1, 2016, at 10:58 AM, Tim Hammerquist  wrote:
> 
> Builds with this patch have been failing due to a segfaulting testcase. See:
> 
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/ 
> 
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/ 
> 
> 
> At first glance, it's possible the failure was introduced by either this 
> commit (r288386) or possibly r288372.
> 
> -Tim
> 
> 
> On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits 
> mailto:lldb-commits@lists.llvm.org>> wrote:
> Author: spyffe
> Date: Thu Dec  1 11:46:51 2016
> New Revision: 288386
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev 
> 
> Log:
> Handle UTF-16 and UTF-32 constant CFStrings
> 
> We have a longstanding issue where the expression parser does not handle wide 
> CFStrings (e.g., @"凸凹") correctly, producing the useless error message
> 
> Internal error [IRForTarget]: An Objective-C constant string's string 
> initializer is not an array
> error: warning: expression result unused
> error: The expression could not be prepared to run in the target
> 
> This is just a side effect of the fact that we don't handle wide string 
> constants when converting these to CFStringCreateWithBytes. That function 
> takes the string's encoding as an argument, so I made it work and added a 
> testcase.
> 
> https://reviews.llvm.org/D27291 
> 
> 
> Added:
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
> 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
> Modified:
> lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=288386&view=auto
>  
> 
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>  (added)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
>  Thu Dec  1 11:46:51 2016
> @@ -0,0 +1,6 @@
> +from lldbsuite.test import lldbinline
> +from lldbsuite.test import decorators
> +
> +lldbinline.MakeInlineTest(
> +__file__, globals(), [
> +decorators.skipUnlessDarwin])
> 
> Added: 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
>  
> 
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
> Thu Dec  1 11:46:51 2016
> @@ -0,0 +1,5 @@
> +#import 
> +
> +int main() {
> +  NSLog(@"凸"); //% self.expect("po @\"凹\"", 
> DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
> +}
> 
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=288385&r2=288386&view=diff
>  
> 
> ==
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
> (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Dec  
> 1 11:46:51 2016
> @@ -498,42 +498,60 @@ bool IRForTarget::RewriteObjCConstString
>Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
>   : Constant::getNullValue(i8_ptr_ty);
>Constant *numBytes_arg = ConstantInt::get(
> -  m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);
> -  Constant *encoding_arg = ConstantInt::get(
> -  i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
> -  Constant *isExternal_arg =
> -  ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
> -
> -  Value *arg

Re: [Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Tim Hammerquist via lldb-commits
Builds with this patch have been failing due to a segfaulting testcase. See:

http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22721/
http://lab.llvm.org:8080/green/view/LLDB/job/lldb_build_test/22722/

At first glance, it's possible the failure was introduced by either this
commit (r288386) or possibly r288372.

-Tim


On Thu, Dec 1, 2016 at 9:46 AM, Sean Callanan via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: spyffe
> Date: Thu Dec  1 11:46:51 2016
> New Revision: 288386
>
> URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev
> Log:
> Handle UTF-16 and UTF-32 constant CFStrings
>
> We have a longstanding issue where the expression parser does not handle
> wide CFStrings (e.g., @"凸凹") correctly, producing the useless error message
>
> Internal error [IRForTarget]: An Objective-C constant string's string
> initializer is not an array
> error: warning: expression result unused
> error: The expression could not be prepared to run in the target
>
> This is just a side effect of the fact that we don't handle wide string
> constants when converting these to CFStringCreateWithBytes. That function
> takes the string's encoding as an argument, so I made it work and added a
> testcase.
>
> https://reviews.llvm.org/D27291
> 
>
> Added:
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
> TestUnicodeString.py
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/
> unicode-string/main.m
> Modified:
> lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
>
> Added: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/
> TestUnicodeString.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/
> Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=
> 288386&view=auto
> 
> ==
> --- 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
> (added)
> +++ 
> lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
> Thu Dec  1 11:46:51 2016
> @@ -0,0 +1,6 @@
> +from lldbsuite.test import lldbinline
> +from lldbsuite.test import decorators
> +
> +lldbinline.MakeInlineTest(
> +__file__, globals(), [
> +decorators.skipUnlessDarwin])
>
> Added: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/
> unicode-string/main.m
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/
> Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
> 
> ==
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
> (added)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
> Thu Dec  1 11:46:51 2016
> @@ -0,0 +1,5 @@
> +#import 
> +
> +int main() {
> +  NSLog(@"凸"); //% self.expect("po @\"凹\"", 
> DATA_TYPES_DISPLAYED_CORRECTLY,
> substrs = ["凹"])
> +}
>
> Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/
> Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=
> 288386&r1=288385&r2=288386&view=diff
> 
> ==
> --- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
> (original)
> +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu
> Dec  1 11:46:51 2016
> @@ -498,42 +498,60 @@ bool IRForTarget::RewriteObjCConstString
>Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
>   : Constant::getNullValue(i8_ptr_ty);
>Constant *numBytes_arg = ConstantInt::get(
> -  m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);
> -  Constant *encoding_arg = ConstantInt::get(
> -  i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
> -  Constant *isExternal_arg =
> -  ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
> -
> -  Value *argument_array[5];
> -
> -  argument_array[0] = alloc_arg;
> -  argument_array[1] = bytes_arg;
> -  argument_array[2] = numBytes_arg;
> -  argument_array[3] = encoding_arg;
> -  argument_array[4] = isExternal_arg;
> -
> -  ArrayRef CFSCWB_arguments(argument_array, 5);
> -
> -  FunctionValueCache CFSCWB_Caller(
> -  [this, &CFSCWB_arguments](llvm::Function *function) -> llvm::Value
> * {
> -return CallInst::Create(
> -m_CFStringCreateWithBytes, CFSCWB_arguments,
> -"CFStringCreateWithBytes",
> -llvm::cast(
> -m_entry_instruction_finder.GetValue(function)));
> -  });
> -
> -  if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller,
> -  m_entry_instruction_finder, m_error_stream)) {
> -if (log)
> -  log->PutCString(
> -  "Couldn't replace the NSStri

[Lldb-commits] [lldb] r288386 - Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Thu Dec  1 11:46:51 2016
New Revision: 288386

URL: http://llvm.org/viewvc/llvm-project?rev=288386&view=rev
Log:
Handle UTF-16 and UTF-32 constant CFStrings

We have a longstanding issue where the expression parser does not handle wide 
CFStrings (e.g., @"凸凹") correctly, producing the useless error message

Internal error [IRForTarget]: An Objective-C constant string's string 
initializer is not an array
error: warning: expression result unused
error: The expression could not be prepared to run in the target

This is just a side effect of the fact that we don't handle wide string 
constants when converting these to CFStringCreateWithBytes. That function takes 
the string's encoding as an argument, so I made it work and added a testcase.

https://reviews.llvm.org/D27291


Added:
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/

lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Added: 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py?rev=288386&view=auto
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
 (added)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/TestUnicodeString.py
 Thu Dec  1 11:46:51 2016
@@ -0,0 +1,6 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(
+__file__, globals(), [
+decorators.skipUnlessDarwin])

Added: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m?rev=288386&view=auto
==
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
(added)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/unicode-string/main.m 
Thu Dec  1 11:46:51 2016
@@ -0,0 +1,5 @@
+#import 
+
+int main() {
+  NSLog(@"凸"); //% self.expect("po @\"凹\"", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["凹"])
+}

Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp?rev=288386&r1=288385&r2=288386&view=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Dec  1 
11:46:51 2016
@@ -498,42 +498,60 @@ bool IRForTarget::RewriteObjCConstString
   Constant *bytes_arg = cstr ? ConstantExpr::getBitCast(cstr, i8_ptr_ty)
  : Constant::getNullValue(i8_ptr_ty);
   Constant *numBytes_arg = ConstantInt::get(
-  m_intptr_ty, cstr ? string_array->getNumElements() - 1 : 0, false);
-  Constant *encoding_arg = ConstantInt::get(
-  i32_ty, 0x0600, false); /* 0x0600 is kCFStringEncodingASCII */
-  Constant *isExternal_arg =
-  ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
-
-  Value *argument_array[5];
-
-  argument_array[0] = alloc_arg;
-  argument_array[1] = bytes_arg;
-  argument_array[2] = numBytes_arg;
-  argument_array[3] = encoding_arg;
-  argument_array[4] = isExternal_arg;
-
-  ArrayRef CFSCWB_arguments(argument_array, 5);
-
-  FunctionValueCache CFSCWB_Caller(
-  [this, &CFSCWB_arguments](llvm::Function *function) -> llvm::Value * {
-return CallInst::Create(
-m_CFStringCreateWithBytes, CFSCWB_arguments,
-"CFStringCreateWithBytes",
-llvm::cast(
-m_entry_instruction_finder.GetValue(function)));
-  });
-
-  if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller,
-  m_entry_instruction_finder, m_error_stream)) {
-if (log)
-  log->PutCString(
-  "Couldn't replace the NSString with the result of the call");
-
-m_error_stream.Printf("error [IRForTarget internal]: Couldn't replace an "
-  "Objective-C constant string with a dynamic "
-  "string\n");
+  m_intptr_ty, cstr ? (string_array->getNumElements() - 1) * 
string_array->getElementByteSize() : 0, false);
+ int encoding_flags = 0;
+ switch (string_array->getElementByteSize()) {
+ case 1:
+   encoding_flags = 0x08000100; /* 0x08000100 is kCFStringEncodingUTF8 */
+   break;
+ case 2:
+   encoding_flags = 0x0100; /* 0x0100 is kCFStringEncodingUTF16 */
+   break;
+ case 4:
+   encoding_flags = 0x0c000100; /* 0x0c000100 i