[Lldb-commits] [lldb] 20ce8af - [lldb/API] NFC: Reformat and simplify SBThread::GetStopDescription()

2020-03-02 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-02T17:43:35-08:00
New Revision: 20ce8affce85ddea069e979a6e79a2c62ca7a0bc

URL: 
https://github.com/llvm/llvm-project/commit/20ce8affce85ddea069e979a6e79a2c62ca7a0bc
DIFF: 
https://github.com/llvm/llvm-project/commit/20ce8affce85ddea069e979a6e79a2c62ca7a0bc.diff

LOG: [lldb/API] NFC: Reformat and simplify SBThread::GetStopDescription()

Summary:
This gets rid of some nesting and of the raw char* variable that caused
the memory management bug we hit recently.

This commit also removes the fallback code which should trigger when
the StopInfo provides no stop description. All currently implemented
StopInfos have a `GetDescription()` method that shouldn't return an
empty description.

Reviewers: JDevlieghere, labath, mib

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/API/SBThread.cpp
lldb/source/Target/Thread.cpp

Removed: 




diff  --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp
index ad509b81d2bf..c7786534076e 100644
--- a/lldb/source/API/SBThread.cpp
+++ b/lldb/source/API/SBThread.cpp
@@ -40,7 +40,6 @@
 #include "lldb/Target/ThreadPlanStepInstruction.h"
 #include "lldb/Target/ThreadPlanStepOut.h"
 #include "lldb/Target/ThreadPlanStepRange.h"
-#include "lldb/Target/UnixSignals.h"
 #include "lldb/Utility/State.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/StructuredData.h"
@@ -319,97 +318,26 @@ size_t SBThread::GetStopDescription(char *dst, size_t 
dst_len) {
   std::unique_lock lock;
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
 
-  if (exe_ctx.HasThreadScope()) {
-Process::StopLocker stop_locker;
-if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) {
+  if (dst)
+*dst = 0;
 
-  StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo();
-  if (stop_info_sp) {
-std::string thread_stop_desc =
-exe_ctx.GetThreadPtr()->GetStopDescription();
-const char *stop_desc = thread_stop_desc.c_str();
-
-if (stop_desc[0] != '\0') {
-  if (dst)
-return ::snprintf(dst, dst_len, "%s", stop_desc);
-  else {
-// NULL dst passed in, return the length needed to contain the
-// description
-return ::strlen(stop_desc) + 1; // Include the NULL byte for size
-  }
-} else {
-  size_t stop_desc_len = 0;
-  switch (stop_info_sp->GetStopReason()) {
-  case eStopReasonTrace:
-  case eStopReasonPlanComplete: {
-static char trace_desc[] = "step";
-stop_desc = trace_desc;
-stop_desc_len =
-sizeof(trace_desc); // Include the NULL byte for size
-  } break;
-
-  case eStopReasonBreakpoint: {
-static char bp_desc[] = "breakpoint hit";
-stop_desc = bp_desc;
-stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size
-  } break;
-
-  case eStopReasonWatchpoint: {
-static char wp_desc[] = "watchpoint hit";
-stop_desc = wp_desc;
-stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size
-  } break;
-
-  case eStopReasonSignal: {
-stop_desc =
-exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString(
-stop_info_sp->GetValue());
-if (stop_desc == nullptr || stop_desc[0] == '\0') {
-  static char signal_desc[] = "signal";
-  stop_desc = signal_desc;
-  stop_desc_len =
-  sizeof(signal_desc); // Include the NULL byte for size
-}
-  } break;
-
-  case eStopReasonException: {
-char exc_desc[] = "exception";
-stop_desc = exc_desc;
-stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
-  } break;
-
-  case eStopReasonExec: {
-char exc_desc[] = "exec";
-stop_desc = exc_desc;
-stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size
-  } break;
-
-  case eStopReasonThreadExiting: {
-char limbo_desc[] = "thread exiting";
-stop_desc = limbo_desc;
-stop_desc_len = sizeof(limbo_desc);
-  } break;
-  default:
-break;
-  }
+  if (!exe_ctx.HasThreadScope())
+return 0;
 
-  if (stop_desc && stop_desc[0]) {
-if (dst)
-  return ::snprintf(dst, dst_len, "%s", stop_desc) +
- 1; // Include the NULL byte
+  Process::StopLocker stop_locker;
+  if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
+return 0;
 
-if (stop_desc_len == 0)
-  stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte
+  std::string thr

[Lldb-commits] [lldb] 138c7ac - [lldb/GDBRemote] Fix obvious typo in error message.

2020-03-02 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-02T17:53:39-08:00
New Revision: 138c7ac5b60fae9f4b048a268e069f3ed895a098

URL: 
https://github.com/llvm/llvm-project/commit/138c7ac5b60fae9f4b048a268e069f3ed895a098
DIFF: 
https://github.com/llvm/llvm-project/commit/138c7ac5b60fae9f4b048a268e069f3ed895a098.diff

LOG: [lldb/GDBRemote] Fix obvious typo in error message.

It's unlikely that `errno` is the value the user wants to see in this
error message.

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 156f6f7f4fc9..72907a95f3ab 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -3123,7 +3123,7 @@ Status 
ProcessGDBRemote::EnableBreakpointSite(BreakpointSite *bp_site) {
 if (m_gdb_comm.SupportsGDBStoppointPacket(eBreakpointSoftware)) {
   if (error_no != UINT8_MAX)
 error.SetErrorStringWithFormat(
-"error: %d sending the breakpoint request", errno);
+"error: %d sending the breakpoint request", error_no);
   else
 error.SetErrorString("error sending the breakpoint request");
   return error;



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


[Lldb-commits] [lldb] b40ee7f - [lldb/MemoryHistoryAsan] Fix address resolution for recorded backtraces

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T13:18:02-07:00
New Revision: b40ee7ff1b16982b39582eee04ca82cac5f3d154

URL: 
https://github.com/llvm/llvm-project/commit/b40ee7ff1b16982b39582eee04ca82cac5f3d154
DIFF: 
https://github.com/llvm/llvm-project/commit/b40ee7ff1b16982b39582eee04ca82cac5f3d154.diff

LOG: [lldb/MemoryHistoryAsan] Fix address resolution for recorded backtraces

Summary:
The memory history plugin for Asan creates a HistoryThread with the
recorded PC values provided by the Asan runtime. In other cases,
thoses PCs are gathered by LLDB directly.

The PCs returned by the Asan runtime are the PCs of the calls in the
backtrace, not the return addresses you would normally get when
unwinding the stack (look for a call to GetPreviousIntructionPc in
AsanGetStack).

When the above addresses are passed to the unwinder, it will subtract
1 from each address of the non zero frames because it treats them as
return addresses. This can lead to the final report referencing the
wrong line.

This patch fixes this issue by threading a flag through HistoryThread
and HistoryUnwinder that tells them to treat every frame like the
first one. The Asan MemoryHistory plugin can then use this flag.

This fixes running TestMemoryHistory on arm64 devices, although it's
hard to guarantee that the test will continue to exhibit the boundary
condition that triggers this bug.

Reviewers: jasonmolenda, kubamracek

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
lldb/source/Plugins/Process/Utility/HistoryThread.cpp
lldb/source/Plugins/Process/Utility/HistoryThread.h
lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
lldb/source/Plugins/Process/Utility/HistoryUnwind.h

Removed: 




diff  --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp 
b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
index 4b9da8f76fd2..333113a0b17a 100644
--- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
+++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
@@ -138,7 +138,12 @@ static void CreateHistoryThreadFromValueObject(ProcessSP 
process_sp,
 pcs.push_back(pc);
   }
 
-  HistoryThread *history_thread = new HistoryThread(*process_sp, tid, pcs);
+  // The ASAN runtime already massages the return addresses into call
+  // addresses, we don't want LLDB's unwinder to try to locate the previous
+  // instruction again as this might lead to us reporting a 
diff erent line.
+  bool pcs_are_call_addresses = true;
+  HistoryThread *history_thread =
+  new HistoryThread(*process_sp, tid, pcs, pcs_are_call_addresses);
   ThreadSP new_thread_sp(history_thread);
   std::ostringstream thread_name_with_number;
   thread_name_with_number << thread_name << " Thread " << tid;

diff  --git a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp 
b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
index 815883d9e2f6..0649cd2f07de 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
+++ b/lldb/source/Plugins/Process/Utility/HistoryThread.cpp
@@ -25,12 +25,13 @@ using namespace lldb_private;
 //  Constructor
 
 HistoryThread::HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
- std::vector pcs)
+ std::vector pcs,
+ bool pcs_are_call_addresses)
 : Thread(process, tid, true), m_framelist_mutex(), m_framelist(),
   m_pcs(pcs), m_extended_unwind_token(LLDB_INVALID_ADDRESS), 
m_queue_name(),
   m_thread_name(), m_originating_unique_thread_id(tid),
   m_queue_id(LLDB_INVALID_QUEUE_ID) {
-  m_unwinder_up.reset(new HistoryUnwind(*this, pcs));
+  m_unwinder_up.reset(new HistoryUnwind(*this, pcs, pcs_are_call_addresses));
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OBJECT));
   LLDB_LOGF(log, "%p HistoryThread::HistoryThread", static_cast(this));
 }

diff  --git a/lldb/source/Plugins/Process/Utility/HistoryThread.h 
b/lldb/source/Plugins/Process/Utility/HistoryThread.h
index 434cf6af7197..a66e0f2d4207 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryThread.h
+++ b/lldb/source/Plugins/Process/Utility/HistoryThread.h
@@ -33,7 +33,8 @@ namespace lldb_private {
 class HistoryThread : public lldb_private::Thread {
 public:
   HistoryThread(lldb_private::Process &process, lldb::tid_t tid,
-std::vector pcs);
+std::vector pcs,
+bool pcs_are_call_addresses = false);
 
   ~HistoryThread() override;
 

diff  --git a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp 
b/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
index 93fcde72bf99..9b9522955de9 100644
--- a/lldb/source/Plugins/Process/Utility/HistoryUnwind.cpp
+++ b/lldb/source/Plugins/Process/Utility/HistoryU

[Lldb-commits] [lldb] 52b2bae - [lldb/testsuite] Skip TestEmptyStdModule.py if using a remote platform

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: 52b2bae777f2a30d1ed6e87c8812bbffc4f4feeb

URL: 
https://github.com/llvm/llvm-project/commit/52b2bae777f2a30d1ed6e87c8812bbffc4f4feeb
DIFF: 
https://github.com/llvm/llvm-project/commit/52b2bae777f2a30d1ed6e87c8812bbffc4f4feeb.diff

LOG: [lldb/testsuite] Skip TestEmptyStdModule.py if using a remote platform

The test runs `platform select host`, so it make no sense to run it
when remote debugging.

Added: 


Modified: 

lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py

Removed: 




diff  --git 
a/lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
index 76e79df5cd1c..2b1cb100a325 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/empty-module/TestEmptyStdModule.py
@@ -15,6 +15,7 @@ class ImportStdModule(TestBase):
 # but we still add the libc++ category so that this test is only run in
 # test configurations where libc++ is actually supposed to be tested.
 @add_test_categories(["libc++"])
+@skipIfRemote
 @skipIf(compiler=no_match("clang"))
 def test(self):
 self.build()



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


[Lldb-commits] [lldb] 59918d3 - [lldb/testsuite] Make TestObjCIvarStripped.py working with codesigning

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: 59918d3793a1136e7041b1a76f38a42cf8644474

URL: 
https://github.com/llvm/llvm-project/commit/59918d3793a1136e7041b1a76f38a42cf8644474
DIFF: 
https://github.com/llvm/llvm-project/commit/59918d3793a1136e7041b1a76f38a42cf8644474.diff

LOG: [lldb/testsuite] Make TestObjCIvarStripped.py working with codesigning

This test was stripping a binary generated by Makefile.rules which is
potentially codesigned. Stripping invalidates the code signature, so
we might need to re-sign after stripping.

Added: 


Modified: 
lldb/test/API/lang/objc/objc-ivar-stripped/Makefile

Removed: 




diff  --git a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile 
b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
index 0aaa021132e1..8b63215d6d9d 100644
--- a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
+++ b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
@@ -3,7 +3,10 @@ LD_EXTRAS := -lobjc -framework Foundation
 
 all:a.out.stripped
 
+include Makefile.rules
+
 a.out.stripped: a.out.dSYM
strip -o a.out.stripped a.out
-
-include Makefile.rules
+ifneq "$(CODESIGN)" ""
+   $(CODESIGN) -fs - a.out.stripped
+endif



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


[Lldb-commits] [lldb] c182be2 - [lldb/testsuite] Tweak TestBreakpointLocations.py to pass for arm64

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: c182be211a4d1a79390703ede8f041dcbaaf7947

URL: 
https://github.com/llvm/llvm-project/commit/c182be211a4d1a79390703ede8f041dcbaaf7947
DIFF: 
https://github.com/llvm/llvm-project/commit/c182be211a4d1a79390703ede8f041dcbaaf7947.diff

LOG: [lldb/testsuite] Tweak TestBreakpointLocations.py to pass for arm64

The test checks that we correctly set the right number of breakpoints
when breaking into an `always_inline` function. The line of this
funstion selected for this test was the return statement, but with
recent compiler, this return statement doesn't necessarily exist after
inlining, even at O0.

Switch the breakpoint to a different line of the inline function.

Added: 


Modified: 
lldb/test/API/functionalities/breakpoint/breakpoint_locations/main.c

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_locations/main.c 
b/lldb/test/API/functionalities/breakpoint/breakpoint_locations/main.c
index 7ec3ded67b74..f6ccb031c744 100644
--- a/lldb/test/API/functionalities/breakpoint/breakpoint_locations/main.c
+++ b/lldb/test/API/functionalities/breakpoint/breakpoint_locations/main.c
@@ -14,9 +14,9 @@ func_inlined (void)
 {
 static int func_inline_call_count = 0;
 printf ("Called func_inlined.\n");
-++func_inline_call_count;
+++func_inline_call_count;  // Set break point at this line.
 printf ("Returning func_inlined call count: %d.\n", 
func_inline_call_count);
-return func_inline_call_count; // Set break point at this line.
+return func_inline_call_count;
 }
 
 extern int func_inlined (void);



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


[Lldb-commits] [lldb] 71db787 - [lldb/testsuite] Rewrite TestThreadLocal.py

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: 71db787c4583b5b05b9066509c36eb996924aeda

URL: 
https://github.com/llvm/llvm-project/commit/71db787c4583b5b05b9066509c36eb996924aeda
DIFF: 
https://github.com/llvm/llvm-project/commit/71db787c4583b5b05b9066509c36eb996924aeda.diff

LOG: [lldb/testsuite] Rewrite TestThreadLocal.py

It was an inline test before. Clang stopped emitting line information
for the TLS initialization and the inline test didn't have a way to
break before it anymore.

This rewrites the test as a full-fldeged python test and improves the
checking of the error case to verify that the failure we are looking
for is related to the TLS setup not being complete.

Added: 


Modified: 
lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py
lldb/test/API/lang/cpp/thread_local/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py 
b/lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py
index 5152c0010d10..e7cfa1ca14f2 100644
--- a/lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py
+++ b/lldb/test/API/lang/cpp/thread_local/TestThreadLocal.py
@@ -1,6 +1,49 @@
-from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(),
-  lldbinline.expectedFailureAll(oslist=[
-  "windows", "linux", "netbsd"]))
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbtest
+
+
+class PlatformProcessCrashInfoTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+@expectedFailureAll(oslist=["windows", "linux", "netbsd"])
+def test_thread_local(self):
+# Set a breakpoint on the first instruction of the main function,
+# before the TLS initialization has run.
+self.build()
+exe = self.getBuildArtifact("a.out")
+
+(target, process, _, _) = \
+lldbutil.run_to_source_breakpoint(self, "Set breakpoint here",
+  lldb.SBFileSpec("main.cpp"))
+self.expect_expr("tl_local_int + 1",
+ result_type="int", result_value="323")
+self.expect_expr("*tl_local_ptr + 2",
+ result_type="int", result_value="324")
+self.expect_expr("tl_global_int",
+ result_type="int", result_value="123")
+self.expect_expr("*tl_global_ptr",
+ result_type="int", result_value="45")
+
+# Now see if we emit the correct error when the TLS is not yet
+# initialized. Let's set a breakpoint on the first instruction
+# of main.
+main_module = target.FindModule(lldb.SBFileSpec(exe))
+main_address = main_module.FindSymbol("main").GetStartAddress()
+main_bkpt = target.BreakpointCreateBySBAddress(main_address)
+
+process.Kill()
+lldbutil.run_to_breakpoint_do_run(self, target, main_bkpt)
+
+self.expect("expr tl_local_int", error=True,
+substrs=["couldn't get the value of variable tl_local_int",
+ "No TLS data currently exists for this thread"])
+self.expect("expr *tl_local_ptr", error=True,
+substrs=["couldn't get the value of variable tl_local_ptr",
+ "No TLS data currently exists for this thread"])
+

diff  --git a/lldb/test/API/lang/cpp/thread_local/main.cpp 
b/lldb/test/API/lang/cpp/thread_local/main.cpp
index 1855b7c5f344..04c7fc0ed74d 100644
--- a/lldb/test/API/lang/cpp/thread_local/main.cpp
+++ b/lldb/test/API/lang/cpp/thread_local/main.cpp
@@ -3,15 +3,9 @@ thread_local int tl_global_int = 123;
 thread_local int *tl_global_ptr = &storage;
 
 int main(int argc, char **argv) {
-  //% self.expect("expr tl_local_int", error=True, substrs=["couldn't get the 
value of variable tl_local_int"])
-  //% self.expect("expr *tl_local_ptr", error=True, substrs=["couldn't get the 
value of variable tl_local_ptr"])
   thread_local int tl_local_int = 321;
   thread_local int *tl_local_ptr = nullptr;
   tl_local_ptr = &tl_local_int;
   tl_local_int++;
-  //% self.expect("expr tl_local_int + 1", substrs=["int", "= 323"])
-  //% self.expect("expr *tl_local_ptr + 2", substrs=["int", "= 324"])
-  //% self.expect("expr tl_global_int", substrs=["int", "= 123"])
-  //% self.expect("expr *tl_global_ptr", substrs=["int", "= 45"])
-  return 0;
+  return 0; // Set breakpoint here
 }



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


[Lldb-commits] [lldb] 127b9d9 - [lldb/testsuite] Apply @skipIfDarwinEmbedded to part of TestHWBreakMultiThread

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: 127b9d9d774dcc593cfd50eccde307dbe96097a2

URL: 
https://github.com/llvm/llvm-project/commit/127b9d9d774dcc593cfd50eccde307dbe96097a2
DIFF: 
https://github.com/llvm/llvm-project/commit/127b9d9d774dcc593cfd50eccde307dbe96097a2.diff

LOG: [lldb/testsuite] Apply @skipIfDarwinEmbedded to part of 
TestHWBreakMultiThread

The comment in the test wrongfully claimed that we support hardware
breakpoints on darwin for arm64, but we never did.

Added: 


Modified: 

lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
 
b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
index f778b8e39e72..a4a1d9effbe1 100644
--- 
a/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
+++ 
b/lldb/test/API/functionalities/breakpoint/hardware_breakpoints/hardware_breakpoint_on_multiple_threads/TestHWBreakMultiThread.py
@@ -32,19 +32,21 @@ def test_hw_break_set_disable_multi_thread_linux(self):
 self.setTearDownCleanup()
 self.break_multi_thread('disable', False) # llvm.org/PR44659
 
-# LLDB on darwin supports hardware breakpoints for arm, aarch64, x86_64 and
-# i386 architectures.
+# LLDB on darwin supports hardware breakpoints for x86_64 and i386
+# architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
+@skipIfDarwinEmbedded
 def test_hw_break_set_delete_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()
 self.break_multi_thread('delete')
 
-# LLDB on darwin supports hardware breakpoints for arm, aarch64, x86_64 and
-# i386 architectures.
+# LLDB on darwin supports hardware breakpoints for x86_64 and i386
+# architectures.
 @skipUnlessDarwin
 @skipIfOutOfTreeDebugserver
+@skipIfDarwinEmbedded
 def test_hw_break_set_disable_multi_thread_macos(self):
 self.build()
 self.setTearDownCleanup()



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


[Lldb-commits] [lldb] acd641c - [lldb/testsuite] Slightly rework TestHiddenIvars.py

2020-03-18 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-18T20:52:28-07:00
New Revision: acd641c19d687c7117b08cdd568a91a381043ebb

URL: 
https://github.com/llvm/llvm-project/commit/acd641c19d687c7117b08cdd568a91a381043ebb
DIFF: 
https://github.com/llvm/llvm-project/commit/acd641c19d687c7117b08cdd568a91a381043ebb.diff

LOG: [lldb/testsuite] Slightly rework TestHiddenIvars.py

The test was stripping the binaries from the Python
code. Unfortunately, if running on darwin embedded in a context that
requires code signing, the stripping was invalidating the signature,
thus breaking the test.

This patch moves the stripping to the Makefile and resigns the
stripped binaries if required.

Added: 


Modified: 
lldb/test/API/lang/objc/hidden-ivars/Makefile
lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py

Removed: 




diff  --git a/lldb/test/API/lang/objc/hidden-ivars/Makefile 
b/lldb/test/API/lang/objc/hidden-ivars/Makefile
index 0664769456ef..283e8a118fb1 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/Makefile
+++ b/lldb/test/API/lang/objc/hidden-ivars/Makefile
@@ -4,4 +4,24 @@ OBJC_SOURCES := main.m
 
 LD_EXTRAS = -framework Foundation
 
+all: a.out libInternalDefiner.dylib stripped
+
 include Makefile.rules
+
+ifeq "$(MAKE_DSYM)" "YES"
+stripped: a.out.dSYM
+endif
+
+stripped: a.out libInternalDefiner.dylib
+   mkdir stripped
+   strip -Sx a.out -o stripped/a.out
+   strip -Sx libInternalDefiner.dylib -o stripped/libInternalDefiner.dylib
+ifneq "$(CODESIGN)" ""
+   $(CODESIGN) -fs - stripped/a.out
+endif
+ifneq "$(CODESIGN)" ""
+   $(CODESIGN) -fs - stripped/libInternalDefiner.dylib
+endif
+ifeq "$(MAKE_DSYM)" "YES"
+   cp -r a.out.dSYM stripped/a.out.dSYM
+endif

diff  --git a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py 
b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
index 03a325ac49c6..5930ffdc958a 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
+++ b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
@@ -80,20 +80,11 @@ def test_frame_variable_across_modules(self):
 def common_setup(self, strip):
 
 if strip:
-self.assertTrue(subprocess.call(
-['/usr/bin/strip', '-Sx',
- self.getBuildArtifact('libInternalDefiner.dylib')]) == 0,
-'stripping dylib succeeded')
-self.assertTrue(subprocess.call(
-['/bin/rm', '-rf',
- self.getBuildArtifact('libInternalDefiner.dylib.dSYM')]) == 0,
-'remove dylib dSYM file succeeded')
-self.assertTrue(subprocess.call(['/usr/bin/strip', '-Sx',
- self.getBuildArtifact("a.out")
-]) == 0,
-'stripping a.out succeeded')
+exe = self.getBuildArtifact("stripped/a.out")
+else:
+exe = self.getBuildArtifact("a.out")
 # Create a target by the debugger.
-target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+target = self.dbg.CreateTarget(exe)
 self.assertTrue(target, VALID_TARGET)
 
 # Create the breakpoint inside function 'main'.
@@ -110,7 +101,6 @@ def common_setup(self, strip):
 None, environment, self.get_process_working_directory())
 self.assertTrue(process, PROCESS_IS_VALID)
 
-exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Break inside the foo function which takes a bar_ptr argument.



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


[Lldb-commits] [lldb] ecc6c42 - [lldb/testsuite] Fix TestInlineStepping on arm64 with newer compilers

2020-03-19 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-19T08:25:59-07:00
New Revision: ecc6c426977f59f69b683d67ceb3157fb694ce09

URL: 
https://github.com/llvm/llvm-project/commit/ecc6c426977f59f69b683d67ceb3157fb694ce09
DIFF: 
https://github.com/llvm/llvm-project/commit/ecc6c426977f59f69b683d67ceb3157fb694ce09.diff

LOG: [lldb/testsuite] Fix TestInlineStepping on arm64 with newer compilers

Summary:
TestInlineStepping tests LLDB's ability to step in the presence of
inline frames. The testcase source has a number of functions and some
of them are marked `always_inline`.

The test is built around the assumption that the inline function will
be fully represented once inlined, but this is not true with the
current arm64 code generation. For example:

void caller() {
 always_inline_function(); // Step here
}

When stppeing into `caller()` above, you might immediatly end up in
the inlines frame for `always_inline_function()`, because there might
literally be no code associated with `caller()` itself.

This patch hacks around the issue by adding an `asm volatile("nop")`
on some lines with inlined calls where we expect to be able to
step. Like so:

void caller() {
 asm volatile("nop"); always_inline_function(); // Step here
}

This guarantees there is always going to be one instruction for this
line in the caller.

Reviewers: labath, jingham

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/test/API/functionalities/inline-stepping/calling.cpp

Removed: 




diff  --git a/lldb/test/API/functionalities/inline-stepping/calling.cpp 
b/lldb/test/API/functionalities/inline-stepping/calling.cpp
index 9982fbf42734..49179ce7c978 100644
--- a/lldb/test/API/functionalities/inline-stepping/calling.cpp
+++ b/lldb/test/API/functionalities/inline-stepping/calling.cpp
@@ -75,7 +75,7 @@ caller_trivial_1 ()
 void
 caller_trivial_2 ()
 {
-inline_trivial_1 (); // In caller_trivial_2.
+asm volatile ("nop"); inline_trivial_1 (); // In caller_trivial_2.
 inline_value += 1;  // At increment in caller_trivial_2.
 }
 
@@ -88,7 +88,7 @@ called_by_inline_trivial ()
 void
 inline_trivial_1 ()
 {
-inline_trivial_2(); // In inline_trivial_1.
+asm volatile ("nop"); inline_trivial_2(); // In inline_trivial_1.
 inline_value += 1;  // At increment in inline_trivial_1.
 }
 



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


[Lldb-commits] [lldb] e154cbb - [lldb/testsuite] XFail TestBuiltinTrap.py not only on linux

2020-03-19 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-19T08:25:59-07:00
New Revision: e154cbb124a63057356dede8bca5bdbd2f60d44c

URL: 
https://github.com/llvm/llvm-project/commit/e154cbb124a63057356dede8bca5bdbd2f60d44c
DIFF: 
https://github.com/llvm/llvm-project/commit/e154cbb124a63057356dede8bca5bdbd2f60d44c.diff

LOG: [lldb/testsuite] XFail TestBuiltinTrap.py not only on linux

Summary:
TestBuiltinTrap fail on darwin embedded because the `__builin_trap`
builtin doesn't get any line info attached to it by clang when
building for arm64.

The test was already XFailed for linux arm(64), I presume for the same
reasons. This patch just XFails it independently of the platform.

Reviewers: labath

Subscribers: kristof.beyls, danielkiss, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/test/API/linux/builtin_trap/TestBuiltinTrap.py

Removed: 




diff  --git a/lldb/test/API/linux/builtin_trap/TestBuiltinTrap.py 
b/lldb/test/API/linux/builtin_trap/TestBuiltinTrap.py
index 22de873e29fa..added4ef508a 100644
--- a/lldb/test/API/linux/builtin_trap/TestBuiltinTrap.py
+++ b/lldb/test/API/linux/builtin_trap/TestBuiltinTrap.py
@@ -23,7 +23,7 @@ def setUp(self):
 
 # gcc generates incorrect linetable
 @expectedFailureAll(archs="arm", compiler="gcc", triple=".*-android")
-@expectedFailureAll(oslist=['linux'], archs=['arm', 'aarch64'])
+@expectedFailureAll(archs=['arm', 'aarch64'])
 @skipIfWindows
 def test_with_run_command(self):
 """Test that LLDB handles a function with __builtin_trap correctly."""



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


[Lldb-commits] [lldb] 8758d02 - [lldb/testsuite] Skip part of TestProcessCrashInfo.py on Darwin embedded

2020-03-19 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-19T08:26:00-07:00
New Revision: 8758d02074be7b80b804fad19e8b7de6ebd43c31

URL: 
https://github.com/llvm/llvm-project/commit/8758d02074be7b80b804fad19e8b7de6ebd43c31
DIFF: 
https://github.com/llvm/llvm-project/commit/8758d02074be7b80b804fad19e8b7de6ebd43c31.diff

LOG: [lldb/testsuite] Skip part of TestProcessCrashInfo.py on Darwin embedded

See https://reviews.llvm.org/D76407 for discussion.

Added: 


Modified: 
lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py 
b/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
index d0f47de83eea..6ef5018204fd 100644
--- a/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
+++ b/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
@@ -69,6 +69,8 @@ def test_api(self):
 
 self.assertIn("pointer being freed was not allocated", 
stream.GetData())
 
+# dyld leaves permanent crash_info records when testing on device.
+@skipIfDarwinEmbedded
 def test_on_sane_process(self):
 """Test that lldb doesn't fetch the extended crash information
 dictionnary from a 'sane' stopped process."""



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


[Lldb-commits] [lldb] 76a5451 - [lldb/testsuite] un-XFail TestInlineStepping.py on linux and windows

2020-03-19 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-19T09:24:11-07:00
New Revision: 76a5451a524c0cecdf21a03844ba628bfe857369

URL: 
https://github.com/llvm/llvm-project/commit/76a5451a524c0cecdf21a03844ba628bfe857369
DIFF: 
https://github.com/llvm/llvm-project/commit/76a5451a524c0cecdf21a03844ba628bfe857369.diff

LOG: [lldb/testsuite] un-XFail TestInlineStepping.py on linux and windows

It looks like my tweak in ecc6c426977f5 made the test pass on windows
and the linux aarch64 bot.

Added: 


Modified: 
lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py 
b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
index 40e29e614ad6..8e84566d9f69 100644
--- a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
+++ b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
@@ -16,9 +16,6 @@ class TestInlineStepping(TestBase):
 @expectedFailureAll(
 compiler="icc",
 bugnumber="# Not really a bug.  ICC combines two inlined functions.")
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
-@expectedFailureAll(archs=["aarch64"], oslist=["linux"],
-bugnumber="llvm.org/pr44057")
 def test_with_python_api(self):
 """Test stepping over and into inlined functions."""
 self.build()



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


[Lldb-commits] [lldb] b4a6e63 - [lldb/Target] Rework the way the inferior environment is created

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:34-07:00
New Revision: b4a6e63ea12309bf667d1569a20ec5b081cbf2a4

URL: 
https://github.com/llvm/llvm-project/commit/b4a6e63ea12309bf667d1569a20ec5b081cbf2a4
DIFF: 
https://github.com/llvm/llvm-project/commit/b4a6e63ea12309bf667d1569a20ec5b081cbf2a4.diff

LOG: [lldb/Target] Rework the way the inferior environment is created

Summary:
The interactions between the environment settings (`target.env-vars`,
`target.inherit-env`) and the inferior life-cycle are non-obvious
today. For example, if `target.inherit-env` is set, the `target.env-vars`
setting will be augmented with the contents of the host environment
the first time the launch environment is queried (usually at
launch). After that point, toggling `target.inherit-env` will have no
effect as there's no tracking of what comes from the host and what is
a user setting.

This patch computes the environment every time it is queried rather
than updating the contents of the `target.env-vars` property. This
means that toggling the `target.inherit-env` property later will now
have the intended effect.

This patch also adds a `target.unset-env-vars` settings that one can
use to remove variables from the launch environment. Using this, you
can inherit all but a few of the host environment.

The way the launch environment is constructed is:
  1/ if `target.inherit-env` is set, then read the host environment
  into the launch environment.
  2/ Remove for the environment the variables listed in
  `target.unset-env`.
  3/ Augment the launch environment with the contents of
  `target.env-vars`. This overrides any common values with the host
  environment.

The one functional difference here that could be seen as a regression
is that `target.env-vars` will not contain the inferior environment
after launch. The patch implements a better alternative in the
`target show-launch-environment` command which will return the
environment computed through the above rules.

Reviewers: labath, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Commands/CommandObjectTarget.cpp
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 2e7932f49e6f..77cda4998192 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -225,9 +225,12 @@ class TargetProperties : public Properties {
   void DisableASLRValueChangedCallback();
   void DisableSTDIOValueChangedCallback();
 
+  Environment ComputeEnvironment() const;
+
   // Member variables.
   ProcessLaunchInfo m_launch_info;
   std::unique_ptr m_experimental_properties_up;
+  Target *m_target;
 };
 
 class EvaluateExpressionOptions {

diff  --git a/lldb/source/Commands/CommandObjectTarget.cpp 
b/lldb/source/Commands/CommandObjectTarget.cpp
index c70117c7a80a..95f81fc6cd54 100644
--- a/lldb/source/Commands/CommandObjectTarget.cpp
+++ b/lldb/source/Commands/CommandObjectTarget.cpp
@@ -682,6 +682,41 @@ class CommandObjectTargetDelete : public 
CommandObjectParsed {
   OptionGroupBoolean m_cleanup_option;
 };
 
+class CommandObjectTargetShowLaunchEnvironment : public CommandObjectParsed {
+public:
+  CommandObjectTargetShowLaunchEnvironment(CommandInterpreter &interpreter)
+  : CommandObjectParsed(
+interpreter, "target show-launch-environment",
+"Shows the environment being passed to the process when launched, "
+"taking info account 3 settings: target.env-vars, "
+"target.inherit-env and target.unset-env-vars.",
+nullptr, eCommandRequiresTarget) {}
+
+  ~CommandObjectTargetShowLaunchEnvironment() override = default;
+
+protected:
+  bool DoExecute(Args &args, CommandReturnObject &result) override {
+Target *target = m_exe_ctx.GetTargetPtr();
+Environment env = target->GetEnvironment();
+
+std::vector env_vector;
+env_vector.reserve(env.size());
+for (auto &KV : env)
+  env_vector.push_back(&KV);
+std::sort(env_vector.begin(), env_vector.end(),
+  [](Environment::value_type *a, Environment::value_type *b) {
+return a->first() < b->first();
+  });
+
+auto &strm = result.GetOutputStream();
+for (auto &KV : env_vector)
+  strm.Format("{0}={1}\n", KV->first(), KV->second);
+
+result.SetStatus(eReturnStatusSuccessFinishResult);
+return result.Succeeded();
+  }
+};
+
 #pragma mark CommandObjectTargetVariable
 
 // "target variable"
@@ -4876,6 +4911,9 @@ 
CommandObjectMultiwordTarget::CommandObjectMultiwordTarget(
  CommandObjectSP(new CommandObjectTargetList(interpreter)));
   LoadSubCommand("select",
  Command

[Lldb-commits] [lldb] cd7b450 - [lldb/API] Make Launch(Simple) use args and env from target properties

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:33-07:00
New Revision: cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf

URL: 
https://github.com/llvm/llvm-project/commit/cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf
DIFF: 
https://github.com/llvm/llvm-project/commit/cd7b45057ca9bc72b99a0abc6c9be25e0f72fbcf.diff

LOG: [lldb/API] Make Launch(Simple) use args and env from target properties

Summary:
When no arguments or environment is provided to SBTarget::LaunchSimple,
make it use the values surrently set in the target properties. You can
get the current behavior back by passing an empty array instead.

It seems like using the target defaults is a much more intuitive
behavior for those APIs. It's unllikely that anyone passed NULL/None to
this API after having set properties in order to explicitely ignore them.

One direct application of this change is within the testsuite. We have
plenty of tests calling LaunchSimple and passing None as environment.
If you passed --inferior-env to dotest.py to, for example, set
(DY)LD_LIBRARY_PATH, it wouldn't be taken into account.

Reviewers: jingham, labath, #libc_abi!

Subscribers: libcxx-commits, lldb-commits

Tags: #lldb, #libc_abi

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

Added: 


Modified: 
lldb/include/lldb/API/SBTarget.h
lldb/source/API/SBTarget.cpp
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBTarget.h 
b/lldb/include/lldb/API/SBTarget.h
index a50e791d4fe3..1db54279fcb5 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -127,7 +127,9 @@ class LLDB_API SBTarget {
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this is null, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] stdin_path
   /// The path to use when re-directing the STDIN of the new
@@ -175,7 +177,9 @@ class LLDB_API SBTarget {
   /// The argument array.
   ///
   /// \param[in] envp
-  /// The environment array.
+  /// The environment array. If this isn't provided, the default
+  /// environment values (provided through `settings set
+  /// target.env-vars`) will be used.
   ///
   /// \param[in] working_directory
   /// The working directory to have the child process run in

diff  --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp
index b90e77280d24..a70f54135e02 100644
--- a/lldb/source/API/SBTarget.cpp
+++ b/lldb/source/API/SBTarget.cpp
@@ -371,10 +371,19 @@ SBProcess SBTarget::Launch(SBListener &listener, char 
const **argv,
 Module *exe_module = target_sp->GetExecutableModulePointer();
 if (exe_module)
   launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true);
-if (argv)
+if (argv) {
   launch_info.GetArguments().AppendArguments(argv);
-if (envp)
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetArguments().AppendArguments(
+  default_launch_info.GetArguments());
+}
+if (envp) {
   launch_info.GetEnvironment() = Environment(envp);
+} else {
+  auto default_launch_info = target_sp->GetProcessLaunchInfo();
+  launch_info.GetEnvironment() = default_launch_info.GetEnvironment();
+}
 
 if (listener.IsValid())
   launch_info.SetListener(listener.GetSP());

diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 6ec59bbe7a09..b203f85de9fb 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -204,10 +204,15 @@ def test_disassembler_settings(self):
 
 @skipIfDarwinEmbedded   #  debugserver on ios etc 
can't write files
 def test_run_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=False)
+
+@skipIfDarwinEmbedded   #  debugserver on ios etc 
can't write files
+def test_launchsimple_args_and_env_vars(self):
+self.do_test_run_args_and_env_vars(use_launchsimple=True)
+
+def do_test_run_args_and_env_vars(self, use_launchsimple):
 """Test that run-args and env-vars are passed to the launched 
process."""
 self.build()
-exe = self.getBuildArtifact("a.out")
-self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # Set the run-args and the env-vars.
 # And add hooks to restore the settings during tearDown().
@@ -218,7 +223,11 @@ def test_run_args_and_env_vars(self):
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
-launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+exe = self.getBuildArtifact("a.out")
+self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)

[Lldb-commits] [lldb] 9228a9e - [lldb/Target] Initialize new targets environment variables from target.env-vars

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T07:58:33-07:00
New Revision: 9228a9efc6c57a932d936ebb214f6ff5bafe79ff

URL: 
https://github.com/llvm/llvm-project/commit/9228a9efc6c57a932d936ebb214f6ff5bafe79ff
DIFF: 
https://github.com/llvm/llvm-project/commit/9228a9efc6c57a932d936ebb214f6ff5bafe79ff.diff

LOG: [lldb/Target] Initialize new targets environment variables from 
target.env-vars

Summary:
The TargetProperties constructor invokes a series of callbacks to
prime the properties from the default ones. The one callback in
charge of updating the inferior environment was commented out
because it crashed.

The reason for the crash is that TargetProperties is a parent class
of Target and the callbacks were invoked using a Target that was
not fully initialized. This patch moves the initial callback
invocations to a separate function that can be called at the end
the Target constructor, thus preventing the crash.

One existing test had to be modified, because the initialization of
the environment properties now take place at the time the target is
created, not at the first use of the environment (usually launch
time).

The added test checks that the LaunchInfo object returned by
the target has been primed with the values from the settings.

Reviewers: jingham, labath

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Target/Target.cpp
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 3a8570c0d630..2e7932f49e6f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -211,6 +211,8 @@ class TargetProperties : public Properties {
 
   bool GetAutoInstallMainExecutable() const;
 
+  void UpdateLaunchInfoFromProperties();
+
 private:
   // Callbacks for m_launch_info.
   void Arg0ValueChangedCallback();

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 2bb53bcd4230..0162ca838e78 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -113,6 +113,8 @@ Target::Target(Debugger &debugger, const ArchSpec 
&target_arch,
  target_arch.GetArchitectureName(),
  target_arch.GetTriple().getTriple().c_str());
   }
+
+  UpdateLaunchInfoFromProperties();
 }
 
 Target::~Target() {
@@ -3468,18 +3470,6 @@ TargetProperties::TargetProperties(Target *target)
 ConstString("Experimental settings - setting these won't produce "
 "errors if the setting is not present."),
 true, m_experimental_properties_up->GetValueProperties());
-
-// Update m_launch_info once it was created
-Arg0ValueChangedCallback();
-RunArgsValueChangedCallback();
-// EnvVarsValueChangedCallback(); // FIXME: cause segfault in
-// Target::GetPlatform()
-InputPathValueChangedCallback();
-OutputPathValueChangedCallback();
-ErrorPathValueChangedCallback();
-DetachOnErrorValueChangedCallback();
-DisableASLRValueChangedCallback();
-DisableSTDIOValueChangedCallback();
   } else {
 m_collection_sp =
 std::make_shared(ConstString("target"));
@@ -3498,6 +3488,18 @@ TargetProperties::TargetProperties(Target *target)
 
 TargetProperties::~TargetProperties() = default;
 
+void TargetProperties::UpdateLaunchInfoFromProperties() {
+  Arg0ValueChangedCallback();
+  RunArgsValueChangedCallback();
+  EnvVarsValueChangedCallback();
+  InputPathValueChangedCallback();
+  OutputPathValueChangedCallback();
+  ErrorPathValueChangedCallback();
+  DetachOnErrorValueChangedCallback();
+  DisableASLRValueChangedCallback();
+  DisableSTDIOValueChangedCallback();
+}
+
 bool TargetProperties::GetInjectLocalVariables(
 ExecutionContext *exe_ctx) const {
   const Property *exp_property = m_collection_sp->GetPropertyAtIndex(

diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index ffb194fda808..6ec59bbe7a09 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -218,6 +218,15 @@ def test_run_args_and_env_vars(self):
 self.addTearDownHook(
 lambda: self.runCmd("settings clear target.env-vars"))
 
+launch_info = self.dbg.GetTargetAtIndex(0).GetLaunchInfo()
+found_env_var = False
+for i in range(0, launch_info.GetNumEnvironmentEntries()):
+if launch_info.GetEnvironmentEntryAtIndex(i) == "MY_ENV_VAR=YES":
+found_env_var = True
+break
+self.assertTrue(found_env_var,
+"MY_ENV_VAR was not set in LunchInfo object")
+
 self.runCmd("process launch --working-dir 
'{0}'".format(self.get_process_working_directory()),
 RUN_SUCCEEDED)
 
@

[Lldb-commits] [lldb] 7e10581 - [lldb/testsuite] Skip part of TestSettings.py on windows

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T09:15:16-07:00
New Revision: 7e10581e8c15af39e6f0820768c5d43587f9088d

URL: 
https://github.com/llvm/llvm-project/commit/7e10581e8c15af39e6f0820768c5d43587f9088d
DIFF: 
https://github.com/llvm/llvm-project/commit/7e10581e8c15af39e6f0820768c5d43587f9088d.diff

LOG: [lldb/testsuite] Skip part of TestSettings.py on windows

The newly introduced tests for unsetting environment variables
is failing on Windows. Skip the test there to allow investigation.

It seems like setting inherit-env to false was never tested
before. Could it be that the Windows process launcher doesn't
honor this setting?

Added: 


Modified: 
lldb/test/API/commands/settings/TestSettings.py

Removed: 




diff  --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 29360856a735..c0cdc085f129 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -286,6 +286,7 @@ def do_test_run_args_and_env_vars(self, use_launchsimple):
 "Environment variable 'MY_ENV_VAR' successfully passed."])
 
 @skipIfRemote  # it doesn't make sense to send host env to remote target
+@skipIf(oslist=["windows"])
 def test_pass_host_env_vars(self):
 """Test that the host env vars are passed to the launched process."""
 self.build()



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


[Lldb-commits] [lldb] b6ae893 - [lldb/PlatformDarwin] Always delete destination file first in PutFile

2020-03-23 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-03-23T14:34:17-07:00
New Revision: b6ae8937e031cde2e70e6a83d46c21e940fdf4ac

URL: 
https://github.com/llvm/llvm-project/commit/b6ae8937e031cde2e70e6a83d46c21e940fdf4ac
DIFF: 
https://github.com/llvm/llvm-project/commit/b6ae8937e031cde2e70e6a83d46c21e940fdf4ac.diff

LOG: [lldb/PlatformDarwin] Always delete destination file first in PutFile

Summary:
The default behavior of Platform::PutFile is to open the file and
truncate it if it already exists. This works fine and is a sensible
default, but it interacts badly with code-signing on iOS, as doing so
invalidates the signature of the file (even if the new content has a
valid code signature).

We have a couple tests which on purpose reload a different binary with
the same name. Those tests are currently broken because of the above
interaction.

This patch simply makes the Darwin platform unconditionally delete the
destination file before sending the new one to work around this issue.

Reviewers: jasonmolenda

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 46dd3774e5a9..350043f8d4e9 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -58,6 +58,17 @@ PlatformDarwin::PlatformDarwin(bool is_host)
 /// inherited from by the plug-in instance.
 PlatformDarwin::~PlatformDarwin() {}
 
+lldb_private::Status
+PlatformDarwin::PutFile(const lldb_private::FileSpec &source,
+const lldb_private::FileSpec &destination, uint32_t 
uid,
+uint32_t gid) {
+  // Unconditionally unlink the destination. If it is an executable,
+  // simply opening it and truncating its contents would invalidate
+  // its cached code signature.
+  Unlink(destination);
+  return PlatformPOSIX::PutFile(source, destination, uid, gid);
+}
+
 FileSpecList PlatformDarwin::LocateExecutableScriptingResources(
 Target *target, Module &module, Stream *feedback_stream) {
   FileSpecList file_list;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
index 6d51edbc9294..f6729c508f00 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
@@ -25,6 +25,11 @@ class PlatformDarwin : public PlatformPOSIX {
 
   ~PlatformDarwin() override;
 
+  lldb_private::Status PutFile(const lldb_private::FileSpec &source,
+   const lldb_private::FileSpec &destination,
+   uint32_t uid = UINT32_MAX,
+   uint32_t gid = UINT32_MAX) override;
+
   // lldb_private::Platform functions
   lldb_private::Status
   ResolveSymbolFile(lldb_private::Target &target,



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


[Lldb-commits] [lldb] 06ea05a - [lldb/test] Fix TestDSYMSourcePathRemapping in the presence of symlnks

2020-04-06 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-04-06T19:50:34-07:00
New Revision: 06ea05a3fbc6e70cd4c492cced363a8630d65c6a

URL: 
https://github.com/llvm/llvm-project/commit/06ea05a3fbc6e70cd4c492cced363a8630d65c6a
DIFF: 
https://github.com/llvm/llvm-project/commit/06ea05a3fbc6e70cd4c492cced363a8630d65c6a.diff

LOG: [lldb/test] Fix TestDSYMSourcePathRemapping in the presence of symlnks

My main work directory is on a separate partition, but I usually access
it through a symlink in my home directory. When running the tests,
either Clang or make resolves the symlink, and the real path of the
test directory ends up in the debug information.

This confuses this test as LLDB is trying to remap the real path, but
the remapping description uses the path with the symlink in
it. Calling realpath on the source path when constructing the
remapping description fixes it.

Added: 


Modified: 
lldb/test/API/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py

Removed: 




diff  --git 
a/lldb/test/API/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py 
b/lldb/test/API/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py
index 0f5daf51e975..5075868e9c1a 100644
--- a/lldb/test/API/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py
+++ b/lldb/test/API/macosx/DBGSourcePathRemapping/TestDSYMSourcePathRemapping.py
@@ -42,7 +42,7 @@ def build(self):
 f.write('\n')
 f.write('  DBGSourcePathRemapping\n')
 f.write('  \n')
-f.write('' + botdir + '\n')
+f.write('' + os.path.realpath(botdir) + '\n')
 f.write('' + userdir + '\n')
 f.write('  \n')
 f.write('\n')



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


[Lldb-commits] [lldb] 91e90cf - lldb/Instrumentation: NFC-ish use GetFrameCodeAddressForSymbolication()

2021-04-22 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2021-04-22T13:32:43-07:00
New Revision: 91e90cf622074633009788a220a354043a609dee

URL: 
https://github.com/llvm/llvm-project/commit/91e90cf622074633009788a220a354043a609dee
DIFF: 
https://github.com/llvm/llvm-project/commit/91e90cf622074633009788a220a354043a609dee.diff

LOG: lldb/Instrumentation: NFC-ish use GetFrameCodeAddressForSymbolication()

A couple of our Instrumentation runtimes were gathering backtraces,
storing it in a StructuredData array and later creating a HistoryThread
using this data. By deafult HistoryThread will consider the history PCs
as return addresses and thus will substract 1 from them to go to the
call address.

This is usually correct, but it's also wasteful as when we gather the
backtraces ourselves, we have much better information to decide how
to backtrace and symbolicate. This patch uses the new
GetFrameCodeAddressForSymbolication() to gather the PCs that should
be used for symbolication and configures the HistoryThread to just
use those PCs as-is.

(The MTC plugin was actaully applying a -1 itself and then the
HistoryThread would do it again, so this actaully fixes a bug there.)

rdar://77027680

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

Added: 


Modified: 

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
index 99784bd3dbd19..9a88b343878cc 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
@@ -127,7 +127,7 @@ InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
   StackFrameSP responsible_frame;
   for (unsigned I = 0; I < thread_sp->GetStackFrameCount(); ++I) {
 StackFrameSP frame = thread_sp->GetStackFrameAtIndex(I);
-Address addr = frame->GetFrameCodeAddress();
+Address addr = frame->GetFrameCodeAddressForSymbolication();
 if (addr.GetModule() == runtime_module_sp) // Skip PCs from the runtime.
   continue;
 
@@ -135,11 +135,6 @@ 
InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
 if (!responsible_frame)
   responsible_frame = frame;
 
-// First frame in stacktrace should point to a real PC, not return address.
-if (I != 0 && trace->GetSize() == 0) {
-  addr.Slide(-1);
-}
-
 lldb::addr_t PC = addr.GetLoadAddress(&target);
 trace->AddItem(StructuredData::ObjectSP(new StructuredData::Integer(PC)));
   }
@@ -271,8 +266,11 @@ 
InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
   info->GetObjectForDotSeparatedPath("tid");
   tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
 
-  HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
-  ThreadSP new_thread_sp(history_thread);
+  // We gather symbolication addresses above, so no need for HistoryThread to
+  // try to infer the call addresses.
+  bool pcs_are_call_addresses = true;
+  ThreadSP new_thread_sp = std::make_shared(
+  *process_sp, tid, PCs, pcs_are_call_addresses);
 
   // Save this in the Process' ExtendedThreadList so a strong pointer retains
   // the object

diff  --git 
a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
 
b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
index b60eb53f3d4a7..5f27da609f84b 100644
--- 
a/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
+++ 
b/lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
@@ -150,8 +150,8 @@ StructuredData::ObjectSP 
InstrumentationRuntimeUBSan::RetrieveReportData(
   StructuredData::Array *trace = new StructuredData::Array();
   auto trace_sp = StructuredData::ObjectSP(trace);
   for (unsigned I = 0; I < thread_sp->GetStackFrameCount(); ++I) {
-const Address FCA =
-thread_sp->GetStackFrameAtIndex(I)->GetFrameCodeAddress();
+const Address FCA = thread_sp->GetStackFrameAtIndex(I)
+->GetFrameCodeAddressForSymbolication();
 if (FCA.GetModule() == runtime_module_sp) // Skip PCs from the runtime.
   continue;
 
@@ -324,8 +324,11 @@ 
InstrumentationRuntimeUBSan::GetBacktracesFromExtendedStopInfo(
   info->GetObjectForDotSeparatedPath("tid");
   tid_t tid = thread_id_obj ? thread_id_obj->GetIntegerValue() : 0;
 
-  HistoryThread *history_thread = new HistoryThread(*process_sp, tid, PCs);
-  ThreadSP new_thread_sp(history_thread);
+  // We gather symbolication addres

[Lldb-commits] [lldb] 22c1636 - [lldb/ObjectFileMachO] Correctly account for resolver symbols

2020-07-24 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-24T09:19:17-07:00
New Revision: 22c16360dd00230987fee5f6f3c57f8071144cc1

URL: 
https://github.com/llvm/llvm-project/commit/22c16360dd00230987fee5f6f3c57f8071144cc1
DIFF: 
https://github.com/llvm/llvm-project/commit/22c16360dd00230987fee5f6f3c57f8071144cc1.diff

LOG: [lldb/ObjectFileMachO] Correctly account for resolver symbols

Summary:
The resolver addresses stored in the dyld trie are relative to the base
of the __TEXT segment. This is usually 0 in a dylib, so this was never
noticed, but it is not 0 for most dylibs integrated in the shared cache.
As we started using the shared cache images recently as symbol source,
this causes LLDB to fail to resolve symbols which go through a runtime
resolver.

Reviewers: jasonmolenda, jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/test/API/macosx/indirect_symbol/Makefile

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ab1a6a8bb5f3..338c798e6cef 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1990,6 +1990,8 @@ static bool ParseTrieEntries(DataExtractor &data, 
lldb::offset_t offset,
   if (e.entry.flags & EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER) {
 e.entry.other = data.GetULEB128(&offset);
 uint64_t resolver_addr = e.entry.other;
+if (text_seg_base_addr != LLDB_INVALID_ADDRESS)
+  resolver_addr += text_seg_base_addr;
 if (is_arm)
   resolver_addr &= THUMB_ADDRESS_BIT_MASK;
 resolver_addresses.insert(resolver_addr);

diff  --git a/lldb/test/API/macosx/indirect_symbol/Makefile 
b/lldb/test/API/macosx/indirect_symbol/Makefile
index 929ed58f7575..9069302b39c4 100644
--- a/lldb/test/API/macosx/indirect_symbol/Makefile
+++ b/lldb/test/API/macosx/indirect_symbol/Makefile
@@ -8,7 +8,8 @@ include Makefile.rules
 
 build-libindirect: indirect.c
$(MAKE) -f $(MAKEFILE_RULES) \
-   DYLIB_C_SOURCES=indirect.c DYLIB_NAME=indirect DYLIB_ONLY=YES
+   DYLIB_C_SOURCES=indirect.c DYLIB_NAME=indirect DYLIB_ONLY=YES \
+   LD_EXTRAS="-Wl,-image_base,0x2"
 
 build-libreepxoprt: reexport.c
$(MAKE) -f $(MAKEFILE_RULES) \



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


[Lldb-commits] [lldb] 4c6eebf - [lldb/AppleSimulator] Always provide a -simulator environment

2020-07-27 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-27T12:50:50-07:00
New Revision: 4c6eebf86a0734779cd20473cfcaa9d7c8899298

URL: 
https://github.com/llvm/llvm-project/commit/4c6eebf86a0734779cd20473cfcaa9d7c8899298
DIFF: 
https://github.com/llvm/llvm-project/commit/4c6eebf86a0734779cd20473cfcaa9d7c8899298.diff

LOG: [lldb/AppleSimulator] Always provide a -simulator environment

Summary:
This commit is somewhat NFC-ish today as the environment of triples
is not considered when comparing s if one of them is
not set (I plan to change that).

We have made simulator triples unambiguous these days, but the
simulator platforms still advertise triples without the
environment. This wasn't an issue when the sims ran only on
a very different architecure than the real device, but this
has changed with Apple Silicon.

This patch simplifies the way GetSupportedArchitectureAtIndex
is implemented for the sim platforms and adds the environment.
It also trivially adds support for Apple Silicon to those
platforms.

Reviewers: aprantl

Subscribers: lldb-commits

Added: 
lldb/unittests/Platform/PlatformAppleSimulatorTest.cpp

Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
lldb/unittests/Platform/CMakeLists.txt

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index bd0a231303bd..0160fb95c58a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -253,3 +253,11 @@ CoreSimulatorSupport::Device 
PlatformAppleSimulator::GetSimulatorDevice() {
 return CoreSimulatorSupport::Device();
 }
 #endif
+
+bool PlatformAppleSimulator::GetSupportedArchitectureAtIndex(uint32_t idx,
+ ArchSpec &arch) {
+  if (idx >= m_supported_triples.size())
+return false;
+  arch = ArchSpec(m_supported_triples[idx]);
+  return true;
+}

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
index 8c0174f2946e..6182acaf229a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
@@ -44,6 +44,9 @@ class PlatformAppleSimulator : public PlatformDarwin {
lldb_private::Target *target,
lldb_private::Status &error) override;
 
+  bool GetSupportedArchitectureAtIndex(uint32_t idx,
+   lldb_private::ArchSpec &arch) override;
+
 protected:
   std::mutex m_core_sim_path_mutex;
   llvm::Optional m_core_simulator_framework_path;
@@ -52,6 +55,9 @@ class PlatformAppleSimulator : public PlatformDarwin {
 
   lldb_private::FileSpec GetCoreSimulatorPath();
 
+  llvm::Triple::OSType m_os_type = llvm::Triple::UnknownOS;
+  llvm::ArrayRef m_supported_triples = {};
+
   void LoadCoreSimulator();
 
 #if defined(__APPLE__)

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
index 461624a2adaa..27f798b00ebf 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp
@@ -77,6 +77,7 @@ PlatformSP PlatformAppleTVSimulator::CreateInstance(bool 
force,
   bool create = force;
   if (!create && arch && arch->IsValid()) {
 switch (arch->GetMachine()) {
+case llvm::Triple::aarch64:
 case llvm::Triple::x86_64: {
   const llvm::Triple &triple = arch->GetTriple();
   switch (triple.getVendor()) {
@@ -144,7 +145,24 @@ const char 
*PlatformAppleTVSimulator::GetDescriptionStatic() {
 /// Default Constructor
 PlatformAppleTVSimulator::PlatformAppleTVSimulator()
 : PlatformAppleSimulator(
-  CoreSimulatorSupport::DeviceType::ProductFamilyID::appleTV) {}
+  CoreSimulatorSupport::DeviceType::ProductFamilyID::appleTV) {
+#ifdef __APPLE__
+#if __arm64__
+  static const llvm::StringRef supported_triples[] = {
+  "arm64e-apple-tvos-simulator",
+  "arm64-apple-tvos-simulator",
+  "x86_64h-apple-tvos-simulator",
+  "x86_64-apple-tvos-simulator",
+  };
+#else
+  static const llvm::StringRef supported_triples[] = {
+  "x86_64h-apple-tvos-simulator",
+  "x86_64-apple-tvos-

[Lldb-commits] [lldb] ef748b5 - [lldb] NFC: Use early exit in ArchSpec::IsEqualTo

2020-07-27 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-27T14:12:02-07:00
New Revision: ef748b58d3b3edfaf0278d454cb30f7816c04aee

URL: 
https://github.com/llvm/llvm-project/commit/ef748b58d3b3edfaf0278d454cb30f7816c04aee
DIFF: 
https://github.com/llvm/llvm-project/commit/ef748b58d3b3edfaf0278d454cb30f7816c04aee.diff

LOG: [lldb] NFC: Use early exit in ArchSpec::IsEqualTo

Added: 


Modified: 
lldb/source/Utility/ArchSpec.cpp

Removed: 




diff  --git a/lldb/source/Utility/ArchSpec.cpp 
b/lldb/source/Utility/ArchSpec.cpp
index a77ae8633070..cd382a322da7 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -1010,77 +1010,70 @@ static bool 
IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs,
 bool ArchSpec::IsEqualTo(const ArchSpec &rhs, bool exact_match) const {
   // explicitly ignoring m_distribution_id in this method.
 
-  if (GetByteOrder() != rhs.GetByteOrder())
+  if (GetByteOrder() != rhs.GetByteOrder() ||
+  !cores_match(GetCore(), rhs.GetCore(), true, exact_match))
 return false;
 
-  const ArchSpec::Core lhs_core = GetCore();
-  const ArchSpec::Core rhs_core = rhs.GetCore();
+  const llvm::Triple &lhs_triple = GetTriple();
+  const llvm::Triple &rhs_triple = rhs.GetTriple();
+
+  const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
+  const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
+  if (lhs_triple_vendor != rhs_triple_vendor) {
+const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
+const bool lhs_vendor_specified = TripleVendorWasSpecified();
+// Both architectures had the vendor specified, so if they aren't equal
+// then we return false
+if (rhs_vendor_specified && lhs_vendor_specified)
+  return false;
 
-  const bool core_match = cores_match(lhs_core, rhs_core, true, exact_match);
-
-  if (core_match) {
-const llvm::Triple &lhs_triple = GetTriple();
-const llvm::Triple &rhs_triple = rhs.GetTriple();
-
-const llvm::Triple::VendorType lhs_triple_vendor = lhs_triple.getVendor();
-const llvm::Triple::VendorType rhs_triple_vendor = rhs_triple.getVendor();
-if (lhs_triple_vendor != rhs_triple_vendor) {
-  const bool rhs_vendor_specified = rhs.TripleVendorWasSpecified();
-  const bool lhs_vendor_specified = TripleVendorWasSpecified();
-  // Both architectures had the vendor specified, so if they aren't equal
-  // then we return false
-  if (rhs_vendor_specified && lhs_vendor_specified)
-return false;
-
-  // Only fail if both vendor types are not unknown
-  if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
-  rhs_triple_vendor != llvm::Triple::UnknownVendor)
-return false;
-}
+// Only fail if both vendor types are not unknown
+if (lhs_triple_vendor != llvm::Triple::UnknownVendor &&
+rhs_triple_vendor != llvm::Triple::UnknownVendor)
+  return false;
+  }
 
-const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
-const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
-const llvm::Triple::EnvironmentType lhs_triple_env =
+  const llvm::Triple::OSType lhs_triple_os = lhs_triple.getOS();
+  const llvm::Triple::OSType rhs_triple_os = rhs_triple.getOS();
+  const llvm::Triple::EnvironmentType lhs_triple_env =
   lhs_triple.getEnvironment();
-const llvm::Triple::EnvironmentType rhs_triple_env =
+  const llvm::Triple::EnvironmentType rhs_triple_env =
   rhs_triple.getEnvironment();
 
-if (!exact_match) {
-  // x86_64-apple-ios-macabi, x86_64-apple-macosx are compatible, no match.
-  if ((lhs_triple_os == llvm::Triple::IOS &&
-   lhs_triple_env == llvm::Triple::MacABI &&
-   rhs_triple_os == llvm::Triple::MacOSX) ||
-  (lhs_triple_os == llvm::Triple::MacOSX &&
-   rhs_triple_os == llvm::Triple::IOS &&
-   rhs_triple_env == llvm::Triple::MacABI))
-return true;
-}
-
-if (lhs_triple_os != rhs_triple_os) {
-  const bool rhs_os_specified = rhs.TripleOSWasSpecified();
-  const bool lhs_os_specified = TripleOSWasSpecified();
-  // Both architectures had the OS specified, so if they aren't equal then
-  // we return false
-  if (rhs_os_specified && lhs_os_specified)
-return false;
-
-  // Only fail if both os types are not unknown
-  if (lhs_triple_os != llvm::Triple::UnknownOS &&
-  rhs_triple_os != llvm::Triple::UnknownOS)
-return false;
-}
+  if (!exact_match) {
+// x86_64-apple-ios-macabi, x86_64-apple-macosx are compatible, no match.
+if ((lhs_triple_os == llvm::Triple::IOS &&
+ lhs_triple_env == llvm::Triple::MacABI &&
+ rhs_triple_os == llvm::Triple::MacOSX) ||
+(lhs_triple_os == llvm::Triple::MacOSX &&
+ rhs_triple_os == llvm::Triple::IOS &&
+ rhs_triple_env == llvm::Triple::MacABI))
+  return 

[Lldb-commits] [lldb] 8120eba - [lldb/ArchSpec] Always match simulator environment in IsEqualTo

2020-07-27 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-27T17:33:37-07:00
New Revision: 8120eba5fce378083ef22651f2b7b6dcaa54a098

URL: 
https://github.com/llvm/llvm-project/commit/8120eba5fce378083ef22651f2b7b6dcaa54a098
DIFF: 
https://github.com/llvm/llvm-project/commit/8120eba5fce378083ef22651f2b7b6dcaa54a098.diff

LOG: [lldb/ArchSpec] Always match simulator environment in IsEqualTo

Summary:
Initially, Apple simulator binarie triples didn't use a `-simulator`
environment and were just differentiated based on the architecture.
For example, `x86_64-apple-ios` would obviously be a simualtor as iOS
doesn't run on x86_64. With Catalyst, we made the disctinction
explicit and today, all simulator triples (even the legacy ones) are
constructed with an environment. This is especially important on Apple
Silicon were the architecture is not different from the one of the
simulated device.

This change makes the simulator part of the environment always part of
the criteria to detect whether 2 `ArchSpec`s are equal or compatible.

Reviewers: aprantl

Subscribers: inglorion, dexonsmith, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Utility/ArchSpec.cpp
lldb/unittests/Utility/ArchSpecTest.cpp

Removed: 




diff  --git a/lldb/source/Utility/ArchSpec.cpp 
b/lldb/source/Utility/ArchSpec.cpp
index cd382a322da7..6e4f1b5326dd 100644
--- a/lldb/source/Utility/ArchSpec.cpp
+++ b/lldb/source/Utility/ArchSpec.cpp
@@ -987,6 +987,12 @@ static bool 
IsCompatibleEnvironment(llvm::Triple::EnvironmentType lhs,
   if (lhs == rhs)
 return true;
 
+  // Apple simulators are a 
diff erent platform than what they simulate.
+  // As the environments are 
diff erent at this point, if one of them is a
+  // simulator, then they are 
diff erent.
+  if (lhs == llvm::Triple::Simulator || rhs == llvm::Triple::Simulator)
+return false;
+
   // If any of the environment is unknown then they are compatible
   if (lhs == llvm::Triple::UnknownEnvironment ||
   rhs == llvm::Triple::UnknownEnvironment)

diff  --git a/lldb/unittests/Utility/ArchSpecTest.cpp 
b/lldb/unittests/Utility/ArchSpecTest.cpp
index a8f43ed7dc7c..ad0a8ac18cd1 100644
--- a/lldb/unittests/Utility/ArchSpecTest.cpp
+++ b/lldb/unittests/Utility/ArchSpecTest.cpp
@@ -306,6 +306,14 @@ TEST(ArchSpecTest, Compatibility) {
 ASSERT_FALSE(A.IsExactMatch(B));
 ASSERT_FALSE(A.IsCompatibleMatch(B));
   }
+  {
+ArchSpec A("arm64-apple-ios");
+ArchSpec B("arm64-apple-ios-simulator");
+ASSERT_FALSE(A.IsExactMatch(B));
+ASSERT_FALSE(A.IsCompatibleMatch(B));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+ASSERT_FALSE(B.IsCompatibleMatch(A));
+  }
   {
 ArchSpec A("arm64-*-*");
 ArchSpec B("arm64-apple-ios");



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


[Lldb-commits] [lldb] 4c9ed3e - [lldb/testsuite] Skip 'frame diagnose' tests based on architecture

2020-08-04 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-08-04T17:45:55-07:00
New Revision: 4c9ed3ed3d2fc7622acf5fc0d80ad20b44cf376a

URL: 
https://github.com/llvm/llvm-project/commit/4c9ed3ed3d2fc7622acf5fc0d80ad20b44cf376a
DIFF: 
https://github.com/llvm/llvm-project/commit/4c9ed3ed3d2fc7622acf5fc0d80ad20b44cf376a.diff

LOG: [lldb/testsuite] Skip 'frame diagnose' tests based on architecture

AFAICS, the feature only works on x86, skipping the tests has nothing to
do with the target being iOS or remote.

Added: 


Modified: 
lldb/test/API/commands/frame/diagnose/array/TestArray.py
lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py

lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py

lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py

lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py

lldb/test/API/commands/frame/diagnose/dereference-this/TestDiagnoseDereferenceThis.py
lldb/test/API/commands/frame/diagnose/inheritance/TestDiagnoseInheritance.py
lldb/test/API/commands/frame/diagnose/local-variable/TestLocalVariable.py

lldb/test/API/commands/frame/diagnose/virtual-method-call/TestDiagnoseDereferenceVirtualMethodCall.py

Removed: 




diff  --git a/lldb/test/API/commands/frame/diagnose/array/TestArray.py 
b/lldb/test/API/commands/frame/diagnose/array/TestArray.py
index 9b049a2bf2a4..5788cacb9a2e 100644
--- a/lldb/test/API/commands/frame/diagnose/array/TestArray.py
+++ b/lldb/test/API/commands/frame/diagnose/array/TestArray.py
@@ -13,7 +13,7 @@ class TestArray(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_array(self):
 self.build()
 exe = self.getBuildArtifact("a.out")

diff  --git 
a/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py 
b/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
index 8650484f12a6..737b297ed76b 100644
--- a/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
+++ b/lldb/test/API/commands/frame/diagnose/bad-reference/TestBadReference.py
@@ -13,7 +13,7 @@ class TestBadReference(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_bad_reference(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
 
b/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
index ccc0f88efe06..277fafd14b57 100644
--- 
a/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
+++ 
b/lldb/test/API/commands/frame/diagnose/complicated-expression/TestComplicatedExpression.py
@@ -13,7 +13,7 @@ class TestDiagnoseDereferenceArgument(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_diagnose_dereference_argument(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
 
b/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
index bdc89a6ed83d..5d5b3a0cf17f 100644
--- 
a/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
+++ 
b/lldb/test/API/commands/frame/diagnose/dereference-argument/TestDiagnoseDereferenceArgument.py
@@ -13,7 +13,7 @@ class TestDiagnoseDereferenceArgument(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipUnlessDarwin
-@skipIfDarwinEmbedded  #  frame diagnose doesn't 
work for armv7 or arm64
+@skipIf(archs=no_match(['x86_64'])) #  frame 
diagnose doesn't work for armv7 or arm64
 def test_diagnose_dereference_argument(self):
 TestBase.setUp(self)
 self.build()

diff  --git 
a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
 
b/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
index c49c80791af8..25d7519e5330 100644
--- 
a/lldb/test/API/commands/frame/diagnose/dereference-function-return/TestDiagnoseDereferenceFunctionReturn.py
+++ 
b/lldb/test/API/commands/frame/diagnose/dereference-function-return/Test

[Lldb-commits] [lldb] 99298c7 - [lldb/testsuite] Change get_debugserver_exe to support Rosetta

2020-08-06 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-08-06T10:38:30-07:00
New Revision: 99298c7fc540c74c89c92f0e5d617e00cb87cf19

URL: 
https://github.com/llvm/llvm-project/commit/99298c7fc540c74c89c92f0e5d617e00cb87cf19
DIFF: 
https://github.com/llvm/llvm-project/commit/99298c7fc540c74c89c92f0e5d617e00cb87cf19.diff

LOG: [lldb/testsuite] Change get_debugserver_exe to support Rosetta

In order to be able to run the debugserver tests against the Rosetta
debugserver, detect the Rosetta run configuration and return the
system Rosetta debugserver.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
index 815ba3491c1d..e0ea38c78840 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
@@ -12,6 +12,7 @@
 import socket_packet_pump
 import subprocess
 from lldbsuite.test.lldbtest import *
+from lldbsuite.test import configuration
 
 from six.moves import queue
 
@@ -89,6 +90,10 @@ def get_debugserver_exe():
 if "LLDB_DEBUGSERVER_PATH" in os.environ:
 return os.environ["LLDB_DEBUGSERVER_PATH"]
 
+if configuration.arch and configuration.arch == "x86_64" and \
+   platform.machine().startswith("arm64"):
+return '/Library/Apple/usr/libexec/oah/debugserver'
+
 return _get_debug_monitor_from_lldb(
 lldbtest_config.lldbExec, "debugserver")
 



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


[Lldb-commits] [lldb] 2ff545e - Modernize add-dsym test Makefile

2019-11-05 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-05T12:22:59-08:00
New Revision: 2ff545e76d11bc4fdd7663945d6ac343575530fe

URL: 
https://github.com/llvm/llvm-project/commit/2ff545e76d11bc4fdd7663945d6ac343575530fe
DIFF: 
https://github.com/llvm/llvm-project/commit/2ff545e76d11bc4fdd7663945d6ac343575530fe.diff

LOG: Modernize add-dsym test Makefile

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile 
b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
index 5abcf02738c4..4e1ec2202d0b 100644
--- a/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/macosx/add-dsym/Makefile
@@ -1,24 +1,14 @@
-CC ?= clang
-ifeq "$(ARCH)" ""
-   ARCH = x86_64
-endif
-
-ifeq "$(OS)" ""
-   OS = $(shell uname -s)
-endif
+C_SOURCES = main.c
 
-CFLAGS ?= -g -O0
+include Makefile.rules
 
-ifeq "$(OS)" "Darwin"
-   CFLAGS += -arch $(ARCH)
-endif
+all: a.out.dSYM hide.app/Contents/a.out.dSYM
 
-all: main.c clean
+hide.app/Contents/a.out.dSYM:
mkdir hide.app
mkdir hide.app/Contents
-   $(CC) $(CFLAGS) -g $<
mv a.out.dSYM hide.app/Contents
strip -x a.out
-
-clean:
-   rm -rf a.out a.out.dSYM hide.app
+ifneq "$(CODESIGN)" ""
+   $(CODESIGN) -fs - a.out
+endif



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


[Lldb-commits] [lldb] 270fe47 - testsuite: skipIfNoSBHeaders should skip when running remotely

2019-11-05 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-05T12:22:59-08:00
New Revision: 270fe47aae4ac0bf72251161ad3320de56055c3a

URL: 
https://github.com/llvm/llvm-project/commit/270fe47aae4ac0bf72251161ad3320de56055c3a
DIFF: 
https://github.com/llvm/llvm-project/commit/270fe47aae4ac0bf72251161ad3320de56055c3a.diff

LOG: testsuite: skipIfNoSBHeaders should skip when running remotely

The LLDB dylib/framework will not be available on the remote host, it makes
no sense to try to run those tests in a remote scenario.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 5d9838f2f58a..2816cb7e39a5 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -517,6 +517,9 @@ def is_remote():
 def skipIfNoSBHeaders(func):
 """Decorate the item to mark tests that should be skipped when LLDB is 
built with no SB API headers."""
 def are_sb_headers_missing():
+if lldb.remote_platform:
+return "skip because SBHeaders tests make no sense remotely"
+
 if lldbplatformutil.getHostPlatform() == 'darwin':
 header = os.path.join(
 os.environ["LLDB_LIB_DIR"],



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


[Lldb-commits] [lldb] 8243918 - Testuite: Support Asan test with remote testing

2019-11-06 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-06T14:28:48-08:00
New Revision: 8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e

URL: 
https://github.com/llvm/llvm-project/commit/8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e
DIFF: 
https://github.com/llvm/llvm-project/commit/8243918f43c6eedc2b018c1edc9c6b72fe9b3c1e.diff

LOG: Testuite: Support Asan test with remote testing

To do so, we need to register the sanitizer libraries with the target
so that they get uploaded before running. This patch adds a helper to
the test class to this effect.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
index 6b299e6c3b8c..6b192b3fc304 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestMemoryHistory.py
@@ -17,7 +17,6 @@ class AsanTestCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
-@skipIfRemote
 @skipUnlessAddressSanitizer
 def test(self):
 self.build()
@@ -33,9 +32,10 @@ def setUp(self):
 
 def asan_tests(self):
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+self.registerSanitizerLibrariesWithTarget(target)
 
 self.runCmd("breakpoint set -f main.c -l %d" % self.line_breakpoint)
 

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py 
b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
index d523b472b3e7..18d99638925d 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
@@ -17,7 +17,6 @@ class AsanTestReportDataCase(TestBase):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIfFreeBSD  # llvm.org/pr21136 runtimes not yet available by default
-@skipIfRemote
 @skipUnlessAddressSanitizer
 @skipIf(archs=['i386'], bugnumber="llvm.org/PR36710")
 def test(self):
@@ -36,9 +35,11 @@ def setUp(self):
 
 def asan_tests(self):
 exe = self.getBuildArtifact("a.out")
-self.expect(
-"file " + exe,
-patterns=["Current executable set to .*a.out"])
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+self.registerSanitizerLibrariesWithTarget(target)
+
 self.runCmd("run")
 
 stop_reason = 
self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f3165ab32585..0b32fc4ef585 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1922,6 +1922,15 @@ def registerSharedLibrariesWithTarget(self, target, 
shlibs):
 
 return environment
 
+def registerSanitizerLibrariesWithTarget(self, target):
+runtimes = []
+for m in target.module_iter():
+libspec = m.GetFileSpec()
+if "clang_rt" in libspec.GetFilename():
+runtimes.append(os.path.join(libspec.GetDirectory(),
+ libspec.GetFilename()))
+return self.registerSharedLibrariesWithTarget(target, runtimes)
+
 # utility methods that tests can use to access the current objects
 def target(self):
 if not self.dbg:



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


[Lldb-commits] [lldb] cbdd92b - Modernize TestWeakSymbols Makefile

2019-11-07 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-07T14:53:52-08:00
New Revision: cbdd92be8a57e204aeb346c02ec6c4f440499679

URL: 
https://github.com/llvm/llvm-project/commit/cbdd92be8a57e204aeb346c02ec6c4f440499679
DIFF: 
https://github.com/llvm/llvm-project/commit/cbdd92be8a57e204aeb346c02ec6c4f440499679.diff

LOG: Modernize TestWeakSymbols Makefile

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
index c8b38907ac92..6fd8133312ad 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/Makefile
@@ -1,25 +1,20 @@
-CFLAGS_EXTRAS := -std=c99
-LD_FLAGS := -dynamiclib
-include Makefile.rules
-
-all: a.out dylib missing
+C_SOURCES := main.c
+CFLAGS_EXTRAS := -std=c99 -fmodules
+LD_EXTRAS := -ldylib -L.
 
-dylib: dylib.o
-   $(CC)  $(LD_FLAGS) -o libdylib.dylib dylib.o
-
-missing: dylib2.o
-   mkdir hidden
-   $(CC)  $(LD_FLAGS) -o hidden/libdylib.dylib dylib2.o
+all: a.out hidden/libdylib.dylib
 
-a.out: main.o dylib missing
-   $(CC)  $(CFLAGS) -L. -ldylib main.o
+a.out: libdylib.dylib
 
-dylib.o: dylib.h $(SRCDIR)/dylib.c
-   $(CC) -DHAS_THEM  $(CFLAGS) -c $(SRCDIR)/dylib.c
-
-dylib2.o: dylib.h $(SRCDIR)/dylib.c
-   $(CC)  $(CFLAGS) -c $(SRCDIR)/dylib.c -o dylib2.o
+include Makefile.rules
 
-main.o: dylib.h $(SRCDIR)/main.c
-   $(CC)  $(CFLAGS) -c $(SRCDIR)/main.c -fmodules 
-fmodules-cache-path=$(CLANG_MODULE_CACHE_DIR)
+libdylib.dylib: dylib.c
+   $(MAKE) -C $(BUILDDIR) -f $(MAKEFILE_RULES) \
+   C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
+   CFLAGS_EXTRAS=-DHAS_THEM LD_EXTRAS=-dynamiclib
 
+hidden/libdylib.dylib:
+   mkdir hidden
+   $(MAKE) -C $(BUILDDIR)/hidden -f $(MAKEFILE_RULES) \
+   C_SOURCES= DYLIB_C_SOURCES=dylib.c DYLIB_NAME=dylib \
+   LD_EXTRAS=-dynamiclib



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


[Lldb-commits] [lldb] a578adc - dotest: Add a way for the run_to_* helpers to register dylibs

2019-11-16 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2019-11-15T15:17:27-08:00
New Revision: a578adc1bc8e17b147ed5ef4794cd6f3f82b584b

URL: 
https://github.com/llvm/llvm-project/commit/a578adc1bc8e17b147ed5ef4794cd6f3f82b584b
DIFF: 
https://github.com/llvm/llvm-project/commit/a578adc1bc8e17b147ed5ef4794cd6f3f82b584b.diff

LOG: dotest: Add a way for the run_to_* helpers to register dylibs

Summary:
To run the testsuite remotely the executable needs to be uploaded to
the target system. The Target takes care of this by default.

When the test uses additional shared libraries, those won't be handled
by default and need to be registered with the target using
test.registerSharedLibrariesWithTarget(target, dylib).

Calling this API requires a target, so it doesn't mesh well with the
run_to_* helpers that we've been advertising as the right way to write
tests.

This patch adds an extra_images argument to all the helpers and does
the registration automatically when running a remote
testsuite. TestWeakSymbols.py was converted to use this new scheme.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py
lldb/packages/Python/lldbsuite/test/lldbutil.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py
index 2999cba7d99d..2b097e81ddfa 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/weak_symbols/TestWeakSymbols.py
@@ -49,17 +49,20 @@ def run_weak_var_check (self, weak_varname, present):
 
 def do_test(self):
 hidden_dir = os.path.join(self.getBuildDir(), "hidden")
-
+hidden_dylib = os.path.join(hidden_dir, "libdylib.dylib")
+
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetWorkingDirectory(self.getBuildDir())
 # We have to point to the hidden directory to pick up the
 # version of the dylib without the weak symbols:
 env_expr = self.platformContext.shlib_environment_var + "=" + 
hidden_dir
 launch_info.SetEnvironmentEntries([env_expr], True)
-
-(self.target, process, thread, bkpt) = 
lldbutil.run_to_source_breakpoint(self,
-
"Set a breakpoint here", self.main_source_file,
-
launch_info = launch_info)
+
+(self.target, _, thread, _) = lldbutil.run_to_source_breakpoint(
+  self, "Set a breakpoint here",
+  self.main_source_file,
+  launch_info = launch_info,
+  extra_images = [hidden_dylib])
 # First we have to import the Dylib module so we get the type info
 # for the weak symbol.  We need to add the source dir to the module
 # search paths, and then run @import to introduce it into the 
expression

diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 5100dd596d0d..05d0c9f9d3e9 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -760,13 +760,18 @@ def run_to_breakpoint_make_target(test, exe_name = 
"a.out", in_cwd = True):
 test.assertTrue(target, "Target: %s is not valid."%(exe_name))
 return target
 
-def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None, 
only_one_thread = True):
+def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None,
+ only_one_thread = True, extra_images = None):
 
 # Launch the process, and do not stop at the entry point.
 if not launch_info:
 launch_info = lldb.SBLaunchInfo(None)
 launch_info.SetWorkingDirectory(test.get_process_working_directory())
 
+if extra_images and lldb.remote_platform:
+environ = test.registerSharedLibrariesWithTarget(target, extra_images)
+launch_info.SetEnvironmentEntries(environ, True)
+
 error = lldb.SBError()
 process = target.Launch(launch_info, error)
 
@@ -791,7 +796,8 @@ def run_to_name_breakpoint (test, bkpt_name, launch_info = 
None,
 exe_name = "a.out",
 bkpt_module = None,
 in_cwd = True,
-only_one_thread = True):
+only_one_thread = True,
+extra_images = None):
 """Start up a target, 

[Lldb-commits] [lldb] c9537b9 - [lldb/debugserver] Include TargetConditionals.h where needed

2020-05-09 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-05-09T10:12:17-07:00
New Revision: c9537b9cc862b7ec1ba502043e42bc6ebd24dec0

URL: 
https://github.com/llvm/llvm-project/commit/c9537b9cc862b7ec1ba502043e42bc6ebd24dec0
DIFF: 
https://github.com/llvm/llvm-project/commit/c9537b9cc862b7ec1ba502043e42bc6ebd24dec0.diff

LOG: [lldb/debugserver] Include TargetConditionals.h where needed

MachProcess.mm uses a TARGET_OS_ macro without directly including
TargetConditionals.h. This currently works as we get the header
as an indirect dependency, but might not in the future.

I just spent some time investigating an internal regression
caused by a similar issue, so I audited the codebase for such
cases.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 032f2a877903..95060c552f25 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -34,6 +34,7 @@
 #include 
 #include 
 
+#include 
 #import 
 
 #include "DNBDataRef.h"



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


[Lldb-commits] [lldb] d9166ad - [lldb/Driver] Support terminal resizing

2020-05-12 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-05-12T11:55:25-07:00
New Revision: d9166ad272847e246799afbb5e0c71874f83aa12

URL: 
https://github.com/llvm/llvm-project/commit/d9166ad272847e246799afbb5e0c71874f83aa12
DIFF: 
https://github.com/llvm/llvm-project/commit/d9166ad272847e246799afbb5e0c71874f83aa12.diff

LOG: [lldb/Driver] Support terminal resizing

Summary:
The comment in the Editine.h header made it sound like editline was
just unable to handle terminal resizing. We were not ever telling
editline that the terminal had changed size, which might explain why
it wasn't working.

This patch threads a `TerminalSizeChanged()` callback through the
IOHandler and invokes it from the SIGWINCH handler in the driver. Our
`Editline` class already had a `TerminalSizeChanged()` method which
was invoked only when editline was configured.

This patch also changes `Editline` to not apply the changes right away
in `TerminalSizeChanged()`, but instead defer that to the next
character read. During my testing, it happened once that the signal
was received while our `ConnectionFileDescriptor::Read` was allocating
memory. As `el_resize` seems to allocate memory too, this crashed.

Reviewers: labath, teemperor

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
lldb/test/API/iohandler/resize/TestIOHandlerResize.py

Modified: 
lldb/include/lldb/Core/IOHandler.h
lldb/include/lldb/Host/Editline.h
lldb/source/Core/Debugger.cpp
lldb/source/Core/IOHandler.cpp
lldb/source/Host/common/Editline.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/IOHandler.h 
b/lldb/include/lldb/Core/IOHandler.h
index ff75bfb15cfb..539ba04ab84c 100644
--- a/lldb/include/lldb/Core/IOHandler.h
+++ b/lldb/include/lldb/Core/IOHandler.h
@@ -95,6 +95,8 @@ class IOHandler {
 
   virtual void Deactivate() { m_active = false; }
 
+  virtual void TerminalSizeChanged() {}
+
   virtual const char *GetPrompt() {
 // Prompt support isn't mandatory
 return nullptr;
@@ -369,6 +371,8 @@ class IOHandlerEditline : public IOHandler {
 
   void Deactivate() override;
 
+  void TerminalSizeChanged() override;
+
   ConstString GetControlSequence(char ch) override {
 return m_delegate.IOHandlerGetControlSequence(ch);
   }

diff  --git a/lldb/include/lldb/Host/Editline.h 
b/lldb/include/lldb/Host/Editline.h
index 6590a1603bf0..6e9daae42217 100644
--- a/lldb/include/lldb/Host/Editline.h
+++ b/lldb/include/lldb/Host/Editline.h
@@ -19,13 +19,10 @@
 //good amount of the text will
 //disappear.  It's still in the buffer, just invisible.
 // b) The prompt printing logic for dealing with ANSI formatting characters is
-// broken, which is why we're
-//working around it here.
-// c) When resizing the terminal window, if the cursor moves between rows
-// libedit will get confused. d) The incremental search uses escape to cancel
-// input, so it's confused by
+// broken, which is why we're working around it here.
+// c) The incremental search uses escape to cancel input, so it's confused by
 // ANSI sequences starting with escape.
-// e) Emoji support is fairly terrible, presumably it doesn't understand
+// d) Emoji support is fairly terrible, presumably it doesn't understand
 // composed characters?
 
 #ifndef LLDB_HOST_EDITLINE_H
@@ -50,6 +47,7 @@
 #include 
 #endif
 
+#include 
 #include 
 #include 
 #include 
@@ -171,9 +169,7 @@ class Editline {
   /// editing scenarios.
   void SetContinuationPrompt(const char *continuation_prompt);
 
-  /// Required to update the width of the terminal registered for I/O.  It is
-  /// critical that this
-  /// be correct at all times.
+  /// Call when the terminal size changes
   void TerminalSizeChanged();
 
   /// Returns the prompt established by SetPrompt()
@@ -328,6 +324,8 @@ class Editline {
 
   bool CompleteCharacter(char ch, EditLineGetCharType &out);
 
+  void ApplyTerminalSizeChange();
+
 private:
 #if LLDB_EDITLINE_USE_WCHAR
   std::wstring_convert> m_utf8conv;
@@ -350,6 +348,7 @@ class Editline {
   std::string m_set_continuation_prompt;
   std::string m_current_prompt;
   bool m_needs_prompt_repaint = false;
+  volatile std::sig_atomic_t m_terminal_size_has_changed = 0;
   std::string m_editor_name;
   FILE *m_input_file;
   FILE *m_output_file;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 1d4bf0dafb72..546dc9e86e7d 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -315,6 +315,9 @@ uint32_t Debugger::GetTerminalWidth() const {
 }
 
 bool Debugger::SetTerminalWidth(uint32_t term_width) {
+  if (auto handler_sp = m_io_handler_stack.Top())
+handler_sp->TerminalSizeChanged();
+
   const uint32_t idx = ePropertyTerminalWidth;
   return m_collection_sp->SetPropertyAtIndexAsSInt64(nullptr, idx, term_width);
 }

diff  --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 933

[Lldb-commits] [lldb] 977f001 - [lldb/test] Fix TestAppleSimulatorOSType when multiple runtimes are installed

2020-05-29 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-05-29T08:30:04-07:00
New Revision: 977f00123a6d94c634d22356cae1da2a22f0e3df

URL: 
https://github.com/llvm/llvm-project/commit/977f00123a6d94c634d22356cae1da2a22f0e3df
DIFF: 
https://github.com/llvm/llvm-project/commit/977f00123a6d94c634d22356cae1da2a22f0e3df.diff

LOG: [lldb/test] Fix TestAppleSimulatorOSType when multiple runtimes are 
installed

One can have multiple simulator runtimes installed, supporting
various generations of OSs. The logic in TestAppleSimulatorOSType
might select a rnutime older than the one targeted by the current
tools, preventing the executable from running. This commit changes
the test to look for the most recent runtime available instead.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 86b54dd3e8e5..a259ef66832b 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -18,6 +18,7 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 sim_devices = json.loads(sim_devices_str)['devices']
 # Find an available simulator for the requested platform
 deviceUDID = None
+deviceRuntime = None
 for simulator in sim_devices:
 if isinstance(simulator,dict):
 runtime = simulator['name']
@@ -32,9 +33,11 @@ def check_simulator_ostype(self, sdk, platform, 
arch='x86_64'):
 continue
 if 'isAvailable' in device and device['isAvailable'] != True:
 continue
+if deviceRuntime and runtime < deviceRuntime:
+continue
 deviceUDID = device['udid']
-break
-if deviceUDID != None:
+deviceRuntime = runtime
+# Stop searching in this runtime
 break
 
 # Launch the process using simctl



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


[Lldb-commits] [lldb] c9f251a - [lldb/build.py] Always pass an SDK to the compiler on Darwin

2020-07-01 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-01T20:27:38-07:00
New Revision: c9f251aa6f6221a45d926bc12bd25d1833e5d945

URL: 
https://github.com/llvm/llvm-project/commit/c9f251aa6f6221a45d926bc12bd25d1833e5d945
DIFF: 
https://github.com/llvm/llvm-project/commit/c9f251aa6f6221a45d926bc12bd25d1833e5d945.diff

LOG: [lldb/build.py] Always pass an SDK to the compiler on Darwin

On macOS 11, system libraries which are part of the shared cache
are not present on the filesystem anymore. This causes issues
with build.py, because it fails to link binaries with libSystem
or libc++.

The real issue is that build.py was not passing an SDK to the
compiler. The script accepts an argument for the SDK, but it
is currently unused. This patch just threads the SDK through
to the compile and link steps and this fixes a bunch of Shell
test failures on very recent macOS builds.

Added: 


Modified: 
lldb/test/Shell/helper/build.py

Removed: 




diff  --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index d2cb52f00e55..3de2f3350318 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -623,6 +623,9 @@ def output_files(self):
 class GccBuilder(Builder):
 def __init__(self, toolchain_type, args):
 Builder.__init__(self, toolchain_type, args, '.o')
+if sys.platform == 'darwin':
+cmd = ['xcrun', '--sdk', args.apple_sdk, '--show-sdk-path']
+self.apple_sdk = 
subprocess.check_output(cmd).strip().decode('utf-8')
 
 def _get_compilation_command(self, source, obj):
 args = []
@@ -645,6 +648,9 @@ def _get_compilation_command(self, source, obj):
 args.extend(['-o', obj])
 args.append(source)
 
+if sys.platform == 'darwin':
+args.extend(['-isysroot', self.apple_sdk])
+
 return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
@@ -664,6 +670,9 @@ def _get_link_command(self):
 args.extend(['-o', self._exe_file_name()])
 args.extend(self._obj_file_names())
 
+if sys.platform == 'darwin':
+args.extend(['-isysroot', self.apple_sdk])
+
 return ('linking', self._obj_file_names(), self._exe_file_name(), 
None, args)
 
 



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


[Lldb-commits] [lldb] 61d22ef - [lldb/ObjCRuntime] Implement support for small method lists

2020-07-01 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-01T20:27:37-07:00
New Revision: 61d22ef236206f17d7abcdcdf9da3c99074432d5

URL: 
https://github.com/llvm/llvm-project/commit/61d22ef236206f17d7abcdcdf9da3c99074432d5
DIFF: 
https://github.com/llvm/llvm-project/commit/61d22ef236206f17d7abcdcdf9da3c99074432d5.diff

LOG: [lldb/ObjCRuntime] Implement support for small method lists

On macOS 11 (and other aligned Apple OSs), the Objective-C runtime
has a new optimization which saves memory by making the method
lists smaller.
This patch adds support for this new method list encoding (while
also keeping backward compatibility). This is implicitely covered
by some existing Objective-C tests.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index 06aa861d5f69..ff9c86608b8a 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -241,15 +241,19 @@ bool ClassDescriptorV2::method_list_t::Read(Process 
*process,
 
   lldb::offset_t cursor = 0;
 
-  m_entsize = extractor.GetU32_unchecked(&cursor) & ~(uint32_t)3;
+  uint32_t entsize = extractor.GetU32_unchecked(&cursor);
+  m_is_small = (entsize & 0x8000) != 0;
+  m_entsize = entsize & 0xfffc;
   m_count = extractor.GetU32_unchecked(&cursor);
   m_first_ptr = addr + cursor;
 
   return true;
 }
 
-bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr) {
-  size_t size = GetSize(process);
+bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr,
+   bool is_small) {
+  size_t ptr_size = process->GetAddressByteSize();
+  size_t size = GetSize(process, is_small);
 
   DataBufferHeap buffer(size, '\0');
   Status error;
@@ -260,13 +264,27 @@ bool ClassDescriptorV2::method_t::Read(Process *process, 
lldb::addr_t addr) {
   }
 
   DataExtractor extractor(buffer.GetBytes(), size, process->GetByteOrder(),
-  process->GetAddressByteSize());
-
+  ptr_size);
   lldb::offset_t cursor = 0;
 
-  m_name_ptr = extractor.GetAddress_unchecked(&cursor);
-  m_types_ptr = extractor.GetAddress_unchecked(&cursor);
-  m_imp_ptr = extractor.GetAddress_unchecked(&cursor);
+  if (is_small) {
+uint32_t nameref_offset = extractor.GetU32_unchecked(&cursor);
+uint32_t types_offset = extractor.GetU32_unchecked(&cursor);
+uint32_t imp_offset = extractor.GetU32_unchecked(&cursor);
+
+// The SEL offset points to a SELRef. We need to dereference twice.
+lldb::addr_t selref_addr = addr + nameref_offset;
+m_name_ptr =
+process->ReadUnsignedIntegerFromMemory(selref_addr, ptr_size, 0, 
error);
+if (!error.Success())
+  return false;
+m_types_ptr = addr + 4 + types_offset;
+m_imp_ptr = addr + 8 + imp_offset;
+  } else {
+m_name_ptr = extractor.GetAddress_unchecked(&cursor);
+m_types_ptr = extractor.GetAddress_unchecked(&cursor);
+m_imp_ptr = extractor.GetAddress_unchecked(&cursor);
+  }
 
   process->ReadCStringFromMemory(m_name_ptr, m_name, error);
   if (error.Fail()) {
@@ -361,15 +379,18 @@ bool ClassDescriptorV2::Describe(
 if (!base_method_list->Read(process, class_ro->m_baseMethods_ptr))
   return false;
 
-if (base_method_list->m_entsize != method_t::GetSize(process))
+bool is_small = base_method_list->m_is_small;
+if (base_method_list->m_entsize != method_t::GetSize(process, is_small))
   return false;
 
 std::unique_ptr method;
 method = std::make_unique();
 
 for (uint32_t i = 0, e = base_method_list->m_count; i < e; ++i) {
-  method->Read(process, base_method_list->m_first_ptr +
-(i * base_method_list->m_entsize));
+  method->Read(process,
+   base_method_list->m_first_ptr +
+   (i * base_method_list->m_entsize),
+   is_small);
 
   if (instance_method_func(method->m_name.c_str(), 
method->m_types.c_str()))
 break;

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index 56728cff5b3f..a8db060c5b56 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -133,7 +133,8 @@ class ClassDescriptorV2 : public 
ObjCLanguageRuntime::C

[Lldb-commits] [lldb] 4a674b6 - [lldb/ObjC] Add support for direct selector references

2020-07-01 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-01T20:27:37-07:00
New Revision: 4a674b623796dc5c5778fc6998f788044137d61d

URL: 
https://github.com/llvm/llvm-project/commit/4a674b623796dc5c5778fc6998f788044137d61d
DIFF: 
https://github.com/llvm/llvm-project/commit/4a674b623796dc5c5778fc6998f788044137d61d.diff

LOG: [lldb/ObjC] Add support for direct selector references

On macOS 11 (and other aligned OSs), the shared cache method
lists get an additional optimization which removes one level
of indirection to get to the selector.
This patch supports this new optimization. Both codepaths are
covered byt the existing Objective-C tests.

Added: 


Modified: 

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
index ff9c86608b8a..bdd5c29db848 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.cpp
@@ -243,6 +243,7 @@ bool ClassDescriptorV2::method_list_t::Read(Process 
*process,
 
   uint32_t entsize = extractor.GetU32_unchecked(&cursor);
   m_is_small = (entsize & 0x8000) != 0;
+  m_has_direct_selector = (entsize & 0x4000) != 0;
   m_entsize = entsize & 0xfffc;
   m_count = extractor.GetU32_unchecked(&cursor);
   m_first_ptr = addr + cursor;
@@ -251,7 +252,7 @@ bool ClassDescriptorV2::method_list_t::Read(Process 
*process,
 }
 
 bool ClassDescriptorV2::method_t::Read(Process *process, lldb::addr_t addr,
-   bool is_small) {
+   bool is_small, bool has_direct_sel) {
   size_t ptr_size = process->GetAddressByteSize();
   size_t size = GetSize(process, is_small);
 
@@ -272,12 +273,15 @@ bool ClassDescriptorV2::method_t::Read(Process *process, 
lldb::addr_t addr,
 uint32_t types_offset = extractor.GetU32_unchecked(&cursor);
 uint32_t imp_offset = extractor.GetU32_unchecked(&cursor);
 
-// The SEL offset points to a SELRef. We need to dereference twice.
-lldb::addr_t selref_addr = addr + nameref_offset;
-m_name_ptr =
-process->ReadUnsignedIntegerFromMemory(selref_addr, ptr_size, 0, 
error);
-if (!error.Success())
-  return false;
+m_name_ptr = addr + nameref_offset;
+
+if (!has_direct_sel) {
+  // The SEL offset points to a SELRef. We need to dereference twice.
+  m_name_ptr = process->ReadUnsignedIntegerFromMemory(m_name_ptr, ptr_size,
+  0, error);
+  if (!error.Success())
+return false;
+}
 m_types_ptr = addr + 4 + types_offset;
 m_imp_ptr = addr + 8 + imp_offset;
   } else {
@@ -380,6 +384,8 @@ bool ClassDescriptorV2::Describe(
   return false;
 
 bool is_small = base_method_list->m_is_small;
+bool has_direct_selector = base_method_list->m_has_direct_selector;
+
 if (base_method_list->m_entsize != method_t::GetSize(process, is_small))
   return false;
 
@@ -390,7 +396,7 @@ bool ClassDescriptorV2::Describe(
   method->Read(process,
base_method_list->m_first_ptr +
(i * base_method_list->m_entsize),
-   is_small);
+   is_small, has_direct_selector);
 
   if (instance_method_func(method->m_name.c_str(), 
method->m_types.c_str()))
 break;

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
index a8db060c5b56..9ef21c6e7208 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCClassDescriptorV2.h
@@ -135,6 +135,7 @@ class ClassDescriptorV2 : public 
ObjCLanguageRuntime::ClassDescriptor {
   struct method_list_t {
 uint16_t m_entsize;
 bool m_is_small;
+bool m_has_direct_selector;
 uint32_t m_count;
 lldb::addr_t m_first_ptr;
 
@@ -161,7 +162,7 @@ class ClassDescriptorV2 : public 
ObjCLanguageRuntime::ClassDescriptor {
  + field_size; // IMP imp;
 }
 
-bool Read(Process *process, lldb::addr_t addr, bool);
+bool Read(Process *process, lldb::addr_t addr, bool, bool);
   };
 
   struct ivar_list_t {



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


[Lldb-commits] [lldb] e529d77 - [lldb] Use enum constant instead of raw value

2020-07-09 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-09T09:43:50-07:00
New Revision: e529d774c4d5d1eba13dcad5eef2195dd06741c6

URL: 
https://github.com/llvm/llvm-project/commit/e529d774c4d5d1eba13dcad5eef2195dd06741c6
DIFF: 
https://github.com/llvm/llvm-project/commit/e529d774c4d5d1eba13dcad5eef2195dd06741c6.diff

LOG: [lldb] Use enum constant instead of raw value

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
llvm/include/llvm/BinaryFormat/MachO.h

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 6c2f22b837c5..2bb4b21adeae 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2297,7 +2297,7 @@ size_t ObjectFileMachO::ParseSymtab() {
 
 #if defined(__APPLE__) &&  
\
 (defined(__arm__) || defined(__arm64__) || defined(__aarch64__))
-  if (m_header.flags & 0x8000u &&
+  if (m_header.flags & MH_DYLIB_IN_CACHE &&
   process->GetAddressByteSize() == sizeof(void *)) {
 // This mach-o memory file is in the dyld shared cache. If this
 // program is not remote and this is iOS, then this process will
@@ -2379,7 +2379,7 @@ size_t ObjectFileMachO::ParseSymtab() {
 // problem. For binaries outside the shared cache, it's faster to
 // read the entire strtab at once instead of piece-by-piece as we
 // process the nlist records.
-if ((m_header.flags & 0x8000u) == 0) {
+if ((m_header.flags & MH_DYLIB_IN_CACHE) == 0) {
   DataBufferSP strtab_data_sp(
   ReadMemory(process_sp, strtab_addr, strtab_data_byte_size));
   if (strtab_data_sp) {
@@ -2608,7 +2608,7 @@ size_t ObjectFileMachO::ParseSymtab() {
   // to parse any DSC unmapped symbol information. If we find any, we set a
   // flag that tells the normal nlist parser to ignore all LOCAL symbols.
 
-  if (m_header.flags & 0x8000u) {
+  if (m_header.flags & MH_DYLIB_IN_CACHE) {
 // Before we can start mapping the DSC, we need to make certain the
 // target process is actually using the cache we can find.
 

diff  --git a/llvm/include/llvm/BinaryFormat/MachO.h 
b/llvm/include/llvm/BinaryFormat/MachO.h
index 0010f36e8b89..e43fea0a2465 100644
--- a/llvm/include/llvm/BinaryFormat/MachO.h
+++ b/llvm/include/llvm/BinaryFormat/MachO.h
@@ -82,7 +82,8 @@ enum {
   MH_HAS_TLV_DESCRIPTORS = 0x0080u,
   MH_NO_HEAP_EXECUTION = 0x0100u,
   MH_APP_EXTENSION_SAFE = 0x0200u,
-  MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x0400u
+  MH_NLIST_OUTOFSYNC_WITH_DYLDINFO = 0x0400u,
+  MH_DYLIB_IN_CACHE = 0x8000u,
 };
 
 enum : uint32_t {



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


[Lldb-commits] [lldb] a4a00ce - [lldb/Module] Allow for the creation of memory-only modules

2020-07-14 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-14T08:45:44-07:00
New Revision: a4a00ced0cf8cc5663ff0ced801d6139153f3f76

URL: 
https://github.com/llvm/llvm-project/commit/a4a00ced0cf8cc5663ff0ced801d6139153f3f76
DIFF: 
https://github.com/llvm/llvm-project/commit/a4a00ced0cf8cc5663ff0ced801d6139153f3f76.diff

LOG: [lldb/Module] Allow for the creation of memory-only modules

Summary:
This patch extends the ModuleSpec class to include a
DataBufferSP which contains the module data. If this
data is provided, LLDB won't try to hit the filesystem
to create the Module, but use only the data stored in
the ModuleSpec.

Reviewers: labath, espindola

Subscribers: emaste, MaskRay, lldb-commits

Tags: #lldb

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

Added: 
lldb/unittests/Core/ModuleSpecTest.cpp

Modified: 
lldb/include/lldb/Core/Module.h
lldb/include/lldb/Core/ModuleSpec.h
lldb/include/lldb/Symbol/ObjectFile.h
lldb/include/lldb/Utility/DataBuffer.h
lldb/source/Core/Module.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Symbol/ObjectFile.cpp
lldb/unittests/Core/CMakeLists.txt
lldb/unittests/Core/MangledTest.cpp
lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
lldb/unittests/Symbol/TestLineEntry.cpp
lldb/unittests/TestingSupport/TestUtilities.cpp
lldb/unittests/TestingSupport/TestUtilities.h

Removed: 




diff  --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 3fae2d0cd04a..8bd70ab16b5a 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -958,6 +958,12 @@ class Module : public std::enable_shared_from_this,
  ///by \a m_file.
   uint64_t m_object_offset;
   llvm::sys::TimePoint<> m_object_mod_time;
+
+  /// DataBuffer containing the module image, if it was provided at
+  /// construction time. Otherwise the data will be retrieved by mapping
+  /// one of the FileSpec members above.
+  lldb::DataBufferSP m_data_sp;
+
   lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
///parser for this module as it may or may
///not be shared with the SymbolFile

diff  --git a/lldb/include/lldb/Core/ModuleSpec.h 
b/lldb/include/lldb/Core/ModuleSpec.h
index 01398d443edc..9dd398a05291 100644
--- a/lldb/include/lldb/Core/ModuleSpec.h
+++ b/lldb/include/lldb/Core/ModuleSpec.h
@@ -30,11 +30,19 @@ class ModuleSpec {
 m_object_name(), m_object_offset(0), m_object_size(0),
 m_source_mappings() {}
 
-  ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID())
+  /// If the \param data argument is passed, its contents will be used
+  /// as the module contents instead of trying to read them from
+  /// \param file_spec.
+  ModuleSpec(const FileSpec &file_spec, const UUID &uuid = UUID(),
+ lldb::DataBufferSP data = lldb::DataBufferSP())
   : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(),
-m_uuid(uuid), m_object_name(), m_object_offset(0),
-m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
-m_source_mappings() {}
+m_uuid(uuid), m_object_name(), m_object_offset(0), m_source_mappings(),
+m_data(data) {
+if (data)
+  m_object_size = data->GetByteSize();
+else if (m_file)
+  m_object_size = FileSystem::Instance().GetByteSize(file_spec);
+  }
 
   ModuleSpec(const FileSpec &file_spec, const ArchSpec &arch)
   : m_file(file_spec), m_platform_file(), m_symbol_file(), m_arch(arch),
@@ -42,30 +50,6 @@ class ModuleSpec {
 m_object_size(FileSystem::Instance().GetByteSize(file_spec)),
 m_source_mappings() {}
 
-  ModuleSpec(const ModuleSpec &rhs)
-  : m_file(rhs.m_file), m_platform_file(rhs.m_platform_file),
-m_symbol_file(rhs.m_symbol_file), m_arch(rhs.m_arch),
-m_uuid(rhs.m_uuid), m_object_name(rhs.m_object_name),
-m_object_offset(rhs.m_object_offset), m_object_size(rhs.m_object_size),
-m_object_mod_time(rhs.m_object_mod_time),
-m_source_mappings(rhs.m_source_mappings) {}
-
-  ModuleSpec &operator=(const ModuleSpec &rhs) {
-if (this != &rhs) {
-  m_file = rhs.m_file;
-  m_platform_file = rhs.m_platform_file;
-  m_symbol_file = rhs.m_symbol_file;
-  m_arch = rhs.m_arch;
-  m_uuid = rhs.m_uuid;
-  m_object_name = rhs.m_object_name;
-  m_object_offset = rhs.m_object_offset;
-  m_object_size = rhs.m_object_size;
-  m_object_mod_time = rhs.m_object_mod_time;
-  m_source_mappings = rhs.m_source_mappings;
-}
-return *this;
-  }
-
   FileSpec *GetFileSpecPtr() { return (m_file ? &m_file : nullptr); }
 
   const

[Lldb-commits] [lldb] 8113a8b - [lldb/ObjectFileMachO] Fetch shared cache images from our own shared cache

2020-07-16 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-07-16T10:37:37-07:00
New Revision: 8113a8bb793453832301e2684dc2b8cebec331b0

URL: 
https://github.com/llvm/llvm-project/commit/8113a8bb793453832301e2684dc2b8cebec331b0
DIFF: 
https://github.com/llvm/llvm-project/commit/8113a8bb793453832301e2684dc2b8cebec331b0.diff

LOG: [lldb/ObjectFileMachO] Fetch shared cache images from our own shared cache

Summary:
On macOS 11, the libraries that have been integrated in the system
shared cache are not present on the filesystem anymore. LLDB was
using those files to get access to the symbols of those libraries.
LLDB can get the images from the target process memory though.

This has 2 consequences:
 - LLDB cannot load the images before the process starts, reporting
   an error if someone tries to break on a system symbol.
 - Loading the symbols by downloading the data from the inferior
   is super slow. It takes tens of seconds at the start of the
   debug session to populate the Module list.

To fix this, we can use the library images LLDB has in its own
mapping of the shared cache. Shared cache images are somewhat
special as their LINKEDIT segment is moved to the end of the cache
and thus the images are not contiguous in memory. All of this can
hidden in ObjectFileMachO.

This patch fixes a number of test failures on macOS 11 due to the
first problem described above and adds some specific unittesting
for the new SharedCache Host utilities.

Reviewers: jasonmolenda, labath

Subscribers: llvm-commits, lldb-commits

Tags: #lldb, #llvm

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

Added: 
lldb/unittests/ObjectFile/MachO/CMakeLists.txt
lldb/unittests/ObjectFile/MachO/TestObjectFileMachO.cpp

Modified: 
lldb/include/lldb/Host/HostInfoBase.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/unittests/ObjectFile/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/Host/HostInfoBase.h 
b/lldb/include/lldb/Host/HostInfoBase.h
index 70682c9b685e..15bb168aad97 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
 #include "lldb/Utility/UserIDResolver.h"
 #include "lldb/Utility/XcodeSDK.h"
 #include "lldb/lldb-enumerations.h"
@@ -24,6 +25,11 @@ namespace lldb_private {
 
 class FileSpec;
 
+struct SharedCacheImageInfo {
+  UUID uuid;
+  lldb::DataBufferSP data_sp;
+};
+
 class HostInfoBase {
 private:
   // Static class, unconstructable.
@@ -98,6 +104,13 @@ class HostInfoBase {
   /// Return the directory containing a specific Xcode SDK.
   static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk) { return {}; }
 
+  /// Return information about module \p image_name if it is loaded in
+  /// the current process's address space.
+  static SharedCacheImageInfo
+  GetSharedCacheImageInfo(llvm::StringRef image_name) {
+return {};
+  }
+
 protected:
   static bool ComputeSharedLibraryDirectory(FileSpec &file_spec);
   static bool ComputeSupportExeDirectory(FileSpec &file_spec);

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 3941414f8abd..ee9f12a90943 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -37,6 +37,11 @@ class HostInfoMacOSX : public HostInfoPosix {
 
   /// Query xcrun to find an Xcode SDK directory.
   static llvm::StringRef GetXcodeSDKPath(XcodeSDK sdk);
+
+  /// Shared cache utilities
+  static SharedCacheImageInfo
+  GetSharedCacheImageInfo(llvm::StringRef image_name);
+
 protected:
   static bool ComputeSupportExeDirectory(FileSpec &file_spec);
   static void ComputeHostArchitectureSupport(ArchSpec &arch_32,

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 60eacb1e49b2..b325bd2c5b74 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -12,8 +12,10 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/Args.h"
 #include "lldb/Utility/Log.h"
+#include "Utility/UuidCompatibility.h"
 
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
@@ -457,3 +459,64 @@ FileSpec path(
   auto it_new = g_sdk_path.insert({sdk.GetString(), GetXcodeSDK(sdk)});
   return it_new.first->second;
 }
+
+namespace {
+struct dyld_shared_cache_dylib_text_info {
+  uint64_t version; 

[Lldb-commits] [lldb] 509b788 - [lldb/Makefile.rules] Force the default target to be 'all'

2020-01-17 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-01-17T20:34:16-08:00
New Revision: 509b78883d4f8fdb13ccc754bba9782d51b477d8

URL: 
https://github.com/llvm/llvm-project/commit/509b78883d4f8fdb13ccc754bba9782d51b477d8
DIFF: 
https://github.com/llvm/llvm-project/commit/509b78883d4f8fdb13ccc754bba9782d51b477d8.diff

LOG: [lldb/Makefile.rules] Force the default target to be 'all'

The test harness invokes the test Makefiles with an explicit 'all'
target, but it's handy to be able to recursively call Makefile.rules
without speficying a goal.

Some time ago, we rewrote some tests in terms of recursive invocations
of Makefile.rules. It turns out this had an unintended side
effect. While using $(MAKE) for a recursive invocation passes all the
variables set on the command line down, it doesn't pass the make
goals. This means that those recursive invocations would invoke the
default rule. It turns out the default rule of Makefile.rules is not
'all', but $(EXE). This means that ti would work becuase the
executable is always needed, but it also means that the created
binaries would not follow some of the other top-level build
directives, like MAKE_DSYM.

Forcing 'all' to be the default target seems easier than making sure
all the invocations are correct going forward. This patch does this
using the .DEFAULT_GOAL directive rather than hoisting the 'all' rule
to be the first one of the file. It seems like this explicit approach
will be less prone to be broken in the future. Hopefully all the make
implementations we use support it.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index f25d062ca43f..ecb75413a0c0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -41,6 +41,13 @@ MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))
 THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))
 LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 
+# The test harness invokes the test Makefiles with an explicit 'all'
+# target, but its handy to be able to recursively call this Makefile
+# without speficying a goal. You almost certainly want to build 'all',
+# and not only the first target defined in this file (which might vary
+# according to varaible values).
+.DEFAULT_GOAL := all
+
 #--
 # If OS is not defined, use 'uname -s' to determine the OS name.
 #



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


[Lldb-commits] [lldb] 546f8f4 - [lldb/testsuite] Modernize 2 test Makefiles

2020-01-17 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-01-17T20:56:28-08:00
New Revision: 546f8f426463c7c22a3a8731803a501ff044ba20

URL: 
https://github.com/llvm/llvm-project/commit/546f8f426463c7c22a3a8731803a501ff044ba20
DIFF: 
https://github.com/llvm/llvm-project/commit/546f8f426463c7c22a3a8731803a501ff044ba20.diff

LOG: [lldb/testsuite] Modernize 2 test Makefiles

Those old Makefiles used completely ad-hoc rules for building files,
which means they didn't obey the test harness' variants.

They were somewhat tricky to update as they use very peculiar build
flags for some files. For this reason I was careful to compare the
build commands before and after the change, which is how I found the
discrepancy fixed by the previous commit.

While some of the make syntax used here might not be easy to grasp for
newcomers (per-target variable overrides), it seems better than to
have to repliacte the Makefile.rules logic for the test variants and
platform support.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile 
b/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
index 769920c28336..c39743d999da 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile
@@ -1,33 +1,22 @@
-CXX_SOURCES = main.cpp length.cpp a.cpp
-
-CFLAGS_LIMIT = -c $(CXXFLAGS)
-CFLAGS_NO_LIMIT = -c $(CXXFLAGS)
-
-ifneq (,$(findstring clang,$(CC)))
-  CFLAGS_LIMIT += -flimit-debug-info
-  CFLAGS_NO_LIMIT += -fno-limit-debug-info
-endif
+CXX_SOURCES := length.cpp a.o main.o
+EXE := nolimit
 
 all: limit nolimit
 
-limit: main.o length_limit.o a.o
-   $(CXX) main.o length_limit.o a.o -o limit $(LDFLAGS)
-
-nolimit: main.o length_nolimit.o a.o
-   $(CXX) main.o length_nolimit.o a.o -o nolimit $(LDFLAGS)
-
-main.o: main.cpp
-   $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/main.cpp -o main.o
-
-length_limit.o: length.cpp
-   $(CXX) $(CFLAGS_LIMIT) $(SRCDIR)/length.cpp -o length_limit.o
+include Makefile.rules
 
-length_nolimit.o: length.cpp
-   $(CXX) $(CFLAGS_NO_LIMIT) $(SRCDIR)/length.cpp -o length_nolimit.o
+# Force a.cpp to be built with no debug inforamtion
+a.o: CFLAGS = $(CFLAGS_NO_DEBUG)
 
-a.o: a.cpp
-   $(CXX) $(CFLAGS_NO_DEBUG) -c $(SRCDIR)/a.cpp -o a.o
+# The default testsuite setup forces -fno-limit-debug-info. Let's not rely on
+# CFLAGS_EXTRAS being passed after the default arguments. This rule makes
+# sure the variable used by Makefile.rules for this argument is cleared.
+main.o: NO_LIMIT_DEBUG_INFO_FLAGS = ""
+main.o: CFLAGS_EXTRAS = -flimit-debug-info
 
-clean: OBJECTS += limit nolimit length_limit.o length_nolimit.o 
length_limit.dwo length_nolimit.dwo
+limit: a.o main.o
+   mkdir -p build_limit
+   $(MAKE) -C $(BUILDDIR)/build_limit -f $(MAKEFILE_RULES) \
+   EXE=../limit CXX_SOURCES="length.cpp ../a.o ../main.o" \
+   CFLAGS_EXTRAS=-flimit-debug-info NO_LIMIT_DEBUG_INFO_FLAGS=""
 
-include Makefile.rules

diff  --git a/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile 
b/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile
index ba7e23acabab..5d920f442136 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/ivar-IMP/Makefile
@@ -1,13 +1,8 @@
-CFLAGS := -g -O0
-CFLAGS_NO_DEBUG = 
+OBJC_SOURCES := myclass.m repro.m
+LD_EXTRAS := -framework Foundation
 
-all: aout
-
-aout: 
-   $(CC) $(CFLAGS_NO_DEBUG) $(SRCDIR)/myclass.m -c -o myclass.o
-   $(CC) $(CFLAGS) myclass.o $(SRCDIR)/repro.m -framework Foundation
+include Makefile.rules
 
-clean::
-   rm -f myclass.o
+# Force myclass.m to be compiled without debug info
+myclass.o: CFLAGS = $(CFLAGS_NO_DEBUG)
 
-include Makefile.rules



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


[Lldb-commits] [lldb] 0478ead - [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

2020-01-21 Thread Fred Riss via lldb-commits

Author: Fred Riss
Date: 2020-01-21T13:35:55-08:00
New Revision: 0478eadf73c191199cba12c85785cfafb8bfa174

URL: 
https://github.com/llvm/llvm-project/commit/0478eadf73c191199cba12c85785cfafb8bfa174
DIFF: 
https://github.com/llvm/llvm-project/commit/0478eadf73c191199cba12c85785cfafb8bfa174.diff

LOG: [lldb/DataFormatters] Fix the `$$deference$$` synthetic child

Summary:
The ValueObject code checks for a special `$$dereference$$` synthetic
child to allow formatter providers to implement a natural
dereferencing behavior in `frame variable` for objects like smart
pointers.

This support was broken when used directly throught the Python API and
not trhough `frame variable`. The reason is that
SBFrame.FindVariable() will return by default the synthetic variable
if it exists, while `frame variable` will not do this eagerly. The
code in `ValueObject::Dereference()` accounted for the latter but not
for the former. The fix is trivial. The test change includes
additional covergage for the already-working bahevior as it wasn't
covered by the testsuite before.

This commit also adds a short piece of documentatione explaining that
it is possible (even advisable) to provide this synthetic child
outstide of the range of the normal children.

Reviewers: jingham

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/docs/use/variable.rst

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/fooSynthProvider.py

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/main.cpp
lldb/source/Core/ValueObject.cpp

Removed: 




diff  --git a/lldb/docs/use/variable.rst b/lldb/docs/use/variable.rst
index 13a56637ecea..4e3f25eb6a4a 100644
--- a/lldb/docs/use/variable.rst
+++ b/lldb/docs/use/variable.rst
@@ -846,7 +846,7 @@ adheres to a given interface (the word is italicized 
because Python has no
 explicit notion of interface, by that word we mean a given set of methods must
 be implemented by the Python class):
 
-::
+.. code-block:: python
 
class SyntheticChildrenProvider:
   def __init__(self, valobj, internal_dict):
@@ -885,7 +885,28 @@ returning default no-children responses.
 
 If a synthetic child provider supplies a special child named
 ``$$dereference$$`` then it will be used when evaluating ``operator *`` and
-``operator ->`` in the frame variable command and related SB API functions.
+``operator ->`` in the frame variable command and related SB API
+functions. It is possible to declare this synthetic child without
+including it in the range of children displayed by LLDB. For example,
+this subset of a synthetic children provider class would allow the
+synthetic value to be dereferenced without actually showing any
+synthtic children in the UI:
+
+.. code-block:: python
+
+  class SyntheticChildrenProvider:
+  [...]
+  def num_children(self):
+  return 0
+  def get_child_index(self, name):
+  if name == '$$dereference$$':
+  return 0
+  return -1
+  def get_child_at_index(self, index):
+  if index == 0:
+  return 
+  return None
+
 
 For examples of how synthetic children are created, you are encouraged to look
 at examples/synthetic in the LLDB trunk. Please, be aware that the code in

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
index 5f908f76b0ab..9d4759100ce2 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-python-synth/TestDataFormatterPythonSynth.py
@@ -38,19 +38,9 @@ def setUp(self):
 
 def data_formatter_commands(self):
 """Test using Python synthetic children provider."""
-self.runCmd("file " + self.getBuildArtifact("a.out"), 
CURRENT_EXECUTABLE_SET)
-
-lldbutil.run_break_set_by_file_and_line(
-self, "main.cpp", self.line, num_expected_locations=1, 
loc_exact=True)
-
-self.runCmd("run", RUN_SUCCEEDED)
-
-process = self.dbg.GetSelectedTarget().GetProcess()
 
-# The stop reason of the thread should be breakpoint.
-self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-substrs=['stopped',
- 'stop reason = breakpoint'])
+_, process, thread, _ = lldbutil.run_to_line_breakpoint(