[Lldb-commits] [PATCH] D54567: Fix LLDB's lit files

2018-11-14 Thread Zachary Turner via Phabricator via lldb-commits
zturner created this revision.
zturner added reviewers: stella.stamenova, labath, aleksandr.urakov, rnk.
Herald added subscribers: jfb, arphaman, delcypher, JDevlieghere, aheejin, 
aprantl, mgorny.
Herald added a reviewer: alexshap.

Recently I tried to port LLDB's lit configuration files over to use a lot of 
the common lit infrastructure down in LLVM.  This appeared to work on the 
surface, but broke some cases that weren't broken before and also exposed some 
additional problems with the old approach that we were just getting lucky with.

This is a big patch, so I'll try to give a high level overview of the problem 
as best I can to make reviewing easier.

When we set up a lit environment, the goal is to make it as hermetic as 
possible.  We should not be relying on PATH and enabling the use of arbitrary 
shell commands.  Instead, only whitelisted commands should be allowed.  These 
are, generally speaking, the lit builtins such as `echo`, `cd`, etc, as well as 
anything for which substitutions have been explicitly set up for.  These 
substitutions should map to the build output directory, but in some cases it's 
useful to be able to override this (for example to point to an installed tools 
directory).

This is, of course, how it's //supposed// to work.  What was //actually// 
happening is that we were bringing in `PATH` and `LD_LIBRARY_PATH` and then 
just running the given run line as a shell command.  This led to problems such 
as finding the wrong version of `clang-cl` on `PATH` since it wasn't even a 
substitution, and flakiness / non-determinism since the environment the tests 
were running in would change per-machine.  On the other hand, it also made 
other things possible.  For example, we had some tests that were explicitly 
running `cl.exe` and `link.exe` instead of `clang-cl` and `lld-link` and the 
only reason it worked at all is because it was finding them on `PATH`.  
Unfortunately we can't entirely get rid of these tests, because they support a 
few things in debug info that `clang-cl` and `lld-link` don't (notably, the 
`LF_UDT_MOD_SRC_LINE` record which makes some of the tests fail.

This patch attempts to fix all of this.  It's a large patch, but I'll try to 
summarize the changes:

1. **Removal of functionality** - The lit test suite no longer respects 
`LLDB_TEST_C_COMPILER` and `LLDB_TEST_CXX_COMPILER`.  This means there is no 
more support for gcc, but nobody was using this anyway (note: The functionality 
is still there for the dotest suite, just not the lit test suite).  There is no 
longer a single substitution `%cxx` and `%cc` which maps to 
, you now explicitly specify the compiler with a 
substitution like `%clang` or `%clangxx` or `%clang_cl`.  We can revisit this 
in the future when someone needs gcc.

2. Introduction of the `LLDB_LIT_TOOLS_DIR` directory.  This does in spirit 
what `LLDB_TEST_C_COMPILER` and `LLDB_TEST_CXX_COMPILER` used to do, but now 
more friendly.  If this is not specified, all tools are expected to be the 
just-built tools.  If it is specified, the tools which are not themselves being 
tested but are being used to construct and run checks (e.g. `clang`, 
`FileCheck`, `llvm-mc`, etc) will be searched for in this directory first, then 
the build output directory.

3. Changes to core llvm lit files.  The `use_lld()` and `use_clang()` functions 
were introduced long ago in anticipation of using them in lldb, but since they 
were never actually used anywhere but their respective problems, there were 
some issues to be resolved regarding generality and ability to use them outside 
their project.

4. Changes to .test files - These are all just replacing things like `clang-cl` 
with `%clang_cl` and `%cxx` with `%clangxx`, etc.

5. Changes to `lit.cfg.py` - Previously we would load up some system 
environment variables and then add some new things to them.  Then do a bunch of 
work building out our own substitutions.  First, we delete the system 
environment variable code, making the environment hermetic.  Then, we refactor 
the substitution logic into two separate helper functions, one which sets up 
substitutions for the tools we want to test (which must come from the build 
output directory), and another which sets up substitutions for support tools 
(like compilers, etc).

6. New substitutions for MSVC -- Previously we relied on location of MSVC by 
bringing in the entire parent's `PATH` and letting `subprocess.Popen` just run 
the command line.  Now we set up real substitutions that should have the same 
effect.  We use `PATH` to find them, and then look for `INCLUDE` and `LIB` to 
construct a substitution command line with appropriate `/I` and `/LIBPATH:` 
arguments.  The nice thing about this is that it opens the door to having 
separate `%msvc-cl32` and `%msvc-cl64` substitutions, rather than only 
requiring the user to run vcvars first.  Because we can deduce the path to 
32-bit libraries from 64-bit library directories, and vice versa.  Without 

[Lldb-commits] [lldb] r346932 - Fix a use-after-free of the ABI plugin.

2018-11-14 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Wed Nov 14 21:06:59 2018
New Revision: 346932

URL: http://llvm.org/viewvc/llvm-project?rev=346932=rev
Log:
Fix a use-after-free of the ABI plugin.

This was introduced in r346775.  Previously the ABI shared_ptr
was declared as a function local static meaning it would live
forever.  After the change, someone has to create a strong
reference to it or it will go away.  In this code, we were
calling ABI::FindPlugin(...).get(), so it was being immediately
destroyed and we were holding onto a dangling pointer.

Modified:
lldb/trunk/source/Symbol/Variable.cpp

Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=346932=346931=346932=diff
==
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Wed Nov 14 21:06:59 2018
@@ -156,14 +156,14 @@ void Variable::Dump(Stream *s, bool show
 .GetBaseAddress()
 .GetFileAddress();
 }
-ABI *abi = nullptr;
+ABISP abi;
 if (m_owner_scope) {
   ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
   if (module_sp)
-abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture()).get();
+abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
 }
 m_location.GetDescription(s, lldb::eDescriptionLevelBrief,
-  loclist_base_addr, abi);
+  loclist_base_addr, abi.get());
   }
 
   if (m_external)
@@ -458,11 +458,11 @@ bool Variable::DumpLocationForAddress(St
 SymbolContext sc;
 CalculateSymbolContext();
 if (sc.module_sp == address.GetModule()) {
-  ABI *abi = nullptr;
+  ABISP abi;
   if (m_owner_scope) {
 ModuleSP module_sp(m_owner_scope->CalculateSymbolContextModule());
 if (module_sp)
-  abi = ABI::FindPlugin(ProcessSP(), 
module_sp->GetArchitecture()).get();
+  abi = ABI::FindPlugin(ProcessSP(), module_sp->GetArchitecture());
   }
 
   const addr_t file_addr = address.GetFileAddress();
@@ -474,11 +474,12 @@ bool Variable::DumpLocationForAddress(St
 return false;
   return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief,
loclist_base_file_addr,
-   file_addr, abi);
+   file_addr, abi.get());
 }
   }
-  return m_location.DumpLocationForAddress(
-  s, eDescriptionLevelBrief, LLDB_INVALID_ADDRESS, file_addr, abi);
+  return m_location.DumpLocationForAddress(s, eDescriptionLevelBrief,
+   LLDB_INVALID_ADDRESS, file_addr,
+   abi.get());
 }
   }
   return false;


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


[Lldb-commits] [PATCH] D54221: Add setting to require hardware breakpoints.

2018-11-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346920: Add setting to require hardware breakpoints. 
(authored by JDevlieghere, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54221?vs=174091=174136#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54221

Files:
  include/lldb/API/SBBreakpoint.h
  include/lldb/API/SBThreadPlan.h
  include/lldb/Breakpoint/Breakpoint.h
  include/lldb/Target/Target.h
  include/lldb/Target/Thread.h
  include/lldb/Target/ThreadPlan.h
  include/lldb/Target/ThreadPlanPython.h
  include/lldb/Target/ThreadPlanShouldStopHere.h
  include/lldb/Target/ThreadPlanStepInRange.h
  include/lldb/Target/ThreadPlanStepInstruction.h
  include/lldb/Target/ThreadPlanStepOut.h
  include/lldb/Target/ThreadPlanStepThrough.h
  include/lldb/Target/ThreadPlanStepUntil.h
  include/lldb/lldb-private-interfaces.h
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c
  
packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
  scripts/interface/SBBreakpoint.i
  source/API/SBBreakpoint.cpp
  source/API/SBThread.cpp
  source/API/SBThreadPlan.cpp
  source/Breakpoint/Breakpoint.cpp
  source/Commands/CommandObjectThread.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  source/Target/Process.cpp
  source/Target/StopInfo.cpp
  source/Target/Target.cpp
  source/Target/Thread.cpp
  source/Target/ThreadPlan.cpp
  source/Target/ThreadPlanCallOnFunctionExit.cpp
  source/Target/ThreadPlanPython.cpp
  source/Target/ThreadPlanRunToAddress.cpp
  source/Target/ThreadPlanShouldStopHere.cpp
  source/Target/ThreadPlanStepInRange.cpp
  source/Target/ThreadPlanStepInstruction.cpp
  source/Target/ThreadPlanStepOut.cpp
  source/Target/ThreadPlanStepOverRange.cpp
  source/Target/ThreadPlanStepRange.cpp
  source/Target/ThreadPlanStepThrough.cpp
  source/Target/ThreadPlanStepUntil.cpp

Index: include/lldb/lldb-private-interfaces.h
===
--- include/lldb/lldb-private-interfaces.h
+++ include/lldb/lldb-private-interfaces.h
@@ -84,10 +84,10 @@
OptionValue *option_value);
 typedef bool (*ThreadPlanShouldStopHereCallback)(
 ThreadPlan *current_plan, Flags , lldb::FrameComparison operation,
-void *baton);
+Status , void *baton);
 typedef lldb::ThreadPlanSP (*ThreadPlanStepFromHereCallback)(
 ThreadPlan *current_plan, Flags , lldb::FrameComparison operation,
-void *baton);
+Status , void *baton);
 typedef UnwindAssembly *(*UnwindAssemblyCreateInstance)(const ArchSpec );
 typedef lldb::MemoryHistorySP (*MemoryHistoryCreateInstance)(
 const lldb::ProcessSP _sp);
Index: include/lldb/Target/ThreadPlanStepOut.h
===
--- include/lldb/Target/ThreadPlanStepOut.h
+++ include/lldb/Target/ThreadPlanStepOut.h
@@ -77,7 +77,7 @@
   friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut(
   bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
   bool stop_others, Vote stop_vote, Vote run_vote, uint32_t frame_idx,
-  LazyBool step_out_avoids_code_without_debug_info);
+  Status , LazyBool step_out_avoids_code_without_debug_info);
 
   void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
   // Need an appropriate marker for the current stack so we can tell step out
Index: include/lldb/Target/ThreadPlanShouldStopHere.h
===
--- include/lldb/Target/ThreadPlanShouldStopHere.h
+++ include/lldb/Target/ThreadPlanShouldStopHere.h
@@ -97,10 +97,12 @@
 
   void ClearShouldStopHereCallbacks() { m_callbacks.Clear(); }
 
-  bool InvokeShouldStopHereCallback(lldb::FrameComparison operation);
+  bool InvokeShouldStopHereCallback(lldb::FrameComparison operation,
+Status );
 
   lldb::ThreadPlanSP
-  CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation);
+  CheckShouldStopHereAndQueueStepOut(lldb::FrameComparison operation,
+ Status );
 
   lldb_private::Flags () { return m_flags; }
 
@@ -110,14 +112,16 @@
   static bool DefaultShouldStopHereCallback(ThreadPlan *current_plan,
 Flags ,
 lldb::FrameComparison operation,
-void *baton);
+Status , void *baton);
 
   static lldb::ThreadPlanSP
   DefaultStepFromHereCallback(ThreadPlan *current_plan, Flags ,
-  lldb::FrameComparison 

[Lldb-commits] [lldb] r346921 - Fix copy/paste mistake for r346919.

2018-11-14 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 14 17:18:16 2018
New Revision: 346921

URL: http://llvm.org/viewvc/llvm-project?rev=346921=rev
Log:
Fix copy/paste mistake for r346919.

Modified:
lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=346921=346920=346921=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Nov 14 17:18:16 2018
@@ -426,7 +426,7 @@ void Debugger::SetReproducerPath(llvm::S
 
 llvm::Error Debugger::SetReproducerCapture(bool b) {
   auto  = repro::Reproducer::Instance();
-  if (auto e = r.SetGenerateReproducer(false))
+  if (auto e = r.SetGenerateReproducer(b))
 return e;
   return llvm::Error::success();
 }


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


[Lldb-commits] [lldb] r346920 - Add setting to require hardware breakpoints.

2018-11-14 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 14 17:18:15 2018
New Revision: 346920

URL: http://llvm.org/viewvc/llvm-project?rev=346920=rev
Log:
Add setting to require hardware breakpoints.

When debugging read-only memory we cannot use software breakpoint. We
already have support for hardware breakpoints and users can specify them
with `-H`. However, there's no option to force LLDB to use hardware
breakpoints internally, for example while stepping.

This patch adds a setting target.require-hardware-breakpoint that forces
LLDB to always use hardware breakpoints. Because hardware breakpoints
are a limited resource and can fail to resolve, this patch also extends
error handling in thread plans, where breakpoints are used for stepping.

Differential revision: https://reviews.llvm.org/D54221

Added:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c
Modified:
lldb/trunk/include/lldb/API/SBBreakpoint.h
lldb/trunk/include/lldb/API/SBThreadPlan.h
lldb/trunk/include/lldb/Breakpoint/Breakpoint.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/include/lldb/Target/Thread.h
lldb/trunk/include/lldb/Target/ThreadPlan.h
lldb/trunk/include/lldb/Target/ThreadPlanPython.h
lldb/trunk/include/lldb/Target/ThreadPlanShouldStopHere.h
lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h
lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h
lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h
lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h
lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h
lldb/trunk/include/lldb/lldb-private-interfaces.h

lldb/trunk/packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
lldb/trunk/scripts/interface/SBBreakpoint.i
lldb/trunk/source/API/SBBreakpoint.cpp
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/API/SBThreadPlan.cpp
lldb/trunk/source/Breakpoint/Breakpoint.cpp
lldb/trunk/source/Commands/CommandObjectThread.cpp

lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
lldb/trunk/source/Target/Process.cpp
lldb/trunk/source/Target/StopInfo.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/Thread.cpp
lldb/trunk/source/Target/ThreadPlan.cpp
lldb/trunk/source/Target/ThreadPlanCallOnFunctionExit.cpp
lldb/trunk/source/Target/ThreadPlanPython.cpp
lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp
lldb/trunk/source/Target/ThreadPlanShouldStopHere.cpp
lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp
lldb/trunk/source/Target/ThreadPlanStepOut.cpp
lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp
lldb/trunk/source/Target/ThreadPlanStepRange.cpp
lldb/trunk/source/Target/ThreadPlanStepThrough.cpp
lldb/trunk/source/Target/ThreadPlanStepUntil.cpp

Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=346920=346919=346920=diff
==
--- lldb/trunk/include/lldb/API/SBBreakpoint.h (original)
+++ lldb/trunk/include/lldb/API/SBBreakpoint.h Wed Nov 14 17:18:15 2018
@@ -129,6 +129,8 @@ public:
   static uint32_t
   GetNumBreakpointLocationsFromEvent(const lldb::SBEvent _sp);
 
+  bool IsHardware() const;
+
   // Can only be called from a ScriptedBreakpointResolver...
   SBError
   AddLocation(SBAddress );

Modified: lldb/trunk/include/lldb/API/SBThreadPlan.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThreadPlan.h?rev=346920=346919=346920=diff
==
--- lldb/trunk/include/lldb/API/SBThreadPlan.h (original)
+++ lldb/trunk/include/lldb/API/SBThreadPlan.h Wed Nov 14 17:18:15 2018
@@ -79,16 +79,28 @@ public:
   // plans...
   SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress _address,
lldb::addr_t range_size);
+  SBThreadPlan QueueThreadPlanForStepOverRange(SBAddress _address,
+   lldb::addr_t range_size,
+   SBError );
 
   SBThreadPlan QueueThreadPlanForStepInRange(SBAddress _address,
  lldb::addr_t range_size);
+  SBThreadPlan QueueThreadPlanForStepInRange(SBAddress _address,
+ lldb::addr_t range_size,
+ 

[Lldb-commits] [lldb] r346919 - [reproducer] Post-commit cleanup

2018-11-14 Thread Jonas Devlieghere via lldb-commits
Author: jdevlieghere
Date: Wed Nov 14 17:05:40 2018
New Revision: 346919

URL: http://llvm.org/viewvc/llvm-project?rev=346919=rev
Log:
[reproducer] Post-commit cleanup

After committing the initial reproducer feature I noticed a few small
issues which warranted addressing here. It fixes incorrect documentation
in the command object and extract some duplicated code into the debugger
object.

Modified:
lldb/trunk/include/lldb/Core/Debugger.h
lldb/trunk/source/Commands/CommandObjectReproducer.cpp
lldb/trunk/source/Core/Debugger.cpp

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=346919=346918=346919=diff
==
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Wed Nov 14 17:05:40 2018
@@ -266,6 +266,8 @@ public:
   void SetReproducerPath(llvm::StringRef p);
   void SetReproducerPath(const char *) = delete;
 
+  llvm::Error SetReproducerCapture(bool b);
+
   bool GetUseExternalEditor() const;
 
   bool SetUseExternalEditor(bool use_external_editor_p);

Modified: lldb/trunk/source/Commands/CommandObjectReproducer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectReproducer.cpp?rev=346919=346918=346919=diff
==
--- lldb/trunk/source/Commands/CommandObjectReproducer.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectReproducer.cpp Wed Nov 14 17:05:40 
2018
@@ -11,6 +11,7 @@
 
 #include "lldb/Utility/Reproducer.h"
 
+#include "lldb/Interpreter/CommandInterpreter.h"
 #include "lldb/Interpreter/CommandReturnObject.h"
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupBoolean.h"
@@ -40,8 +41,7 @@ protected:
   return false;
 }
 
-auto  = repro::Reproducer::Instance();
-if (auto e = r.SetGenerateReproducer(true)) {
+if (auto e = m_interpreter.GetDebugger().SetReproducerCapture(true)) {
   AppendErrorToResult(std::move(e), result);
   return false;
 }
@@ -68,8 +68,7 @@ protected:
   return false;
 }
 
-auto  = repro::Reproducer::Instance();
-if (auto e = r.SetGenerateReproducer(false)) {
+if (auto e = m_interpreter.GetDebugger().SetReproducerCapture(false)) {
   AppendErrorToResult(std::move(e), result);
   return false;
 }
@@ -114,10 +113,8 @@ protected:
 class CommandObjectReproducerReplay : public CommandObjectParsed {
 public:
   CommandObjectReproducerReplay(CommandInterpreter )
-  : CommandObjectParsed(interpreter, "reproducer capture",
-"Enable or disable gathering of information needed 
"
-"to generate a reproducer.",
-nullptr) {
+  : CommandObjectParsed(interpreter, "reproducer replay",
+"Replay a reproducer.", nullptr) {
 CommandArgumentEntry arg1;
 CommandArgumentData path_arg;
 

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=346919=346918=346919=diff
==
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Nov 14 17:05:40 2018
@@ -424,6 +424,13 @@ void Debugger::SetReproducerPath(llvm::S
 llvm::consumeError(std::move(e));
 }
 
+llvm::Error Debugger::SetReproducerCapture(bool b) {
+  auto  = repro::Reproducer::Instance();
+  if (auto e = r.SetGenerateReproducer(false))
+return e;
+  return llvm::Error::success();
+}
+
 const FormatEntity::Entry *Debugger::GetThreadFormat() const {
   const uint32_t idx = ePropertyThreadFormat;
   return m_collection_sp->GetPropertyAtIndexAsFormatEntity(nullptr, idx);


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


[Lldb-commits] [lldb] r346906 - Remove the expectedFlakeyDsym decorator. It's not useful anymore.

2018-11-14 Thread Adrian Prantl via lldb-commits
Author: adrian
Date: Wed Nov 14 14:54:43 2018
New Revision: 346906

URL: http://llvm.org/viewvc/llvm-project?rev=346906=rev
Log:
Remove the expectedFlakeyDsym decorator. It's not useful anymore.

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

lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=346906=346905=346906=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Wed Nov 14 14:54:43 
2018
@@ -457,12 +457,6 @@ def expectedFlakey(expected_fn, bugnumbe
 return expectedFailure_impl
 
 
-def expectedFlakeyDsym(bugnumber=None):
-def fn(self):
-return self.getDebugInfo() == "dwarf"
-return expectedFlakey(fn, bugnumber)
-
-
 def expectedFlakeyOS(oslist, bugnumber=None, compilers=None):
 def fn(self):
 return (self.getPlatform() in oslist and

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py?rev=346906=346905=346906=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallUserDefinedFunction.py
 Wed Nov 14 14:54:43 2018
@@ -28,7 +28,6 @@ class ExprCommandCallUserDefinedFunction
 'main.cpp',
 '// Please test these expressions while stopped at this line:')
 
-@expectedFlakeyDsym("llvm.org/pr20274")
 @expectedFailureAll(
 oslist=["windows"],
 bugnumber="llvm.org/pr24489: Name lookup not working correctly on 
Windows")


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


[Lldb-commits] [PATCH] D54221: Add setting to require hardware breakpoints.

2018-11-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D54221



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


[Lldb-commits] [lldb] r346900 - update xcode project file for reproducers.

2018-11-14 Thread Jason Molenda via lldb-commits
Author: jmolenda
Date: Wed Nov 14 14:14:07 2018
New Revision: 346900

URL: http://llvm.org/viewvc/llvm-project?rev=346900=rev
Log:
update xcode project file for reproducers.

Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=346900=346899=346900=diff
==
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 14 14:14:07 2018
@@ -194,6 +194,7 @@
2689002113353DDE00698AC0 /* CommandObjectQuit.cpp in Sources */ 
= {isa = PBXBuildFile; fileRef = 26BC7E3910F1B84700F91463 /* 
CommandObjectQuit.cpp */; };
2689008413353E2200698AC0 /* CommandObjectRegexCommand.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 26DFBC59113B48F300DD817F /* 
CommandObjectRegexCommand.cpp */; };
2689002213353DDE00698AC0 /* CommandObjectRegister.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E3B10F1B84700F91463 /* 
CommandObjectRegister.cpp */; };
+   AFCB1D5C219CD5A800730AD5 /* CommandObjectReproducer.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = AFCB1D5A219CD5A700730AD5 /* 
CommandObjectReproducer.cpp */; };
2689002313353DDE00698AC0 /* CommandObjectScript.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 26BC7E3D10F1B84700F91463 /* 
CommandObjectScript.cpp */; };
2689002413353DDE00698AC0 /* CommandObjectSettings.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E4010F1B84700F91463 /* 
CommandObjectSettings.cpp */; };
2689002513353DDE00698AC0 /* CommandObjectSource.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 26BC7E4210F1B84700F91463 /* 
CommandObjectSource.cpp */; };
@@ -321,6 +322,8 @@
2689009D13353E4200698AC0 /* GDBRemoteCommunication.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 2618EE5B1315B29C001D6D71 /* 
GDBRemoteCommunication.cpp */; };
26744EF11338317700EF765A /* GDBRemoteCommunicationClient.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 26744EED1338317700EF765A /* 
GDBRemoteCommunicationClient.cpp */; };
23CB153D1D66DA9300EDDDE1 /* 
GDBRemoteCommunicationClientTest.cpp in Sources */ = {isa = PBXBuildFile; 
fileRef = 2370A37E1D66C587000E7BE6 /* GDBRemoteCommunicationClientTest.cpp */; 
};
+   AF8AD945219CD45800614785 /* GDBRemoteCommunicationHistory.cpp 
in Sources */ = {isa = PBXBuildFile; fileRef = AF8AD943219CD45700614785 /* 
GDBRemoteCommunicationHistory.cpp */; };
+   AFCB1D59219CD4FD00730AD5 /* 
GDBRemoteCommunicationReplayServer.cpp in Sources */ = {isa = PBXBuildFile; 
fileRef = AFCB1D57219CD4FD00730AD5 /* GDBRemoteCommunicationReplayServer.cpp 
*/; };
26744EF31338317700EF765A /* GDBRemoteCommunicationServer.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 26744EEF1338317700EF765A /* 
GDBRemoteCommunicationServer.cpp */; };
6D55B2901A8A806200A70529 /* 
GDBRemoteCommunicationServerCommon.cpp in Sources */ = {isa = PBXBuildFile; 
fileRef = 6D55B28D1A8A806200A70529 /* GDBRemoteCommunicationServerCommon.cpp 
*/; };
6D55B2911A8A806200A70529 /* 
GDBRemoteCommunicationServerLLGS.cpp in Sources */ = {isa = PBXBuildFile; 
fileRef = 6D55B28E1A8A806200A70529 /* GDBRemoteCommunicationServerLLGS.cpp */; 
};
@@ -698,6 +701,7 @@
23D065901D4A7BEE0008EDE6 /* RenderScriptRuntime.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 23D065841D4A7BDA0008EDE6 /* 
RenderScriptRuntime.cpp */; };
9485545A1DCBAE3B00345FF5 /* RenderScriptScriptGroup.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 948554591DCBAE3B00345FF5 /* 
RenderScriptScriptGroup.cpp */; };
23D065911D4A7BEE0008EDE6 /* RenderScriptx86ABIFixups.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 23D065861D4A7BDA0008EDE6 /* 
RenderScriptx86ABIFixups.cpp */; };
+   AFCB1D5F219CD5EA00730AD5 /* Reproducer.cpp in Sources */ = {isa 
= PBXBuildFile; fileRef = AFCB1D5E219CD5EA00730AD5 /* Reproducer.cpp */; };
4FBC04ED211A06200015A814 /* RichManglingContext.cpp in Sources 
*/ = {isa = PBXBuildFile; fileRef = 4FBC04EC211A06200015A814 /* 
RichManglingContext.cpp */; };
4FBC04EF211A06820015A814 /* RichManglingContext.h in Headers */ 
= {isa = PBXBuildFile; fileRef = 4FBC04EE211A06820015A814 /* 
RichManglingContext.h */; };
4FBC04F5211A13770015A814 /* RichManglingContextTest.cpp in 
Sources */ = {isa = PBXBuildFile; fileRef = 4FBC04F3211A0F0F0015A814 /* 
RichManglingContextTest.cpp */; };
@@ -1616,6 +1620,8 @@
26DFBC52113B48D600DD817F /* CommandObjectRegexCommand.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
name = CommandObjectRegexCommand.h; path = 

[Lldb-commits] [PATCH] D54221: Add setting to require hardware breakpoints.

2018-11-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 174091.
JDevlieghere added a comment.

Feedback Jim: move argument to the end of the list.


https://reviews.llvm.org/D54221

Files:
  include/lldb/API/SBBreakpoint.h
  include/lldb/API/SBThreadPlan.h
  include/lldb/Breakpoint/Breakpoint.h
  include/lldb/Target/Target.h
  include/lldb/Target/Thread.h
  include/lldb/Target/ThreadPlan.h
  include/lldb/Target/ThreadPlanPython.h
  include/lldb/Target/ThreadPlanShouldStopHere.h
  include/lldb/Target/ThreadPlanStepInRange.h
  include/lldb/Target/ThreadPlanStepInstruction.h
  include/lldb/Target/ThreadPlanStepOut.h
  include/lldb/Target/ThreadPlanStepThrough.h
  include/lldb/Target/ThreadPlanStepUntil.h
  include/lldb/lldb-private-interfaces.h
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/Makefile
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/TestRequireHWBreakpoints.py
  
packages/Python/lldbsuite/test/functionalities/breakpoint/require_hw_breakpoints/main.c
  
packages/Python/lldbsuite/test/functionalities/step_scripted/TestStepScripted.py
  scripts/interface/SBBreakpoint.i
  source/API/SBBreakpoint.cpp
  source/API/SBThread.cpp
  source/API/SBThreadPlan.cpp
  source/Breakpoint/Breakpoint.cpp
  source/Commands/CommandObjectThread.cpp
  
source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
  source/Target/Process.cpp
  source/Target/StopInfo.cpp
  source/Target/Target.cpp
  source/Target/Thread.cpp
  source/Target/ThreadPlan.cpp
  source/Target/ThreadPlanCallOnFunctionExit.cpp
  source/Target/ThreadPlanPython.cpp
  source/Target/ThreadPlanRunToAddress.cpp
  source/Target/ThreadPlanShouldStopHere.cpp
  source/Target/ThreadPlanStepInRange.cpp
  source/Target/ThreadPlanStepInstruction.cpp
  source/Target/ThreadPlanStepOut.cpp
  source/Target/ThreadPlanStepOverRange.cpp
  source/Target/ThreadPlanStepRange.cpp
  source/Target/ThreadPlanStepThrough.cpp
  source/Target/ThreadPlanStepUntil.cpp

Index: source/Target/ThreadPlanStepUntil.cpp
===
--- source/Target/ThreadPlanStepUntil.cpp
+++ source/Target/ThreadPlanStepUntil.cpp
@@ -53,7 +53,10 @@
   m_return_addr = return_frame_sp->GetStackID().GetPC();
   Breakpoint *return_bp =
   target_sp->CreateBreakpoint(m_return_addr, true, false).get();
+
   if (return_bp != nullptr) {
+if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
+  m_could_not_resolve_hw_bp = true;
 return_bp->SetThreadID(thread_id);
 m_return_bp_id = return_bp->GetID();
 return_bp->SetBreakpointKind("until-return-backstop");
@@ -93,6 +96,7 @@
 }
   }
   m_until_points.clear();
+  m_could_not_resolve_hw_bp = false;
 }
 
 void ThreadPlanStepUntil::GetDescription(Stream *s,
@@ -123,9 +127,16 @@
 }
 
 bool ThreadPlanStepUntil::ValidatePlan(Stream *error) {
-  if (m_return_bp_id == LLDB_INVALID_BREAK_ID)
+  if (m_could_not_resolve_hw_bp) {
+if (error)
+  error->PutCString(
+  "Could not create hardware breakpoint for thread plan.");
+return false;
+  } else if (m_return_bp_id == LLDB_INVALID_BREAK_ID) {
+if (error)
+  error->PutCString("Could not create return breakpoint.");
 return false;
-  else {
+  } else {
 until_collection::iterator pos, end = m_until_points.end();
 for (pos = m_until_points.begin(); pos != end; pos++) {
   if (!LLDB_BREAK_ID_IS_VALID((*pos).second))
Index: source/Target/ThreadPlanStepThrough.cpp
===
--- source/Target/ThreadPlanStepThrough.cpp
+++ source/Target/ThreadPlanStepThrough.cpp
@@ -58,7 +58,10 @@
   ->GetTarget()
   .CreateBreakpoint(m_backstop_addr, true, false)
   .get();
+
   if (return_bp != nullptr) {
+if (return_bp->IsHardware() && !return_bp->HasResolvedLocations())
+  m_could_not_resolve_hw_bp = true;
 return_bp->SetThreadID(m_thread.GetID());
 m_backstop_bkpt_id = return_bp->GetID();
 return_bp->SetBreakpointKind("step-through-backstop");
@@ -135,7 +138,26 @@
 }
 
 bool ThreadPlanStepThrough::ValidatePlan(Stream *error) {
-  return m_sub_plan_sp.get() != nullptr;
+  if (m_could_not_resolve_hw_bp) {
+if (error)
+  error->PutCString(
+  "Could not create hardware breakpoint for thread plan.");
+return false;
+  }
+
+  if (m_backstop_bkpt_id == LLDB_INVALID_BREAK_ID) {
+if (error)
+  error->PutCString("Could not create backstop breakpoint.");
+return false;
+  }
+
+  if (!m_sub_plan_sp.get()) {
+if (error)
+  error->PutCString("Does not have a subplan.");
+return false;
+  }
+
+  return true;
 }
 
 bool ThreadPlanStepThrough::DoPlanExplainsStop(Event *event_ptr) {
@@ -211,6 +233,7 @@
   if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID) {
 

Re: [Lldb-commits] [PATCH] D54009: Refactor LLDB lit configuration files

2018-11-14 Thread Zachary Turner via lldb-commits
I think I have a pretty good handle on what the problems are.  I'm honestly
surprised the lit test suite ever worked, even before my patch that "broke"
it.  We were basically just picking up whatever the system PATH was and
just going with it, so a lot of the substitutions weren't actually
substitutions at all, they were just random executables found on path.
That's totally not how this is supposed to work at all.

The idea is to set up a hermetic environment where we we create
substitutions for everything we care about, those resolve to things in the
build tree (with suitable hooks for overriding the search path where that's
desired), and we actually delete the system path entirely so that it's
impossible to find anything on PATH.

So I'm currently working through getting all this working the way it's
supposed to, hopefully I can have something by tomorrow.

On Wed, Nov 14, 2018 at 9:21 AM Stella Stamenova 
wrote:

> Simplifying (and making things more robust in the process) sounds great to
> me. I think the current iteration of how parameters are passed to the tests
> is quite complicated and unclear, so this will be a step in the right
> direction and if there’s a need for gcc later, we can take the time to
> design the feature properly so that it works across the lit tests and the
> test suite both.
>
>
>
> Thanks,
>
> -Stella
>
>
>
> *From:* Zachary Turner 
> *Sent:* Tuesday, November 13, 2018 4:30 PM
>
>
> *To:* Stella Stamenova 
> *Cc:* reviews+d54009+public+0e164460da8f1...@reviews.llvm.org;
> pa...@labath.sk; chris.biene...@me.com; dccitali...@gmail.com;
> aleksandr.ura...@jetbrains.com; jdevliegh...@apple.com;
> abidh@gmail.com; teempe...@gmail.com; ki.s...@gmail.com;
> mgo...@gentoo.org; d...@su-root.co.uk; jfbast...@apple.com;
> lldb-commits@lists.llvm.org; l...@inglorion.net
> *Subject:* Re: [PATCH] D54009: Refactor LLDB lit configuration files
>
>
>
> use_clang() already will fall back on searching the environment variable
> 'CLANG' to find a path to it.
>
>
>
> self.config.clang = self.use_llvm_tool(
>
> 'clang', search_env='CLANG', required=required)
>
>
>
> But we could make this environment variable a parameter to use_clang() if
> we wanted to.  As long as we can agree that we don't need to worry about
> gcc -- at least for now -- then it should all simplify down quite a bit.
> And AFAICT, there's nobody using gcc with the lit tests right now, so it
> just adds unnecessary complexity.  And if and when we do have people using
> it, there is even more work to be done.
>
>
>
> If someone only wants a clang that isn't the just-built clang (for example
> a release version to make sure the tests run faster), all they need to do
> is set the environment variable 'CLANG' and it should be fine.
>
>
>
> Since the lit suite is still very new and developing, I'm not too
> concerned about regressing a feature (especially one with zero users),
> because the important thing to me is that it's designed right so that the
> feature can grow in organically and not be "forced" in with a subpar
> implementation.
>
>
>
> On Tue, Nov 13, 2018 at 4:23 PM Stella Stamenova 
> wrote:
>
> The plan for the lit tests sounds reasonable to me. I would also remove
> LLDB_TEST_C/CXX_COMPILER entirely so that we can reduce confusion since
> they’re only used for the lit tests, right?
>
>
>
> My only concern is that I’ve been told that there are people who will
> build lldb with a different compiler than the tests – so the properties for
> LLDB_TEST_C/CXX_COMPILER might actually be used especially in cases where
> clang is not built alongside lldb.
>
>
>
> Thanks,
>
> -Stella
>
>
>
> *From:* Zachary Turner 
> *Sent:* Tuesday, November 13, 2018 4:16 PM
>
>
> *To:* Stella Stamenova 
> *Cc:* reviews+d54009+public+0e164460da8f1...@reviews.llvm.org;
> pa...@labath.sk; chris.biene...@me.com; dccitali...@gmail.com;
> aleksandr.ura...@jetbrains.com; jdevliegh...@apple.com;
> abidh@gmail.com; teempe...@gmail.com; ki.s...@gmail.com;
> mgo...@gentoo.org; d...@su-root.co.uk; jfbast...@apple.com;
> lldb-commits@lists.llvm.org; l...@inglorion.net
> *Subject:* Re: [PATCH] D54009: Refactor LLDB lit configuration files
>
>
>
> Ok so for dotest, it seems to be ignoring the config.cc and config.cxx
> entirely.  So we can theoretically do whatever we want with it, or change
> around the directory structure so that it's more like:
>
>
>
> lldb
>
> * lit
>
> * * Dotest
>
> * * Unit
>
> * * Tests
>
>
>
> and put the config.cc / config.cxx logic under Tests.  That's a large
> change though and probably not worth making such a large change right away.
>
>
>
> dotest tests manually construct the command line directly in CMake via
> this `LLDB_DOTEST_ARGS_PROPERTY` global property, and then in
> lldb/lit/Suite/lit.cfg we have this line:
>
>
>
> dotest_cmd = [config.dotest_path, '-q']
>
> dotest_cmd.extend(config.dotest_args_str.split(';'))
>
>
>
>
>
> So pretty much everythign the parent lit file has done is totally
> 

[Lldb-commits] [PATCH] D54221: Add setting to require hardware breakpoints.

2018-11-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham requested changes to this revision.
jingham added a comment.
This revision now requires changes to proceed.

The lldb API's parameters are ordered input first than output.  Pretty much all 
the API's that take a Status as a parameter take it as the last parameter.  So 
it looks weird to have the Status  first in the QueueThreadPlan... API's. 
 This pattern gets annoying when you have default parameters, so it's okay to 
put the out parameters before the default parameters (though default parameters 
are also not so great, so removing them is also okay...)

Other than that this looked fine.


https://reviews.llvm.org/D54221



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


[Lldb-commits] [PATCH] D54444: [CMake] Use extended llvm_codesign to pass entitlements for lldb-server

2018-11-14 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

We do use lldb-server, though only in the platform mode, for remote testsuite 
running.  The gdbserver mode doesn't do anything for a macOS hosted 
lldb-server, so lldb-server should not require any entitlements.  But we do use 
it.


https://reviews.llvm.org/D5



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


[Lldb-commits] [PATCH] D54444: [CMake] Use extended llvm_codesign to pass entitlements for lldb-server

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

+ LLDB.framework has lldb-server as a dependency there. Not sure if it's 
(really) necessary, though.


https://reviews.llvm.org/D5



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


[Lldb-commits] [PATCH] D54444: [CMake] Use extended llvm_codesign to pass entitlements for lldb-server

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

In Xcode we have ad-hoc signing when targeting iOS and signing with 
entitlements in case of macOS for lldb-server.


https://reviews.llvm.org/D5



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


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz added a comment.

Two use-cases for executables:
LLDB lldb-server https://reviews.llvm.org/D5
LLDB debugserver https://reviews.llvm.org/D54476

I have no use-case for shared libraries (yet), so I didn't add ENTITLEMENTS 
there. Is that ok?


Repository:
  rL LLVM

https://reviews.llvm.org/D54443



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


[Lldb-commits] [PATCH] D54444: [CMake] Use extended llvm_codesign to pass entitlements for lldb-server

2018-11-14 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Why does lldb-server need to be signed? I was under the impression that on 
macOS lldb-server is not used? Or are we building it for testing and need sign 
it because of that?


https://reviews.llvm.org/D5



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


[Lldb-commits] [PATCH] D54443: [CMake] Accept ENTITLEMENTS in add_llvm_executable and llvm_codesign

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 174055.
sgraenitz added a comment.

Remove force option


Repository:
  rL LLVM

https://reviews.llvm.org/D54443

Files:
  CMakeLists.txt
  cmake/modules/AddLLVM.cmake


Index: cmake/modules/AddLLVM.cmake
===
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -580,7 +580,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(${name})
+llvm_codesign(TARGET ${name})
   endif()
 endfunction()
 
@@ -708,7 +708,12 @@
 
 
 macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG 
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" 
"DEPENDS" ${ARGN})
+  cmake_parse_arguments(ARG
+
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"ENTITLEMENTS"
+"DEPENDS"
+${ARGN})
+
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
   list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
@@ -787,7 +792,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1626,7 +1631,14 @@
   endif()
 endfunction()
 
-function(llvm_codesign name)
+# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
+#
+# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
+# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
+#
+function(llvm_codesign)
+  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
   endif()
@@ -1642,12 +1654,16 @@
 OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE
   )
 endif()
+if(DEFINED ARG_ENTITLEMENTS)
+  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+endif()
+
 add_custom_command(
-  TARGET ${name} POST_BUILD
+  TARGET ${ARG_TARGET} POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E
   env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
   ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
-  $
+  ${PASS_ENTITLEMENTS} $
 )
   endif()
 endfunction()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -399,8 +399,8 @@
 option(LLVM_EXTERNALIZE_DEBUGINFO
   "Generate dSYM files and strip executables and libraries (Darwin Only)" OFF)
 
-option(LLVM_CODESIGNING_IDENTITY
-  "Sign executables and dylibs with the given identity (Darwin Only)" OFF)
+set(LLVM_CODESIGNING_IDENTITY "" CACHE STRING
+  "Sign executables and dylibs with the given identity or skip if empty 
(Darwin Only)")
 
 # If enabled, verify we are on a platform that supports oprofile.
 if( LLVM_USE_OPROFILE )


Index: cmake/modules/AddLLVM.cmake
===
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -580,7 +580,7 @@
 
   if(ARG_SHARED OR ARG_MODULE)
 llvm_externalize_debuginfo(${name})
-llvm_codesign(${name})
+llvm_codesign(TARGET ${name})
   endif()
 endfunction()
 
@@ -708,7 +708,12 @@
 
 
 macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH" "" "DEPENDS" ${ARGN})
+  cmake_parse_arguments(ARG
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"ENTITLEMENTS"
+"DEPENDS"
+${ARGN})
+
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
   list(APPEND LLVM_COMMON_DEPENDS ${ARG_DEPENDS})
@@ -787,7 +792,7 @@
 target_link_libraries(${name} PRIVATE ${LLVM_PTHREAD_LIB})
   endif()
 
-  llvm_codesign(${name})
+  llvm_codesign(TARGET ${name} ENTITLEMENTS ${ARG_ENTITLEMENTS})
 endmacro(add_llvm_executable name)
 
 function(export_executable_symbols target)
@@ -1626,7 +1631,14 @@
   endif()
 endfunction()
 
-function(llvm_codesign name)
+# Usage: llvm_codesign(TARGET name [ENTITLEMENTS file])
+#
+# Code-sign the given TARGET with the global LLVM_CODESIGNING_IDENTITY or skip
+# if undefined. Customize capabilities by passing a file path to ENTITLEMENTS.
+#
+function(llvm_codesign)
+  cmake_parse_arguments(ARG "" "TARGET;ENTITLEMENTS" "" ${ARGN})
+
   if(NOT LLVM_CODESIGNING_IDENTITY)
 return()
   endif()
@@ -1642,12 +1654,16 @@
 OUTPUT_VARIABLE CMAKE_CODESIGN_ALLOCATE
   )
 endif()
+if(DEFINED ARG_ENTITLEMENTS)
+  set(PASS_ENTITLEMENTS --entitlements ${ARG_ENTITLEMENTS})
+endif()
+
 add_custom_command(
-  TARGET ${name} POST_BUILD
+  TARGET ${ARG_TARGET} POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E
   env CODESIGN_ALLOCATE=${CMAKE_CODESIGN_ALLOCATE}
   ${CMAKE_CODESIGN} -s ${LLVM_CODESIGNING_IDENTITY}
-  $
+  ${PASS_ENTITLEMENTS} $
 

[Lldb-commits] [PATCH] D54528: [lldb] NFC: Remove the extra ';'

2018-11-14 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for fixing this.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54528



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


[Lldb-commits] [lldb] r346873 - Fix some compilation failures introduced in recent patches.

2018-11-14 Thread Zachary Turner via lldb-commits
Author: zturner
Date: Wed Nov 14 09:22:09 2018
New Revision: 346873

URL: http://llvm.org/viewvc/llvm-project?rev=346873=rev
Log:
Fix some compilation failures introduced in recent patches.

This fixes two compilation failures:

  1) Designated initializers are C++20.  We can't use them in LLVM.
  2) thread_result_t is not a pointer type on all platforms, so
 returning nullptr is an error.

Modified:
lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp

Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=346873=346872=346873=diff
==
--- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
+++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Wed Nov 14 09:22:09 2018
@@ -783,7 +783,8 @@ static uint64_t decodeTaggedTimeInterval
   if (encodedTimeInterval == std::numeric_limits::max())
 return (uint64_t)-0.0;
 
-  TaggedDoubleBits encodedBits = { .i = encodedTimeInterval };
+  TaggedDoubleBits encodedBits = {};
+  encodedBits.i = encodedTimeInterval;
   DoubleBits decodedBits;
 
   // Sign and fraction are represented exactly.

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp?rev=346873=346872=346873=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationReplayServer.cpp
 Wed Nov 14 09:22:09 2018
@@ -190,15 +190,15 @@ thread_result_t GDBRemoteCommunicationRe
 case eBroadcastBitAsyncContinue:
   ReceivePacket(*server, done);
   if (done)
-return nullptr;
+return {};
   break;
 case eBroadcastBitAsyncThreadShouldExit:
 default:
-  return nullptr;
+  return {};
 }
   }
 }
   }
 
-  return nullptr;
+  return {};
 }


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


Re: [Lldb-commits] [PATCH] D54009: Refactor LLDB lit configuration files

2018-11-14 Thread Stella Stamenova via lldb-commits
Simplifying (and making things more robust in the process) sounds great to me. 
I think the current iteration of how parameters are passed to the tests is 
quite complicated and unclear, so this will be a step in the right direction 
and if there’s a need for gcc later, we can take the time to design the feature 
properly so that it works across the lit tests and the test suite both.

Thanks,
-Stella

From: Zachary Turner 
Sent: Tuesday, November 13, 2018 4:30 PM
To: Stella Stamenova 
Cc: reviews+d54009+public+0e164460da8f1...@reviews.llvm.org; pa...@labath.sk; 
chris.biene...@me.com; dccitali...@gmail.com; aleksandr.ura...@jetbrains.com; 
jdevliegh...@apple.com; abidh@gmail.com; teempe...@gmail.com; 
ki.s...@gmail.com; mgo...@gentoo.org; d...@su-root.co.uk; jfbast...@apple.com; 
lldb-commits@lists.llvm.org; l...@inglorion.net
Subject: Re: [PATCH] D54009: Refactor LLDB lit configuration files

use_clang() already will fall back on searching the environment variable 
'CLANG' to find a path to it.

self.config.clang = self.use_llvm_tool(
'clang', search_env='CLANG', required=required)

But we could make this environment variable a parameter to use_clang() if we 
wanted to.  As long as we can agree that we don't need to worry about gcc -- at 
least for now -- then it should all simplify down quite a bit.  And AFAICT, 
there's nobody using gcc with the lit tests right now, so it just adds 
unnecessary complexity.  And if and when we do have people using it, there is 
even more work to be done.

If someone only wants a clang that isn't the just-built clang (for example a 
release version to make sure the tests run faster), all they need to do is set 
the environment variable 'CLANG' and it should be fine.

Since the lit suite is still very new and developing, I'm not too concerned 
about regressing a feature (especially one with zero users), because the 
important thing to me is that it's designed right so that the feature can grow 
in organically and not be "forced" in with a subpar implementation.

On Tue, Nov 13, 2018 at 4:23 PM Stella Stamenova 
mailto:sti...@microsoft.com>> wrote:
The plan for the lit tests sounds reasonable to me. I would also remove 
LLDB_TEST_C/CXX_COMPILER entirely so that we can reduce confusion since they’re 
only used for the lit tests, right?

My only concern is that I’ve been told that there are people who will build 
lldb with a different compiler than the tests – so the properties for 
LLDB_TEST_C/CXX_COMPILER might actually be used especially in cases where clang 
is not built alongside lldb.

Thanks,
-Stella

From: Zachary Turner mailto:ztur...@google.com>>
Sent: Tuesday, November 13, 2018 4:16 PM

To: Stella Stamenova mailto:sti...@microsoft.com>>
Cc: 
reviews+d54009+public+0e164460da8f1...@reviews.llvm.org;
 pa...@labath.sk; 
chris.biene...@me.com; 
dccitali...@gmail.com; 
aleksandr.ura...@jetbrains.com; 
jdevliegh...@apple.com; 
abidh@gmail.com; 
teempe...@gmail.com; 
ki.s...@gmail.com; 
mgo...@gentoo.org; 
d...@su-root.co.uk; 
jfbast...@apple.com; 
lldb-commits@lists.llvm.org; 
l...@inglorion.net
Subject: Re: [PATCH] D54009: Refactor LLDB lit configuration files

Ok so for dotest, it seems to be ignoring the config.cc and config.cxx 
entirely.  So we can theoretically do whatever we want with it, or change 
around the directory structure so that it's more like:

lldb
* lit
* * Dotest
* * Unit
* * Tests

and put the config.cc / config.cxx logic under Tests.  That's a large change 
though and probably not worth making such a large change right away.

dotest tests manually construct the command line directly in CMake via this 
`LLDB_DOTEST_ARGS_PROPERTY` global property, and then in lldb/lit/Suite/lit.cfg 
we have this line:

dotest_cmd = [config.dotest_path, '-q']
dotest_cmd.extend(config.dotest_args_str.split(';'))


So pretty much everythign the parent lit file has done is totally ignored.

With that in mind, **for the lit tests only** I propose dropping support for 
non-clang compilers and ignoring LLDB_TEST_C_COMPILER and 
LLDB_TEST_CXX_COMPILER (you can still have a custom path to clang executable 
via an environment variable, which is consistent with how clang's test suite 
works).

Note that when you run ninja check-lldb-lit you will now get messages that tell 
you the exact path to the clang executable, so you can see what the PATH 
resolution is doing.

On Tue, Nov 13, 2018 at 4:02 PM Zachary Turner 
mailto:ztur...@google.com>> wrote:
On Tue, Nov 13, 2018 at 3:47 PM Stella Stamenova 

Re: [Lldb-commits] [lldb] r346783 - [Cocoa] Implement formatter for the new NSDate representation.

2018-11-14 Thread Zachary Turner via lldb-commits
On Tue, Nov 13, 2018 at 11:46 AM Davide Italiano via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: davide
> Date: Tue Nov 13 11:43:43 2018
> New Revision: 346783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346783=rev
> Log:
> [Cocoa] Implement formatter for the new NSDate representation.
>
> 
>
> Modified:
> lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
>
> Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=346783=346782=346783=diff
>
> ==
> --- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Tue Nov 13 11:43:43
> 2018
> @@ -742,6 +742,60 @@ bool lldb_private::formatters::NSURLSumm
>return false;
>  }
>
> +/// Bias value for tagged pointer exponents.
> +/// Recommended values:
> +/// 0x3e3: encodes all dates between distantPast and distantFuture
> +///   except for the range within about 1e-28 second of the reference
> date.
> +/// 0x3ef: encodes all dates for a few million years beyond distantPast
> and
> +///   distantFuture, except within about 1e-25 second of the reference
> date.
> +const int TAGGED_DATE_EXPONENT_BIAS = 0x3ef;
> +
> +typedef union {
> +  struct {
> +uint64_t fraction:52;  // unsigned
> +uint64_t exponent:11;  // signed
> +uint64_t sign:1;
> +  };
> +  uint64_t i;
> +  double d;
> +} DoubleBits;
> +typedef union {
> +  struct {
> +uint64_t fraction:52;  // unsigned
> +uint64_t exponent:7;   // signed
> +uint64_t sign:1;
> +uint64_t unused:4;  // placeholder for pointer tag bits
> +  };
> +  uint64_t i;
> +} TaggedDoubleBits;
> +
> +static uint64_t decodeExponent(uint64_t exp) {
> +  int64_t exp7 = exp;
> +  // Tagged exponent field is 7-bit signed. Sign-extend the value to 64
> bits
> +  // before performing arithmetic.
> +  int64_t exp11 = ((exp7 << 57) >> 57) + TAGGED_DATE_EXPONENT_BIAS;
> +  return exp11;
> +}
> +
> +static uint64_t decodeTaggedTimeInterval(uint64_t encodedTimeInterval) {
> +  if (encodedTimeInterval == 0)
> +return 0.0;
> +  if (encodedTimeInterval == std::numeric_limits::max())
> +return -0.0;
> +
> +  TaggedDoubleBits encodedBits = { .i = encodedTimeInterval };
> +  DoubleBits decodedBits;
> +
> +  // Sign and fraction are represented exactly.
> +  // Exponent is encoded.
> +  assert(encodedBits.unused == 0);
> +  decodedBits.sign = encodedBits.sign;
> +  decodedBits.fraction = encodedBits.fraction;
> +  decodedBits.exponent = decodeExponent(encodedBits.exponent);
> +
> +  return decodedBits.d;
>
This is undefined behavior since it's type punning through a union.
Normally this is harmless and all compilers actually do what you would
expect them to do.  In this case, however, it isn't because bitfield layout
is implementation defined so not every compiler will lay the bitfield out
in the way you expect.  So if you want this to be correct you have to
explicitly construct the bits of the double using bitshifts, going through
a union will fail on some implementations.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [lldb] r346783 - [Cocoa] Implement formatter for the new NSDate representation.

2018-11-14 Thread Zachary Turner via lldb-commits
On Tue, Nov 13, 2018 at 11:46 AM Davide Italiano via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> Author: davide
> Date: Tue Nov 13 11:43:43 2018
> New Revision: 346783
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346783=rev
> Log:
> [Cocoa] Implement formatter for the new NSDate representation.
>
> 
>
> Modified:
> lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
>
> Modified: lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp?rev=346783=346782=346783=diff
>
> ==
> --- lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/ObjC/Cocoa.cpp Tue Nov 13 11:43:43
> 2018
> @@ -742,6 +742,60 @@ bool lldb_private::formatters::NSURLSumm
>return false;
>  }
>
> +/// Bias value for tagged pointer exponents.
> +/// Recommended values:
> +/// 0x3e3: encodes all dates between distantPast and distantFuture
> +///   except for the range within about 1e-28 second of the reference
> date.
> +/// 0x3ef: encodes all dates for a few million years beyond distantPast
> and
> +///   distantFuture, except within about 1e-25 second of the reference
> date.
> +const int TAGGED_DATE_EXPONENT_BIAS = 0x3ef;
> +
> +typedef union {
> +  struct {
> +uint64_t fraction:52;  // unsigned
> +uint64_t exponent:11;  // signed
> +uint64_t sign:1;
> +  };
> +  uint64_t i;
> +  double d;
> +} DoubleBits;
> +typedef union {
> +  struct {
> +uint64_t fraction:52;  // unsigned
> +uint64_t exponent:7;   // signed
> +uint64_t sign:1;
> +uint64_t unused:4;  // placeholder for pointer tag bits
> +  };
>
MSVC gives:

warning C4201: nonstandard extension used: nameless struct/union


> +  uint64_t i;
> +} TaggedDoubleBits;
> +
> +static uint64_t decodeExponent(uint64_t exp) {
> +  int64_t exp7 = exp;
> +  // Tagged exponent field is 7-bit signed. Sign-extend the value to 64
> bits
> +  // before performing arithmetic.
> +  int64_t exp11 = ((exp7 << 57) >> 57) + TAGGED_DATE_EXPONENT_BIAS;
> +  return exp11;
> +}
>
this should probably be:

return llvm::SignExtend64<7>(exp) + TAGGED_DATE_EXPONENT_BIAS;


> +
> +static uint64_t decodeTaggedTimeInterval(uint64_t encodedTimeInterval) {
> +  if (encodedTimeInterval == 0)
> +return 0.0;
> +  if (encodedTimeInterval == std::numeric_limits::max())
> +return -0.0;
> +
> +  TaggedDoubleBits encodedBits = { .i = encodedTimeInterval };
>
Designated initializers are C++20 which are not allowed in LLVM.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D54476: [CMake] Streamline code signing for debugserver

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz marked 2 inline comments as not done.
sgraenitz added inline comments.



Comment at: tools/debugserver/source/CMakeLists.txt:128-133
+# TODO: Following the old behavior, DEBUGSERVER_PATH still points to the
+# original system binary, even if we copy it over. Keep this?
+set(DEBUGSERVER_PATH 
"${lldb_framework_dir}/LLDB.framework/Resources/debugserver" CACHE FILEPATH "" 
FORCE)
+
+# If we haven't built a signed debugserver. If possible, copy the one from
+# the system to make the built debugger functional on Darwin.

sgraenitz wrote:
> xiaobai wrote:
> > I'm pretty sure that if you do not copy debugserver it will still find the 
> > one from your `${lldb_framework_dir}` when you run lldb anyway. Do you know 
> > why we copy it over?
> Yes this is what I mean with "old behaviour" here. `DEBUGSERVER_PATH` still 
> points to the original system binary and gets passed to tests, e.g. in 
> `test/CMakeLists.txt` above.
> Do you know why we copy it over?

It was introduced with https://reviews.llvm.org/rL325068 and the commit message 
points out, that this makes the built debugger functional on Darwin when 
compiling without code signing. In order to use debugserver on Darwin, it 
cannot be ad-hoc code signed, but needs a "real" certificate (as documented in 
docs/code-signing.txt).

Got in touch with Vedant and it seems, that `DEBUGSERVER_PATH` could also point 
to the copied version. Did that.



https://reviews.llvm.org/D54476



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


[Lldb-commits] [PATCH] D54476: [CMake] Streamline code signing for debugserver

2018-11-14 Thread Stefan Gränitz via Phabricator via lldb-commits
sgraenitz updated this revision to Diff 174053.
sgraenitz marked 4 inline comments as done.
sgraenitz added a comment.

debugserver cannot be ad-hoc code signed; handle entitlements also in 
standalone debugserver, add feasibility checks, polishing


https://reviews.llvm.org/D54476

Files:
  test/CMakeLists.txt
  tools/debugserver/CMakeLists.txt
  tools/debugserver/source/CMakeLists.txt
  unittests/tools/CMakeLists.txt

Index: unittests/tools/CMakeLists.txt
===
--- unittests/tools/CMakeLists.txt
+++ unittests/tools/CMakeLists.txt
@@ -1,5 +1,5 @@
 if(CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|Linux|NetBSD")
-  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
+  if ((CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_TEST_DEBUGSERVER) OR (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin" AND SKIP_LLDB_SERVER_BUILD))
 # These tests are meant to test lldb-server/debugserver in isolation, and
 # don't provide any value if run against a server copied from somewhere.
   else()
Index: tools/debugserver/source/CMakeLists.txt
===
--- tools/debugserver/source/CMakeLists.txt
+++ tools/debugserver/source/CMakeLists.txt
@@ -94,32 +94,74 @@
 
 add_library(lldbDebugserverCommon ${lldbDebugserverCommonSources})
 
+option(LLDB_NO_DEBUGSERVER "Delete debugserver after building it, and don't try to codesign it" OFF)
+option(LLDB_USE_SYSTEM_DEBUGSERVER "Neither build nor codesign debugserver. Use the system's debugserver instead (Darwin only)." OFF)
 
-set(LLDB_CODESIGN_IDENTITY "lldb_codesign"
-  CACHE STRING "Identity used for code signing. Set to empty string to skip the signing step.")
-
-if(NOT LLDB_CODESIGN_IDENTITY STREQUAL "")
-  set(DEBUGSERVER_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/debugserver${CMAKE_EXECUTABLE_SUFFIX} CACHE PATH "Path to debugserver.")
-  set(SKIP_DEBUGSERVER OFF CACHE BOOL "Skip building the in-tree debug server")
+# Feasibility checks
+if (APPLE)
+  if(LLDB_NO_DEBUGSERVER AND LLDB_USE_SYSTEM_DEBUGSERVER)
+message(WARNING "Options LLDB_NO_DEBUGSERVER and LLDB_USE_SYSTEM_DEBUGSERVER"
+"are not compatible. Will use the system's debugserver.")
+set(LLDB_NO_DEBUGSERVER OFF CACHE BOOL "" FORCE)
+  endif()
 else()
-  execute_process(
-COMMAND xcode-select -p
-OUTPUT_VARIABLE XCODE_DEV_DIR)
-  string(STRIP ${XCODE_DEV_DIR} XCODE_DEV_DIR)
-  if(EXISTS "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/../SharedFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  elseif(EXISTS "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/")
-set(DEBUGSERVER_PATH
-  "${XCODE_DEV_DIR}/Library/PrivateFrameworks/LLDB.framework/Resources/debugserver" CACHE PATH "Path to debugserver.")
-  else()
-message(SEND_ERROR "Cannot find debugserver on system.")
+  if(LLDB_USE_SYSTEM_DEBUGSERVER)
+message(WARNING "Ignoring option LLDB_USE_SYSTEM_DEBUGSERVER (Darwin only)")
+set(LLDB_USE_SYSTEM_DEBUGSERVER OFF CACHE BOOL "" FORCE)
+  endif()
+endif()
+
+# Cannot ad-hoc code sign debugserver on Darwin.
+# See lldb/docs/code-signing.txt for details.
+if (APPLE AND NOT LLVM_CODESIGNING_IDENTITY STREQUAL "lldb_codesign")
+  set(cannot_codesign_debugserver ON)
+endif()
+
+# Remember where our debugserver lives and whether or not we have to test it.
+set(DEBUGSERVER_PATH "" CACHE FILEPATH "Path to debugserver")
+set(SKIP_TEST_DEBUGSERVER OFF CACHE BOOL "Building the in-tree debugserver was skipped")
+
+if(LLDB_NO_DEBUGSERVER)
+  # No debugserver at all.
+  set(SKIP_TEST_DEBUGSERVER ON CACHE BOOL "" FORCE)
+elseif(LLDB_USE_SYSTEM_DEBUGSERVER OR cannot_codesign_debugserver)
+  # Use system debugserver (Darwin only).
+  set(SKIP_TEST_DEBUGSERVER ON CACHE BOOL "" FORCE)
+
+  if(CMAKE_HOST_APPLE)
+execute_process(
+  COMMAND xcode-select -p
+  OUTPUT_VARIABLE xcode_dev_dir)
+string(STRIP ${xcode_dev_dir} xcode_dev_dir)
+
+if(EXISTS "${xcode_dev_dir}/../SharedFrameworks/LLDB.framework/")
+  set(lldb_framework_dir "${xcode_dev_dir}/../SharedFrameworks")
+elseif(EXISTS "${xcode_dev_dir}/Library/PrivateFrameworks/LLDB.framework/")
+  set(lldb_framework_dir "${xcode_dev_dir}/Library/PrivateFrameworks")
+else()
+  message(SEND_ERROR "Cannot find debugserver on system.")
+endif()
+set(debugserver_system_path "${lldb_framework_dir}/LLDB.framework/Resources/debugserver")
+
+# We haven't built a signed debugserver. If possible, copy the one from
+# the system to make the built debugger functional on Darwin.
+add_custom_target(debugserver
+  COMMAND ${CMAKE_COMMAND} -E copy_if_different ${debugserver_system_path} ${LLVM_TOOLS_BINARY_DIR}
+  VERBATIM
+  COMMENT "Copying the system debugserver to LLDB's binaries directory.")
+
+# TODO: 

[Lldb-commits] [lldb] r346867 - Move DataExtractorTest to unittests/Utility

2018-11-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 14 06:58:36 2018
New Revision: 346867

URL: http://llvm.org/viewvc/llvm-project?rev=346867=rev
Log:
Move DataExtractorTest to unittests/Utility

The DataExtractor class itself was moved to Utility some time ago, but
it seems this was not reflected in the location of the test code. Fix
that.

Added:
lldb/trunk/unittests/Utility/DataExtractorTest.cpp
  - copied, changed from r346853, 
lldb/trunk/unittests/Core/DataExtractorTest.cpp
Removed:
lldb/trunk/unittests/Core/DataExtractorTest.cpp
Modified:
lldb/trunk/unittests/Core/CMakeLists.txt
lldb/trunk/unittests/Utility/CMakeLists.txt

Modified: lldb/trunk/unittests/Core/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/CMakeLists.txt?rev=346867=346866=346867=diff
==
--- lldb/trunk/unittests/Core/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Core/CMakeLists.txt Wed Nov 14 06:58:36 2018
@@ -1,6 +1,5 @@
 add_lldb_unittest(LLDBCoreTests
   BroadcasterTest.cpp
-  DataExtractorTest.cpp
   EventTest.cpp
   ListenerTest.cpp
   MangledTest.cpp

Removed: lldb/trunk/unittests/Core/DataExtractorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Core/DataExtractorTest.cpp?rev=346866=auto
==
--- lldb/trunk/unittests/Core/DataExtractorTest.cpp (original)
+++ lldb/trunk/unittests/Core/DataExtractorTest.cpp (removed)
@@ -1,168 +0,0 @@
-//===-- DataExtractorTest.cpp ---*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "gtest/gtest.h"
-
-#include "lldb/Utility/DataExtractor.h"
-
-using namespace lldb_private;
-
-TEST(DataExtractorTest, GetBitfield) {
-  uint8_t buffer[] = {0x01, 0x23, 0x45, 0x67};
-  DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
-   sizeof(void *));
-  DataExtractor BE(buffer, sizeof(buffer), lldb::eByteOrderBig, sizeof(void 
*));
-
-  lldb::offset_t offset;
-
-  offset = 0;
-  ASSERT_EQ(buffer[1], LE.GetMaxU64Bitfield(, sizeof(buffer), 8, 8));
-  offset = 0;
-  ASSERT_EQ(buffer[1], BE.GetMaxU64Bitfield(, sizeof(buffer), 8, 8));
-
-  offset = 0;
-  ASSERT_EQ(int8_t(buffer[1]),
-LE.GetMaxS64Bitfield(, sizeof(buffer), 8, 8));
-  offset = 0;
-  ASSERT_EQ(int8_t(buffer[1]),
-BE.GetMaxS64Bitfield(, sizeof(buffer), 8, 8));
-}
-
-TEST(DataExtractorTest, PeekData) {
-  uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04};
-  DataExtractor E(buffer, sizeof buffer, lldb::eByteOrderLittle, 4);
-
-  EXPECT_EQ(buffer + 0, E.PeekData(0, 0));
-  EXPECT_EQ(buffer + 0, E.PeekData(0, 4));
-  EXPECT_EQ(nullptr, E.PeekData(0, 5));
-
-  EXPECT_EQ(buffer + 2, E.PeekData(2, 0));
-  EXPECT_EQ(buffer + 2, E.PeekData(2, 2));
-  EXPECT_EQ(nullptr, E.PeekData(2, 3));
-
-  EXPECT_EQ(buffer + 4, E.PeekData(4, 0));
-  EXPECT_EQ(nullptr, E.PeekData(4, 1));
-}
-
-TEST(DataExtractorTest, GetMaxU64) {
-  uint8_t buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
-  DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
-   sizeof(void *));
-  DataExtractor BE(buffer, sizeof(buffer), lldb::eByteOrderBig, sizeof(void 
*));
-
-  lldb::offset_t offset;
-
-  // Check with the minimum allowed byte size.
-  offset = 0;
-  EXPECT_EQ(0x01U, LE.GetMaxU64(, 1));
-  EXPECT_EQ(1U, offset);
-  offset = 0;
-  EXPECT_EQ(0x01U, BE.GetMaxU64(, 1));
-  EXPECT_EQ(1U, offset);
-
-  // Check with a non-zero offset.
-  offset = 1;
-  EXPECT_EQ(0x0302U, LE.GetMaxU64(, 2));
-  EXPECT_EQ(3U, offset);
-  offset = 1;
-  EXPECT_EQ(0x0203U, BE.GetMaxU64(, 2));
-  EXPECT_EQ(3U, offset);
-
-  // Check with the byte size not being a multiple of 2.
-  offset = 0;
-  EXPECT_EQ(0x07060504030201U, LE.GetMaxU64(, 7));
-  EXPECT_EQ(7U, offset);
-  offset = 0;
-  EXPECT_EQ(0x01020304050607U, BE.GetMaxU64(, 7));
-  EXPECT_EQ(7U, offset);
-
-  // Check with the maximum allowed byte size.
-  offset = 0;
-  EXPECT_EQ(0x0807060504030201U, LE.GetMaxU64(, 8));
-  EXPECT_EQ(8U, offset);
-  offset = 0;
-  EXPECT_EQ(0x0102030405060708U, BE.GetMaxU64(, 8));
-  EXPECT_EQ(8U, offset);
-}
-
-TEST(DataExtractorTest, GetMaxS64) {
-  uint8_t buffer[] = {0x01, 0x02, 0x83, 0x04, 0x05, 0x06, 0x07, 0x08};
-  DataExtractor LE(buffer, sizeof(buffer), lldb::eByteOrderLittle,
-   sizeof(void *));
-  DataExtractor BE(buffer, sizeof(buffer), lldb::eByteOrderBig, sizeof(void 
*));
-
-  lldb::offset_t offset;
-
-  // Check with the minimum allowed byte size.
-  offset = 0;
-  EXPECT_EQ(0x01, LE.GetMaxS64(, 1));
-  EXPECT_EQ(1U, offset);
-  offset = 0;
-  EXPECT_EQ(0x01, BE.GetMaxS64(, 1));
-  EXPECT_EQ(1U, offset);
-
-  // Check that 

[Lldb-commits] [lldb] r346855 - [LLDB] - Recommit r346848 "[LLDB] - Support the single file split DWARF.".

2018-11-14 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Nov 14 05:01:15 2018
New Revision: 346855

URL: http://llvm.org/viewvc/llvm-project?rev=346855=rev
Log:
[LLDB] - Recommit r346848 "[LLDB] - Support the single file split DWARF.".

Test cases were updated to not use the local compilation dir which
is different between development pc and build bots.

Original commit message:

[LLDB] - Support the single file split DWARF.

DWARF5 spec describes a single file split dwarf case
(when .dwo sections are in the .o files).

Problem is that LLDB does not work correctly in that case.
The issue is that, for example, both .debug_info and .debug_info.dwo
has the same type: eSectionTypeDWARFDebugInfo. And when code searches
section by type it might find the regular debug section
and not the .dwo one.

The patch fixes that. With it, LLDB is able to work with
output compiled with -gsplit-dwarf=single flag correctly.

Differential revision: https://reviews.llvm.org/D52403

Added:
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=346855=346854=346855=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Nov 14 05:01:15 2018
@@ -708,6 +708,10 @@ enum SectionType {
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
   eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
+  eSectionTypeDWARFDebugAbbrevDwo,
+  eSectionTypeDWARFDebugInfoDwo,
+  eSectionTypeDWARFDebugStrDwo,
+  eSectionTypeDWARFDebugStrOffsetsDwo,
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Added: lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml?rev=346855=auto
==
--- lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml Wed Nov 14 
05:01:15 2018
@@ -0,0 +1,84 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x0010
+Content: 554889E531C0C745FC5DC390554889E55DC3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 0C000500
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400
+  - Name:.debug_loc.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: ''
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 01110010177217B042251B25B44219B342171101120600
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
2B00050004083F4B7684A29835B90100011600
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: '00'
+  - Name:.debug_str_offsets.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: 
250007002A00330038003C004400
+  - Name:.debug_str.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+

[Lldb-commits] [lldb] r346853 - Revert r346848 "[LLDB] - Support the single file split DWARF."

2018-11-14 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Nov 14 04:04:31 2018
New Revision: 346853

URL: http://llvm.org/viewvc/llvm-project?rev=346853=rev
Log:
Revert r346848 "[LLDB] - Support the single file split DWARF."

It broke BB:
http://green.lab.llvm.org/green/job/lldb-cmake/12522/testReport/junit/LLDB/Breakpoint/single_file_split_dwarf_test/

Removed:
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=346853=346852=346853=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Nov 14 04:04:31 2018
@@ -708,10 +708,6 @@ enum SectionType {
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
   eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
-  eSectionTypeDWARFDebugAbbrevDwo,
-  eSectionTypeDWARFDebugInfoDwo,
-  eSectionTypeDWARFDebugStrDwo,
-  eSectionTypeDWARFDebugStrOffsetsDwo,
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Removed: lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml?rev=346852=auto
==
--- lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml (original)
+++ lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml (removed)
@@ -1,84 +0,0 @@
 !ELF
-FileHeader:  
-  Class:   ELFCLASS64
-  Data:ELFDATA2LSB
-  Type:ET_REL
-  Machine: EM_X86_64
-Sections:
-  - Name:.text
-Type:SHT_PROGBITS
-Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
-AddressAlign:0x0010
-Content: 554889E531C0C745FC5DC390554889E55DC3
-  - Name:.debug_str_offsets
-Type:SHT_PROGBITS
-AddressAlign:0x0001
-Content: 0C000500
-  - Name:.debug_str
-Type:SHT_PROGBITS
-Flags:   [ SHF_MERGE, SHF_STRINGS ]
-AddressAlign:0x0001
-Content: 
746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400
-  - Name:.debug_loc.dwo
-Type:SHT_PROGBITS
-Flags:   [ SHF_EXCLUDE ]
-AddressAlign:0x0001
-Content: ''
-  - Name:.debug_abbrev
-Type:SHT_PROGBITS
-AddressAlign:0x0001
-Content: 01110010177217B042251B25B44219B342171101120600
-  - Name:.debug_info
-Type:SHT_PROGBITS
-AddressAlign:0x0001
-Content: 
2B00050004083F4B7684A29835B90100011600
-  - Name:.debug_macinfo
-Type:SHT_PROGBITS
-AddressAlign:0x0001
-Content: '00'
-  - Name:.debug_str_offsets.dwo
-Type:SHT_PROGBITS
-Flags:   [ SHF_EXCLUDE ]
-AddressAlign:0x0001
-Content: 
250007002A00330038003C004400
-  - Name:.debug_str.dwo
-Type:SHT_PROGBITS
-Flags:   [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
-AddressAlign:0x0001
-Content: 
746573742E6F00636C616E672076657273696F6E20382E302E3020287472756E6B203334323731382900746573742E637070006D61696E00696E74005F5A33666F6F7600666F6F00
-  - Name:.debug_info.dwo
-Type:SHT_PROGBITS
-Flags:   [ SHF_EXCLUDE ]
-AddressAlign:0x0001
-Content: 
3600050005083F4B7684A29835B901000104000202000F0001560301013500030106000156050601050404050400
-  - Name:.debug_abbrev.dwo
-Type:SHT_PROGBITS
-Flags:   [ SHF_EXCLUDE ]
-AddressAlign:0x0001
-Content: 

[Lldb-commits] [PATCH] D54417: Fix a crash when parsing incorrect DWARF

2018-11-14 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB346849: Fix a crash when parsing incorrect DWARF 
(authored by labath, committed by ).
Herald added a subscriber: abidh.

Changed prior to commit:
  https://reviews.llvm.org/D54417?vs=173634=174006#toc

Repository:
  rLLDB LLDB

https://reviews.llvm.org/D54417

Files:
  lit/SymbolFile/DWARF/childless-compile-unit.s
  source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp


Index: lit/SymbolFile/DWARF/childless-compile-unit.s
===
--- lit/SymbolFile/DWARF/childless-compile-unit.s
+++ lit/SymbolFile/DWARF/childless-compile-unit.s
@@ -0,0 +1,45 @@
+# Test that we don't crash when parsing slightly invalid DWARF.  The compile
+# unit in this file sets DW_CHILDREN_no, but it still includes an
+# end-of-children marker in its contribution.
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: lldb-test symbols %t.o
+
+   .section.debug_str,"MS",@progbits,1
+.Linfo_string0:
+   .asciz  "Hand-written DWARF"
+.Linfo_string1:
+   .asciz  "-"
+.Linfo_string2:
+   .asciz  "/tmp"
+
+   .section.debug_abbrev,"",@progbits
+   .byte   1   # Abbreviation Code
+   .byte   17  # DW_TAG_compile_unit
+   .byte   0   # DW_CHILDREN_no
+   .byte   37  # DW_AT_producer
+   .byte   14  # DW_FORM_strp
+   .byte   19  # DW_AT_language
+   .byte   5   # DW_FORM_data2
+   .byte   3   # DW_AT_name
+   .byte   14  # DW_FORM_strp
+   .byte   27  # DW_AT_comp_dir
+   .byte   14  # DW_FORM_strp
+   .byte   0   # EOM(1)
+   .byte   0   # EOM(2)
+   .byte   0   # EOM(3)
+
+   .section.debug_info,"",@progbits
+.Lcu_begin0:
+   .long   .Lcu_length_end-.Lcu_length_start # Length of Unit
+.Lcu_length_start:
+   .short  4   # DWARF version number
+   .long   .debug_abbrev   # Offset Into Abbrev. Section
+   .byte   8   # Address Size (in bytes)
+   .byte   1   # Abbrev [1] 0xb:0x30 
DW_TAG_compile_unit
+   .long   .Linfo_string0  # DW_AT_producer
+   .short  12  # DW_AT_language
+   .long   .Linfo_string1  # DW_AT_name
+   .long   .Linfo_string2  # DW_AT_comp_dir
+   .byte   0   # Bogus End Of Children Mark
+.Lcu_length_end:
Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -244,9 +244,6 @@
 
   if (depth > 0)
 --depth;
-  if (depth == 0)
-break; // We are done with this compile unit!
-
   prev_die_had_children = false;
 } else {
   die_index_stack.back() = m_die_array.size() - 1;
@@ -258,6 +255,9 @@
   }
   prev_die_had_children = die_has_children;
 }
+
+if (depth == 0)
+  break; // We are done with this compile unit!
   }
 
   if (!m_die_array.empty()) {


Index: lit/SymbolFile/DWARF/childless-compile-unit.s
===
--- lit/SymbolFile/DWARF/childless-compile-unit.s
+++ lit/SymbolFile/DWARF/childless-compile-unit.s
@@ -0,0 +1,45 @@
+# Test that we don't crash when parsing slightly invalid DWARF.  The compile
+# unit in this file sets DW_CHILDREN_no, but it still includes an
+# end-of-children marker in its contribution.
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: lldb-test symbols %t.o
+
+	.section	.debug_str,"MS",@progbits,1
+.Linfo_string0:
+	.asciz	"Hand-written DWARF"
+.Linfo_string1:
+	.asciz	"-"
+.Linfo_string2:
+	.asciz	"/tmp"
+
+	.section	.debug_abbrev,"",@progbits
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	0   # DW_CHILDREN_no
+	.byte	37  # DW_AT_producer
+	.byte	14  # DW_FORM_strp
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	14  # DW_FORM_strp
+	.byte	27  # DW_AT_comp_dir
+	.byte	14  # DW_FORM_strp
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	0   # EOM(3)
+
+	.section	.debug_info,"",@progbits
+.Lcu_begin0:
+	.long	.Lcu_length_end-.Lcu_length_start # Length of Unit
+.Lcu_length_start:
+	.short	4   # DWARF version number
+	.long	

[Lldb-commits] [lldb] r346849 - Fix a crash when parsing incorrect DWARF

2018-11-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Nov 14 03:12:40 2018
New Revision: 346849

URL: http://llvm.org/viewvc/llvm-project?rev=346849=rev
Log:
Fix a crash when parsing incorrect DWARF

Summary:
While parsing a childless compile unit DIE we could crash if the DIE was
followed by any extra data (such as a superfluous end-of-children
marker). This happened because the break-on-depth=0 check was performed
only when parsing the null DIE, which was not correct because with a
childless root DIE, we could reach the end of the unit without ever
encountering the null DIE.

If the compile unit contribution ended directly after the CU DIE,
everything would be fine as we would terminate parsing due to reaching
EOF. However, if the contribution contained extra data (perhaps a
superfluous end-of-children marker), we would crash because we would
treat that data as the begging of another compile unit.

This fixes the crash by moving the depth=0 check to a more generic
place, and also adds a regression test.

Reviewers: clayborg, jankratochvil, JDevlieghere

Subscribers: lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp

Added: lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s?rev=346849=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/childless-compile-unit.s Wed Nov 14 
03:12:40 2018
@@ -0,0 +1,45 @@
+# Test that we don't crash when parsing slightly invalid DWARF.  The compile
+# unit in this file sets DW_CHILDREN_no, but it still includes an
+# end-of-children marker in its contribution.
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: lldb-test symbols %t.o
+
+   .section.debug_str,"MS",@progbits,1
+.Linfo_string0:
+   .asciz  "Hand-written DWARF"
+.Linfo_string1:
+   .asciz  "-"
+.Linfo_string2:
+   .asciz  "/tmp"
+
+   .section.debug_abbrev,"",@progbits
+   .byte   1   # Abbreviation Code
+   .byte   17  # DW_TAG_compile_unit
+   .byte   0   # DW_CHILDREN_no
+   .byte   37  # DW_AT_producer
+   .byte   14  # DW_FORM_strp
+   .byte   19  # DW_AT_language
+   .byte   5   # DW_FORM_data2
+   .byte   3   # DW_AT_name
+   .byte   14  # DW_FORM_strp
+   .byte   27  # DW_AT_comp_dir
+   .byte   14  # DW_FORM_strp
+   .byte   0   # EOM(1)
+   .byte   0   # EOM(2)
+   .byte   0   # EOM(3)
+
+   .section.debug_info,"",@progbits
+.Lcu_begin0:
+   .long   .Lcu_length_end-.Lcu_length_start # Length of Unit
+.Lcu_length_start:
+   .short  4   # DWARF version number
+   .long   .debug_abbrev   # Offset Into Abbrev. Section
+   .byte   8   # Address Size (in bytes)
+   .byte   1   # Abbrev [1] 0xb:0x30 
DW_TAG_compile_unit
+   .long   .Linfo_string0  # DW_AT_producer
+   .short  12  # DW_AT_language
+   .long   .Linfo_string1  # DW_AT_name
+   .long   .Linfo_string2  # DW_AT_comp_dir
+   .byte   0   # Bogus End Of Children Mark
+.Lcu_length_end:

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp?rev=346849=346848=346849=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp Wed Nov 14 
03:12:40 2018
@@ -244,9 +244,6 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 
   if (depth > 0)
 --depth;
-  if (depth == 0)
-break; // We are done with this compile unit!
-
   prev_die_had_children = false;
 } else {
   die_index_stack.back() = m_die_array.size() - 1;
@@ -258,6 +255,9 @@ void DWARFUnit::ExtractDIEsRWLocked() {
   }
   prev_die_had_children = die_has_children;
 }
+
+if (depth == 0)
+  break; // We are done with this compile unit!
   }
 
   if (!m_die_array.empty()) {


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


[Lldb-commits] [PATCH] D52403: [LLDB] - Support the single file split DWARF.

2018-11-14 Thread George Rimar via Phabricator via lldb-commits
grimar closed this revision.
grimar added a comment.

Committed as https://reviews.llvm.org/rLLDB346848.
The commit message has a wrong review link by mistake.


https://reviews.llvm.org/D52403



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


[Lldb-commits] [lldb] r346848 - [LLDB] - Support the single file split DWARF.

2018-11-14 Thread George Rimar via lldb-commits
Author: grimar
Date: Wed Nov 14 02:35:14 2018
New Revision: 346848

URL: http://llvm.org/viewvc/llvm-project?rev=346848=rev
Log:
[LLDB] - Support the single file split DWARF.

DWARF5 spec describes a single file split dwarf case
(when .dwo sections are in the .o files).

Problem is that LLDB does not work correctly in that case.
The issue is that, for example, both .debug_info and .debug_info.dwo
has the same type: eSectionTypeDWARFDebugInfo. And when code searches
section by type it might find the regular debug section
and not the .dwo one.

The patch fixes that. With it, LLDB is able to work with
output compiled with -gsplit-dwarf=single flag correctly.

Differential revision: https://reviews.llvm.org/D52296

Added:
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.yaml
lldb/trunk/lit/Breakpoint/single-file-split-dwarf.test
Modified:
lldb/trunk/include/lldb/lldb-enumerations.h
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
lldb/trunk/source/Symbol/ObjectFile.cpp

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=346848=346847=346848=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Nov 14 02:35:14 2018
@@ -708,6 +708,10 @@ enum SectionType {
   eSectionTypeDWARFDebugLineStr, // DWARF v5 .debug_line_str
   eSectionTypeDWARFDebugRngLists, // DWARF v5 .debug_rnglists
   eSectionTypeDWARFDebugLocLists, // DWARF v5 .debug_loclists
+  eSectionTypeDWARFDebugAbbrevDwo,
+  eSectionTypeDWARFDebugInfoDwo,
+  eSectionTypeDWARFDebugStrDwo,
+  eSectionTypeDWARFDebugStrOffsetsDwo,
 };
 
 FLAGS_ENUM(EmulateInstructionOptions){

Added: lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml?rev=346848=auto
==
--- lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml (added)
+++ lldb/trunk/lit/Breakpoint/Inputs/single-file-split-dwarf.o.yaml Wed Nov 14 
02:35:14 2018
@@ -0,0 +1,84 @@
+--- !ELF
+FileHeader:  
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+AddressAlign:0x0010
+Content: 554889E531C0C745FC5DC390554889E55DC3
+  - Name:.debug_str_offsets
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 0C000500
+  - Name:.debug_str
+Type:SHT_PROGBITS
+Flags:   [ SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
746573742E6F002F686F6D652F756D622F74657374735F323031382F39355F6C6C64622F726570726F2F6477617266355F73706C69745F73696E676C655F66696C652F707265706172655F73616D706C65006D61696E00666F6F005F5A33666F6F7600696E7400
+  - Name:.debug_loc.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: ''
+  - Name:.debug_abbrev
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 01110010177217B042251B25B44219B342171101120600
+  - Name:.debug_info
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: 
2B00050004083F4B7684A29835B90100011600
+  - Name:.debug_macinfo
+Type:SHT_PROGBITS
+AddressAlign:0x0001
+Content: '00'
+  - Name:.debug_str_offsets.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE ]
+AddressAlign:0x0001
+Content: 
250007002A00330038003C004400
+  - Name:.debug_str.dwo
+Type:SHT_PROGBITS
+Flags:   [ SHF_EXCLUDE, SHF_MERGE, SHF_STRINGS ]
+AddressAlign:0x0001
+Content: 
746573742E6F00636C616E672076657273696F6E20382E302E3020287472756E6B203334323731382900746573742E637070006D61696E00696E74005F5A33666F6F7600666F6F00
+  - Name:.debug_info.dwo
+Type: