[Lldb-commits] [PATCH] D27222: Remove an x86-ism from RegisterInfoInterface

2016-11-30 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288236: Remove an x86-ism from RegisterInfoInterface 
(authored by labath).

Changed prior to commit:
  https://reviews.llvm.org/D27222?vs=79618&id=79713#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27222

Files:
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
  lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
  lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h


Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
@@ -18,8 +18,6 @@
 
   size_t GetGPRSize() const override;
 
-  size_t GetFXSAVEOffset() const override;
-
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
   uint32_t GetRegisterCount() const override;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
@@ -420,7 +420,7 @@
 }
 
 size_t RegisterContextPOSIX_x86::GetFXSAVEOffset() {
-  return m_register_info_ap->GetFXSAVEOffset();
+  return GetRegisterInfo()[m_reg_info.first_fpr].byte_offset;
 }
 
 const RegisterInfo *RegisterContextPOSIX_x86::GetRegisterInfo() {
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
@@ -179,11 +179,6 @@
 
 size_t RegisterContextLinux_x86_64::GetGPRSize() const { return sizeof(GPR); }
 
-size_t RegisterContextLinux_x86_64::GetFXSAVEOffset() const {
-  return (LLVM_EXTENSION offsetof(UserArea, fpr) +
-  LLVM_EXTENSION offsetof(FPR, xstate));
-}
-
 const std::vector *
 RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const {
   return &d_register_infos;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
@@ -111,10 +111,6 @@
 
 size_t RegisterContextLinux_i386::GetGPRSize() const { return sizeof(GPR); }
 
-size_t RegisterContextLinux_i386::GetFXSAVEOffset() const {
-  return (LLVM_EXTENSION offsetof(UserArea, i387));
-}
-
 const RegisterInfo *RegisterContextLinux_i386::GetRegisterInfo() const {
   switch (m_target_arch.GetMachine()) {
   case llvm::Triple::x86:
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
@@ -18,8 +18,6 @@
 
   size_t GetGPRSize() const override;
 
-  size_t GetFXSAVEOffset() const override;
-
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
   uint32_t GetRegisterCount() const override;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h
@@ -29,8 +29,6 @@
 
   virtual size_t GetGPRSize() const = 0;
 
-  virtual size_t GetFXSAVEOffset() const { return 0; }
-
   virtual const lldb_private::RegisterInfo *GetRegisterInfo() const = 0;
 
   // Returns the number of registers including the user registers and the


Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
@@ -18,8 +18,6 @@
 
   size_t GetGPRSize() const override;
 
-  size_t GetFXSAVEOffset() const override;
-
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
   uint32_t GetRegisterCount() const override;
Index: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContext

[Lldb-commits] [lldb] r288236 - Remove an x86-ism from RegisterInfoInterface

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 04:17:58 2016
New Revision: 288236

URL: http://llvm.org/viewvc/llvm-project?rev=288236&view=rev
Log:
Remove an x86-ism from RegisterInfoInterface

Summary:
While adding FPR support to x86 elf core files (D26300), we ended up adding a
very x86-specific function to the general RegisterInfoInterface class, which I
didn't catch in review. This removes that function. The only reason we needed
it was to find the offset of the FXSAVE area. This is the same as the offset of
the first register within that area, so we might as well use that.

Reviewers: clayborg, dvlahovski

Subscribers: lldb-commits

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

Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
lldb/trunk/source/Plugins/Process/Utility/RegisterInfoInterface.h

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp?rev=288236&r1=288235&r2=288236&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp Wed 
Nov 30 04:17:58 2016
@@ -111,10 +111,6 @@ RegisterContextLinux_i386::RegisterConte
 
 size_t RegisterContextLinux_i386::GetGPRSize() const { return sizeof(GPR); }
 
-size_t RegisterContextLinux_i386::GetFXSAVEOffset() const {
-  return (LLVM_EXTENSION offsetof(UserArea, i387));
-}
-
 const RegisterInfo *RegisterContextLinux_i386::GetRegisterInfo() const {
   switch (m_target_arch.GetMachine()) {
   case llvm::Triple::x86:

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h?rev=288236&r1=288235&r2=288236&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_i386.h Wed 
Nov 30 04:17:58 2016
@@ -18,8 +18,6 @@ public:
 
   size_t GetGPRSize() const override;
 
-  size_t GetFXSAVEOffset() const override;
-
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
   uint32_t GetRegisterCount() const override;

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp?rev=288236&r1=288235&r2=288236&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp 
Wed Nov 30 04:17:58 2016
@@ -179,11 +179,6 @@ RegisterContextLinux_x86_64::RegisterCon
 
 size_t RegisterContextLinux_x86_64::GetGPRSize() const { return sizeof(GPR); }
 
-size_t RegisterContextLinux_x86_64::GetFXSAVEOffset() const {
-  return (LLVM_EXTENSION offsetof(UserArea, fpr) +
-  LLVM_EXTENSION offsetof(FPR, xstate));
-}
-
 const std::vector *
 RegisterContextLinux_x86_64::GetDynamicRegisterInfoP() const {
   return &d_register_infos;

Modified: 
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h?rev=288236&r1=288235&r2=288236&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h Wed 
Nov 30 04:17:58 2016
@@ -18,8 +18,6 @@ public:
 
   size_t GetGPRSize() const override;
 
-  size_t GetFXSAVEOffset() const override;
-
   const lldb_private::RegisterInfo *GetRegisterInfo() const override;
 
   uint32_t GetRegisterCount() const override;

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp?rev=288236&r1=288235&r2=288236&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp Wed 
Nov 30 04:17:58 2016
@@ -420,7 +42

[Lldb-commits] [lldb] r288237 - Remove a spurious reference to ProcessElfCore

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 04:25:02 2016
New Revision: 288237

URL: http://llvm.org/viewvc/llvm-project?rev=288237&view=rev
Log:
Remove a spurious reference to ProcessElfCore

We were referencing a the process class from a register context, which seems
intuitively wrong. Also, the comment above that code is now definitely 
incorrect,
as ProcessElfCore now does support floating point registers. Also, the code
wasn't really doing anything, as it was just skipping a zero-initialization of a
field that was most likely zero-initialized anyway. Linux elf core FPR test 
still
passes after this.

Modified:
lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
lldb/trunk/tools/lldb-server/CMakeLists.txt

Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp?rev=288237&r1=288236&r2=288237&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextPOSIX_x86.cpp Wed 
Nov 30 04:25:02 2016
@@ -18,9 +18,9 @@
 #include "lldb/Host/Endian.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
+#include "lldb/Target/Process.h"
 #include "llvm/Support/Compiler.h"
 
-#include "Plugins/Process/elf-core/ProcessElfCore.h"
 #include "RegisterContextPOSIX_x86.h"
 #include "RegisterContext_x86.h"
 
@@ -373,11 +373,6 @@ RegisterContextPOSIX_x86::RegisterContex
 
   ::memset(&m_fpr, 0, sizeof(FPR));
 
-  // elf-core yet to support ReadFPR()
-  ProcessSP base = CalculateProcess();
-  if (base.get()->GetPluginName() == ProcessElfCore::GetPluginNameStatic())
-return;
-
   m_fpr_type = eNotValid;
 }
 

Modified: lldb/trunk/tools/lldb-server/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-server/CMakeLists.txt?rev=288237&r1=288236&r2=288237&view=diff
==
--- lldb/trunk/tools/lldb-server/CMakeLists.txt (original)
+++ lldb/trunk/tools/lldb-server/CMakeLists.txt Wed Nov 30 04:25:02 2016
@@ -72,7 +72,6 @@ set( LLDB_USED_LIBS
   lldbPluginInstructionMIPS
   lldbPluginInstructionMIPS64
   lldbPluginObjectFilePECOFF
-  lldbPluginProcessElfCore
   lldbPluginExpressionParserClang
   lldbPluginExpressionParserGo
   )


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


[Lldb-commits] [lldb] r288238 - Use Timeout<> in the Listener class

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 04:41:42 2016
New Revision: 288238

URL: http://llvm.org/viewvc/llvm-project?rev=288238&view=rev
Log:
Use Timeout<> in the Listener class

Summary:
Communication classes use the Timeout<> class to specify the timeout. Listener
class was converted to chrono some time ago, but it used a different meaning for
a timeout of zero (Listener: infinite wait, Communication: no wait). Instead,
Listener provided separate functions which performed a non-blocking event read.

This converts the Listener class to the new Timeout class, to improve
consistency. It also allows us to get merge the different GetNextEvent*** and
WaitForEvent*** functions into one. No functional change intended.

Reviewers: jingham, clayborg, zturner

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Core/Listener.h
lldb/trunk/source/API/SBDebugger.cpp
lldb/trunk/source/API/SBListener.cpp
lldb/trunk/source/Core/Communication.cpp
lldb/trunk/source/Core/Debugger.cpp
lldb/trunk/source/Core/IOHandler.cpp
lldb/trunk/source/Core/Listener.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/unittests/Core/BroadcasterTest.cpp
lldb/trunk/unittests/Core/ListenerTest.cpp
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp

Modified: lldb/trunk/include/lldb/Core/Listener.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Listener.h?rev=288238&r1=288237&r2=288238&view=diff
==
--- lldb/trunk/include/lldb/Core/Listener.h (original)
+++ lldb/trunk/include/lldb/Core/Listener.h Wed Nov 30 04:41:42 2016
@@ -22,6 +22,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Event.h"
+#include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-private.h"
 
 namespace lldb_private {
@@ -70,18 +71,6 @@ public:
 
   bool StopListeningForEvents(Broadcaster *broadcaster, uint32_t event_mask);
 
-  // Returns true if an event was received, false if we timed out.
-  bool WaitForEvent(const std::chrono::microseconds &timeout,
-lldb::EventSP &event_sp);
-
-  bool WaitForEventForBroadcaster(const std::chrono::microseconds &timeout,
-  Broadcaster *broadcaster,
-  lldb::EventSP &event_sp);
-
-  bool WaitForEventForBroadcasterWithType(
-  const std::chrono::microseconds &timeout, Broadcaster *broadcaster,
-  uint32_t event_type_mask, lldb::EventSP &event_sp);
-
   Event *PeekAtNextEvent();
 
   Event *PeekAtNextEventForBroadcaster(Broadcaster *broadcaster);
@@ -89,14 +78,16 @@ public:
   Event *PeekAtNextEventForBroadcasterWithType(Broadcaster *broadcaster,
uint32_t event_type_mask);
 
-  bool GetNextEvent(lldb::EventSP &event_sp);
+  // Returns true if an event was received, false if we timed out.
+  bool GetEvent(lldb::EventSP &event_sp, const Timeout &timeout);
 
-  bool GetNextEventForBroadcaster(Broadcaster *broadcaster,
-  lldb::EventSP &event_sp);
+  bool GetEventForBroadcaster(Broadcaster *broadcaster, lldb::EventSP 
&event_sp,
+  const Timeout &timeout);
 
-  bool GetNextEventForBroadcasterWithType(Broadcaster *broadcaster,
-  uint32_t event_type_mask,
-  lldb::EventSP &event_sp);
+  bool GetEventForBroadcasterWithType(Broadcaster *broadcaster,
+  uint32_t event_type_mask,
+  lldb::EventSP &event_sp,
+  const Timeout &timeout);
 
   size_t HandleBroadcastEvent(lldb::EventSP &event_sp);
 
@@ -128,14 +119,7 @@ private:
 uint32_t num_sources, uint32_t event_type_mask,
 lldb::EventSP &event_sp, bool remove);
 
-  bool
-  GetNextEventInternal(Broadcaster *broadcaster, // nullptr for any broadcaster
-   const ConstString *sources, // nullptr for any event
-   uint32_t num_sources, uint32_t event_type_mask,
-   lldb::EventSP &event_sp);
-
-  bool
-  WaitForEventsInternal(const std::chrono::microseconds &timeout,
+  bool GetEventInternal(const Timeout &timeout,
 Broadcaster *broadcaster, // nullptr for any 
broadcaster
 const ConstString *sources, // nullptr for any event
 uint32_t num_sources, uint32_t event_type_mask,

Modified: lldb/trunk/source/API/SBDebugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=288238&r1=288237&r2=288238&view=diff
==
--- lldb/tr

[Lldb-commits] [PATCH] D27136: Use Timeout<> in the Listener class

2016-11-30 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288238: Use Timeout<> in the Listener class (authored by 
labath).

Changed prior to commit:
  https://reviews.llvm.org/D27136?vs=79313&id=79714#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27136

Files:
  lldb/trunk/include/lldb/Core/Listener.h
  lldb/trunk/source/API/SBDebugger.cpp
  lldb/trunk/source/API/SBListener.cpp
  lldb/trunk/source/Core/Communication.cpp
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/IOHandler.cpp
  lldb/trunk/source/Core/Listener.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/unittests/Core/BroadcasterTest.cpp
  lldb/trunk/unittests/Core/ListenerTest.cpp
  lldb/trunk/unittests/Process/gdb-remote/GDBRemoteClientBaseTest.cpp

Index: lldb/trunk/unittests/Core/ListenerTest.cpp
===
--- lldb/trunk/unittests/Core/ListenerTest.cpp
+++ lldb/trunk/unittests/Core/ListenerTest.cpp
@@ -17,7 +17,7 @@
 using namespace lldb;
 using namespace lldb_private;
 
-TEST(ListenerTest, GetNextEvent) {
+TEST(ListenerTest, GetEventImmediate) {
   EventSP event_sp;
   Broadcaster broadcaster(nullptr, "test-broadcaster");
 
@@ -27,31 +27,34 @@
   ASSERT_EQ(event_mask,
 listener_sp->StartListeningForEvents(&broadcaster, event_mask));
 
+  const std::chrono::seconds timeout(0);
   // Without any events sent, these should return false.
-  EXPECT_FALSE(listener_sp->GetNextEvent(event_sp));
-  EXPECT_FALSE(listener_sp->GetNextEventForBroadcaster(nullptr, event_sp));
-  EXPECT_FALSE(listener_sp->GetNextEventForBroadcaster(&broadcaster, event_sp));
-  EXPECT_FALSE(listener_sp->GetNextEventForBroadcasterWithType(
-  &broadcaster, event_mask, event_sp));
+  EXPECT_FALSE(listener_sp->GetEvent(event_sp, timeout));
+  EXPECT_FALSE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout));
+  EXPECT_FALSE(
+  listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout));
+  EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType(
+  &broadcaster, event_mask, event_sp, timeout));
 
   // Now send events and make sure they get it.
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_TRUE(listener_sp->GetNextEvent(event_sp));
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
 
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_TRUE(listener_sp->GetNextEventForBroadcaster(nullptr, event_sp));
+  EXPECT_TRUE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout));
 
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_TRUE(listener_sp->GetNextEventForBroadcaster(&broadcaster, event_sp));
+  EXPECT_TRUE(
+  listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout));
 
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_FALSE(listener_sp->GetNextEventForBroadcasterWithType(
-  &broadcaster, event_mask * 2, event_sp));
-  EXPECT_TRUE(listener_sp->GetNextEventForBroadcasterWithType(
-  &broadcaster, event_mask, event_sp));
+  EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType(
+  &broadcaster, event_mask * 2, event_sp, timeout));
+  EXPECT_TRUE(listener_sp->GetEventForBroadcasterWithType(
+  &broadcaster, event_mask, event_sp, timeout));
 }
 
-TEST(ListenerTest, WaitForEvent) {
+TEST(ListenerTest, GetEventWait) {
   EventSP event_sp;
   Broadcaster broadcaster(nullptr, "test-broadcaster");
 
@@ -63,33 +66,30 @@
 
   // Without any events sent, these should make a short wait and return false.
   std::chrono::microseconds timeout(10);
-  EXPECT_FALSE(listener_sp->WaitForEvent(timeout, event_sp));
+  EXPECT_FALSE(listener_sp->GetEvent(event_sp, timeout));
+  EXPECT_FALSE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout));
   EXPECT_FALSE(
-  listener_sp->WaitForEventForBroadcaster(timeout, nullptr, event_sp));
-  EXPECT_FALSE(
-  listener_sp->WaitForEventForBroadcaster(timeout, &broadcaster, event_sp));
-  EXPECT_FALSE(listener_sp->WaitForEventForBroadcasterWithType(
-  timeout, &broadcaster, event_mask, event_sp));
+  listener_sp->GetEventForBroadcaster(&broadcaster, event_sp, timeout));
+  EXPECT_FALSE(listener_sp->GetEventForBroadcasterWithType(
+  &broadcaster, event_mask, event_sp, timeout));
 
   // Now send events and make sure they get it.
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_TRUE(listener_sp->WaitForEvent(timeout, event_sp));
+  EXPECT_TRUE(listener_sp->GetEvent(event_sp, timeout));
 
   broadcaster.BroadcastEvent(event_mask, nullptr);
-  EXPECT_TRUE(
-  listener_sp->WaitForEventForBroadcaster(timeout, nullptr, event_sp));
+  EXPECT_TRUE(listener_sp->GetEventForBroadcaster(nullptr, event_sp, timeout));
 
   broadcaster.BroadcastEvent(event_mask, nullptr);
   EXPECT_TRUE(
-  listener_sp->WaitForEventForBroadcaster(timeout, &broadcaster, event_sp));
+  listener_sp->GetEv

[Lldb-commits] [lldb] r288239 - Fix OSX build for r288238

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 05:09:47 2016
New Revision: 288239

URL: http://llvm.org/viewvc/llvm-project?rev=288239&view=rev
Log:
Fix OSX build for r288238

Modified:
lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=288239&r1=288238&r2=288239&view=diff
==
--- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Wed Nov 30 
05:09:47 2016
@@ -796,7 +796,7 @@ void *ProcessKDP::AsyncThread(void *arg)
 log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
 ") listener.WaitForEvent (NULL, event_sp)...",
 pid);
-  if (listener_sp->WaitForEvent(std::chrono::microseconds(0), event_sp)) {
+  if (listener_sp->GetEvent(event_sp, llvm::None)) {
 uint32_t event_type = event_sp->GetType();
 if (log)
   log->Printf("ProcessKDP::AsyncThread (pid = %" PRIu64
@@ -831,7 +831,8 @@ void *ProcessKDP::AsyncThread(void *arg)
   // Check to see if we are supposed to exit. There is no way to
   // interrupt a running kernel, so all we can do is wait for an
   // exception or detach...
-  if (listener_sp->GetNextEvent(event_sp)) {
+  if (listener_sp->GetEvent(event_sp,
+std::chrono::microseconds(0))) {
 // We got an event, go through the loop again
 event_type = event_sp->GetType();
   }


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


[Lldb-commits] [lldb] r288241 - Convert most of the Process class to Timeout<>

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 05:56:32 2016
New Revision: 288241

URL: http://llvm.org/viewvc/llvm-project?rev=288241&view=rev
Log:
Convert most of the Process class to Timeout<>

This changes most of the class to use the new Timeout class. The one function
left is RunThreadPlan, which I left for a separate change as the function is
massive. A couple of things to call out:
- I've renamed the affected functions to match the listener interface names. 
This
  should also help catch any places I did not convert at compile time.
- I've deleted the WaitForState function as it was unused.

Modified:
lldb/trunk/include/lldb/Target/Process.h
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=288241&r1=288240&r2=288241&view=diff
==
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Wed Nov 30 05:56:32 2016
@@ -2415,7 +2415,7 @@ public:
   // false
   // will avoid this behavior.
   lldb::StateType
-  WaitForProcessToStop(const std::chrono::microseconds &timeout,
+  WaitForProcessToStop(const Timeout &timeout,
lldb::EventSP *event_sp_ptr = nullptr,
bool wait_always = true,
lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
@@ -2436,8 +2436,8 @@ public:
   
//--
   void SyncIOHandler(uint32_t iohandler_id, uint64_t timeout_msec);
 
-  lldb::StateType WaitForStateChangedEvents(
-  const std::chrono::microseconds &timeout, lldb::EventSP &event_sp,
+  lldb::StateType GetStateChangedEvents(
+  lldb::EventSP &event_sp, const Timeout &timeout,
   lldb::ListenerSP
   hijack_listener); // Pass an empty ListenerSP to use builtin listener
 
@@ -3105,24 +3105,19 @@ protected:
 
   Error HaltPrivate();
 
-  lldb::StateType
-  WaitForProcessStopPrivate(const std::chrono::microseconds &timeout,
-lldb::EventSP &event_sp);
+  lldb::StateType WaitForProcessStopPrivate(lldb::EventSP &event_sp,
+const Timeout 
&timeout);
 
   // This waits for both the state change broadcaster, and the control
   // broadcaster.
   // If control_only, it only waits for the control broadcaster.
 
-  bool WaitForEventsPrivate(const std::chrono::microseconds &timeout,
-lldb::EventSP &event_sp, bool control_only);
+  bool GetEventsPrivate(lldb::EventSP &event_sp,
+const Timeout &timeout, bool control_only);
 
   lldb::StateType
-  WaitForStateChangedEventsPrivate(const std::chrono::microseconds &timeout,
-   lldb::EventSP &event_sp);
-
-  lldb::StateType WaitForState(const std::chrono::microseconds &timeout,
-   const lldb::StateType *match_states,
-   const uint32_t num_match_states);
+  GetStateChangedEventsPrivate(lldb::EventSP &event_sp,
+   const Timeout &timeout);
 
   size_t WriteMemoryPrivate(lldb::addr_t addr, const void *buf, size_t size,
 Error &error);

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=288241&r1=288240&r2=288241&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Wed Nov 30 
05:56:32 2016
@@ -644,7 +644,7 @@ PlatformLinux::DebugProcess(ProcessLaunc
 // Handle the hijacking of process events.
 if (listener_sp) {
   const StateType state = process_sp->WaitForProcessToStop(
-  std::chrono::microseconds(0), NULL, false, listener_sp);
+  llvm::None, NULL, false, listener_sp);
 
   if (state == eStateStopped) {
 if (log)

Modified: lldb/trunk/source/Target/Process.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=288241&r1=288240&r2=288241&view=diff
==
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed Nov 30 05:56:32 2016
@@ -67,6 +67,7 @@
 
 using namespace lldb;
 using namespace lldb_private;
+using namespace std::chrono;
 
 // A temporary function to convert between old representations of timeouts (0
 // means infinite wait) and new Timeout class (0 means "poll").
@@ -971,11 +972,10 @@ void Process::SyncIOHandler(uint32_t ioh
 __FU

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

2016-11-30 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added a reviewer: jingham.
labath added a subscriber: lldb-commits.

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, but I could use another pair of eyes for this.


https://reviews.llvm.org/D27258

Files:
  source/Target/Process.cpp

Index: source/Target/Process.cpp
===
--- source/Target/Process.cpp
+++ 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 &options) {
+  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 &options,
+ 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 &exe_ctx,
lldb::ThreadPlanSP &thread_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 without 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_ti

[Lldb-commits] [lldb] r288247 - Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()

2016-11-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 30 10:08:45 2016
New Revision: 288247

URL: http://llvm.org/viewvc/llvm-project?rev=288247&view=rev
Log:
Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()

The core of the function was actually handling them correctly. However, the
early exit was being too optimistic and did not give the function a chance to
fire if the path did not contain dots as well.

Fix that and add a couple of unit tests.

Modified:
lldb/trunk/source/Host/common/FileSpec.cpp
lldb/trunk/unittests/Host/FileSpecTest.cpp

Modified: lldb/trunk/source/Host/common/FileSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=288247&r1=288246&r2=288247&view=diff
==
--- lldb/trunk/source/Host/common/FileSpec.cpp (original)
+++ lldb/trunk/source/Host/common/FileSpec.cpp Wed Nov 30 10:08:45 2016
@@ -544,7 +544,8 @@ bool FileSpec::Equal(const FileSpec &a,
 FileSpec FileSpec::GetNormalizedPath() const {
   // Fast path. Do nothing if the path is not interesting.
   if (!m_directory.GetStringRef().contains(".") &&
-  (m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != "."))
+  !m_directory.GetStringRef().contains("//") &&
+  m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != ".")
 return *this;
 
   llvm::SmallString<64> path, result;

Modified: lldb/trunk/unittests/Host/FileSpecTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/FileSpecTest.cpp?rev=288247&r1=288246&r2=288247&view=diff
==
--- lldb/trunk/unittests/Host/FileSpecTest.cpp (original)
+++ lldb/trunk/unittests/Host/FileSpecTest.cpp Wed Nov 30 10:08:45 2016
@@ -206,6 +206,9 @@ TEST(FileSpecTest, GetNormalizedPath) {
   {"/foo/./bar", "/foo/bar"},
   {"/foo/..", "/"},
   {"/foo/.", "/foo"},
+  {"/foo//bar", "/foo/bar"},
+  {"/foo//bar/baz", "/foo/bar/baz"},
+  {"/foo//bar/./baz", "/foo/bar/baz"},
   {"/./foo", "/foo"},
   {"/", "/"},
   {"//", "//"},


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


[Lldb-commits] [PATCH] D27126: Merge Linux and FreeBSD arm register contexts

2016-11-30 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In https://reviews.llvm.org/D27126#607057, @dmikulin wrote:

> I can run tests on 32bit ARM FreeBSD 11.RC3 rpi2, but without software single 
> step not a lot of tests pass on ARM FreeBSD ;)
>  Can we get https://reviews.llvm.org/D25756 committed?


I'll leave that decision up to Ed.
I am not particularly fond of copying code around, but I do see the value of 
having some freebsd arm support instead of none.

As for this patch. A basic does-it-compile test should be enough, but I am 
pretty confident this is fine even without it, as I am just merging two 
identical files.


https://reviews.llvm.org/D27126



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


[Lldb-commits] [PATCH] D27017: Support more report types in AddressSanitizerRuntime.cpp

2016-11-30 Thread Anna Zaks via Phabricator via lldb-commits
zaks.anna accepted this revision.
zaks.anna added a comment.
This revision is now accepted and ready to land.

Looks great to me. Thank you Kuba!!!


https://reviews.llvm.org/D27017



___
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-11-30 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.

That looks correct to me as well.  Thanks for taking the time to clean this up.




Comment at: source/Target/Process.cpp:4926-4928
+diagnostic_manager.PutString(eDiagnosticSeverityError,
+ "RunThreadPlan called without one thread "
+ "timeout greater than total timeout");

without -> with

The error was in the original.


https://reviews.llvm.org/D27258



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


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

2016-11-30 Thread Ed Maste via Phabricator via lldb-commits
emaste added inline comments.



Comment at: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp:551-557
+} else {
+  static const uint8_t g_arm_breakpoint_opcode[] = {0xFE,0xDE,0xFF,0xE7};
+  size_t trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+  assert(bp_site);
+  if (bp_site->SetTrapOpcode(g_arm_breakpoint_opcode, trap_opcode_size))
+return trap_opcode_size;
 }

according to LLVM style this should be promoted out of an `else` block because 
of the `return` above (use early exits / don't use else after a return).

As an aside it appears 0xe7fddefe is ARM-recommended breakpoint opcode and 
Linux is the outlier. So the generic Platform::GetSoftwareBreakpointTrapOpcode 
ought to use 0xFE,0xDE,0xFF,0xE7, with 
PlatformLinux::GetSoftwareBreakpointTrapOpcode having the override?




Comment at: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:957
+
+  // The emulator only fill in the dwarf regsiter numbers (and in some case
+  // the generic register numbers). Get the full register info from the

Few typo / nits:

only fill**s** in
s/regsiter/register/
in some case**s**



Comment at: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:1063
+  if (emulator_ap == nullptr) {
+printf("Error: Instruction emulator not found!\n");
+return;

We should really be returning an `Error` from this fn instead, no?



Comment at: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp:1101-1104
+// Emulate instruction failed and it haven't changed PC. Advance PC
+// with the size of the current opcode because the emulation of all
+// PC modifying instruction should be successful. The failure most
+// likely caused by a not supported instruction which don't modify PC.

Hope you don't mind a minor rewording of the comment:

The emulated instruction failed and it did not change the PC. Advance the PC by 
the size of the current opcode, as all PC-modifying instructions should be 
successfully emulated. The failure was most likely caused by an unsupported 
instruction.


Repository:
  rL LLVM

https://reviews.llvm.org/D25756



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


[Lldb-commits] [PATCH] D27126: Merge Linux and FreeBSD arm register contexts

2016-11-30 Thread Ed Maste via Phabricator via lldb-commits
emaste added a comment.

In https://reviews.llvm.org/D27126#609150, @labath wrote:

> In https://reviews.llvm.org/D27126#607057, @dmikulin wrote:
>
> > I can run tests on 32bit ARM FreeBSD 11.RC3 rpi2, but without software 
> > single step not a lot of tests pass on ARM FreeBSD ;)
> >  Can we get https://reviews.llvm.org/D25756 committed?
>
>
> I'll leave that decision up to Ed.
>  I am not particularly fond of copying code around, but I do see the value of 
> having some freebsd arm support instead of none.


I'd be happy for https://reviews.llvm.org/D25756 to go in, but have a few 
comments added just now that should be addressed.


https://reviews.llvm.org/D27126



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


[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 Thread Paul Robinson via Phabricator via lldb-commits
probinson created this revision.
probinson added a reviewer: jingham.
probinson added a subscriber: LLDB.

LLVM is about to start emitting "line 0" records more often in the DWARF line 
table.
One test tripped over this; made the test accommodate the new records.


https://reviews.llvm.org/D27282

Files:
  
packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py


Index: 
packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
===
--- 
packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
+++ 
packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
@@ -23,32 +23,35 @@
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-inst -m all-threads",
-'stop reason = instruction step')
+'stop reason = instruction step',
+True)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_over(self):
 """Test thread exit during step-over handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-over -m all-threads",
-'stop reason = step over')
+'stop reason = step over',
+False)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_in(self):
 """Test thread exit during step-in handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-in -m all-threads",
-'stop reason = step in')
+'stop reason = step in',
+False)
 
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line numbers to break and continue.
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 self.continuepoint = line_number('main.cpp', '// Continue from here')
 
-def exit_during_step_base(self, step_cmd, step_stop_reason):
+def exit_during_step_base(self, step_cmd, step_stop_reason, 
by_instruction):
 """Test thread exit during step handling."""
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -111,6 +114,9 @@
 
 current_line = frame.GetLineEntry().GetLine()
 
+if by_instruction and current_line == 0:
+continue
+
 self.assertGreaterEqual(
 current_line,
 self.breakpoint,


Index: packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
===
--- packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
+++ packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
@@ -23,32 +23,35 @@
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-inst -m all-threads",
-'stop reason = instruction step')
+'stop reason = instruction step',
+True)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_over(self):
 """Test thread exit during step-over handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-over -m all-threads",
-'stop reason = step over')
+'stop reason = step over',
+False)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_in(self):
 """Test thread exit during step-in handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-in -m all-threads",
-'stop reason = step in')
+'stop reason = step in',
+False)
 
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line numbers to break and continue.
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 self.continuepoint = line_number('main.cpp', '// Continue from here')
 
-def exit_during_step_base(self, step_cmd, step_stop_reason):
+def exit_during_step_base(self, step_cmd, step_stop_reason, by_instruction):
 """Test thread exit during step handling."""
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -111,6 +114,9 @@
 
 current_line = frame.GetLineEntry().GetLine()
 
+if by_instruction and current_line == 0:
+continue
+
 self.assertGreaterEqual(
 current_line,
 self.breakpoint,
_

[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 Thread Paul Robinson via Phabricator via lldb-commits
probinson added a comment.

Forgot to mention this is for PR31214.


https://reviews.llvm.org/D27282



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


[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

That's great.  The source stepping should never have to do this by hand, so 
special casing the instruction stepping was perfect.


https://reviews.llvm.org/D27282



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


[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 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.

And remember to check the accept revision...


https://reviews.llvm.org/D27282



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


[Lldb-commits] [lldb] r288282 - PR31214: Make a test tolerate "line 0" when stepping by instruction.

2016-11-30 Thread Paul Robinson via lldb-commits
Author: probinson
Date: Wed Nov 30 16:47:25 2016
New Revision: 288282

URL: http://llvm.org/viewvc/llvm-project?rev=288282&view=rev
Log:
PR31214: Make a test tolerate "line 0" when stepping by instruction.

Differential Revision: http://reviews.llvm.org/D27282

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py?rev=288282&r1=288281&r2=288282&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
 Wed Nov 30 16:47:25 2016
@@ -23,7 +23,8 @@ class ExitDuringStepTestCase(TestBase):
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-inst -m all-threads",
-'stop reason = instruction step')
+'stop reason = instruction step',
+True)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_over(self):
@@ -31,7 +32,8 @@ class ExitDuringStepTestCase(TestBase):
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-over -m all-threads",
-'stop reason = step over')
+'stop reason = step over',
+False)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_in(self):
@@ -39,7 +41,8 @@ class ExitDuringStepTestCase(TestBase):
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-in -m all-threads",
-'stop reason = step in')
+'stop reason = step in',
+False)
 
 def setUp(self):
 # Call super's setUp().
@@ -48,7 +51,7 @@ class ExitDuringStepTestCase(TestBase):
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 self.continuepoint = line_number('main.cpp', '// Continue from here')
 
-def exit_during_step_base(self, step_cmd, step_stop_reason):
+def exit_during_step_base(self, step_cmd, step_stop_reason, 
by_instruction):
 """Test thread exit during step handling."""
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -111,6 +114,9 @@ class ExitDuringStepTestCase(TestBase):
 
 current_line = frame.GetLineEntry().GetLine()
 
+if by_instruction and current_line == 0:
+continue
+
 self.assertGreaterEqual(
 current_line,
 self.breakpoint,


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


[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 Thread Paul Robinson via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL288282: PR31214: Make a test tolerate "line 0" when stepping 
by instruction. (authored by probinson).

Changed prior to commit:
  https://reviews.llvm.org/D27282?vs=79813&id=79824#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27282

Files:
  
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py


Index: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
===
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
@@ -23,32 +23,35 @@
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-inst -m all-threads",
-'stop reason = instruction step')
+'stop reason = instruction step',
+True)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_over(self):
 """Test thread exit during step-over handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-over -m all-threads",
-'stop reason = step over')
+'stop reason = step over',
+False)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_in(self):
 """Test thread exit during step-in handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-in -m all-threads",
-'stop reason = step in')
+'stop reason = step in',
+False)
 
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line numbers to break and continue.
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 self.continuepoint = line_number('main.cpp', '// Continue from here')
 
-def exit_during_step_base(self, step_cmd, step_stop_reason):
+def exit_during_step_base(self, step_cmd, step_stop_reason, 
by_instruction):
 """Test thread exit during step handling."""
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -111,6 +114,9 @@
 
 current_line = frame.GetLineEntry().GetLine()
 
+if by_instruction and current_line == 0:
+continue
+
 self.assertGreaterEqual(
 current_line,
 self.breakpoint,


Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
===
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
@@ -23,32 +23,35 @@
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-inst -m all-threads",
-'stop reason = instruction step')
+'stop reason = instruction step',
+True)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_over(self):
 """Test thread exit during step-over handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-over -m all-threads",
-'stop reason = step over')
+'stop reason = step over',
+False)
 
 @skipIfFreeBSD  # llvm.org/pr21411: test is hanging
 def test_step_in(self):
 """Test thread exit during step-in handling."""
 self.build(dictionary=self.getBuildFlags())
 self.exit_during_step_base(
 "thread step-in -m all-threads",
-'stop reason = step in')
+'stop reason = step in',
+False)
 
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line numbers to break and continue.
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 self.continuepoint = line_number('main.cpp', '// Continue from here')
 
-def exit_during_step_base(self, step_cmd, step_stop_reason):
+def exit_during_step_base(self, step_cmd, step_stop_reason, by_instruction):
 """Test thread exit during step handling."""
 exe = os.path.join(os.getcwd(), "a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
@@ -111,6 +114,9 @@
 
 current_line = frame.GetLineEntry().GetLine()
 
+if by_instruction and current_line == 0:
+continue
+
 self.asser

[Lldb-commits] [PATCH] D27282: Accommodate line-0 records in a test

2016-11-30 Thread Paul Robinson via Phabricator via lldb-commits
probinson added a comment.

Thanks for helping to decipher the test result!


Repository:
  rL LLVM

https://reviews.llvm.org/D27282



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


[Lldb-commits] [lldb] r288284 - Add another address to look for the kernel load addr in

2016-11-30 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Wed Nov 30 17:00:52 2016
New Revision: 288284

URL: http://llvm.org/viewvc/llvm-project?rev=288284&view=rev
Log:
Add another address to look for the kernel load addr in
DynamicLoaderDarwinKernel::SearchForKernelWithDebugHints
on 32-bit devices.

 

Modified:

lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Modified: 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp?rev=288284&r1=288283&r2=288284&view=diff
==
--- 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
 Wed Nov 30 17:00:52 2016
@@ -244,7 +244,9 @@ DynamicLoaderDarwinKernel::SearchForKern
   0xff804010ULL, // 2014-2015-ish arm64 devices
   0xff802010ULL, // oldest arm64 devices
   LLDB_INVALID_ADDRESS};
-  addr_t kernel_addresses_32[] = {0x0110, LLDB_INVALID_ADDRESS};
+  addr_t kernel_addresses_32[] = {0x0110, // 2016 and earlier armv7 devices
+  0x1010, 
+  LLDB_INVALID_ADDRESS};
 
   uint8_t uval[8];
   if (process->GetAddressByteSize() == 8) {


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


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

2016-11-30 Thread Jason Majors via Phabricator via lldb-commits
jmajors created this revision.
jmajors added a reviewer: labath.
jmajors added a subscriber: lldb-commits.
Herald added a subscriber: danalbert.

To prevent costly calls to the server to get the PC for every thread,
add all the thread's PCs to the jstopinfo message. This also makes the
Linux/Android server behave like the macOS server.


https://reviews.llvm.org/D27289

Files:
  source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp


Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -415,18 +415,20 @@
 
 static void WriteRegisterValueInHexFixedWidth(
 StreamString &response, NativeRegisterContextSP ®_ctx_sp,
-const RegisterInfo ®_info, const RegisterValue *reg_value_p) {
+const RegisterInfo ®_info, const RegisterValue *reg_value_p,
+lldb::ByteOrder byte_order) {
   RegisterValue reg_value;
   if (!reg_value_p) {
 Error error = reg_ctx_sp->ReadRegister(®_info, reg_value);
 if (error.Success())
   reg_value_p = ®_value;
 // else log.
   }
 
+  bool little_endian = byte_order == lldb::eByteOrderLittle;
   if (reg_value_p) {
 AppendHexValue(response, (const uint8_t *)reg_value_p->GetBytes(),
-   reg_value_p->GetByteSize(), false);
+   reg_value_p->GetByteSize(), little_endian);
   } else {
 // Zero-out any unreadable values.
 if (reg_info.byte_size > 0) {
@@ -436,6 +438,13 @@
   }
 }
 
+static void WriteRegisterValueInHexFixedWidth(
+StreamString &response, NativeRegisterContextSP ®_ctx_sp,
+const RegisterInfo ®_info, const RegisterValue *reg_value_p) {
+  WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, reg_info,
+  reg_value_p, lldb::eByteOrderBig);
+}
+
 static JSONObject::SP GetRegistersAsJSON(NativeThreadProtocol &thread,
  bool abridged) {
   Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_THREAD));
@@ -570,6 +579,7 @@
 if (JSONObject::SP registers_sp = GetRegistersAsJSON(*thread_sp, abridged))
   thread_obj_sp->SetObject("registers", registers_sp);
 
+
 thread_obj_sp->SetObject("tid", std::make_shared(tid));
 if (signum != 0)
   thread_obj_sp->SetObject("signal", std::make_shared(signum));
@@ -721,6 +731,41 @@
 "jstopinfo field for pid %" PRIu64,
 __FUNCTION__, m_debugged_process_sp->GetID());
 }
+
+uint32_t i = 0;
+ByteOrder byte_order = endian::InlHostByteOrder();
+response.PutCString("thread-pcs");
+char delimiter = ':';
+for (NativeThreadProtocolSP thread_sp;
+(thread_sp = m_debugged_process_sp->GetThreadAtIndex(i)) != nullptr;
+++i) {
+  NativeRegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
+  if (!reg_ctx_sp)
+continue;
+
+  uint32_t reg_to_read = reg_ctx_sp->ConvertRegisterKindToRegisterNumber(
+  eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC);
+  const RegisterInfo* const reg_info_p =
+reg_ctx_sp->GetRegisterInfoAtIndex(reg_to_read);
+
+  RegisterValue reg_value;
+  Error error = reg_ctx_sp->ReadRegister(reg_info_p, reg_value);
+  if (error.Fail()) {
+if (log)
+  log->Printf("%s failed to read register '%s' index %" PRIu32 ": %s",
+  __FUNCTION__,
+  reg_info_p->name ? reg_info_p->name : 
"",
+  reg_to_read, error.AsCString());
+continue;
+  }
+
+  response.PutChar(delimiter);
+  delimiter = ',';
+  WriteRegisterValueInHexFixedWidth(response, reg_ctx_sp, *reg_info_p,
+®_value, byte_order);
+}
+
+response.PutChar(';');
   }
 
   //


Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -415,18 +415,20 @@
 
 static void WriteRegisterValueInHexFixedWidth(
 StreamString &response, NativeRegisterContextSP ®_ctx_sp,
-const RegisterInfo ®_info, const RegisterValue *reg_value_p) {
+const RegisterInfo ®_info, const RegisterValue *reg_value_p,
+lldb::ByteOrder byte_order) {
   RegisterValue reg_value;
   if (!reg_value_p) {
 Error error = reg_ctx_sp->ReadRegister(®_info, reg_value);
 if (error.Success())
   reg_value_p = ®_value;
 // else log.
   }
 
+  bool little_endian = byte_order == lldb::eByteOrderLittle;
   if (reg_value_p) {
 AppendHexValue(response, (const uint8_t *)reg_value_p->GetBytes(),
-   reg_value_p->GetByteSize(), false);
+   reg_value_p->GetByteSize(), little_endian);
   } else {

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

2016-11-30 Thread Sean Callanan via Phabricator via lldb-commits
spyffe created this revision.
spyffe added a reviewer: jingham.
spyffe added a subscriber: LLDB.
spyffe set the repository for this revision to rL LLVM.

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.


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,55 @@
   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 */
+ }
+ 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, &CFSCWB_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, &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");
+ 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 +655,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 = 

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

2016-11-30 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

For what it's worth, this change was part of the changes we made to reduce 
packet traffic for "private stops".  When a high-level "step" or "next" command 
is done, we instruction step (or fast-step with Jim's fast-step code when it 
sees a sequence of instructions that cannot branch - we set a breakpoint and 
continue instead of instruction stepping) until we reach the end of the 
stepping range and then we do a "public stop".  Given that the private stops 
are more numerous, we spent a bunch of time looking at everything we could 
eliminate for those private stops.  Getting all the pc values into the stop 
packet (aka T or ? packet) was a big one.  For multi-threaded programs we also 
added a "jstopinfo" which gives the stop reasons for all threads that had a 
stop reason, e.g.

T05thread:90834;threads:90834,90845,90846,90847,90848,90849,9084a,9084b,9084c,9084d,9084e,9084f,90850,90851;thread-pcs:10ac4,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda,7fffb3eb1fda;jstopinfo:5b7b22746964223a3539313932342c226d6574797065223a362c226d6564617461223a5b322c305d2c22726561736f6e223a22657863657074696f6e227d5d;metype:6;mecount:2;medata:2;medata:0;memory:0x7fff5fbff8e0=30f9bf5fff7fb20c0100;memory:0x7fff5fbff930=40f9bf5fff7f5532d8b3ff7f;

(I elided the expedited registers)

The jstopinfo above is ascii-hex encoding of the JSON,

[{"tid":591924,"metype":6,"medata":[2,0],"reason":"exception"}]

else lldb would iterate over all the threads to see if any of them stopped for 
some reason (e.g. hitting a breakpoint) while we were instruction stepping.  If 
you don't see lldb doing that thread-stop-reason checking for your platform, it 
won't be needed.

(and looking at this, it's giving the stop reasoon for the thread that hit a 
breakpoint -- which we already get from the T packet.  Hmmm, I see another tiny 
perf win in the near future! ;)

We're also sending up 4 words of stack memory which might be the start of this 
function's stack frame and it's caller's stack frame.  For a simple "find the 
pc of the caller stack frame" in lldb, this can remove a couple of memory reads 
as the thread stepping logic needs to know who the caller stack frame is.

We also did some work on the public stop side, adding a jThreadsInfo packet 
which gives us all the information about all of the threads.  We get all the 
expedited registers, the thread name, the stop reasons, information about the 
darwin libdispatch queues, and expedited stack memory to help speed up a stack 
walk (I don't remember offhand if debugserver tries to walk the entire stack 
using the simple follow-the-frame-chain-in-stack-memory technique or if it caps 
the stack walk.  but our main IDE, Xcode, needs the full stack for its UI so we 
wanted to fetch that in one big packet so we can give the pc and function names 
without any additional packet traffic.)


https://reviews.llvm.org/D27289



___
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-11-30 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Other than the request for a more logging, this seems fine.




Comment at: source/Plugins/ExpressionParser/Clang/IRForTarget.cpp:514-515
+ default:
+   encoding_flags = 0x0600; /* fall back to 0x0600, kCFStringEncodingASCII */
+ }
+ Constant *encoding_arg = ConstantInt::get(i32_ty, encoding_flags, false);

The default case here expresses "I don't know what this string is so I'm just 
going to try ASCII".  That's fine, but we should log the unknown kind so that 
when this happens in the wild and we can't get a repro case, we'll be able to 
figure out something from the log.


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


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

2016-11-30 Thread Nitesh Jain via Phabricator via lldb-commits
nitesh.jain updated the summary for this revision.
nitesh.jain updated this revision to Diff 79864.
nitesh.jain added a comment.

Updated diff as per suggestion.


https://reviews.llvm.org/D27124

Files:
  source/Target/StopInfo.cpp


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,9 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +712,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }


Index: source/Target/StopInfo.cpp
===
--- source/Target/StopInfo.cpp
+++ source/Target/StopInfo.cpp
@@ -692,7 +692,9 @@
 if (process_sp->GetWatchpointSupportInfo(num, wp_triggers_after)
 .Success()) {
   if (!wp_triggers_after) {
-process_sp->DisableWatchpoint(wp_sp.get(), false);
+Watchpoint *wp = wp_sp.get();
+uint32_t watch_index = wp->GetHardwareIndex();
+process_sp->DisableWatchpoint(wp, false);
 StopInfoSP stored_stop_info_sp = thread_sp->GetStopInfo();
 assert(stored_stop_info_sp.get() == this);
 
@@ -710,7 +712,8 @@
 process_sp->GetThreadList().SetSelectedThreadByID(
 thread_sp->GetID());
 thread_sp->SetStopInfo(stored_stop_info_sp);
-process_sp->EnableWatchpoint(wp_sp.get(), false);
+process_sp->EnableWatchpoint(wp, false);
+wp->SetHardwareIndex(watch_index);
   }
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits