[Lldb-commits] [PATCH] D25756: FreeBSD ARM support for software single step.

2016-12-01 Thread Dmitry Mikulin via Phabricator via lldb-commits
dmikulin updated this revision to Diff 79987.
dmikulin added a comment.

Addressed review comments.
Haven't had a chance to re-test it on an arm board.


Repository:
  rL LLVM

https://reviews.llvm.org/D25756

Files:
  source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
  source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
  source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Index: source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
===
--- source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
+++ source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
@@ -1141,11 +1141,17 @@
 
   case SI_KERNEL:
   case TRAP_BRKPT:
-if (log)
-  log->Printf(
-  "ProcessMonitor::%s() received breakpoint event, tid = %" PRIu64,
-  __FUNCTION__, tid);
-message = ProcessMessage::Break(tid);
+if (monitor->m_process->IsSoftwareStepBreakpoint(tid)) {
+  if (log)
+log->Printf ("ProcessMonitor::%s() received sw single step breakpoint "
+ "event, tid = %" PRIu64, __FUNCTION__, tid);
+  message = ProcessMessage::Trace(tid);
+} else {
+  if (log)
+log->Printf ("ProcessMonitor::%s() received breakpoint event, tid = %"
+ PRIu64, __FUNCTION__, tid);
+  message = ProcessMessage::Break(tid);
+}
 break;
   }
 
Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
===
--- source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
+++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
@@ -171,7 +171,27 @@
   virtual FreeBSDThread *CreateNewFreeBSDThread(lldb_private::Process ,
 lldb::tid_t tid);
 
-protected:
+  static bool
+  SingleStepBreakpointHit(void *baton,
+			  lldb_private::StoppointCallbackContext *context,
+			  lldb::user_id_t break_id,
+			  lldb::user_id_t break_loc_id);
+
+  lldb_private::Error SetupSoftwareSingleStepping(lldb::tid_t tid);
+
+  lldb_private::Error
+  SetSoftwareSingleStepBreakpoint (lldb::tid_t tid, lldb::addr_t addr);
+
+  bool IsSoftwareStepBreakpoint(lldb::tid_t tid);
+
+  bool SupportHardwareSingleStepping() const;
+
+  typedef std::vector tid_collection;
+  tid_collection () { return m_step_tids; }
+
+ protected:
+  static const size_t MAX_TRAP_OPCODE_SIZE = 8;
+
   /// Target byte order.
   lldb::ByteOrder m_byte_order;
 
@@ -207,10 +227,10 @@
 
   friend class FreeBSDThread;
 
-  typedef std::vector tid_collection;
   tid_collection m_suspend_tids;
   tid_collection m_run_tids;
   tid_collection m_step_tids;
+  std::map m_threads_stepping_with_breakpoint;
 
   int m_resume_signo;
 };
Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===
--- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
+++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
@@ -13,6 +13,7 @@
 
 // C++ Includes
 #include 
+#include 
 
 // Other libraries and framework includes
 #include "lldb/Core/PluginManager.h"
@@ -122,6 +123,7 @@
 
   std::lock_guard guard(m_thread_list.GetMutex());
   bool do_step = false;
+  bool software_single_step = !SupportHardwareSingleStepping();
 
   for (tid_collection::const_iterator t_pos = m_run_tids.begin(),
   t_end = m_run_tids.end();
@@ -133,6 +135,11 @@
t_pos != t_end; ++t_pos) {
 m_monitor->ThreadSuspend(*t_pos, false);
 do_step = true;
+if (software_single_step) {
+  Error error = SetupSoftwareSingleStepping(*t_pos);
+  if (error.Fail())
+return error;
+}
   }
   for (tid_collection::const_iterator t_pos = m_suspend_tids.begin(),
   t_end = m_suspend_tids.end();
@@ -145,7 +152,7 @@
   if (log)
 log->Printf("process %" PRIu64 " resuming (%s)", GetID(),
 do_step ? "step" : "continue");
-  if (do_step)
+  if (do_step && !software_single_step)
 m_monitor->SingleStep(GetID(), m_resume_signo);
   else
 m_monitor->Resume(GetID(), m_resume_signo);
@@ -913,3 +920,194 @@
   "no platform or not the host - how did we get here with ProcessFreeBSD?");
   return DataBufferSP();
 }
+
+struct EmulatorBaton {
+  ProcessFreeBSD *m_process;
+  RegisterContext *m_reg_context;
+
+  // eRegisterKindDWARF -> RegisterValue
+  std::unordered_map m_register_values;
+
+  EmulatorBaton(ProcessFreeBSD *process, RegisterContext *reg_context)
+  : m_process(process), m_reg_context(reg_context) {}
+};
+
+static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton,
+ const EmulateInstruction::Context ,
+ lldb::addr_t addr, void *dst, size_t length) {
+  EmulatorBaton *emulator_baton = static_cast(baton);
+
+  Error error;
+  size_t bytes_read =
+  

[Lldb-commits] [PATCH] D27289: Return "thread-pcs" in jstopinfo on Linux/Android.

2016-12-01 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

@labath ah I see I hadn't looked at the lldb-server packets so I didn't know 
you had jThreadsInfo, good to hear.  Yes, if your target is built mostly 
-fomit-frame-pointer, lldb-server won't be able to do a stack walk without 
reading eh_frame or the arm unwind info that Tamas added a year or so ago.  
We've always avoided having lldb-server/debugserver know anything about files 
and symbols else the memory footprint will grow and we need these stubs to run 
in low-memory environments; I'm not sure how it could do a stalk walk.  It's a 
pretty big perf hit for lldb to walk to stacks of modern apps that have tens of 
threads on every public stop. :(

Agree with not sending the registers in the jstopinfo kv pair in the T/? packet 
- \it's such a space-inefficient encoding compared to the usual kv pairs of 
info in the T packet, as weirdly as they're formatted.  JSON requires we use 
base 10 for numbers, and then ascii-hex encoding it doubles it (I played with 
the idea of using base64 for jstopinfo originally, but instead worked on 
including the smallest amount of info we needed).

If we were going to be serious about the T packet format, I think we'd add a 
new JT packet (or whatever) which is all the information in straight JSON, and 
some request from lldb to enable JT packets instead of T packets.  But it 
doesn't seem like a pressing concern, and the more we deviate from standard 
gdb-remote protocol (even if it's optional deviation with fallback to standard 
packets), I think it makes lldb more fragile for interop.


https://reviews.llvm.org/D27289



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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=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=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=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=
>> 288385=288386=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;
>> -  

[Lldb-commits] [PATCH] D27124: [LLDB][MIPS] Fix TestWatchpointIter failure

2016-12-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

This looks fine.  Can you add a comment explaining why this is necessary, it 
isn't obvious right off the bat?

If this is fixing a test case, then just add a comment and this change is fine. 
 If the fix is test-suite neutral, then please add a test case.


https://reviews.llvm.org/D27124



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27291: Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Looks good.


Repository:
  rL LLVM

https://reviews.llvm.org/D27291



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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 
>> > 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 
>>> > wrote:
>>> Author: spyffe
>>> Date: Thu Dec  1 11:46:51 2016
>>> New Revision: 288386
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=288386=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=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=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=288385=288386=diff
>>>  
>>> 
>>> ==
>>> --- 

[Lldb-commits] [lldb] r288403 - Handle empty strings when looking for a CFString's encoding.

2016-12-01 Thread Sean Callanan via lldb-commits
Author: spyffe
Date: Thu Dec  1 13:14:55 2016
New Revision: 288403

URL: http://llvm.org/viewvc/llvm-project?rev=288403=rev
Log:
Handle empty strings when looking for a CFString's encoding.
Should fix the bots.

Modified:
lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

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=288403=288402=288403=diff
==
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp (original)
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp Thu Dec  1 
13:14:55 2016
@@ -500,7 +500,7 @@ bool IRForTarget::RewriteObjCConstString
   Constant *numBytes_arg = ConstantInt::get(
   m_intptr_ty, cstr ? (string_array->getNumElements() - 1) * 
string_array->getElementByteSize() : 0, false);
  int encoding_flags = 0;
- switch (string_array->getElementByteSize()) {
+ switch (cstr ? string_array->getElementByteSize() : 1) {
  case 1:
encoding_flags = 0x08000100; /* 0x08000100 is kCFStringEncodingUTF8 */
break;


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


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 
>> > wrote:
>> Author: spyffe
>> Date: Thu Dec  1 11:46:51 2016
>> New Revision: 288386
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=288386=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=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=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=288385=288386=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 ? 

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 
> > wrote:
> Author: spyffe
> Date: Thu Dec  1 11:46:51 2016
> New Revision: 288386
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=288386=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=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=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=288385=288386=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 

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=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=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=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=288385=288386=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, _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 

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I am not sure I like the implications of all this MIPS specific knowledge in 
this test. I would like it if we can abstract this into the GDB remote 
protocol. Since we get the register descriptions from the lldb-server, it would 
be nice if the register description for the float registers that change size 
get an extra key/value pair in them. Maybe something like: 
"variable-size-key:mips-fpr".  Then each time we get a stop reply packet from 
the remote server, any GDB server binaries that specify the "variable-size-key" 
in their description would update their sizes when we stop. So the stop reply 
packet would contain an extra key value pair: "mips-fpr:4;" or "mips-fpr:8;". 
The ProcessGDBRemote would need to save any variable-size-key values and know 
how to update the register sizes for any such registers.

So my general take is there are way too many places that are getting special 
knowledge of the MIPS SR register, so lets try to abstract this out in an 
architecture agnostic way.


https://reviews.llvm.org/D27088



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27124: [LLDB][MIPS] Fix TestWatchpointIter failure

2016-12-01 Thread Greg Clayton via Phabricator via lldb-commits
clayborg resigned from this revision.
clayborg removed a reviewer: clayborg.
clayborg added a comment.

I let Jim OK this patch.


https://reviews.llvm.org/D27124



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27305: Replace __ANDROID_NDK__ with simply ANDROID

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
labath planned changes to this revision.
labath added a comment.

Thanks for the suggestion. I'll try using `__ANDROID__` instead.




Comment at: cmake/platforms/Android.cmake:36
 # flags and definitions
 remove_definitions( -DANDROID -D__ANDROID__ )
+add_definitions( -DANDROID -DLLDB_DISABLE_LIBEDIT )

danalbert wrote:
> You're removing it a line before just to add it back?
> 
> `__ANDROID__` is probably the one you want. That one is defined by Clang (and 
> GCC if that matters) for any Android target, so no need to worry about 
> dealing with it in cmake (or any other build system).
> 
> This isn't a concern right now, but if LLDB ever needed to become part of the 
> Android platform build, `ANDROID` doesn't actually mean `ANDROID`; it gets 
> set for host modules too :(
I have no idea who wrote this file, but a bit messy, and that's why I am trying 
to get rid of it. :)

I didn't know about the `__ANDROID__` thing. I'll try using that instead (and 
yes, I'd still like this to compile with gcc -- that's what we are using 
currently, although we may switch once this is sorted out).


https://reviews.llvm.org/D27305



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27305: Replace __ANDROID_NDK__ with simply ANDROID

2016-12-01 Thread Dan Albert via Phabricator via lldb-commits
danalbert added inline comments.



Comment at: cmake/platforms/Android.cmake:36
 # flags and definitions
 remove_definitions( -DANDROID -D__ANDROID__ )
+add_definitions( -DANDROID -DLLDB_DISABLE_LIBEDIT )

You're removing it a line before just to add it back?

`__ANDROID__` is probably the one you want. That one is defined by Clang (and 
GCC if that matters) for any Android target, so no need to worry about dealing 
with it in cmake (or any other build system).

This isn't a concern right now, but if LLDB ever needed to become part of the 
Android platform build, `ANDROID` doesn't actually mean `ANDROID`; it gets set 
for host modules too :(


https://reviews.llvm.org/D27305



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27305: Replace __ANDROID_NDK__ with simply ANDROID

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: tberghammer, zturner.
labath added a subscriber: lldb-commits.
Herald added subscribers: mgorny, srhines, danalbert.

This replaces all the uses of the __ANDROID_NDK__ define with ANDROID. This is a
preparatory step to remove our custom android toolchain file and rely on the
standard android NDK one instead. Our toolchain file defined both ANDROID and
__ANDROID_NDK__, while the NDK one just defines ANDROID. So, make things
consistent and just use ANDROID everywhere.

I haven't yet removed the cmake variable with the same name, as we will need to
do something completely different there -- NDK toolchain defines
CMAKE_SYSTEM_NAME to Android, while our current one pretends it's linux.


https://reviews.llvm.org/D27305

Files:
  cmake/platforms/Android.cmake
  include/lldb/Core/RegularExpression.h
  include/lldb/Host/Config.h
  include/lldb/Host/Editline.h
  include/lldb/Host/Host.h
  include/lldb/Host/HostInfo.h
  include/lldb/Host/Time.h
  include/lldb/Host/linux/Personality.h
  include/lldb/Host/posix/Fcntl.h
  source/Host/common/Host.cpp
  source/Host/common/Socket.cpp
  source/Host/linux/ProcessLauncherLinux.cpp
  source/Host/posix/HostInfoPosix.cpp
  source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
  source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
  source/Utility/PseudoTerminal.cpp
  tools/driver/Driver.cpp

Index: tools/driver/Driver.cpp
===
--- tools/driver/Driver.cpp
+++ tools/driver/Driver.cpp
@@ -19,7 +19,7 @@
 #if defined(_WIN32)
 #include 
 #include 
-#elif defined(__ANDROID_NDK__)
+#elif defined(ANDROID)
 #include 
 #else
 #include 
Index: source/Utility/PseudoTerminal.cpp
===
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -20,7 +20,7 @@
 
 #include "lldb/Host/PosixApi.h"
 
-#if defined(__ANDROID_NDK__)
+#if defined(ANDROID)
 int posix_openpt(int flags);
 #endif
 
Index: source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
===
--- source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
+++ source/Plugins/Process/Utility/RegisterContextMacOSXFrameBackchain.cpp
@@ -120,7 +120,7 @@
 // the same bytes size as "double"
 #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__) &&   \
 !defined(_MSC_VER) && !defined(__mips__) && !defined(__powerpc__) &&   \
-!defined(__ANDROID_NDK__)
+!defined(ANDROID)
 case sizeof(long double):
   if (sizeof(long double) == sizeof(uint32_t)) {
 value.SetUInt32(reg_value, RegisterValue::eTypeLongDouble);
Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
===
--- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
+++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
@@ -9,7 +9,7 @@
 
 #include "ObjectContainerBSDArchive.h"
 
-#if defined(_WIN32) || defined(__ANDROID_NDK__)
+#if defined(_WIN32) || defined(ANDROID)
 // Defines from ar, missing on Windows
 #define ARMAG "!\n"
 #define SARMAG 8
Index: source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
===
--- source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
+++ source/Plugins/Language/CPlusPlus/CxxStringTypes.cpp
@@ -28,7 +28,7 @@
 
 #include 
 
-#if __ANDROID_NDK__
+#if ANDROID
 #include 
 #endif
 
Index: source/Host/posix/HostInfoPosix.cpp
===
--- source/Host/posix/HostInfoPosix.cpp
+++ source/Host/posix/HostInfoPosix.cpp
@@ -48,7 +48,7 @@
   return false;
 }
 
-#ifdef __ANDROID_NDK__
+#ifdef ANDROID
 #include 
 #endif
 #if defined(__ANDROID_API__) && __ANDROID_API__ < 21
Index: source/Host/linux/ProcessLauncherLinux.cpp
===
--- source/Host/linux/ProcessLauncherLinux.cpp
+++ source/Host/linux/ProcessLauncherLinux.cpp
@@ -26,7 +26,7 @@
 using namespace lldb_private;
 
 static void FixupEnvironment(Args ) {
-#ifdef __ANDROID_NDK__
+#ifdef ANDROID
   // If there is no PATH variable specified inside the environment then set the
   // path to /system/bin. It is required because the default path used by
   // execve() is wrong on android.
Index: source/Host/common/Socket.cpp
===
--- source/Host/common/Socket.cpp
+++ source/Host/common/Socket.cpp
@@ -33,7 +33,7 @@
 #include "lldb/Host/linux/AbstractSocket.h"
 #endif
 
-#ifdef __ANDROID_NDK__
+#ifdef ANDROID
 #include 
 #include 
 #include 
@@ -44,7 +44,7 @@
 #include 
 #include 
 #endif // ANDROID_ARM_BUILD_STATIC || 

[Lldb-commits] [lldb] r288387 - Remove another hack from the android toolchain file

2016-12-01 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  1 11:48:51 2016
New Revision: 288387

URL: http://llvm.org/viewvc/llvm-project?rev=288387=rev
Log:
Remove another hack from the android toolchain file

This is no longer an issue with recent versions of the android ndk.

Modified:
lldb/trunk/cmake/platforms/Android.cmake

Modified: lldb/trunk/cmake/platforms/Android.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/platforms/Android.cmake?rev=288387=288386=288387=diff
==
--- lldb/trunk/cmake/platforms/Android.cmake (original)
+++ lldb/trunk/cmake/platforms/Android.cmake Thu Dec  1 11:48:51 2016
@@ -163,12 +163,3 @@ set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOO
 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
-
-# BEGIN EVIL HACK ##
-# In the android-arm NDK unwind.h and link.h contains 2 conflicting
-# typedef for _Unwind_Ptr. Force HAVE_UNWIND_BACKTRACE to 0 to prevent
-# LLVM from finding unwind.h what would break the build.
-if ( ANDROID_ABI STREQUAL "armeabi" )
- set( HAVE_UNWIND_BACKTRACE 0 CACHE INTERNAL "Hack to disable the finding of 
unwind.h on Android arm" )
-endif()
-# END EVIL HACK 


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[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=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=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=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=288385=288386=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, _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 is kCFStringEncodingUTF32 */
+   

[Lldb-commits] [PATCH] D27291: Handle UTF-16 and UTF-32 constant CFStrings

2016-12-01 Thread Sean Callanan via Phabricator via lldb-commits
spyffe updated this revision to Diff 79935.
spyffe added a comment.

Updated to reflect Jim's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D27291

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

Index: source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
===
--- source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -498,42 +498,60 @@
   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 */
+  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 is kCFStringEncodingUTF32 */
+   break;
+ default:
+   encoding_flags = 0x0600; /* fall back to 0x0600, kCFStringEncodingASCII */
+   if (log) {
+ log->Printf("Encountered an Objective-C constant string with unusual "
+ "element size %llu",
+ string_array->getElementByteSize());
+   }
+ }
+ Constant *encoding_arg = ConstantInt::get(i32_ty, encoding_flags, false);
+ Constant *isExternal_arg =
+ ConstantInt::get(i8_ty, 0x0, false); /* 0x0 is false */
 
-  Value *argument_array[5];
+ 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;
+ 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);
+ ArrayRef CFSCWB_arguments(argument_array, 5);
 
-  FunctionValueCache CFSCWB_Caller(
-  [this, _arguments](llvm::Function *function) -> llvm::Value * {
-return CallInst::Create(
-m_CFStringCreateWithBytes, CFSCWB_arguments,
-"CFStringCreateWithBytes",
-llvm::cast(
-m_entry_instruction_finder.GetValue(function)));
-  });
+ FunctionValueCache CFSCWB_Caller(
+ [this, _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");
+ 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_error_stream.Printf("error [IRForTarget internal]: Couldn't replace an "
+ "Objective-C constant string with a dynamic "
+ "string\n");
 
-return false;
+   return false;
   }
 
   ns_str->eraseFromParent();
@@ -642,31 +660,23 @@
 return false;
   }
 
-  if (nsstring_expr->getOpcode() != Instruction::GetElementPtr) {
-if (log)
-  log->Printf("NSString initializer's str element is not a "
-  "GetElementPtr expression, it's a %s",
-  nsstring_expr->getOpcodeName());
+  GlobalVariable *cstr_global = nullptr;
 
-m_error_stream.Printf("Internal error [IRForTarget]: An Objective-C "
-  "constant string's string initializer is not an "
-  "array\n");
-
-return false;
+  if (nsstring_expr->getOpcode() == Instruction::GetElementPtr) {
+Constant *nsstring_cstr = nsstring_expr->getOperand(0);
+cstr_global = dyn_cast(nsstring_cstr);
+  } else if (nsstring_expr->getOpcode() == 

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 79890.
nitesh.jain added a comment.

Update diff as per suggestion.

Thanks


https://reviews.llvm.org/D27088

Files:
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+_mips_fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in 
range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self._mips_fr_flag = 1
+self._mips_fr_flag = (sr_value >> 26) & self._mips_fr_flag
+
+if reg_info["format"] == "float" and (self._mips_fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+_mips_fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self._mips_fr_flag = 1
+self._mips_fr_flag = (sr_value >> 26) & self._mips_fr_flag
+
+if reg_info["format"] == "float" and (self._mips_fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * 

[Lldb-commits] [PATCH] D26505: Remove a hack from the Android toolchain file

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288331: Remove a hack from the Android toolchain file 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D26505?vs=77484=79889#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26505

Files:
  lldb/trunk/cmake/platforms/Android.cmake


Index: lldb/trunk/cmake/platforms/Android.cmake
===
--- lldb/trunk/cmake/platforms/Android.cmake
+++ lldb/trunk/cmake/platforms/Android.cmake
@@ -172,27 +172,3 @@
  set( HAVE_UNWIND_BACKTRACE 0 CACHE INTERNAL "Hack to disable the finding of 
unwind.h on Android arm" )
 endif()
 # END EVIL HACK 
-
-# BEGIN EVIL HACK ##
-# lldb-server links against libdl even though it's not being used and
-# libdl.a is currently missing from the toolchain (b.android.com/178517).
-# Therefore, in order to statically link lldb-server, we need a temporary
-# workaround. This creates a dummy libdl.a stub until the actual
-# libdl.a can be implemented in the toolchain.
-if( LLVM_BUILD_STATIC )
- set( libdl "${CMAKE_BINARY_DIR}/libdl_stub" )
- file( MAKE_DIRECTORY ${libdl} )
- file( WRITE "${libdl}/libdl.c" "
-#include 
-void *   dlopen  (const char *filename, int flag)   { return 0; }
-const char * dlerror (void) { return 0; }
-void *   dlsym   (void *handle, const char *symbol) { return 0; }
-int  dlclose (void *handle) { return 0; }
-int  dladdr  (const void *addr, Dl_info *info)  { return 0; }")
- set( flags "${CMAKE_C_FLAGS}" )
- separate_arguments( flags )
- execute_process( COMMAND ${CMAKE_C_COMPILER} ${flags} -c ${libdl}/libdl.c -o 
${libdl}/libdl.o )
- execute_process( COMMAND ${CMAKE_AR} rcs ${libdl}/libdl.a ${libdl}/libdl.o )
- set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${libdl}" )
-endif()
-# END EVIL HACK ##


Index: lldb/trunk/cmake/platforms/Android.cmake
===
--- lldb/trunk/cmake/platforms/Android.cmake
+++ lldb/trunk/cmake/platforms/Android.cmake
@@ -172,27 +172,3 @@
  set( HAVE_UNWIND_BACKTRACE 0 CACHE INTERNAL "Hack to disable the finding of unwind.h on Android arm" )
 endif()
 # END EVIL HACK 
-
-# BEGIN EVIL HACK ##
-# lldb-server links against libdl even though it's not being used and
-# libdl.a is currently missing from the toolchain (b.android.com/178517).
-# Therefore, in order to statically link lldb-server, we need a temporary
-# workaround. This creates a dummy libdl.a stub until the actual
-# libdl.a can be implemented in the toolchain.
-if( LLVM_BUILD_STATIC )
- set( libdl "${CMAKE_BINARY_DIR}/libdl_stub" )
- file( MAKE_DIRECTORY ${libdl} )
- file( WRITE "${libdl}/libdl.c" "
-#include 
-void *   dlopen  (const char *filename, int flag)   { return 0; }
-const char * dlerror (void) { return 0; }
-void *   dlsym   (void *handle, const char *symbol) { return 0; }
-int  dlclose (void *handle) { return 0; }
-int  dladdr  (const void *addr, Dl_info *info)  { return 0; }")
- set( flags "${CMAKE_C_FLAGS}" )
- separate_arguments( flags )
- execute_process( COMMAND ${CMAKE_C_COMPILER} ${flags} -c ${libdl}/libdl.c -o ${libdl}/libdl.o )
- execute_process( COMMAND ${CMAKE_AR} rcs ${libdl}/libdl.a ${libdl}/libdl.o )
- set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${libdl}" )
-endif()
-# END EVIL HACK ##
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r288331 - Remove a hack from the Android toolchain file

2016-12-01 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  1 05:30:08 2016
New Revision: 288331

URL: http://llvm.org/viewvc/llvm-project?rev=288331=rev
Log:
Remove a hack from the Android toolchain file

Summary:
The fix is to make sure llvm does not pull in dlopen() in configurations where 
it
is not available.

Reviewers: tberghammer, beanz

Subscribers: danalbert, srhines, lldb-commits, mgorny

Differential Revision: https://reviews.llvm.org/D26505

Modified:
lldb/trunk/cmake/platforms/Android.cmake

Modified: lldb/trunk/cmake/platforms/Android.cmake
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/platforms/Android.cmake?rev=288331=288330=288331=diff
==
--- lldb/trunk/cmake/platforms/Android.cmake (original)
+++ lldb/trunk/cmake/platforms/Android.cmake Thu Dec  1 05:30:08 2016
@@ -172,27 +172,3 @@ if ( ANDROID_ABI STREQUAL "armeabi" )
  set( HAVE_UNWIND_BACKTRACE 0 CACHE INTERNAL "Hack to disable the finding of 
unwind.h on Android arm" )
 endif()
 # END EVIL HACK 
-
-# BEGIN EVIL HACK ##
-# lldb-server links against libdl even though it's not being used and
-# libdl.a is currently missing from the toolchain (b.android.com/178517).
-# Therefore, in order to statically link lldb-server, we need a temporary
-# workaround. This creates a dummy libdl.a stub until the actual
-# libdl.a can be implemented in the toolchain.
-if( LLVM_BUILD_STATIC )
- set( libdl "${CMAKE_BINARY_DIR}/libdl_stub" )
- file( MAKE_DIRECTORY ${libdl} )
- file( WRITE "${libdl}/libdl.c" "
-#include 
-void *   dlopen  (const char *filename, int flag)   { return 0; }
-const char * dlerror (void) { return 0; }
-void *   dlsym   (void *handle, const char *symbol) { return 0; }
-int  dlclose (void *handle) { return 0; }
-int  dladdr  (const void *addr, Dl_info *info)  { return 0; }")
- set( flags "${CMAKE_C_FLAGS}" )
- separate_arguments( flags )
- execute_process( COMMAND ${CMAKE_C_COMPILER} ${flags} -c ${libdl}/libdl.c -o 
${libdl}/libdl.o )
- execute_process( COMMAND ${CMAKE_AR} rcs ${libdl}/libdl.a ${libdl}/libdl.o )
- set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L${libdl}" )
-endif()
-# END EVIL HACK ##


___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27258: Use Timeout<> in Process::RunThreadPlan

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288326: Use Timeout<> in Process::RunThreadPlan (authored by 
labath).

Changed prior to commit:
  https://reviews.llvm.org/D27258?vs=79737=79886#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27258

Files:
  lldb/trunk/source/Target/Process.cpp

Index: lldb/trunk/source/Target/Process.cpp
===
--- lldb/trunk/source/Target/Process.cpp
+++ lldb/trunk/source/Target/Process.cpp
@@ -13,6 +13,7 @@
 #include 
 
 // Other libraries and framework includes
+#include "llvm/Support/ScopedPrinter.h"
 // Project includes
 #include "Plugins/Process/Utility/InferiorCallPOSIX.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
@@ -4799,6 +4800,45 @@
 };
 } // anonymous namespace
 
+static microseconds
+GetOneThreadExpressionTimeout(const EvaluateExpressionOptions ) {
+  const milliseconds default_one_thread_timeout(250);
+
+  // If the overall wait is forever, then we don't need to worry about it.
+  if (options.GetTimeoutUsec() == 0) {
+if (options.GetOneThreadTimeoutUsec() != 0)
+  return microseconds(options.GetOneThreadTimeoutUsec());
+return default_one_thread_timeout;
+  }
+
+  // If the one thread timeout is set, use it.
+  if (options.GetOneThreadTimeoutUsec() != 0)
+return microseconds(options.GetOneThreadTimeoutUsec());
+
+  // Otherwise use half the total timeout, bounded by the
+  // default_one_thread_timeout.
+  return std::min(default_one_thread_timeout,
+microseconds(options.GetTimeoutUsec()) / 2);
+}
+
+static Timeout
+GetExpressionTimeout(const EvaluateExpressionOptions ,
+ bool before_first_timeout) {
+  // If we are going to run all threads the whole time, or if we are only
+  // going to run one thread, we can just return the overall timeout.
+  if (!options.GetStopOthers() || !options.GetTryAllThreads())
+return ConvertTimeout(microseconds(options.GetTimeoutUsec()));
+
+  if (before_first_timeout)
+return GetOneThreadExpressionTimeout(options);
+
+  if (options.GetTimeoutUsec() == 0)
+return llvm::None;
+  else
+return microseconds(options.GetTimeoutUsec()) -
+   GetOneThreadExpressionTimeout(options);
+}
+
 ExpressionResults
 Process::RunThreadPlan(ExecutionContext _ctx,
lldb::ThreadPlanSP _plan_sp,
@@ -4879,6 +4919,16 @@
 }
   }
 
+  // Make sure the timeout values make sense. The one thread timeout needs to be
+  // smaller than the overall timeout.
+  if (options.GetOneThreadTimeoutUsec() != 0 && options.GetTimeoutUsec() != 0 &&
+  options.GetTimeoutUsec() < options.GetOneThreadTimeoutUsec()) {
+diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "RunThreadPlan called with one thread "
+ "timeout greater than total timeout");
+return eExpressionSetupError;
+  }
+
   StackID ctx_frame_id = selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
@@ -4985,67 +5035,20 @@
   // that we have to halt the target.
 bool do_resume = true;
 bool handle_running_event = true;
-const uint64_t default_one_thread_timeout_usec = 25;
 
 // This is just for accounting:
 uint32_t num_resumes = 0;
 
-uint32_t timeout_usec = options.GetTimeoutUsec();
-uint32_t one_thread_timeout_usec;
-uint32_t all_threads_timeout_usec = 0;
-
 // If we are going to run all threads the whole time, or if we are only
-// going to run one thread,
-// then we don't need the first timeout.  So we set the final timeout, and
-// pretend we are after the
-// first timeout already.
-
-if (!options.GetStopOthers() || !options.GetTryAllThreads()) {
+// going to run one thread, then we don't need the first timeout.  So we
+// pretend we are after the first timeout already.
+if (!options.GetStopOthers() || !options.GetTryAllThreads())
   before_first_timeout = false;
-  one_thread_timeout_usec = 0;
-  all_threads_timeout_usec = timeout_usec;
-} else {
-  uint32_t option_one_thread_timeout = options.GetOneThreadTimeoutUsec();
-
-  // If the overall wait is forever, then we only need to set the one thread
-  // timeout:
-  if (timeout_usec == 0) {
-if (option_one_thread_timeout != 0)
-  one_thread_timeout_usec = option_one_thread_timeout;
-else
-  one_thread_timeout_usec = default_one_thread_timeout_usec;
-  } else {
-// Otherwise, if the one thread timeout is set, make sure it isn't
-// longer than the overall timeout,
-// and use it, otherwise use half the total timeout, bounded by the
-// default_one_thread_timeout_usec.
-uint64_t computed_one_thread_timeout;
-if (option_one_thread_timeout != 0) {
-  if 

[Lldb-commits] [lldb] r288326 - Use Timeout<> in Process::RunThreadPlan

2016-12-01 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  1 04:57:30 2016
New Revision: 288326

URL: http://llvm.org/viewvc/llvm-project?rev=288326=rev
Log:
Use Timeout<> in Process::RunThreadPlan

Summary:
Since the function is way too big already, I tried at least to factor out the
timeout computation stuff into a separate function. I've tried to make the new
code semantically equivalent, and it also makes sense when I look at it as a 
done
deal.

Reviewers: jingham

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D27258

Modified:
lldb/trunk/source/Target/Process.cpp

Modified: lldb/trunk/source/Target/Process.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=288326=288325=288326=diff
==
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Thu Dec  1 04:57:30 2016
@@ -13,6 +13,7 @@
 #include 
 
 // Other libraries and framework includes
+#include "llvm/Support/ScopedPrinter.h"
 // Project includes
 #include "Plugins/Process/Utility/InferiorCallPOSIX.h"
 #include "lldb/Breakpoint/BreakpointLocation.h"
@@ -4799,6 +4800,45 @@ private:
 };
 } // anonymous namespace
 
+static microseconds
+GetOneThreadExpressionTimeout(const EvaluateExpressionOptions ) {
+  const milliseconds default_one_thread_timeout(250);
+
+  // If the overall wait is forever, then we don't need to worry about it.
+  if (options.GetTimeoutUsec() == 0) {
+if (options.GetOneThreadTimeoutUsec() != 0)
+  return microseconds(options.GetOneThreadTimeoutUsec());
+return default_one_thread_timeout;
+  }
+
+  // If the one thread timeout is set, use it.
+  if (options.GetOneThreadTimeoutUsec() != 0)
+return microseconds(options.GetOneThreadTimeoutUsec());
+
+  // Otherwise use half the total timeout, bounded by the
+  // default_one_thread_timeout.
+  return std::min(default_one_thread_timeout,
+microseconds(options.GetTimeoutUsec()) / 2);
+}
+
+static Timeout
+GetExpressionTimeout(const EvaluateExpressionOptions ,
+ bool before_first_timeout) {
+  // If we are going to run all threads the whole time, or if we are only
+  // going to run one thread, we can just return the overall timeout.
+  if (!options.GetStopOthers() || !options.GetTryAllThreads())
+return ConvertTimeout(microseconds(options.GetTimeoutUsec()));
+
+  if (before_first_timeout)
+return GetOneThreadExpressionTimeout(options);
+
+  if (options.GetTimeoutUsec() == 0)
+return llvm::None;
+  else
+return microseconds(options.GetTimeoutUsec()) -
+   GetOneThreadExpressionTimeout(options);
+}
+
 ExpressionResults
 Process::RunThreadPlan(ExecutionContext _ctx,
lldb::ThreadPlanSP _plan_sp,
@@ -4879,6 +4919,16 @@ Process::RunThreadPlan(ExecutionContext
 }
   }
 
+  // Make sure the timeout values make sense. The one thread timeout needs to 
be
+  // smaller than the overall timeout.
+  if (options.GetOneThreadTimeoutUsec() != 0 && options.GetTimeoutUsec() != 0 
&&
+  options.GetTimeoutUsec() < options.GetOneThreadTimeoutUsec()) {
+diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "RunThreadPlan called with one thread "
+ "timeout greater than total timeout");
+return eExpressionSetupError;
+  }
+
   StackID ctx_frame_id = selected_frame_sp->GetStackID();
 
   // N.B. Running the target may unset the currently selected thread and frame.
@@ -4985,67 +5035,20 @@ Process::RunThreadPlan(ExecutionContext
   // that we have to halt the target.
 bool do_resume = true;
 bool handle_running_event = true;
-const uint64_t default_one_thread_timeout_usec = 25;
 
 // This is just for accounting:
 uint32_t num_resumes = 0;
 
-uint32_t timeout_usec = options.GetTimeoutUsec();
-uint32_t one_thread_timeout_usec;
-uint32_t all_threads_timeout_usec = 0;
-
 // If we are going to run all threads the whole time, or if we are only
-// going to run one thread,
-// then we don't need the first timeout.  So we set the final timeout, and
-// pretend we are after the
-// first timeout already.
-
-if (!options.GetStopOthers() || !options.GetTryAllThreads()) {
+// going to run one thread, then we don't need the first timeout.  So we
+// pretend we are after the first timeout already.
+if (!options.GetStopOthers() || !options.GetTryAllThreads())
   before_first_timeout = false;
-  one_thread_timeout_usec = 0;
-  all_threads_timeout_usec = timeout_usec;
-} else {
-  uint32_t option_one_thread_timeout = options.GetOneThreadTimeoutUsec();
-
-  // If the overall wait is forever, then we only need to set the one 
thread
-  // timeout:
-  if (timeout_usec == 0) {
-if (option_one_thread_timeout != 0)
-  

[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

lgtm, after you consider my comment below.




Comment at: 
packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py:30
+# Indicating SR.FR bit status
+fr_flag = 1
 

The reason I suggested a different signature for the function 
(`getExpectedBitsize(reg_info, reg_infos)`) was that then you would not need to 
maintain any global state. The function could compute the presence of the flag 
as necessary (maybe even via some helper function). Maybe we'd need to do some 
of the work multiple times, but it's not like this is performance critical code 
anyway.

If you don't want to do that, then at least indicate that this flag is 
mips-specific (`_mips_fr_flag`, leading underscore is python convention of 
"private").


https://reviews.llvm.org/D27088



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D27088: [LLDB][MIPS] Fix TestLldbGdbServer failure for MIPS

2016-12-01 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated this revision to Diff 79881.
nitesh.jain added a comment.

Update diff as per suggestion.


https://reviews.llvm.org/D27088

Files:
  packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in 
range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self.fr_flag = 1
+self.fr_flag = (sr_value >> 26) & self.fr_flag
+
+if reg_info["format"] == "float" and (self.fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop


Index: packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
===
--- packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
+++ packages/Python/lldbsuite/test/tools/lldb-server/TestLldbGdbServer.py
@@ -12,7 +12,7 @@
 
 from __future__ import print_function
 
-
+import struct
 import unittest2
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -26,6 +26,8 @@
 class LldbGdbServerTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
 
 mydir = TestBase.compute_mydir(__file__)
+# Indicating SR.FR bit status
+fr_flag = 1
 
 @debugserver_test
 def test_exe_starts_debugserver(self):
@@ -528,6 +530,25 @@
 self.set_inferior_startup_attach()
 self.qThreadInfo_matches_qC()
 
+def updateRegInfoBitsize(self, reg_info, p_response):
+if reg_info["name"] == "sr":
+split_triple = self.triple.split("--",1)
+if split_triple[0] == "mips64el" or split_triple == "mipsel":
+# In case of little endian
+# first decode the HEX ASCII bytes and then reverse it
+# to get actual value of SR register
+p_response = "".join(reversed([p_response[i:i+2] for i in range(0,
+len(p_response),2)]))
+# Check for SR.FR bit
+# if SR.FR(26) == 0 && reg_info["format"] == "float"
+# then reg_info["bitsize"] = 32
+sr_value = int(p_response,16)
+self.fr_flag = 1
+self.fr_flag = (sr_value >> 26) & self.fr_flag
+
+if reg_info["format"] == "float" and (self.fr_flag != 1):
+reg_info["bitsize"] = 32
+
 def p_returns_correct_data_size_for_each_qRegisterInfo(self):
 procs = self.prep_debug_monitor_and_inferior()
 self.add_register_info_collection_packets()
@@ -565,6 +586,11 @@
 # Verify the response length.
 p_response = context.get("p_response")
 self.assertIsNotNone(p_response)
+self.triple = lldb.DBG.GetSelectedPlatform().GetTriple()
+
+if re.match("^mips",self.triple):
+self.updateRegInfoBitsize(reg_info, p_response)
+
 self.assertEqual(len(p_response), 2 * int(reg_info["bitsize"]) / 8)
 
 # Increment loop

[Lldb-commits] [PATCH] D27289: Return "thread-pcs" in jstopinfo on Linux/Android.

2016-12-01 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Looks like a good starting point. Apart from some style nits, I'd like us to 
remove sending of the `registers` field in the `jstopinfo`, as it is not 
necessary anymore. Also, we should add an lldb-server style test for this.

@jasonmolenda, we already have jThreadsInfo support in lldb-server, albeit 
without the memory snippet parts. A lot less functions use frame pointers on 
linux than on osx, so I was not sure whether implementing the simple 
FP-following will be useful. However, that is the next thing on my mind in 
terms of optimizations here.




Comment at: 
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:441
 
+static void WriteRegisterValueInHexFixedWidth(
+StreamString , NativeRegisterContextSP _ctx_sp,

This function is called in only two sites. My preference would be to update 
them to use the new signature instead of adding another overload.



Comment at: 
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:579
 
 if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
   thread_obj_sp->SetObject("registers", registers_sp);

We can now change this code to:
```
if (!abridged) {
  if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp))
...
}
```

This was my attempt to send the PCs in the `jstopinfo` field, which used to 
work at some point, but now lldb client does not seem to recognize it. When we 
start sending the PC in the `thread-pcs` field, the whole `registers` field 
will become completely redundant, and we should remove it.

This will not affect the `jThreadsInfo` packet, as there we pass `abridged = 
false`.

(Obviously we should also clean up the `GetRegistersAsJSON` function to reflect 
the fact it does not need to support PC-only register sending.)



Comment at: 
source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp:582
 
+
 thread_obj_sp->SetObject("tid", std::make_shared(tid));

Please remove the random whitespace.


https://reviews.llvm.org/D27289



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits