Re: [Lldb-commits] [PATCH] D21221: Fix for PrintStackTraces

2016-06-27 Thread Ravitheja Addepally via lldb-commits
ravitheja updated this revision to Diff 61936.
ravitheja added a comment.

Renaming testcase


http://reviews.llvm.org/D21221

Files:
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile
  
packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py
  packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
  source/Plugins/Process/Utility/RegisterContextLLDB.cpp

Index: source/Plugins/Process/Utility/RegisterContextLLDB.cpp
===
--- source/Plugins/Process/Utility/RegisterContextLLDB.cpp
+++ source/Plugins/Process/Utility/RegisterContextLLDB.cpp
@@ -210,12 +210,28 @@
 m_frame_type = eNormalFrame;
 }
 
+// We've set m_frame_type and m_sym_ctx before these calls.
+
+m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
+m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
+
 // If we were able to find a symbol/function, set addr_range to the bounds of that symbol/function.
 // else treat the current pc value as the start_pc and record no offset.
 if (addr_range.GetBaseAddress().IsValid())
 {
 m_start_pc = addr_range.GetBaseAddress();
-if (m_current_pc.GetSection() == m_start_pc.GetSection())
+if (m_sym_ctx.symbol != nullptr && m_sym_ctx.symbol->IsSynthetic())
+{
+// The current offset should be recalculated here. The m_current_offset is
+// calculated from the base address of the symbol. The symbol can lie in the PLT
+// (Procedure Linkage Table) i.e its a symbol stub for external call. In this case
+// the base address for the unwindplan and the base address of the symbol maybe different, hence
+// the m_current_offset will be wrong.
+AddressRange unwind_address_range = m_full_unwind_plan_sp->GetAddressRange();
+if (unwind_address_range.ContainsFileAddress(m_current_pc))
+m_current_offset = m_current_pc.GetOffset() - unwind_address_range.GetBaseAddress().GetOffset();
+}
+else if (m_current_pc.GetSection() == m_start_pc.GetSection())
 {
 m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset();
 }
@@ -236,11 +252,6 @@
 m_current_offset_backed_up_one = -1;
 }
 
-// We've set m_frame_type and m_sym_ctx before these calls.
-
-m_fast_unwind_plan_sp = GetFastUnwindPlanForFrame ();
-m_full_unwind_plan_sp = GetFullUnwindPlanForFrame ();
-
 UnwindPlan::RowSP active_row;
 lldb::RegisterKind row_register_kind = eRegisterKindGeneric;
 if (m_full_unwind_plan_sp && m_full_unwind_plan_sp->PlanValidAtAddress (m_current_pc))
@@ -255,36 +266,14 @@
 }
 }
 
-if (!active_row.get())
-{
-UnwindLogMsg ("could not find an unwindplan row for this frame's pc");
-m_frame_type = eNotAValidFrame;
-return;
-}
-
-
 if (!ReadCFAValueForRow (row_register_kind, active_row, m_cfa))
 {
 // Try the fall back unwind plan since the
 // full unwind plan failed.
-FuncUnwindersSP func_unwinders_sp;
-UnwindPlanSP call_site_unwind_plan;
 bool cfa_status = false;
+if (TryFallbackUnwindPlan())
+cfa_status = true;
 
-if (m_sym_ctx_valid)
-{
-func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
-}
-
-if(func_unwinders_sp.get() != nullptr)
-call_site_unwind_plan = func_unwinders_sp->GetUnwindPlanAtCallSite(process->GetTarget(), m_current_offset_backed_up_one);
-
-if (call_site_unwind_plan.get() != nullptr)
-{
-m_fallback_unwind_plan_sp = call_site_unwind_plan;
-if(TryFallbackUnwindPlan())
-cfa_status = true;
-}
 if (!cfa_status)
 {
 UnwindLogMsg ("could not read CFA value for first frame.");
@@ -881,6 +870,8 @@
 // call GetUnwindPlanAtCallSite() -- because CallSite may return an unwind plan sourced from
 // either eh_frame (that's what we intend) or compact unwind (this won't work)
 unwind_plan_sp = func_unwinders_sp->GetEHFrameUnwindPlan (process->GetTarget(), m_current_offset_backed_up_one);
+m_fallback_unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (process->GetTarget(), m_thread, m_current_offset_backed_up_one);
+
 if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc))
 {
 UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan because the DynamicLoader suggested we prefer it",
@@ -1608,8 +1599,8 @@
 
 // If a compiler generated unwind plan failed, t

Re: [Lldb-commits] [PATCH] D20464: [LLDB][MIPS] Check if libatomic needs to be specified explicitly.

2016-06-27 Thread Nitesh Jain via lldb-commits
nitesh.jain updated this revision to Diff 61940.
nitesh.jain added a comment.

Thanks Labath.
Updated diff as per suggestion.


Repository:
  rL LLVM

http://reviews.llvm.org/D20464

Files:
  cmake/LLDBDependencies.cmake

Index: cmake/LLDBDependencies.cmake
===
--- cmake/LLDBDependencies.cmake
+++ cmake/LLDBDependencies.cmake
@@ -157,6 +157,11 @@
 endif()
   endif()
 endif()
+
+if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
+list(APPEND LLDB_SYSTEM_LIBS atomic)
+endif()
+
 # On FreeBSD/NetBSD backtrace() is provided by libexecinfo, not libc.
 if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND LLDB_SYSTEM_LIBS execinfo)


Index: cmake/LLDBDependencies.cmake
===
--- cmake/LLDBDependencies.cmake
+++ cmake/LLDBDependencies.cmake
@@ -157,6 +157,11 @@
 endif()
   endif()
 endif()
+
+if (NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB )
+list(APPEND LLDB_SYSTEM_LIBS atomic)
+endif()
+
 # On FreeBSD/NetBSD backtrace() is provided by libexecinfo, not libc.
 if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
   list(APPEND LLDB_SYSTEM_LIBS execinfo)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r273863 - Allow unaligned byte/word selection watchpoints for arm- linux/android targets.

2016-06-27 Thread Omair Javaid via lldb-commits
Author: omjavaid
Date: Mon Jun 27 06:18:23 2016
New Revision: 273863

URL: http://llvm.org/viewvc/llvm-project?rev=273863&view=rev
Log:
Allow unaligned byte/word selection watchpoints for arm- linux/android targets.

Differential revision: http://reviews.llvm.org/D21516


Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp?rev=273863&r1=273862&r2=273863&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
Mon Jun 27 06:18:23 2016
@@ -614,6 +614,7 @@ NativeRegisterContextLinux_arm::SetHardw
 return LLDB_INVALID_INDEX32;

 uint32_t control_value = 0, wp_index = 0, addr_word_offset = 0, byte_mask 
= 0;
+lldb::addr_t real_addr = addr;
 
 // Check if we are setting watchpoint other than read/write/access
 // Also update watchpoint flag to match Arm write-read bit configuration.
@@ -637,7 +638,24 @@ NativeRegisterContextLinux_arm::SetHardw
 if (size == 0 || size > 4)
 return LLDB_INVALID_INDEX32;
 
-// We can only watch up to four bytes that follow a 4 byte aligned address
+// Check 4-byte alignment for hardware watchpoint target address.
+// Below is a hack to recalculate address and size in order to
+// make sure we can watch non 4-byte alligned addresses as well.
+if (addr & 0x03)
+{
+uint8_t watch_mask = (addr & 0x03) + size;
+
+if (watch_mask > 0x04)
+return LLDB_INVALID_INDEX32;
+else if (watch_mask <= 0x02)
+size = 2;
+else if (watch_mask <= 0x04)
+size = 4;
+
+addr = addr & (~0x03);
+}
+
+   // We can only watch up to four bytes that follow a 4 byte aligned 
address
 // per watchpoint register pair, so make sure we can properly encode this.
 addr_word_offset = addr % 4;
 byte_mask = ((1u << size) - 1u) << addr_word_offset;
@@ -682,6 +700,7 @@ NativeRegisterContextLinux_arm::SetHardw
 if ((m_hwp_regs[wp_index].control & 1) == 0)
 {
 // Update watchpoint in local cache
+m_hwp_regs[wp_index].real_addr = real_addr;
 m_hwp_regs[wp_index].address = addr;
 m_hwp_regs[wp_index].control = control_value;
 m_hwp_regs[wp_index].refcount = 1;
@@ -864,6 +883,7 @@ NativeRegisterContextLinux_arm::GetWatch
 if (m_hwp_regs[wp_index].refcount >= 1 && WatchpointIsEnabled(wp_index)
 && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size)
 {
+m_hwp_regs[wp_index].hit_addr = trap_addr;
 return Error();
 }
 }
@@ -884,7 +904,24 @@ NativeRegisterContextLinux_arm::GetWatch
 return LLDB_INVALID_ADDRESS;
 
 if (WatchpointIsEnabled(wp_index))
-return m_hwp_regs[wp_index].address;
+return m_hwp_regs[wp_index].real_addr;
+else
+return LLDB_INVALID_ADDRESS;
+}
+
+lldb::addr_t
+NativeRegisterContextLinux_arm::GetWatchpointHitAddress (uint32_t wp_index)
+{
+Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+
+if (log)
+log->Printf ("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+
+if (wp_index >= m_max_hwp_supported)
+return LLDB_INVALID_ADDRESS;
+
+if (WatchpointIsEnabled(wp_index))
+return m_hwp_regs[wp_index].hit_addr;
 else
 return LLDB_INVALID_ADDRESS;
 }

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h?rev=273863&r1=273862&r2=273863&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h 
Mon Jun 27 06:18:23 2016
@@ -74,6 +74,9 @@ namespace process_linux {
 GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) 
override;
 
 lldb::addr_t
+GetWatchpointHitAddress (uint32_t wp_index) override;
+
+lldb::addr_t
 GetWatchpointAddress (uint32_t wp_index) override;
 
 uint32_t
@@ -162,6 +165,8 @@ namespace process_linux {
 struct DREG
 {
 lldb::addr_t address;  // Breakpoint/watchpoint address value.
+lldb::addr_t hit_addr; // Address at which last watchpoint trigger 
exception occurred.
+ll

Re: [Lldb-commits] [PATCH] D21516: Allow unaligned byte/word selection watchpoints for arm- linux/android targets.

2016-06-27 Thread Muhammad Omair Javaid via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273863: Allow unaligned byte/word selection watchpoints for 
arm- linux/android targets. (authored by omjavaid).

Changed prior to commit:
  http://reviews.llvm.org/D21516?vs=61234&id=61954#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21516

Files:
  lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
  lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.h
@@ -74,6 +74,9 @@
 GetWatchpointHitIndex(uint32_t &wp_index, lldb::addr_t trap_addr) override;
 
 lldb::addr_t
+GetWatchpointHitAddress (uint32_t wp_index) override;
+
+lldb::addr_t
 GetWatchpointAddress (uint32_t wp_index) override;
 
 uint32_t
@@ -162,6 +165,8 @@
 struct DREG
 {
 lldb::addr_t address;  // Breakpoint/watchpoint address value.
+lldb::addr_t hit_addr; // Address at which last watchpoint trigger exception occurred.
+lldb::addr_t real_addr;  // Address value that should cause target to stop.
 uint32_t control;  // Breakpoint/watchpoint control value.
 uint32_t refcount;  // Serves as enable/disable and refernce counter.
 };
Index: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -614,6 +614,7 @@
 return LLDB_INVALID_INDEX32;
 		
 uint32_t control_value = 0, wp_index = 0, addr_word_offset = 0, byte_mask = 0;
+lldb::addr_t real_addr = addr;
 
 // Check if we are setting watchpoint other than read/write/access
 // Also update watchpoint flag to match Arm write-read bit configuration.
@@ -637,7 +638,24 @@
 if (size == 0 || size > 4)
 return LLDB_INVALID_INDEX32;
 
-// We can only watch up to four bytes that follow a 4 byte aligned address
+// Check 4-byte alignment for hardware watchpoint target address.
+// Below is a hack to recalculate address and size in order to
+// make sure we can watch non 4-byte alligned addresses as well.
+if (addr & 0x03)
+{
+uint8_t watch_mask = (addr & 0x03) + size;
+
+if (watch_mask > 0x04)
+return LLDB_INVALID_INDEX32;
+else if (watch_mask <= 0x02)
+size = 2;
+else if (watch_mask <= 0x04)
+size = 4;
+
+addr = addr & (~0x03);
+}
+
+	// We can only watch up to four bytes that follow a 4 byte aligned address
 // per watchpoint register pair, so make sure we can properly encode this.
 addr_word_offset = addr % 4;
 byte_mask = ((1u << size) - 1u) << addr_word_offset;
@@ -682,6 +700,7 @@
 if ((m_hwp_regs[wp_index].control & 1) == 0)
 {
 // Update watchpoint in local cache
+m_hwp_regs[wp_index].real_addr = real_addr;
 m_hwp_regs[wp_index].address = addr;
 m_hwp_regs[wp_index].control = control_value;
 m_hwp_regs[wp_index].refcount = 1;
@@ -864,6 +883,7 @@
 if (m_hwp_regs[wp_index].refcount >= 1 && WatchpointIsEnabled(wp_index)
 && trap_addr >= watch_addr && trap_addr < watch_addr + watch_size)
 {
+m_hwp_regs[wp_index].hit_addr = trap_addr;
 return Error();
 }
 }
@@ -884,7 +904,24 @@
 return LLDB_INVALID_ADDRESS;
 
 if (WatchpointIsEnabled(wp_index))
-return m_hwp_regs[wp_index].address;
+return m_hwp_regs[wp_index].real_addr;
+else
+return LLDB_INVALID_ADDRESS;
+}
+
+lldb::addr_t
+NativeRegisterContextLinux_arm::GetWatchpointHitAddress (uint32_t wp_index)
+{
+Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_WATCHPOINTS));
+
+if (log)
+log->Printf ("NativeRegisterContextLinux_arm::%s()", __FUNCTION__);
+
+if (wp_index >= m_max_hwp_supported)
+return LLDB_INVALID_ADDRESS;
+
+if (WatchpointIsEnabled(wp_index))
+return m_hwp_regs[wp_index].hit_addr;
 else
 return LLDB_INVALID_ADDRESS;
 }
Index: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -2060,7 +2060,7 @@
 WatchpointSP wp_sp;
 ArchSpec::

Re: [Lldb-commits] [PATCH] D21164: Improve watchpoint error reporting specially for arm/aarch64 targets

2016-06-27 Thread Muhammad Omair Javaid via lldb-commits
omjavaid added inline comments.


Comment at: source/Target/Target.cpp:714
@@ -713,2 +713,3 @@
 {
 uint32_t num_current_watchpoints = 
target->GetWatchpointList().GetSize();
+if (num_supported_hardware_watchpoints == 0)

clayborg wrote:
> This logic isn't necessarily correct. If we have the ability to watch N bytes 
> at a time with a single hardware watchpoint, we might have 1 hardware 
> watchpoint that is able to watch multiple things. So for code like:
> 
> ```
> char buffer[8] = ...;
> ```
> 
> then we watch "buffer[1]" and "buffer[7]", we could actually have 2 
> watchpoints but only use 1 hardware watchpoint. We really should be allowing 
> each process plug-in to try and set the watchpoint and return the correct 
> error instead of generically trying to catch _anything_ at the target level. 
> So it seems like this code should be removed and moved into RegisterContext 
> and allow each register context plug-in to respond correctly as only the it 
> will know what can be done.
> 
I am seeing this a little different. GetWatchpointSupportInfo has to provide 
information on number of watchpoint resources a target supports.
We should only fail a watchpoint on the basis of GetWatchpointSupportInfo if it 
returns zero that is for a particular hardware we have no watchpoint support.

For the case where we want to utilize same hardware resource to watch multiple 
watchpoints, we should try to manage that in register context where we can keep 
track of watchpoints previously installed without getting the target backend 
involved. First we can attempt to intall a watchpoint using an existing 
resource and if that fails we can use a new hardware resource. Return failure 
if watchpoint resources are used up. This way you can put multiple watchpoint 
on same address without having to use up hardware watchpoint resources. I will 
post this solution of arm and aarch64 soon.


Comment at: source/Target/Target.cpp:721
@@ +720,3 @@
+}
+else if (num_current_watchpoints >= num_supported_hardware_watchpoints)
+{

I am going to remove this case from final commit as we may have more 
watchpoints utilizing one or more hardware watchpoint resources.


http://reviews.llvm.org/D21164



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


Re: [Lldb-commits] [PATCH] D21164: Improve watchpoint error reporting specially for arm/aarch64 targets

2016-06-27 Thread Muhammad Omair Javaid via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL273869: Improve watchpoint error reporting specially for 
arm/aarch64 targets (authored by omjavaid).

Changed prior to commit:
  http://reviews.llvm.org/D21164?vs=60127&id=61959#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D21164

Files:
  lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
  lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/trunk/source/Target/Target.cpp

Index: lldb/trunk/source/Target/Target.cpp
===
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -709,14 +709,13 @@
 {
 uint32_t num_supported_hardware_watchpoints;
 Error rc = 
target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-if (rc.Success())
+if (num_supported_hardware_watchpoints == 0)
 {
-uint32_t num_current_watchpoints = 
target->GetWatchpointList().GetSize();
-if (num_current_watchpoints >= num_supported_hardware_watchpoints)
-error.SetErrorStringWithFormat("number of supported hardware 
watchpoints (%u) has been reached",
-   num_supported_hardware_watchpoints);
+error.SetErrorStringWithFormat ("Target supports (%u) hardware 
watchpoint slots.\n",
+num_supported_hardware_watchpoints);
+return false;
 }
-return false;
+return true;
 }
 
 // See also Watchpoint::SetWatchpointType(uint32_t type) and
@@ -750,6 +749,9 @@
 error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
 }
 
+if (!CheckIfWatchpointsExhausted (this, error))
+return wp_sp;
+
 // Currently we only support one watchpoint per address, with total number
 // of watchpoints limited by the hardware which the inferior is running on.
 
@@ -798,11 +800,9 @@
 // Remove the said watchpoint from the list maintained by the target 
instance.
 m_watchpoint_list.Remove (wp_sp->GetID(), true);
 // See if we could provide more helpful error message.
-if (!CheckIfWatchpointsExhausted(this, error))
-{
-if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
-error.SetErrorStringWithFormat("watch size of %" PRIu64 " is 
not supported", (uint64_t)size);
-}
+if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
+error.SetErrorStringWithFormat("watch size of %" PRIu64 " is not 
supported", (uint64_t)size);
+
 wp_sp.reset();
 }
 else
Index: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -544,7 +544,7 @@
 error = ReadHardwareDebugInfo ();
 
 if (error.Fail())
-return LLDB_INVALID_INDEX32;
+return 0;
 
 return m_max_hwp_supported;
 }
Index: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
===
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -592,7 +592,7 @@
 error = ReadHardwareDebugInfo ();
 
 if (error.Fail())
-return LLDB_INVALID_INDEX32;
+return 0;
 
 return m_max_hwp_supported;
 }


Index: lldb/trunk/source/Target/Target.cpp
===
--- lldb/trunk/source/Target/Target.cpp
+++ lldb/trunk/source/Target/Target.cpp
@@ -709,14 +709,13 @@
 {
 uint32_t num_supported_hardware_watchpoints;
 Error rc = target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-if (rc.Success())
+if (num_supported_hardware_watchpoints == 0)
 {
-uint32_t num_current_watchpoints = target->GetWatchpointList().GetSize();
-if (num_current_watchpoints >= num_supported_hardware_watchpoints)
-error.SetErrorStringWithFormat("number of supported hardware watchpoints (%u) has been reached",
-   num_supported_hardware_watchpoints);
+error.SetErrorStringWithFormat ("Target supports (%u) hardware watchpoint slots.\n",
+num_supported_hardware_watchpoints);
+return false;
 }
-return false;
+return true;
 }
 
 // See also Watchpoint::SetWatchpointType(uint32_t type) and
@@ -750,6 +749,9 @@
 error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
 }
 
+if (!CheckIfWatchpointsExhausted (this, error))
+return wp_sp;
+
 // Currently we only support one watchpoint per address, with 

[Lldb-commits] [lldb] r273869 - Improve watchpoint error reporting specially for arm/aarch64 targets

2016-06-27 Thread Omair Javaid via lldb-commits
Author: omjavaid
Date: Mon Jun 27 07:35:41 2016
New Revision: 273869

URL: http://llvm.org/viewvc/llvm-project?rev=273869&view=rev
Log:
Improve watchpoint error reporting specially for arm/aarch64 targets

Differential revision: http://reviews.llvm.org/D21164


Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/trunk/source/Target/Target.cpp

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp?rev=273869&r1=273868&r2=273869&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
Mon Jun 27 07:35:41 2016
@@ -592,7 +592,7 @@ NativeRegisterContextLinux_arm::NumSuppo
 error = ReadHardwareDebugInfo ();
 
 if (error.Fail())
-return LLDB_INVALID_INDEX32;
+return 0;
 
 return m_max_hwp_supported;
 }

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp?rev=273869&r1=273868&r2=273869&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
Mon Jun 27 07:35:41 2016
@@ -544,7 +544,7 @@ NativeRegisterContextLinux_arm64::NumSup
 error = ReadHardwareDebugInfo ();
 
 if (error.Fail())
-return LLDB_INVALID_INDEX32;
+return 0;
 
 return m_max_hwp_supported;
 }

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=273869&r1=273868&r2=273869&view=diff
==
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jun 27 07:35:41 2016
@@ -709,14 +709,13 @@ CheckIfWatchpointsExhausted(Target *targ
 {
 uint32_t num_supported_hardware_watchpoints;
 Error rc = 
target->GetProcessSP()->GetWatchpointSupportInfo(num_supported_hardware_watchpoints);
-if (rc.Success())
+if (num_supported_hardware_watchpoints == 0)
 {
-uint32_t num_current_watchpoints = 
target->GetWatchpointList().GetSize();
-if (num_current_watchpoints >= num_supported_hardware_watchpoints)
-error.SetErrorStringWithFormat("number of supported hardware 
watchpoints (%u) has been reached",
-   num_supported_hardware_watchpoints);
+error.SetErrorStringWithFormat ("Target supports (%u) hardware 
watchpoint slots.\n",
+num_supported_hardware_watchpoints);
+return false;
 }
-return false;
+return true;
 }
 
 // See also Watchpoint::SetWatchpointType(uint32_t type) and
@@ -750,6 +749,9 @@ Target::CreateWatchpoint(lldb::addr_t ad
 error.SetErrorStringWithFormat ("invalid watchpoint type: %d", kind);
 }
 
+if (!CheckIfWatchpointsExhausted (this, error))
+return wp_sp;
+
 // Currently we only support one watchpoint per address, with total number
 // of watchpoints limited by the hardware which the inferior is running on.
 
@@ -798,11 +800,9 @@ Target::CreateWatchpoint(lldb::addr_t ad
 // Remove the said watchpoint from the list maintained by the target 
instance.
 m_watchpoint_list.Remove (wp_sp->GetID(), true);
 // See if we could provide more helpful error message.
-if (!CheckIfWatchpointsExhausted(this, error))
-{
-if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
-error.SetErrorStringWithFormat("watch size of %" PRIu64 " is 
not supported", (uint64_t)size);
-}
+if (!OptionGroupWatchpoint::IsWatchSizeSupported(size))
+error.SetErrorStringWithFormat("watch size of %" PRIu64 " is not 
supported", (uint64_t)size);
+
 wp_sp.reset();
 }
 else


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


[Lldb-commits] [PATCH] D21751: Implement GetMemoryRegions() for Linux and Mac OSX core files.

2016-06-27 Thread Howard Hellyer via lldb-commits
hhellyer created this revision.
hhellyer added a reviewer: clayborg.
hhellyer added a subscriber: lldb-commits.

This patch fills in the implementation of GetMemoryRegions() on the Linux and 
Mac OS core file implementations of lldb_private::Process 
(ProcessElfCore::GetMemoryRegions and ProcessMachCore::GetMemoryRegions.) The 
GetMemoryRegions API was added under: http://reviews.llvm.org/D20565

The patch re-uses the m_core_range_infos list that was recently added to 
implement GetMemoryRegionInfo in both ProcessElfCore and ProcessMachCore to 
ensure the returned regions match the regions returned by 
Process::GetMemoryRegionInfo(addr_t load_addr, MemoryRegionInfo ®ion_info).

http://reviews.llvm.org/D21751

Files:
  include/lldb/Target/Process.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h
  source/Plugins/Process/mach-core/ProcessMachCore.cpp
  source/Plugins/Process/mach-core/ProcessMachCore.h

Index: source/Plugins/Process/mach-core/ProcessMachCore.h
===
--- source/Plugins/Process/mach-core/ProcessMachCore.h
+++ source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -107,6 +107,9 @@
 lldb_private::Error
 GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo ®ion_info) override;
 
+lldb_private::Error
+GetMemoryRegions (std::vector ®ions) override;
+
 lldb::addr_t
 GetImageInfoAddress () override;
 
Index: source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -596,6 +596,27 @@
 return Error("invalid address");
 }
 
+Error
+ProcessMachCore::GetMemoryRegions (std::vector ®ions) {
+regions.clear();
+// The list of VMRangeToPermissions is sorted when it is created.
+for( size_t i = 0; i < m_core_range_infos.GetSize(); ++i ) {
+const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.GetEntryAtIndex(i);
+lldb::MemoryRegionInfoSP region_info_sp( new MemoryRegionInfo() );
+region_info_sp->GetRange().SetRangeBase(permission_entry->GetRangeBase());
+region_info_sp->GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
+const Flags permissions(permission_entry->data);
+region_info_sp->SetReadable(permissions.Test(lldb::ePermissionsReadable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetWritable(permissions.Test(lldb::ePermissionsWritable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetExecutable(permissions.Test(lldb::ePermissionsExecutable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+regions.push_back( region_info_sp );
+}
+return Error();
+}
+
 void
 ProcessMachCore::Clear()
 {
Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -105,6 +105,9 @@
 lldb_private::Error
 GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo ®ion_info) override;
 
+lldb_private::Error
+GetMemoryRegions (std::vector ®ions) override;
+
 lldb::addr_t GetImageInfoAddress() override;
 
 lldb_private::ArchSpec
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -359,6 +359,27 @@
 return Error("invalid address");
 }
 
+Error
+ProcessElfCore::GetMemoryRegions (std::vector ®ions) {
+regions.clear();
+// The list of VMRangeToPermissions is sorted when it is created.
+for( size_t i = 0; i < m_core_range_infos.GetSize(); ++i ) {
+const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.GetEntryAtIndex(i);
+lldb::MemoryRegionInfoSP region_info_sp( new MemoryRegionInfo() );
+region_info_sp->GetRange().SetRangeBase(permission_entry->GetRangeBase());
+region_info_sp->GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
+const Flags permissions(permission_entry->data);
+region_info_sp->SetReadable(permissions.Test(lldb::ePermissionsReadable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetWritable(permissions.Test(lldb::ePermissionsWritable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetExecutable(permissions.Test(lldb::ePermissionsExecutable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+regions.push_back( region_info_sp );
+}
+return Error();
+}
+
 size_t
 Proce

Re: [Lldb-commits] [PATCH] D21751: Implement GetMemoryRegions() for Linux and Mac OSX core files.

2016-06-27 Thread Howard Hellyer via lldb-commits
hhellyer updated this revision to Diff 61960.
hhellyer added a comment.

Squashing local commits.


http://reviews.llvm.org/D21751

Files:
  include/lldb/Target/Process.h
  source/Plugins/Process/elf-core/ProcessElfCore.cpp
  source/Plugins/Process/elf-core/ProcessElfCore.h
  source/Plugins/Process/mach-core/ProcessMachCore.cpp
  source/Plugins/Process/mach-core/ProcessMachCore.h

Index: source/Plugins/Process/mach-core/ProcessMachCore.h
===
--- source/Plugins/Process/mach-core/ProcessMachCore.h
+++ source/Plugins/Process/mach-core/ProcessMachCore.h
@@ -107,6 +107,9 @@
 lldb_private::Error
 GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo ®ion_info) override;
 
+lldb_private::Error
+GetMemoryRegions (std::vector ®ions) override;
+
 lldb::addr_t
 GetImageInfoAddress () override;
 
Index: source/Plugins/Process/mach-core/ProcessMachCore.cpp
===
--- source/Plugins/Process/mach-core/ProcessMachCore.cpp
+++ source/Plugins/Process/mach-core/ProcessMachCore.cpp
@@ -596,6 +596,27 @@
 return Error("invalid address");
 }
 
+Error
+ProcessMachCore::GetMemoryRegions (std::vector ®ions) {
+regions.clear();
+// The list of VMRangeToPermissions is sorted when it is created.
+for( size_t i = 0; i < m_core_range_infos.GetSize(); ++i ) {
+const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.GetEntryAtIndex(i);
+lldb::MemoryRegionInfoSP region_info_sp( new MemoryRegionInfo() );
+region_info_sp->GetRange().SetRangeBase(permission_entry->GetRangeBase());
+region_info_sp->GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
+const Flags permissions(permission_entry->data);
+region_info_sp->SetReadable(permissions.Test(lldb::ePermissionsReadable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetWritable(permissions.Test(lldb::ePermissionsWritable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetExecutable(permissions.Test(lldb::ePermissionsExecutable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+regions.push_back( region_info_sp );
+}
+return Error();
+}
+
 void
 ProcessMachCore::Clear()
 {
Index: source/Plugins/Process/elf-core/ProcessElfCore.h
===
--- source/Plugins/Process/elf-core/ProcessElfCore.h
+++ source/Plugins/Process/elf-core/ProcessElfCore.h
@@ -105,6 +105,9 @@
 lldb_private::Error
 GetMemoryRegionInfo(lldb::addr_t load_addr, lldb_private::MemoryRegionInfo ®ion_info) override;
 
+lldb_private::Error
+GetMemoryRegions (std::vector ®ions) override;
+
 lldb::addr_t GetImageInfoAddress() override;
 
 lldb_private::ArchSpec
Index: source/Plugins/Process/elf-core/ProcessElfCore.cpp
===
--- source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -359,6 +359,27 @@
 return Error("invalid address");
 }
 
+Error
+ProcessElfCore::GetMemoryRegions (std::vector ®ions) {
+regions.clear();
+// The list of VMRangeToPermissions is sorted when it is created.
+for( size_t i = 0; i < m_core_range_infos.GetSize(); ++i ) {
+const VMRangeToPermissions::Entry *permission_entry = m_core_range_infos.GetEntryAtIndex(i);
+lldb::MemoryRegionInfoSP region_info_sp( new MemoryRegionInfo() );
+region_info_sp->GetRange().SetRangeBase(permission_entry->GetRangeBase());
+region_info_sp->GetRange().SetRangeEnd(permission_entry->GetRangeEnd());
+const Flags permissions(permission_entry->data);
+region_info_sp->SetReadable(permissions.Test(lldb::ePermissionsReadable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetWritable(permissions.Test(lldb::ePermissionsWritable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+region_info_sp->SetExecutable(permissions.Test(lldb::ePermissionsExecutable) ? MemoryRegionInfo::eYes
+: MemoryRegionInfo::eNo);
+regions.push_back( region_info_sp );
+}
+return Error();
+}
+
 size_t
 ProcessElfCore::DoReadMemory (lldb::addr_t addr, void *buf, size_t size, Error &error)
 {
Index: include/lldb/Target/Process.h
===
--- include/lldb/Target/Process.h
+++ include/lldb/Target/Process.h
@@ -2447,7 +2447,7 @@
 }
 
 virtual Error
-GetMemoryRegions (std::vector&)
+GetMemoryRegions (std::vector ®ions)
 {
 Error error;
 error.SetErrorString ("Process::GetMemoryRegions() not supported");
___
lldb-commits mailing list
lldb-commits@lists.l

Re: [Lldb-commits] [PATCH] D21751: Implement GetMemoryRegions() for Linux and Mac OSX core files.

2016-06-27 Thread Greg Clayton via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

We shouldn't need to implement this on all process subclasses. 
Process::GetMemoryRegions(...) could just call the 
Process::GetMemoryRegionInfo() and fill the stuff in. We would need to modify 
lldb_private::MemoryRegionInfo to support knowing when no memory exists for a 
given address. Why? Because Mac programs actually have a __PAGEZERO section 
that no read/write/execute, but it is actually mapped into memory, but we 
currently can't tell the difference between something that isn't mapped, and a 
section that is mapped with no read/write/exe. If we fix this, then 
lldb_private::Process subclasses only need to override 
Process::GetMemoryRegionInfo(...) and we can do the rest up in 
Process::GetMemoryRegions().


http://reviews.llvm.org/D21751



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


Re: [Lldb-commits] [PATCH] D21751: Implement GetMemoryRegions() for Linux and Mac OSX core files.

2016-06-27 Thread Greg Clayton via lldb-commits
clayborg added a comment.

This of course would rely on the fact that each Process subclass the overrides 
GetMemoryRegionInfo() will follow the following rules:
1 - if no memory is mapped for a given address, set an extra "not_mapped" 
variable in MemoryRegionInfo and provide the next address that is mapped by 
setting the end address of the current MemoryRegionInfo correctly.
2 - set values correctly for mapped regions with the correct permissions
3 - For the last entry that is past all mapped entries, set the extra 
"not_mapped" and set the end address as LLDB_INVALID_ADDRESS


http://reviews.llvm.org/D21751



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


[Lldb-commits] [PATCH] D21770: Improve ADB utilization within Android platform

2016-06-27 Thread Oleksiy Vyalov via lldb-commits
ovyalov created this revision.
ovyalov added reviewers: labath, tberghammer.
ovyalov added a subscriber: lldb-commits.
Herald added subscribers: danalbert, tberghammer.

 - Extract sync commands like push/pull file and stat into SyncService so ADB 
connection that's switched in sync mode can be reused for multiple sync 
commands. 
   Improves a few aspects:
1. No ADB re-connection on every file push/pull
 2. host:transport: and sync commands are called only once per 
connection.
 - Reuse the same ADB connection for all shell commands fired by 
PlatformAndroid. 
Improves following aspects:
1. No ADB re-connection on every shell command
 2. host:transport: is called only once per connection.




http://reviews.llvm.org/D21770

Files:
  source/Plugins/Platform/Android/AdbClient.cpp
  source/Plugins/Platform/Android/AdbClient.h
  source/Plugins/Platform/Android/PlatformAndroid.cpp
  source/Plugins/Platform/Android/PlatformAndroid.h
  source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp

Index: source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -11,6 +11,8 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/Log.h"
 #include "lldb/Host/common/TCPSocket.h"
+#include "lldb/Host/ConnectionFileDescriptor.h"
+
 #include "PlatformAndroidRemoteGDBServer.h"
 #include "Utility/UriParser.h"
 
Index: source/Plugins/Platform/Android/PlatformAndroid.h
===
--- source/Plugins/Platform/Android/PlatformAndroid.h
+++ source/Plugins/Platform/Android/PlatformAndroid.h
@@ -12,12 +12,15 @@
 
 // C Includes
 // C++ Includes
+#include 
 #include 
 
 // Other libraries and framework includes
 // Project includes
 #include "Plugins/Platform/Linux/PlatformLinux.h"
 
+#include "AdbClient.h"
+
 namespace lldb_private {
 namespace platform_android {
 
@@ -102,6 +105,8 @@
 GetLibdlFunctionDeclarations() const override;
 
 private:
+std::unique_ptr m_adb;
+std::unique_ptr m_adb_sync_svc;
 std::string m_device_id;
 uint32_t m_sdk_version;
 
Index: source/Plugins/Platform/Android/PlatformAndroid.cpp
===
--- source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ source/Plugins/Platform/Android/PlatformAndroid.cpp
@@ -204,12 +204,17 @@
 auto error = PlatformLinux::ConnectRemote(args);
 if (error.Success())
 {
-AdbClient adb;
-error = AdbClient::CreateByDeviceID(m_device_id, adb);
+m_adb.reset(new AdbClient);
+error = AdbClient::CreateByDeviceID(m_device_id, *m_adb);
 if (error.Fail())
 return error;
 
-m_device_id = adb.GetDeviceID();
+m_device_id = m_adb->GetDeviceID();
+m_adb_sync_svc = m_adb->GetSyncService(error);
+if (error.Fail())
+return error;
+
+error = m_adb->SwitchDeviceTransport();
 }
 return error;
 }
@@ -225,8 +230,7 @@
 if (source_spec.IsRelative())
 source_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (source_spec.GetCString (false));
 
-AdbClient adb (m_device_id);
-return adb.PullFile (source_spec, destination);
+return m_adb_sync_svc->PullFile (source_spec, destination);
 }
 
 Error
@@ -242,9 +246,8 @@
 if (destination_spec.IsRelative())
 destination_spec = GetRemoteWorkingDirectory ().CopyByAppendingPathComponent (destination_spec.GetCString (false));
 
-AdbClient adb (m_device_id);
 // TODO: Set correct uid and gid on remote file.
-return adb.PushFile(source, destination_spec);
+return m_adb_sync_svc->PushFile(source, destination_spec);
 }
 
 const char *
@@ -293,8 +296,7 @@
 return m_sdk_version;
 
 std::string version_string;
-AdbClient adb(m_device_id);
-Error error = adb.Shell("getprop ro.build.version.sdk", 5000 /* ms */, &version_string);
+Error error = m_adb->Shell("getprop ro.build.version.sdk", 5000 /* ms */, &version_string);
 version_string = llvm::StringRef(version_string).trim().str();
 
 if (error.Fail() || version_string.empty())
@@ -330,21 +332,19 @@
 if (module_sp->GetSectionList()->FindSectionByName(ConstString(".symtab")) != nullptr)
 return Error("Symtab already available in the module");
 
-AdbClient adb(m_device_id);
-
 std::string tmpdir;
-Error error = adb.Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
+Error error = m_adb->Shell("mktemp --directory --tmpdir /data/local/tmp", 5000 /* ms */, &tmpdir);
 if (error.Fail() || tmpdir.empty())
 return Error("Failed to generate temporary directory on the device (%s)", error.AsCString());
 tmpdir = llvm::StringRef(tmpdir

[Lldb-commits] [PATCH] D21757: Fix lldb-mi disable/enable breakpoints commands

2016-06-27 Thread Fangliang Xue via lldb-commits
faxue created this revision.
faxue added reviewers: abidh, ChuckR, jacdavis.
faxue added a subscriber: lldb-commits.
faxue set the repository for this revision to rL LLVM.

1) Make the enable breakpoint command actually enable
2) Remove unnecessary output from disable/enable command which isn't following 
mi spec

Repository:
  rL LLVM

http://reviews.llvm.org/D21757

Files:
  packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
  tools/lldb-mi/MICmdCmdBreak.cpp

Index: tools/lldb-mi/MICmdCmdBreak.cpp
===
--- tools/lldb-mi/MICmdCmdBreak.cpp
+++ tools/lldb-mi/MICmdCmdBreak.cpp
@@ -568,19 +568,9 @@
 {
 if (m_bBrkPtDisabledOk)
 {
-const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
-const CMICmnMIValueResult miValueResult("number", miValueConst);
-CMICmnMIValueTuple miValueTuple(miValueResult);
-const CMICmnMIValueConst miValueConst2("n");
-const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
-miValueTuple.Add(miValueResult2);
-const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
-const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
-bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
-
 const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
 m_miResultRecord = miRecordResult;
-return bOk;
+return MIstatus::success;
 }
 
 const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
@@ -683,7 +673,7 @@
 if (brkPt.IsValid())
 {
 m_bBrkPtEnabledOk = true;
-brkPt.SetEnabled(false);
+brkPt.SetEnabled(true);
 m_nBrkPtId = nBrk;
 }
 
@@ -704,19 +694,9 @@
 {
 if (m_bBrkPtEnabledOk)
 {
-const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", m_nBrkPtId));
-const CMICmnMIValueResult miValueResult("number", miValueConst);
-CMICmnMIValueTuple miValueTuple(miValueResult);
-const CMICmnMIValueConst miValueConst2("y");
-const CMICmnMIValueResult miValueResult2("enabled", miValueConst2);
-miValueTuple.Add(miValueResult2);
-const CMICmnMIValueResult miValueResult3("bkpt", miValueTuple);
-const CMICmnMIOutOfBandRecord miOutOfBandRecord(CMICmnMIOutOfBandRecord::eOutOfBand_BreakPointModified, miValueResult3);
-bool bOk = CMICmnStreamStdout::TextToStdout(miOutOfBandRecord.GetString());
-
 const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done);
 m_miResultRecord = miRecordResult;
-return bOk;
+return MIstatus::success;
 }
 
 const CMIUtilString strBrkPtId(CMIUtilString::Format("%d", m_nBrkPtId));
Index: packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
===
--- packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
+++ packages/Python/lldbsuite/test/tools/lldb-mi/breakpoint/TestMiBreak.py
@@ -246,3 +246,41 @@
 self.runCmd("-exec-continue")
 self.expect("\^running")
 self.expect("\*stopped,reason=\"exited-normally\"")
+
+@skipIfWindows #llvm.org/pr24452: Get lldb-mi tests working on Windows
+@skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+def test_lldbmi_break_enable_disable(self):
+"""Test that 'lldb-mi --interpreter' works for enabling disabling breakpoints."""
+
+self.spawnLldbMi(args = None)
+
+self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+self.expect("\^done")
+
+self.runCmd("-break-insert main")
+self.expect("\^done,bkpt={number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0x)0x[0-9a-f]+\",func=\"main\"")
+
+self.runCmd("-exec-run")
+self.expect("\^running")
+self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+self.runCmd("-break-insert ns::foo1")
+self.expect("\^done,bkpt={number=\"2\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0x)0x[0-9a-f]+\",func=\"ns::foo1\(\)\"")
+
+self.runCmd("-break-insert ns::foo2")
+self.expect("\^done,bkpt={number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"(?!0x)0x[0-9a-f]+\",func=\"ns::foo2\(\)\"")
+
+# disable the 2nd breakpoint
+self.runCmd("-break-disable 2")
+self.expect("\^done")
+
+# disable the 3rd breakpoint and re-enable
+self.runCmd("-break-disable 3")
+self.expect("\^done")
+
+self.runCmd("-break-enable 3")
+self.expect("\^done")
+
+self.runCmd("-exec-continue")
+self.expect("\^running")
+self.

[Lldb-commits] [lldb] r273954 - Change PlatformDarwinKernel::GetSharedModule to be a little more

2016-06-27 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Mon Jun 27 17:48:05 2016
New Revision: 273954

URL: http://llvm.org/viewvc/llvm-project?rev=273954&view=rev
Log:
Change PlatformDarwinKernel::GetSharedModule to be a little more
explicit in how it adds the kernel binary, to guard against the
case where a kernel corefile might incorrectly include the kernel's
UUID in it (so calling ::GetSharedModule may end up returning the
global module cache's copy of the core file instead of adding the
kerenl binary).

 

Modified:
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=273954&r1=273953&r2=273954&view=diff
==
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp 
(original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Mon Jun 
27 17:48:05 2016
@@ -30,6 +30,7 @@
 #include "lldb/Interpreter/OptionValueFileSpecList.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
@@ -881,12 +882,24 @@ PlatformDarwinKernel::GetSharedModule (c
 ModuleSP module_sp (new Module (kern_spec));
 if (module_sp && module_sp->GetObjectFile() && 
module_sp->MatchesModuleSpec (kern_spec))
 {
-Error error;
-error = ModuleList::GetSharedModule (kern_spec, module_sp, 
NULL, NULL, NULL);
-if (module_sp && module_sp->GetObjectFile())
+// module_sp is an actual kernel binary we want to add.
+if (process)
 {
+process->GetTarget().GetImages().AppendIfNeeded 
(module_sp);
+error.Clear();
 return error;
 }
+else
+{
+error = ModuleList::GetSharedModule (kern_spec, 
module_sp, NULL, NULL, NULL);
+if (module_sp 
+&& module_sp->GetObjectFile() 
+&& module_sp->GetObjectFile()->GetType() != 
ObjectFile::Type::eTypeCoreFile)
+{
+return error;
+}
+module_sp.reset();
+}
 }
 }
 }


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


[Lldb-commits] [lldb] r273960 - fix invalid assumption about the executable module in Target::Install()

2016-06-27 Thread Todd Fiala via lldb-commits
Author: tfiala
Date: Mon Jun 27 18:21:49 2016
New Revision: 273960

URL: http://llvm.org/viewvc/llvm-project?rev=273960&view=rev
Log:
fix invalid assumption about the executable module in Target::Install()

Target::Install() was assuming the module at index 0 was the executable.
This is often true, but not guaranteed to be the case.  The
TestInferiorChanged.py test highlighted this when run against iOS.
After the binary is replaced in the middle of the test, it becomes the
last module in the list.  The rest of the Target::Install() logic then
clobbers the executable file by using whatever happens to be the first
module in the target module list.

This change also marks the TestInferiorChanged.py test as a no-debug-info
test.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py
lldb/trunk/source/Target/Target.cpp

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py?rev=273960&r1=273959&r2=273960&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/inferior-changed/TestInferiorChanged.py
 Mon Jun 27 18:21:49 2016
@@ -16,6 +16,7 @@ class ChangedInferiorTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIf(hostoslist=["windows"])
+@no_debug_info_test
 def test_inferior_crashing(self):
 """Test lldb reloads the inferior after it was changed during the 
session."""
 self.build()

Modified: lldb/trunk/source/Target/Target.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=273960&r1=273959&r2=273960&view=diff
==
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Mon Jun 27 18:21:49 2016
@@ -2838,10 +2838,10 @@ Target::Install (ProcessLaunchInfo *laun
 const size_t num_images = modules.GetSize();
 for (size_t idx = 0; idx < num_images; ++idx)
 {
-const bool is_main_executable = idx == 0;
 ModuleSP module_sp(modules.GetModuleAtIndex(idx));
 if (module_sp)
 {
+const bool is_main_executable = module_sp == 
GetExecutableModule();
 FileSpec local_file (module_sp->GetFileSpec());
 if (local_file)
 {


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


[Lldb-commits] [lldb] r273963 - Fixup the "shadow" example command to use the function that takes an execution context now that the @lldb.command decorator does the right thing for the command functio

2016-06-27 Thread Greg Clayton via lldb-commits
Author: gclayton
Date: Mon Jun 27 19:06:35 2016
New Revision: 273963

URL: http://llvm.org/viewvc/llvm-project?rev=273963&view=rev
Log:
Fixup the "shadow" example command to use the function that takes an execution 
context now that the @lldb.command decorator does the right thing for the 
command function that takes 5 arguments.

A few fixes:
- Check the process state to make sure it is stopped
- Grab the frame from the "exe_ctx" so this will work during breakpoint 
callbacks
- Print out the SBDeclaration objects of the variables that shadow each other 
so we can see the source locations of which variable declarations are shodowing 
each other.


Modified:
lldb/trunk/examples/python/shadow.py

Modified: lldb/trunk/examples/python/shadow.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/python/shadow.py?rev=273963&r1=273962&r2=273963&view=diff
==
--- lldb/trunk/examples/python/shadow.py (original)
+++ lldb/trunk/examples/python/shadow.py Mon Jun 27 19:06:35 2016
@@ -4,20 +4,14 @@ import lldb
 import shlex
 
 @lldb.command("shadow")
-def check_shadow_command(debugger, command, result, dict):
-target = debugger.GetSelectedTarget()
-if not target:
-print >>result, "invalid target"
-return
-process = target.GetProcess()
-if not process:
-print >>result, "invalid process"
-return
-thread = process.GetSelectedThread()
-if not thread:
-print >>result, "invalid thread"
-return
-frame = thread.GetSelectedFrame()
+def check_shadow_command(debugger, command, exe_ctx, result, dict):
+'''Check the currently selected stack frame for shadowed variables'''
+process = exe_ctx.GetProcess()
+state = process.GetState()
+if state != lldb.eStateStopped:
+print >>result, "process must be stopped, state is %s" % 
lldb.SBDebugger.StateAsCString(state)
+return
+frame = exe_ctx.GetFrame()
 if not frame:
 print >>result, "invalid frame"
 return
@@ -26,8 +20,9 @@ def check_shadow_command(debugger, comma
 # TODO: add support for using arguments that are passed to this command...
 
 # Make a dictionary of variable name to "SBBlock and SBValue"
-var_dict = {}
+shadow_dict = {}
 
+num_shadowed_variables = 0
 # Get the deepest most block from the current frame
 block = frame.GetBlock()
 # Iterate through the block and all of its parents
@@ -36,24 +31,27 @@ def check_shadow_command(debugger, comma
 block_vars = block.GetVariables(frame, True, True, True, 0)
 # Iterate through all variables in the current block
 for block_var in block_vars:
-# Get the variable name and see if we already have a variable by 
this name?
-block_var_name = block_var.GetName()
-if block_var_name in var_dict:
-# We already have seen a variable with this name, so it is 
shadowed
-shadow_block_and_vars = var_dict[block_var_name]
-for shadow_block_and_var in shadow_block_and_vars:
-print shadow_block_and_var[0], shadow_block_and_var[1]
-print 'is shadowed by:'
-print block, block_var
 # Since we can have multiple shadowed variables, we our variable
 # name dictionary to have an array or "block + variable" pairs so
 # We can correctly print out all shadowed variables and whow which
 # blocks they come from
-if block_var_name in var_dict:
-var_dict[block_var_name].append([block, block_var])
+block_var_name = block_var.GetName()
+if block_var_name in shadow_dict:
+shadow_dict[block_var_name].append(block_var)
 else:
-var_dict[block_var_name] = [[block, block_var]]
+shadow_dict[block_var_name] = [block_var]
 # Get the parent block and continue 
 block = block.GetParent()
-
+
+num_shadowed_variables = 0
+if shadow_dict:
+for name in shadow_dict.keys():
+shadow_vars = shadow_dict[name]
+if len(shadow_vars) > 1:
+print '"%s" is shadowed by the following declarations:' % 
(name)
+num_shadowed_variables += 1
+for shadow_var in shadow_vars:
+print >>result, str(shadow_var.GetDeclaration())
+if num_shadowed_variables == 0:
+print >>result, 'no variables are shadowed'
 


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


[Lldb-commits] [lldb] r273979 - fixits are apparently called fix-its.

2016-06-27 Thread Jim Ingham via lldb-commits
Author: jingham
Date: Mon Jun 27 20:33:03 2016
New Revision: 273979

URL: http://llvm.org/viewvc/llvm-project?rev=273979&view=rev
Log:
fixits are apparently called fix-its.



Modified:
lldb/trunk/include/lldb/Expression/UserExpression.h
lldb/trunk/scripts/interface/SBExpressionOptions.i
lldb/trunk/source/Commands/CommandObjectExpression.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Expression/UserExpression.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/UserExpression.h?rev=273979&r1=273978&r2=273979&view=diff
==
--- lldb/trunk/include/lldb/Expression/UserExpression.h (original)
+++ lldb/trunk/include/lldb/Expression/UserExpression.h Mon Jun 27 20:33:03 2016
@@ -338,7 +338,7 @@ protected:
 Address m_address;  ///< 
The address the process is stopped in.
 std::string m_expr_text;///< 
The text of the expression, as typed by the user
 std::string m_expr_prefix;  ///< 
The text of the translation-level definitions, as provided by the user
-std::string m_fixed_text;   ///< 
The text of the expression with fixits applied - this won't be set if the fixed 
text doesn't parse.
+std::string m_fixed_text;   ///< 
The text of the expression with fix-its applied - this won't be set if the 
fixed text doesn't parse.
 lldb::LanguageType  m_language; ///< 
The language to use when parsing (eLanguageTypeUnknown means use defaults)
 ResultType  m_desired_type; ///< 
The type to coerce the expression's result to.  If eResultTypeAny, inferred 
from the expression.
 EvaluateExpressionOptions   m_options;  ///< 
Additional options provided by the user.

Modified: lldb/trunk/scripts/interface/SBExpressionOptions.i
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/interface/SBExpressionOptions.i?rev=273979&r1=273978&r2=273979&view=diff
==
--- lldb/trunk/scripts/interface/SBExpressionOptions.i (original)
+++ lldb/trunk/scripts/interface/SBExpressionOptions.i Mon Jun 27 20:33:03 2016
@@ -119,11 +119,11 @@ public:
 void
 SetPrefix (const char *prefix);
 
-%feature("docstring", "Sets whether to auto-apply FixIt hints to the 
expression being evaluated.") SetAutoApplyFixIts;
+%feature("docstring", "Sets whether to auto-apply fix-it hints to the 
expression being evaluated.") SetAutoApplyFixIts;
 void
 SetAutoApplyFixIts(bool b = true);
 
-%feature("docstring", "Gets whether to auto-apply FixIt hints to an 
expression.") GetAutoApplyFixIts;
+%feature("docstring", "Gets whether to auto-apply fix-it hints to an 
expression.") GetAutoApplyFixIts;
 bool
 GetAutoApplyFixIts();
 

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=273979&r1=273978&r2=273979&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Jun 27 20:33:03 
2016
@@ -61,7 +61,7 @@ CommandObjectExpression::CommandOptions:
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error",'u', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeBoolean,
"Clean up program state if the expression causes a crash, or raises a signal.  
Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."},
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug",  'g', 
OptionParser::eNoArgument  , nullptr, nullptr, 0, eArgTypeNone,   "When 
specified, debug the JIT code by setting a breakpoint on the first instruction 
and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on 
error (-u0)."},
 { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language",   'l', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   
"Specifies the Language to use when parsing the expression.  If not set the 
target.language setting is used." },
-{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits",   'X', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   "If 
true, simple FixIt hints will be automatically applied to the expression." },
+{ LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "apply-fixits",   'X', 
OptionParser::eRequiredArgument, nullptr, nullptr, 0, eArgTypeLanguage,   "If 
true, simple fix-it hints will be automatically applied to the expression." },
 {