[Lldb-commits] [PATCH] D71575: [LLDB] Add initial support for WebAssembly debugging

2019-12-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added inline comments.



Comment at: 
lldb/source/Plugins/DynamicLoader/WASM-DYLD/DynamicLoaderWasmDYLD.cpp:1
+//===-- DynamicLoaderWasmDYLD.cpp *- C++
+//-*-===//

paolosev wrote:
> aprantl wrote:
> > 1. This hangs over the line
> > 2. a -*- C++ -*- is only necessary for .h files where C vs. C++ is ambiguous
> > 
> Fixed, but I see the -*- C++ -*- in all files.
The line just got cargo-culted into many *.cpp files so all occurrences in 
source files are unintentional.



Comment at: lldb/source/Utility/ArchSpec.cpp:107
+{eByteOrderLittle, 4, 2, 4, llvm::Triple::arm, ArchSpec::eCore_arm_armv8l,
+ "armv8l"},
 {eByteOrderLittle, 4, 4, 4, llvm::Triple::aarch64_32,

paolosev wrote:
> sbc100 wrote:
> > Is this just clang format being greedy?
> Yes, it was edited by clang format.
Can you revert that change? clang-format shouldn't touch these unrelated files 
if you use git-clang-format or something similar.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71575/new/

https://reviews.llvm.org/D71575



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


[Lldb-commits] [PATCH] D70644: [DebugInfo] Support for DW_OP_implicit_pointer (llvm.dbg_derefval)

2019-12-18 Thread Alok Kumar Sharma via Phabricator via lldb-commits
alok marked 12 inline comments as done.
alok added inline comments.



Comment at: llvm/docs/SourceLevelDebugging.rst:261
+This intrinsic is identical to `llvm.dbg.value`, except that it is used to
+describe dereferenced value of pointer variable. The first argument is 
metadata.
+The second argument is a `local variable `_

jmorse wrote:
> I'd add some motivation to the first sentence, such as: "it it used to 
> describe the dereferenced value of a pointer variable, when the pointer 
> itself is no longer available in the program".
Thanks for comment. It will be incorporated in next version.



Comment at: llvm/docs/SourceLevelDebugging.rst:266-267
+interpreted based on the third argument. If the third argument represents
+DW_OP_LLVM_implicit_pointer, the first argument is
+ `local variable `_ , otherwise it is the value
+(wrapped as metadata).

jmorse wrote:
> IMO "is" should read "must", i.e. "the first argument must be a local 
> variable", to indicate this is required for correctness.
Thanks for your comment. It will be included in next version.



Comment at: llvm/docs/SourceLevelDebugging.rst:270
+
+An `llvm.dbg.derefval` intrinsic is usefull when location which the variable
+points to is optimized out, but the dereferenced value is known.

StephenTozer wrote:
> Correct usefull -> useful
Thanks for your comment. It will be incorporated in next version.



Comment at: llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h:369
 
+  /// Build and insert a DBG_VALUE instructions specifying that dereferenced
+  /// value of \p Variable is given by \p V (suitably modified by \p Expr).

jmorse wrote:
> "that the dereferenced"?
Thanks for your comment. It will be incorporated in next version.



Comment at: llvm/include/llvm/CodeGen/MachineInstrBuilder.h:227-238
+  const MachineInstrBuilder &addMetadata(const MDNode *MD,
+ bool IsImplicitPointer = false) const 
{
 MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
-assert((MI->isDebugValue() ? static_cast(MI->getDebugVariable())
-   : true) &&
+assert(((MI->isDebugValue() && !IsImplicitPointer)
+? static_cast(MI->getDebugVariable())
+: true) &&
"first MDNode argument of a DBG_VALUE not a variable");

jmorse wrote:
> Perhaps it's worth adding a new "add" method, i.e. "addImplicitPtrMetadata"? 
> That avoids the extra argument, and in the call sites below it will be a 
> little clearer what's happening, as a "true" argument isn't especially 
> helpful.
> 
> Plus, then you can assert that only DILocalVariables (or whatever) are added 
> as the implicit pointer metadata.
Thanks for your comment. It will be incorporated in next version.



Comment at: llvm/lib/CodeGen/LiveDebugValues.cpp:717-718
   if (isDbgValueDescribedByReg(MI) || MI.getOperand(0).isImm() ||
-  MI.getOperand(0).isFPImm() || MI.getOperand(0).isCImm()) {
+  MI.getOperand(0).isFPImm() || MI.getOperand(0).isCImm() ||
+  MI.getOperand(0).isMetadata()) {
 // Use normal VarLoc constructor for registers and immediates.

jmorse wrote:
> The main VarLoc constructor called on line 720 is going to not recognise the 
> metadata operand and leave some fields uninitialized (it should probably 
> actually assert in this case). I reckon you'll need to add a new location 
> "Kind", and have it emitted in the BuildDbgValue method.
> 
> The LiveDebugValues algorithm should (TM) handle and propagate this kind of 
> location fine.
Thanks for pointing this out. This will be incorporated in next version.



Comment at: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp:1447
   }
+  case Intrinsic::dbg_derefval: {
+// This form of DBG_VALUE is target-independent.

jmorse wrote:
> Perhaps easier here instead to have dbg_derefval and dbg_value share code, 
> with an additional assertion that MetadataAsValue operands can only come from 
> dbg_value's?
Thanks for your comment. It will be incorporated in next version.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70644/new/

https://reviews.llvm.org/D70644



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


[Lldb-commits] [PATCH] D71498: Fix ARM32 inferior calls

2019-12-18 Thread Muhammad Omair Javaid via Phabricator via lldb-commits
omjavaid added a comment.

In D71498#1786341 , @clayborg wrote:

> As I am reading this, I just wanted to send out a note of something else that 
> can cause crashes in ARM/Thumb code. For anyone working with ARM/Thumb on 
> systems that don't use the ARM and Thumb BKPT instruction when setting 
> software breakpoints (like all lldb linux and android flavors IIRC): if you 
> try to overwrite a 32 bit thumb instruction that is a conditional instruction 
> in a Thumb IT instruction with a 16 bit trap or illegal instruction you can 
> crash your program. The issue arises for code like:
>
>   0x1000: xx xx ITTTEE
>   0x1002: 00 11 22 33   32 bit thumb instruction (if condition)
>   0x1006: 44 55 66 77   32 bit thumb instruction (if condition)
>   0x100a: 88 99 aa bb   32 bit thumb instruction (else condition) 
>   0x100e: cc dd ee ff   32 bit thumb instruction (else condition)
>
>
> If you try to set a breakpoint at any of the instructions in [0x1002-0x100e) 
> using a 16 bit trap or illegal instruction (I use "bb bb" below for this trap 
> for example purposes), you change the size of the instructions and which 
> instructions are conditional. If we try to write "bb bb" to 0x1002 we now 
> have:
>
>   0x1000: xx xx ITTTEE
>   0x1002: bb bb (if condition) the first conditional instruction is 
> now 16 bit instead of 32 bit
>   0x1004: 22 33 44 55   (if condition) this has the last half of the previous 
> instruction 
>   0x1008: 66 77 88 99   (else condition) this has the last half of the 
> previous instruction 
>   0x100c: aa bb (else condition) this has the last half of the 
> previous instruction 
>   0x100e: cc dd ee ff   32 bit thumb instruction (NOT conditional anymore)
>
>
> This will work if using the BKPT instruction only. Sorry for the noise if 
> lldb-server is already using the BKPT instruction. But I just wanted to throw 
> this out there in case this issue if affecting anyone.


I do have this thing on my future agenda but it requires wider testing. When 
BKPT was implemented in lldb-server back when we were initially adding support 
for arm/linux, we encountered some unsupported behavior which i dont remember 
exactly that resulted in sticking with legacy behavior.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71498/new/

https://reviews.llvm.org/D71498



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


[Lldb-commits] [PATCH] D70764: build: reduce CMake handling for zlib

2019-12-18 Thread Chris Bieneman via Phabricator via lldb-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

I think this is good, and it has been sitting a while.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70764/new/

https://reviews.llvm.org/D70764



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


[Lldb-commits] [PATCH] D70644: [DebugInfo] Support for DW_OP_implicit_pointer (llvm.dbg_derefval)

2019-12-18 Thread Alok Kumar Sharma via Phabricator via lldb-commits
alok updated this revision to Diff 234356.
alok added a comment.

This version is updated to rebase and to incorporate comments from @jmorse  and 
@StephenTozer.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70644/new/

https://reviews.llvm.org/D70644

Files:
  lldb/source/Expression/IRInterpreter.cpp
  llvm/docs/SourceLevelDebugging.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/MachineInstrBuilder.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/include/llvm/IR/InstVisitor.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ObjCARCInstKind.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  polly/lib/Support/ScopHelper.cpp

Index: polly/lib/Support/ScopHelper.cpp
===
--- polly/lib/Support/ScopHelper.cpp
+++ polly/lib/Support/ScopHelper.cpp
@@ -624,6 +624,7 @@
 case llvm::Intrinsic::assume:
 // Some debug info intrinsics are supported/ignored.
 case llvm::Intrinsic::dbg_value:
+case llvm::Intrinsic::dbg_derefval:
 case llvm::Intrinsic::dbg_declare:
   return true;
 default:
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4010,6 +4010,7 @@
 switch (IntrinsicID) {
 case Intrinsic::dbg_declare:
 case Intrinsic::dbg_value:
+case Intrinsic::dbg_derefval:
 case Intrinsic::dbg_label:
 case Intrinsic::lifetime_end:
   break;
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -385,6 +385,11 @@
   return false;
 return true;
   }
+  if (DbgDerefValueInst *DVI = dyn_cast(I)) {
+if (DVI->getDerefVariable())
+  return false;
+return true;
+  }
   if (DbgLabelInst *DLI = dyn_cast(I)) {
 if (DLI->getLabel())
   return false;
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4322,6 +4322,9 @@
   case Intrinsic::dbg_value: // llvm.dbg.value
 visitDbgIntrinsic("value", cast(Call));
 break;
+  case Intrinsic::dbg_derefval: // llvm.dbg.derefval
+visitDbgIntrinsic("derefval", cast(Call));
+break;
   case Intrinsic::dbg_label: // llvm.dbg.label
 visitDbgLabelIntrinsic("label", cast(Call));
 break;
@@ -4877,8 +4880,9 @@
 void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) {
   auto *MD = cast(DII.getArgOperand(0))->getMetadata();
   AssertDI(isa(MD) ||
- (isa(MD) && !cast(MD)->getNumOperands()),
- "invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD);
+   (isa(MD) && !cast(MD)->getNumOperands()) ||
+   isa(DII),
+   "invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD);
   AssertDI(isa(DII.getRawVariable()),
  "invalid llvm.dbg." + Kind + " intrinsic variable", &DII,
  DII.getRawVariable());
Index: llvm/lib/IR/IntrinsicInst.cpp
===
--- llvm/lib/IR/IntrinsicInst.cpp
+++ llvm/lib/IR/IntrinsicInst.cpp
@@ -50,6 +50,14 @@
   return nullptr;
 }
 
+Value *DbgVariableIntrinsic::getDerefVariable(bool AllowNullOp) const {
+  Value *Op = getArgOperand(0);
+  if (AllowNullOp && !Op)
+return nullptr;
+
+  return Op;
+}
+
 Optional DbgVariableIntrinsic::getFragmentSizeInBits() const {
   if (auto Fragment = getExpression()->getFragmentInfo())
 return Fragment->SizeInBits;
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -887,6 +887,14 @@
   InsertBefore);
 }
 
+Instruction *DIBuilder::insertDbgDerefValueIntrinsic(
+Value *V, DILocalVariable *VarInfo, DIExpression *Expr,
+const DILocation *DL, Instruction *InsertBefore) {
+  return insertDbgDerefValueIntrinsic(
+  V, VarInfo, Expr, DL, InsertBefore ? InsertBefore->getParent() : nullptr,
+  InsertBefore);
+}
+
 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V,
 DI

[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2019-12-18 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 234471.
paolosev retitled this revision from "[LLDB] Add initial support for 
WebAssembly debugging" to "[LLDB] Add ObjectFileWasm plugin for WebAssembly 
debugging".
paolosev edited the summary of this revision.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71575/new/

https://reviews.llvm.org/D71575

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Utility/ArchSpec.cpp
  lldb/unittests/ObjectFile/CMakeLists.txt
  lldb/unittests/ObjectFile/wasm/CMakeLists.txt
  lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp

Index: lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp
===
--- /dev/null
+++ lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp
@@ -0,0 +1,281 @@
+//===-- TestObjectFileWasm.cpp --*- C++ -*-===//
+//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "Plugins/ObjectFile/WASM/ObjectFileWasm.h"
+#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Reproducer.h"
+#include "llvm/Testing/Support/Error.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+using namespace lldb;
+
+class ObjectFileWasmTest : public testing::Test {
+public:
+  void SetUp() override {
+llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None));
+FileSystem::Initialize();
+HostInfo::Initialize();
+wasm::ObjectFileWasm::Initialize();
+  }
+
+  void TearDown() override {
+wasm::ObjectFileWasm::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+Reproducer::Terminate();
+  }
+};
+
+TEST_F(ObjectFileWasmTest, SectionsResolveConsistently) {
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+  - Type:TYPE
+Signatures:
+  - Index:   0
+ParamTypes:
+  - I32
+ReturnTypes:
+  - I32
+  - Type:FUNCTION
+FunctionTypes:   [ 0 ]
+  - Type:TABLE
+Tables:
+  - ElemType:FUNCREF
+Limits:
+  Flags:   [ HAS_MAX ]
+  Initial: 0x0001
+  Maximum: 0x0001
+  - Type:MEMORY
+Memories:
+  - Initial: 0x0002
+  - Type:GLOBAL
+Globals:
+  - Index:   0
+Type:I32
+Mutable: true
+InitExpr:
+  Opcode:  I32_CONST
+  Value:   66560
+  - Type:EXPORT
+Exports:
+  - Name:memory
+Kind:MEMORY
+Index:   0
+  - Name:square
+Kind:FUNCTION
+Index:   0
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:238080808000210141102102200120026B21032003200036020C200328020C2104200328020C2105200420056C210620060F0B
+  - Type:CUSTOM
+Name:name
+FunctionNames:
+  - Index:   0
+Name:square
+  - Type:CUSTOM
+Name:producers
+Languages:
+  - Name:C99
+Version: ''
+Tools:
+  - Name:clang
+Version: '10.0.0'
+  - Type:CUSTOM
+Name:external_debug_info
+Payload: 0F7371756172655F73796D2E7761736D
+...
+)");
+
+  ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+  ArchSpec arch("wasm32-unknown-unknown-wasm");
+  Platform::SetHostPlatform(
+  platform_gdb_server::PlatformRemoteGDBServer::CreateInstance(true,
+   &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp;
+  PlatformSP platform_sp;
+  Status error = debugger_sp->GetTargetList().CreateTarget(
+  *debugger_sp, "", arch, eLoadDependentsNo, platform

[Lldb-commits] [PATCH] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2019-12-18 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 234474.
paolosev set the repository for this revision to rG LLVM Github Monorepo.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71575/new/

https://reviews.llvm.org/D71575

Files:
  lldb/include/lldb/Utility/ArchSpec.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
  lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h
  lldb/source/Utility/ArchSpec.cpp
  lldb/unittests/ObjectFile/CMakeLists.txt
  lldb/unittests/ObjectFile/wasm/CMakeLists.txt
  lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp

Index: lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp
===
--- /dev/null
+++ lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp
@@ -0,0 +1,280 @@
+//===-- TestObjectFileWasm.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "Plugins/ObjectFile/WASM/ObjectFileWasm.h"
+#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
+#include "TestingSupport/TestUtilities.h"
+
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Reproducer.h"
+#include "llvm/Testing/Support/Error.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+using namespace lldb;
+
+class ObjectFileWasmTest : public testing::Test {
+public:
+  void SetUp() override {
+llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None));
+FileSystem::Initialize();
+HostInfo::Initialize();
+wasm::ObjectFileWasm::Initialize();
+  }
+
+  void TearDown() override {
+wasm::ObjectFileWasm::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+Reproducer::Terminate();
+  }
+};
+
+TEST_F(ObjectFileWasmTest, SectionsResolveConsistently) {
+  auto ExpectedFile = TestFile::fromYaml(R"(
+--- !WASM
+FileHeader:
+  Version: 0x0001
+Sections:
+  - Type:TYPE
+Signatures:
+  - Index:   0
+ParamTypes:
+  - I32
+ReturnTypes:
+  - I32
+  - Type:FUNCTION
+FunctionTypes:   [ 0 ]
+  - Type:TABLE
+Tables:
+  - ElemType:FUNCREF
+Limits:
+  Flags:   [ HAS_MAX ]
+  Initial: 0x0001
+  Maximum: 0x0001
+  - Type:MEMORY
+Memories:
+  - Initial: 0x0002
+  - Type:GLOBAL
+Globals:
+  - Index:   0
+Type:I32
+Mutable: true
+InitExpr:
+  Opcode:  I32_CONST
+  Value:   66560
+  - Type:EXPORT
+Exports:
+  - Name:memory
+Kind:MEMORY
+Index:   0
+  - Name:square
+Kind:FUNCTION
+Index:   0
+  - Type:CODE
+Functions:
+  - Index:   0
+Locals:
+  - Type:I32
+Count:   6
+Body:238080808000210141102102200120026B21032003200036020C200328020C2104200328020C2105200420056C210620060F0B
+  - Type:CUSTOM
+Name:name
+FunctionNames:
+  - Index:   0
+Name:square
+  - Type:CUSTOM
+Name:producers
+Languages:
+  - Name:C99
+Version: ''
+Tools:
+  - Name:clang
+Version: '10.0.0'
+  - Type:CUSTOM
+Name:external_debug_info
+Payload: 0F7371756172655F73796D2E7761736D
+...
+)");
+
+  ASSERT_THAT_EXPECTED(ExpectedFile, llvm::Succeeded());
+
+  ArchSpec arch("wasm32-unknown-unknown-wasm");
+  Platform::SetHostPlatform(
+  platform_gdb_server::PlatformRemoteGDBServer::CreateInstance(true,
+   &arch));
+
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  TargetSP target_sp;
+  PlatformSP platform_sp;
+  Status error = debugger_sp->GetTargetList().CreateTarget(
+  *debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
+  ASSERT_TRUE(target_sp);
+  ASSERT_TRUE(target_sp->GetArchitecture().IsValid(

[Lldb-commits] [PATCH] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

Another bug report for this: https://bugs.llvm.org/show_bug.cgi?id=44331 Please 
close when landing this.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71378/new/

https://reviews.llvm.org/D71378



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


[Lldb-commits] [lldb] d8a3194 - [lldb][NFC] Add unit test for persistent variable lookup with ClangExpressionDeclMap

2019-12-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2019-12-18T13:50:05+01:00
New Revision: d8a3194987301672fbd50f4e5703952381f0157c

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

LOG: [lldb][NFC] Add unit test for persistent variable lookup with 
ClangExpressionDeclMap

This adds a unit test for looking up persistent declarations in the scratch AST
context. Also adds the `GetPersistentDecl` hook to the ClangExpressionDeclMap
that this unit test can emulate looking up persistent variables without having
a lldb_private::Target.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
index 33867fb4d45a..232027668923 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -734,29 +734,33 @@ void ClangExpressionDeclMap::MaybeRegisterFunctionBody(
   }
 }
 
-void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
-  const ConstString name,
-  unsigned int current_id) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
+clang::NamedDecl *ClangExpressionDeclMap::GetPersistentDecl(ConstString name) {
   if (!m_parser_vars)
-return;
+return nullptr;
   Target *target = m_parser_vars->m_exe_ctx.GetTargetPtr();
   if (!target)
-return;
+return nullptr;
 
   ClangASTContext *scratch_clang_ast_context =
   ClangASTContext::GetScratch(*target);
 
   if (!scratch_clang_ast_context)
-return;
+return nullptr;
 
   ASTContext *scratch_ast_context = scratch_clang_ast_context->getASTContext();
 
   if (!scratch_ast_context)
-return;
+return nullptr;
+
+  return m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
+}
+
+void ClangExpressionDeclMap::SearchPersistenDecls(NameSearchContext &context,
+  const ConstString name,
+  unsigned int current_id) {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
-  NamedDecl *persistent_decl =
-  m_parser_vars->m_persistent_vars->GetPersistentDecl(name);
+  NamedDecl *persistent_decl = GetPersistentDecl(name);
 
   if (!persistent_decl)
 return;
@@ -1409,6 +1413,10 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls(
 if (name.GetStringRef().startswith("$__lldb"))
   return;
 
+// No ParserVars means we can't do register or variable lookup.
+if (!m_parser_vars)
+  return;
+
 ExpressionVariableSP pvar_sp(
 m_parser_vars->m_persistent_vars->GetVariable(name));
 

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
index 223fd3201097..41e41c1f1fef 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
@@ -283,6 +283,14 @@ class ClangExpressionDeclMap : public ClangASTSource {
 CompilerDeclContext &namespace_decl,
 unsigned int current_id);
 
+protected:
+  /// Retrieves the declaration with the given name from the storage of
+  /// persistent declarations.
+  ///
+  /// \return
+  /// A persistent decl with the given name or a nullptr.
+  virtual clang::NamedDecl *GetPersistentDecl(ConstString name);
+
 private:
   ExpressionVariableList
   m_found_entities; ///< All entities that were looked up for the parser.

diff  --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp 
b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
index 2d93a6120dbd..6fac168462b3 100644
--- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
+++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
@@ -11,12 +11,51 @@
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
+#include "lldb/Symbol/ClangUtil.h"
 #include "lldb/lldb-defines.h"
 #include "gtest/gtest.h"
 
 using namespace lldb_private;
 using namespace lldb;
 
+static std::unique_ptr createAST() {
+  return std::make_unique(HostInfo::GetTargetTriple());
+}
+
+namespace {
+struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap {
+  FakeClangExpressionDeclMap(const ClangASTImporterSP &importe

[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 234568.
JDevlieghere added a comment.

Implement Pavel's suggestion.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306

Files:
  lldb/cmake/modules/LLDBConfig.cmake

Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -24,40 +24,47 @@
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
+function(add_optional_dependency variable description package found)
+  set(${variable} "AUTO" CACHE STRING "${description} On, Off or Auto (default)")
+  string(TOUPPER "${${variable}}" ${variable})
+  if ("${${variable}}" STREQUAL "OFF")
+set(${variable} OFF PARENT_SCOPE)
+  else()
+if ("${${variable}}" STREQUAL "AUTO")
+  set(maybe_required)
+else()
+  set(maybe_required REQUIRED)
+endif()
+find_package(${package} ${maybe_required})
+# We could set ${variable} directory to ${${found}} but then the value is
+# TRUE/FALSE rather than ON/OFF.
+if (${${found}})
+  set(${variable} ON PARENT_SCOPE)
+else()
+  set(${variable} OFF PARENT_SCOPE)
+endif()
+  endif()
+endfunction()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." Curses CURSES_FOUND)
+
 set(default_enable_python ON)
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
 
 # Temporary support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_CURSES)
-  if (LLDB_DISABLE_CURSES)
-set(default_enable_curses OFF)
-  endif()
-endif()
 if (DEFINED LLDB_DISABLE_PYTHON)
   if (LLDB_DISABLE_PYTHON)
 set(default_enable_python OFF)
   endif()
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit ON)
-endif()
-
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
-elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+if(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
-option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." ${default_enable_libedit})
-option(LLDB_ENABLE_CURSES "Enable Curses integration." ${default_enable_curses})
 option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -120,12 +127,9 @@
   add_definitions( -DHAVE_ROUND )
 endif()
 
-
+# Check if we libedit capable of handling wide characters (built with
+# '--enable-widec').
 if (LLDB_ENABLE_LIBEDIT)
-  find_package(LibEdit REQUIRED)
-
-  # Check if we libedit capable of handling wide characters (built with
-  # '--enable-widec').
   set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
   set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
   check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
@@ -141,7 +145,6 @@
   set(CMAKE_EXTRA_INCLUDE_FILES)
 endif()
 
-
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
@@ -498,10 +501,10 @@
 endif()
 
 if (LLDB_ENABLE_CURSES)
-find_package(Curses REQUIRED)
 find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel library")
 if (NOT CURSES_PANEL_LIBRARY)
-message(FATAL_ERROR "A required curses' panel library not found.")
+  set(LLDB_ENABLE_CURSES OFF)
+  message(WARNING "Curses panel library not found.")
 endif ()
 endif ()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Michał Górny via Phabricator via lldb-commits
mgorny requested changes to this revision.
mgorny added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:30
+  string(TOUPPER "${${variable}}" ${variable})
+  if ("${${variable}}" STREQUAL "OFF")
+set(${variable} OFF PARENT_SCOPE)

Any reason not to use the regular `NOT` logic here? It would make it accept all 
kinds of false values just like you accept all kinds of true values below.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306



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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 234584.
JDevlieghere marked an inline comment as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306

Files:
  lldb/cmake/modules/LLDBConfig.cmake

Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -24,40 +24,48 @@
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
+function(add_optional_dependency variable description package found)
+  set(${variable} "AUTO" CACHE STRING "${description} On, Off or Auto (default)")
+  string(TOUPPER "${${variable}}" ${variable})
+
+  if ("${${variable}}" STREQUAL "AUTO")
+set(maybe_required)
+  elseif("${${variable}}" STREQUAL "ON")
+set(maybe_required REQUIRED)
+  else()
+set(${variable} OFF PARENT_SCOPE)
+return()
+  endif()
+
+  find_package(${package} ${maybe_required})
+  # We could set ${variable} directory to ${${found}} but then the value is
+  # TRUE/FALSE rather than ON/OFF.
+  if (${${found}})
+set(${variable} ON PARENT_SCOPE)
+  else()
+set(${variable} OFF PARENT_SCOPE)
+  endif()
+endfunction()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." Curses CURSES_FOUND)
+
 set(default_enable_python ON)
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
 
 # Temporary support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_CURSES)
-  if (LLDB_DISABLE_CURSES)
-set(default_enable_curses OFF)
-  endif()
-endif()
 if (DEFINED LLDB_DISABLE_PYTHON)
   if (LLDB_DISABLE_PYTHON)
 set(default_enable_python OFF)
   endif()
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit ON)
-endif()
-
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
-elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+if(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
-option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." ${default_enable_libedit})
-option(LLDB_ENABLE_CURSES "Enable Curses integration." ${default_enable_curses})
 option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -120,12 +128,9 @@
   add_definitions( -DHAVE_ROUND )
 endif()
 
-
+# Check if we libedit capable of handling wide characters (built with
+# '--enable-widec').
 if (LLDB_ENABLE_LIBEDIT)
-  find_package(LibEdit REQUIRED)
-
-  # Check if we libedit capable of handling wide characters (built with
-  # '--enable-widec').
   set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
   set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
   check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
@@ -141,7 +146,6 @@
   set(CMAKE_EXTRA_INCLUDE_FILES)
 endif()
 
-
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
@@ -498,10 +502,10 @@
 endif()
 
 if (LLDB_ENABLE_CURSES)
-find_package(Curses REQUIRED)
 find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel library")
 if (NOT CURSES_PANEL_LIBRARY)
-message(FATAL_ERROR "A required curses' panel library not found.")
+  set(LLDB_ENABLE_CURSES OFF)
+  message(WARNING "Curses panel library not found.")
 endif ()
 endif ()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-18 Thread Nathan Lanza via Phabricator via lldb-commits
lanza added a comment.

Great point! Fixed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71633/new/

https://reviews.llvm.org/D71633



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


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-18 Thread Nathan Lanza via Phabricator via lldb-commits
lanza updated this revision to Diff 234586.
lanza added a comment.

fixup according to Greg's requests


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71633/new/

https://reviews.llvm.org/D71633

Files:
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1199,14 +1199,18 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
-// if any code in LLDB prints to the debugger file handles, the output and
-// error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
-g_vsc.debugger.SetOutputFileHandle(out, true);
-g_vsc.debugger.SetErrorFileHandle(out, false);
+  if (!g_vsc.input.descriptor.m_is_socket) {
+FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, 
"w");
+if (out) {
+  // If the input and output descriptors are STDIN and STDOUT then we need
+  // to set the output and error file handles to redirect into nothing
+  // otherwise if any code in LLDB prints to the debugger file handles, the
+  // output and error file handles are initialized to STDOUT and STDERR and
+  // any output will kill our debug session. However, if the communication
+  // is via sockets then we can leave these open.
+  g_vsc.debugger.SetOutputFileHandle(out, true);
+  g_vsc.debugger.SetErrorFileHandle(out, false);
+}
   }
 
   g_vsc.target = g_vsc.debugger.CreateTarget(nullptr);


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1199,14 +1199,18 @@
   // before we are given an executable to launch in a "launch" request, or a
   // executable when attaching to a process by process ID in a "attach"
   // request.
-  FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
-  if (out) {
-// Set the output and error file handles to redirect into nothing otherwise
-// if any code in LLDB prints to the debugger file handles, the output and
-// error file handles are initialized to STDOUT and STDERR and any output
-// will kill our debug session.
-g_vsc.debugger.SetOutputFileHandle(out, true);
-g_vsc.debugger.SetErrorFileHandle(out, false);
+  if (!g_vsc.input.descriptor.m_is_socket) {
+FILE *out = llvm::sys::RetryAfterSignal(nullptr, fopen, dev_null_path, "w");
+if (out) {
+  // If the input and output descriptors are STDIN and STDOUT then we need
+  // to set the output and error file handles to redirect into nothing
+  // otherwise if any code in LLDB prints to the debugger file handles, the
+  // output and error file handles are initialized to STDOUT and STDERR and
+  // any output will kill our debug session. However, if the communication
+  // is via sockets then we can leave these open.
+  g_vsc.debugger.SetOutputFileHandle(out, true);
+  g_vsc.debugger.SetErrorFileHandle(out, false);
+}
   }
 
   g_vsc.target = g_vsc.debugger.CreateTarget(nullptr);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:33
+set(maybe_required)
+  elseif("${${variable}}" STREQUAL "ON")
+set(maybe_required REQUIRED)

Now you broke it the other way around. Is there any reason you can't just 
`${${variable}}` here?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306



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


[Lldb-commits] [PATCH] D71633: [lldb-vscode] Only close the debuggers in/out when DAP is over stdin/out

2019-12-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

It would be nice if we could test this works as well. We would need to spawn 
the lldb-vscode manually and specify a socket, connect with a socket with the 
vscode.py test stuff, and get able to get some output from it once the session 
is up and running. Something like sending:

  `script print("stdout outut")

to the debugger console after we stop (note the leading backtick so it will not 
evaluate an expression, but it will cause STDOUT to happen). Make sure the 
session doesn't die due to the output, and make sure we get the output from the 
process we spawned in the test suite


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71633/new/

https://reviews.llvm.org/D71633



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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:33
+set(maybe_required)
+  elseif("${${variable}}" STREQUAL "ON")
+set(maybe_required REQUIRED)

mgorny wrote:
> Now you broke it the other way around. Is there any reason you can't just 
> `${${variable}}` here?
Can you please describe the desired behavior rather than the symptom? I must be 
missing what you're trying to achieve. :-) 

Maybe there's a gap in my CMake knowledge, but wouldn't `if(${${variable}})` 
evaluate to `true` for **any** string value? 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306



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


[Lldb-commits] [lldb] e194d89 - [lldb/MachO] "Fix" intentional out-of-bounds error (NFC)

2019-12-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-18T12:54:04-08:00
New Revision: e194d890126007bc8e5acb655f007ef76002edb7

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

LOG: [lldb/MachO] "Fix" intentional out-of-bounds error (NFC)

Remove the hack that populates the cpsr register in the gpr struct by
writing past the end of the array. This was tripping up ASan.

Patch by: Reva Cuthbertson

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 57c43de0c945..ef6ad1696c47 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -479,12 +479,13 @@ class RegisterContextDarwin_arm_Mach : public 
RegisterContextDarwin_arm {
   switch (flavor) {
   case GPRAltRegSet:
   case GPRRegSet:
-for (uint32_t i = 0; i < count; ++i) {
+// On ARM, the CPSR register is also included in the count but it is
+// not included in gpr.r so loop until (count-1).
+for (uint32_t i = 0; i < (count - 1); ++i) {
   gpr.r[i] = data.GetU32(&offset);
 }
-
-// Note that gpr.cpsr is also copied by the above loop; this loop
-// technically extends one element past the end of the gpr.r[] array.
+// Save cpsr explicitly.
+gpr.cpsr = data.GetU32(&offset);
 
 SetError(GPRRegSet, Read, 0);
 offset = next_thread_state;

diff  --git a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
index 94eebabfe2e0..173e66904151 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextDarwin_arm.cpp
@@ -1140,10 +1140,11 @@ bool RegisterContextDarwin_arm::ReadRegister(const 
RegisterInfo *reg_info,
   case gpr_sp:
   case gpr_lr:
   case gpr_pc:
-  case gpr_cpsr:
 value.SetUInt32(gpr.r[reg - gpr_r0]);
 break;
-
+  case gpr_cpsr:
+value.SetUInt32(gpr.cpsr);
+break;
   case fpu_s0:
   case fpu_s1:
   case fpu_s2:



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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:33
+set(maybe_required)
+  elseif("${${variable}}" STREQUAL "ON")
+set(maybe_required REQUIRED)

JDevlieghere wrote:
> mgorny wrote:
> > Now you broke it the other way around. Is there any reason you can't just 
> > `${${variable}}` here?
> Can you please describe the desired behavior rather than the symptom? I must 
> be missing what you're trying to achieve. :-) 
> 
> Maybe there's a gap in my CMake knowledge, but wouldn't `if(${${variable}})` 
> evaluate to `true` for **any** string value? 
The desired behavior is to keep standard CMake behavior for any value other 
than `AUTO`, and by standard behavior I mean: 
https://cmake.org/cmake/help/v3.0/command/if.html the first definition on the 
list.

Particularly, in Gentoo we default to passing `yes`/`no` for historical 
reasons. I would find it irritating if different places in LLVM accepted 
different constants.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306



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


[Lldb-commits] [PATCH] D71313: [AST] Split parent map traversal logic into ParentMapContext.h

2019-12-18 Thread Reid Kleckner via Phabricator via lldb-commits
rnk planned changes to this revision.
rnk marked an inline comment as done.
rnk added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:653
   template  DynTypedNodeList getParents(const NodeT &Node) {
 return getParents(ast_type_traits::DynTypedNode::create(Node));
   }

Turns out this only worked for me locally because of delayed template parsing. 
I will have to think harder about how to preserve the API while not requiring 
complete types here. I could make an overload set, but I worry it will be 
inconveniently large.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71313/new/

https://reviews.llvm.org/D71313



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


Re: [Lldb-commits] [lldb] 22caa3c - [lldb] Add unit test for ClangASTImporter

2019-12-18 Thread Jordan Rupprecht via lldb-commits
We're seeing some odd test failures internally caused by this patch. For
whatever reason (test ordering based on hashing, I guess), we're running
the tests in a different order than upstream, and TestClangASTContext
crashes when TestClangASTImporter runs first.

By default, it seems like TestClangASTContext happens to run first so the
failure isn't usually seen, but the failure can be reproduced with
--gtest_repeat=2
$ ninja SymbolTests && tools/lldb/unittests/Symbol/SymbolTests
'--gtest_filter=TestClangAST*' --gtest_repeat=2
Repeating all tests (iteration 1) . . .

Note: Google Test filter = TestClangAST*
[[ TestClangASTContext passes ]]
[[ TestClangASTImporter passes ]]

Repeating all tests (iteration 2) . . .

Note: Google Test filter = TestClangAST*
[==] Running 21 tests from 2 test cases.
[--] Global test environment set-up.
[--] 13 tests from TestClangASTContext
[ RUN  ] TestClangASTContext.TestGetBasicTypeFromEnum
SymbolTests: /src/llvm-project/llvm/../clang/include/clang/AST/Type.h:669:
const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const:
Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
 #0 0x0215e5a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:548:11
 #1 0x0215e749 PrintStackTraceSignalHandler(void*)
/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:609:1
 #2 0x0215d02b llvm::sys::RunSignalHandlers()
/src/llvm-project/llvm/lib/Support/Signals.cpp:67:5
 #3 0x0215eec5 SignalHandler(int)
/src/llvm-project/llvm/lib/Support/Unix/Signals.inc:390:1
 #4 0x7f819b4523a0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
 #5 0x7f819a3decfb gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36cfb)
 #6 0x7f819a3c98ad abort (/lib/x86_64-linux-gnu/libc.so.6+0x218ad)
 #7 0x7f819a3c977f __tls_get_addr
(/lib/x86_64-linux-gnu/libc.so.6+0x2177f)
 #8 0x7f819a3d7542 (/lib/x86_64-linux-gnu/libc.so.6+0x2f542)
 #9 0x020531d7 clang::QualType::getCommonPtr() const
/src/llvm-project/llvm/../clang/include/clang/AST/Type.h:0:5
#10 0x020529cc clang::QualType::getCanonicalType() const
/src/llvm-project/llvm/../clang/include/clang/AST/Type.h:6231:20
#11 0x02052879 clang::ASTContext::getCanonicalType(clang::QualType)
const /src/llvm-project/llvm/../clang/include/clang/AST/ASTContext.h:2296:40
#12 0x02050960 clang::ASTContext::hasSameType(clang::QualType,
clang::QualType) const
/src/llvm-project/llvm/../clang/include/clang/AST/ASTContext.h:2312:12
#13 0x02047365
TestClangASTContext_TestGetBasicTypeFromEnum_Test::TestBody()
/src/llvm-project/lldb/unittests/Symbol/TestClangASTContext.cpp:57:3
<...>

Does the failure make sense to you?
No need to revert the patch -- we already have the test disabled
internally, though we would like to re-enable it

On Mon, Dec 16, 2019 at 3:44 AM Raphael Isemann via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

>
> Author: Raphael Isemann
> Date: 2019-12-16T12:43:55+01:00
> New Revision: 22caa3cfbcf5762a47acc40c425d9fe0c40da621
>
> URL:
> https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621
> DIFF:
> https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621.diff
>
> LOG: [lldb] Add unit test for ClangASTImporter
>
> Added:
> lldb/unittests/Symbol/TestClangASTImporter.cpp
>
> Modified:
> lldb/unittests/Symbol/CMakeLists.txt
>
> Removed:
>
>
>
>
> 
> diff  --git a/lldb/unittests/Symbol/CMakeLists.txt
> b/lldb/unittests/Symbol/CMakeLists.txt
> index aa86986f4e0e..02875b8b53c1 100644
> --- a/lldb/unittests/Symbol/CMakeLists.txt
> +++ b/lldb/unittests/Symbol/CMakeLists.txt
> @@ -2,6 +2,7 @@ add_lldb_unittest(SymbolTests
>LocateSymbolFileTest.cpp
>PostfixExpressionTest.cpp
>TestClangASTContext.cpp
> +  TestClangASTImporter.cpp
>TestDWARFCallFrameInfo.cpp
>TestType.cpp
>TestLineEntry.cpp
>
> diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp
> b/lldb/unittests/Symbol/TestClangASTImporter.cpp
> new file mode 100644
> index ..17a0dfb6a348
> --- /dev/null
> +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
> @@ -0,0 +1,220 @@
> +//===-- TestClangASTImporter.cpp *- C++
> -*-===//
> +//
> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM
> Exceptions.
> +// See https://llvm.org/LICENSE.txt for license information.
> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
> +//
>
> +//===--===//
> +
> +#include "gtest/gtest.h"
> +
> +#include "lldb/Host/FileSystem.h"
> +#include "lldb/Host/HostInfo.h"
> +#include "lldb/Symbol/ClangASTContext.h"
> +#include "lldb/Symbol/ClangASTImporter.h"
> +#include "lldb/Symbol/ClangASTMetadata.h"
> +#include "lldb/Symbol/ClangUtil.h"
> +#

Re: [Lldb-commits] [lldb] 22caa3c - [lldb] Add unit test for ClangASTImporter

2019-12-18 Thread Raphael “Teemperor” Isemann via lldb-commits
I’m actually already investigating that because I see the same failure when I 
moved the ::Initialize and ::Terminate calls to SetUp and TearDown as part of 
D71630. I’ll reply here when I have a fix, thanks!

> On Dec 18, 2019, at 10:54 PM, Jordan Rupprecht  wrote:
> 
> We're seeing some odd test failures internally caused by this patch. For 
> whatever reason (test ordering based on hashing, I guess), we're running the 
> tests in a different order than upstream, and TestClangASTContext crashes 
> when TestClangASTImporter runs first.
> 
> By default, it seems like TestClangASTContext happens to run first so the 
> failure isn't usually seen, but the failure can be reproduced with 
> --gtest_repeat=2
> $ ninja SymbolTests && tools/lldb/unittests/Symbol/SymbolTests 
> '--gtest_filter=TestClangAST*' --gtest_repeat=2
> Repeating all tests (iteration 1) . . .
> 
> Note: Google Test filter = TestClangAST*
> [[ TestClangASTContext passes ]]
> [[ TestClangASTImporter passes ]]
> 
> Repeating all tests (iteration 2) . . .
> 
> Note: Google Test filter = TestClangAST*
> [==] Running 21 tests from 2 test cases.
> [--] Global test environment set-up.
> [--] 13 tests from TestClangASTContext
> [ RUN  ] TestClangASTContext.TestGetBasicTypeFromEnum
> SymbolTests: /src/llvm-project/llvm/../clang/include/clang/AST/Type.h:669: 
> const clang::ExtQualsTypeCommonBase *clang::QualType::getCommonPtr() const: 
> Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed.
>  #0 0x0215e5a7 llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
> /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:548:11
>  #1 0x0215e749 PrintStackTraceSignalHandler(void*) 
> /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:609:1
>  #2 0x0215d02b llvm::sys::RunSignalHandlers() 
> /src/llvm-project/llvm/lib/Support/Signals.cpp:67:5
>  #3 0x0215eec5 SignalHandler(int) 
> /src/llvm-project/llvm/lib/Support/Unix/Signals.inc:390:1
>  #4 0x7f819b4523a0 __restore_rt 
> (/lib/x86_64-linux-gnu/libpthread.so.0+0x123a0)
>  #5 0x7f819a3decfb gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36cfb)
>  #6 0x7f819a3c98ad abort (/lib/x86_64-linux-gnu/libc.so.6+0x218ad)
>  #7 0x7f819a3c977f __tls_get_addr 
> (/lib/x86_64-linux-gnu/libc.so.6+0x2177f)
>  #8 0x7f819a3d7542 (/lib/x86_64-linux-gnu/libc.so.6+0x2f542)
>  #9 0x020531d7 clang::QualType::getCommonPtr() const 
> /src/llvm-project/llvm/../clang/include/clang/AST/Type.h:0:5
> #10 0x020529cc clang::QualType::getCanonicalType() const 
> /src/llvm-project/llvm/../clang/include/clang/AST/Type.h:6231:20
> #11 0x02052879 clang::ASTContext::getCanonicalType(clang::QualType) 
> const /src/llvm-project/llvm/../clang/include/clang/AST/ASTContext.h:2296:40
> #12 0x02050960 clang::ASTContext::hasSameType(clang::QualType, 
> clang::QualType) const 
> /src/llvm-project/llvm/../clang/include/clang/AST/ASTContext.h:2312:12
> #13 0x02047365 
> TestClangASTContext_TestGetBasicTypeFromEnum_Test::TestBody() 
> /src/llvm-project/lldb/unittests/Symbol/TestClangASTContext.cpp:57:3
> <...>
> 
> Does the failure make sense to you?
> No need to revert the patch -- we already have the test disabled internally, 
> though we would like to re-enable it
> 
> On Mon, Dec 16, 2019 at 3:44 AM Raphael Isemann via lldb-commits 
> mailto:lldb-commits@lists.llvm.org>> wrote:
> 
> Author: Raphael Isemann
> Date: 2019-12-16T12:43:55+01:00
> New Revision: 22caa3cfbcf5762a47acc40c425d9fe0c40da621
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621
>  
> 
> DIFF: 
> https://github.com/llvm/llvm-project/commit/22caa3cfbcf5762a47acc40c425d9fe0c40da621.diff
>  
> 
> 
> LOG: [lldb] Add unit test for ClangASTImporter
> 
> Added: 
> lldb/unittests/Symbol/TestClangASTImporter.cpp
> 
> Modified: 
> lldb/unittests/Symbol/CMakeLists.txt
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/unittests/Symbol/CMakeLists.txt 
> b/lldb/unittests/Symbol/CMakeLists.txt
> index aa86986f4e0e..02875b8b53c1 100644
> --- a/lldb/unittests/Symbol/CMakeLists.txt
> +++ b/lldb/unittests/Symbol/CMakeLists.txt
> @@ -2,6 +2,7 @@ add_lldb_unittest(SymbolTests
>LocateSymbolFileTest.cpp
>PostfixExpressionTest.cpp
>TestClangASTContext.cpp
> +  TestClangASTImporter.cpp
>TestDWARFCallFrameInfo.cpp
>TestType.cpp
>TestLineEntry.cpp
> 
> diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp 
> b/lldb/unittests/Symbol/TestClangASTImporter.cpp
> new file mode 100644
> index ..17a0dfb6a348
> --- /dev/null
> +++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
> @@ -0,0 +1,220 @@
> +//===-- TestClangASTImporter.cpp --

[Lldb-commits] [PATCH] D71378: Modifying ImportDeclContext(...) to ensure that we complete each FieldDecl of a RecordDecl when we are importing the definiton

2019-12-18 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik updated this revision to Diff 234619.
shafik marked 3 inline comments as done.
shafik added a comment.

- Fix typo
- Adjust error handing
- clang-format test


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71378/new/

https://reviews.llvm.org/D71378

Files:
  clang/lib/AST/ASTImporter.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  
lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
  
lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py

Index: lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
===
--- lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
@@ -1,4 +1,4 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
-lldbinline.MakeInlineTest(__file__, globals(), [decorators.skipIf(bugnumber="rdar://53756116")])
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/main.cpp
@@ -0,0 +1,39 @@
+// This is a reproducer for a crash in codegen. It happens when we have a
+// RecordDecl used in an expression and one of the FieldDecl are not complete.
+// This case happens when:
+// - A RecordDecl (E) has a FieldDecl which is a reference member variable
+// - The underlying type of the FieldDec is a TypedefDecl
+// - The typedef refers to a ClassTemplateSpecialization (DWrapper)
+// - The typedef is not present in the DeclContext of B
+// - The typedef shows up as a return value of a member function of E (f())
+template  struct DWrapper {};
+
+struct D {};
+
+namespace NS {
+typedef DWrapper DW;
+}
+
+struct B {
+  NS::DW spd;
+  int a = 0;
+};
+
+struct E {
+  E(B &b) : b_ref(b) {}
+  NS::DW f() { return {}; };
+  void g() {
+return; //%self.expect("p b_ref", substrs=['(B) $0 =', '(spd = NS::DW', 'a = 0)'])
+  }
+
+  B &b_ref;
+};
+
+int main() {
+  B b;
+  E e(b);
+
+  e.g();
+
+  return 0;
+}
Index: lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals(), [])
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1683,7 +1683,34 @@
   Error ChildErrors = Error::success();
   for (auto *From : FromDC->decls()) {
 ExpectedDecl ImportedOrErr = import(From);
-if (!ImportedOrErr) {
+
+// If we are in the process of ImportDefinition(...) for a RecordDecl we
+// want to make sure that we are also completing each FieldDecl. There
+// are currently cases where this does not happen and this is correctness
+// fix since operations such as code generation will expect this to be so.
+if (ImportedOrErr) {
+  FieldDecl *FieldFrom = dyn_cast_or_null(From);
+  Decl *ImportedDecl = (Decl*)*ImportedOrErr;
+  FieldDecl *FieldTo = dyn_cast_or_null(ImportedDecl);
+  if (FieldFrom && FieldTo) {
+const RecordType *RecordFrom = FieldFrom->getType()->getAs();
+const RecordType *RecordTo = FieldTo->getType()->getAs();
+if (RecordFrom && RecordTo) {
+  RecordDecl *FromRecordDecl = RecordFrom->getDecl();
+  RecordDecl *ToRecordDecl = RecordTo->getDecl();
+
+  if (FromRecordDecl->isCompleteDefinition() &&
+  !ToRecordDecl->isCompleteDefinition()) {
+Error Err = ImportDefinition(FromRecordDecl, ToRecordDecl);
+
+if (Err && AccumulateChildErrors)
+  ChildErrors =  joinErrors(std::move(ChildErrors), std::move(Err));
+else
+  consumeError(std::move(Err));
+  }
+}
+  }
+} else {
   if (AccumulateChildErrors)
 ChildErrors =
 joinErrors(std::move(ChildErrors), ImportedOrErr.takeError());
__

[Lldb-commits] [lldb] 997bc8b - Add prototype for a function we call.

2019-12-18 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2019-12-18T14:18:52-08:00
New Revision: 997bc8b2e6b973dd8c9b17414310cac822543f79

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

LOG: Add prototype for a function we call.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
index ab0b6f5bd5e0..f2dde8155186 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-caching/a.c
@@ -1,5 +1,7 @@
 typedef float float4;
 
+int a();
+
 int main() {
   float4 f = 4.0f;
   // break here



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


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 234624.
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

Accept usual constant in addition to auto.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306

Files:
  lldb/cmake/modules/LLDBConfig.cmake

Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -24,40 +24,48 @@
   set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
+function(add_optional_dependency variable description package found)
+  set(${variable} "AUTO" CACHE STRING "${description} On, Off or Auto (default)")
+  string(TOUPPER "${${variable}}" ${variable})
+
+  if("${${variable}}" STREQUAL "AUTO")
+set(maybe_required)
+  elseif(${${variable}})
+set(maybe_required REQUIRED)
+  else()
+set(${variable} OFF PARENT_SCOPE)
+return()
+  endif()
+
+  find_package(${package} ${maybe_required})
+  # We could set ${variable} directory to ${${found}} but then the value is
+  # TRUE/FALSE rather than ON/OFF.
+  if (${${found}})
+set(${variable} ON PARENT_SCOPE)
+  else()
+set(${variable} OFF PARENT_SCOPE)
+  endif()
+endfunction()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." Curses CURSES_FOUND)
+
 set(default_enable_python ON)
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
 
 # Temporary support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_CURSES)
-  if (LLDB_DISABLE_CURSES)
-set(default_enable_curses OFF)
-  endif()
-endif()
 if (DEFINED LLDB_DISABLE_PYTHON)
   if (LLDB_DISABLE_PYTHON)
 set(default_enable_python OFF)
   endif()
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit ON)
-endif()
-
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
-elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+if(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
-option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." ${default_enable_libedit})
-option(LLDB_ENABLE_CURSES "Enable Curses integration." ${default_enable_curses})
 option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON)
@@ -120,12 +128,9 @@
   add_definitions( -DHAVE_ROUND )
 endif()
 
-
+# Check if we libedit capable of handling wide characters (built with
+# '--enable-widec').
 if (LLDB_ENABLE_LIBEDIT)
-  find_package(LibEdit REQUIRED)
-
-  # Check if we libedit capable of handling wide characters (built with
-  # '--enable-widec').
   set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES})
   set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS})
   check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR)
@@ -141,7 +146,6 @@
   set(CMAKE_EXTRA_INCLUDE_FILES)
 endif()
 
-
 # On Windows, we can't use the normal FindPythonLibs module that comes with CMake,
 # for a number of reasons.
 # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was
@@ -498,10 +502,10 @@
 endif()
 
 if (LLDB_ENABLE_CURSES)
-find_package(Curses REQUIRED)
 find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel library")
 if (NOT CURSES_PANEL_LIBRARY)
-message(FATAL_ERROR "A required curses' panel library not found.")
+  set(LLDB_ENABLE_CURSES OFF)
+  message(WARNING "Curses panel library not found.")
 endif ()
 endif ()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71306: [RFC] Change how we deal with optional dependencies

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:33
+set(maybe_required)
+  elseif("${${variable}}" STREQUAL "ON")
+set(maybe_required REQUIRED)

mgorny wrote:
> JDevlieghere wrote:
> > mgorny wrote:
> > > Now you broke it the other way around. Is there any reason you can't just 
> > > `${${variable}}` here?
> > Can you please describe the desired behavior rather than the symptom? I 
> > must be missing what you're trying to achieve. :-) 
> > 
> > Maybe there's a gap in my CMake knowledge, but wouldn't 
> > `if(${${variable}})` evaluate to `true` for **any** string value? 
> The desired behavior is to keep standard CMake behavior for any value other 
> than `AUTO`, and by standard behavior I mean: 
> https://cmake.org/cmake/help/v3.0/command/if.html the first definition on the 
> list.
> 
> Particularly, in Gentoo we default to passing `yes`/`no` for historical 
> reasons. I would find it irritating if different places in LLVM accepted 
> different constants.
Got it, thanks for the explanation!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71306/new/

https://reviews.llvm.org/D71306



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


[Lldb-commits] [lldb] 48999eb - [lldb/test] Move script interpreter tests

2019-12-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-18T15:44:07-08:00
New Revision: 48999eb398ebec72fdf7194f5d2605dd3c799caf

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

LOG: [lldb/test] Move script interpreter tests

Create a new test for lldb launched without a script interpreter and
move it under a new `ScriptInterpreter` directory. Also move
crashlog.test there for consistency.

Added: 
lldb/test/Shell/ScriptInterpreter/None/none.test
lldb/test/Shell/ScriptInterpreter/Python/crashlog.test

Modified: 


Removed: 
lldb/test/Shell/Python/crashlog.test



diff  --git a/lldb/test/Shell/ScriptInterpreter/None/none.test 
b/lldb/test/Shell/ScriptInterpreter/None/none.test
new file mode 100644
index ..d6ef8d428732
--- /dev/null
+++ b/lldb/test/Shell/ScriptInterpreter/None/none.test
@@ -0,0 +1,2 @@
+# RUN: %lldb --script-language none -o 'script' 2>&1 | FileCheck %s
+# CHECK: error: the script-lang setting is set to none - scripting not 
available

diff  --git a/lldb/test/Shell/Python/crashlog.test 
b/lldb/test/Shell/ScriptInterpreter/Python/crashlog.test
similarity index 96%
rename from lldb/test/Shell/Python/crashlog.test
rename to lldb/test/Shell/ScriptInterpreter/Python/crashlog.test
index 37e0e8c5740d..047cb80bf2f7 100644
--- a/lldb/test/Shell/Python/crashlog.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/crashlog.test
@@ -1,7 +1,7 @@
 # -*- python 
-*-
 # REQUIRES: system-darwin
-# DEBUG: cd %S/../../../examples/python && cat %s | %lldb && false
-# RUN: cd %S/../../../examples/python && cat %s | %lldb | FileCheck %s
+# DEBUG: cd %S/../../../../examples/python && cat %s | %lldb && false
+# RUN: cd %S/../../../../examples/python && cat %s | %lldb | FileCheck %s
 # CHECK-LABEL: {{S}}KIP BEYOND CHECKS
 script
 import crashlog



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


[Lldb-commits] [lldb] 7026b34 - make err msg in MachSymtabSectionInfo::GetSection clear about the file

2019-12-18 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2019-12-18T16:13:17-08:00
New Revision: 7026b34702f3f71ff157876831f29c76b3cb8bb1

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

LOG: make err msg in MachSymtabSectionInfo::GetSection clear about the file

This error message didn't specify which file was malformed, so
there's some hunting-around required if it comes up.  We have the
filename; include it in the error message.

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index ef6ad1696c47..e730aafbd3e2 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1865,9 +1865,15 @@ class MachSymtabSectionInfo {
   m_section_infos[n_sect].vm_range.SetByteSize(
   section_sp->GetByteSize());
 } else {
+  const char *filename = "";
+  SectionSP first_section_sp(m_section_list->GetSectionAtIndex(0));
+  if (first_section_sp)
+filename = 
first_section_sp->GetObjectFile()->GetFileSpec().GetPath().c_str();
+
   Host::SystemLog(Host::eSystemLogError,
-  "error: unable to find section for section %u\n",
-  n_sect);
+  "error: unable to find section %d for a symbol in 
%s, corrupt file?\n",
+  n_sect, 
+  filename);
 }
   }
   if (m_section_infos[n_sect].vm_range.Contains(file_addr)) {



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


[Lldb-commits] [PATCH] D71234: [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 234637.
JDevlieghere added a comment.

- Rebase
- Add test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71234/new/

https://reviews.llvm.org/D71234

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Core/IOHandler.h
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/test/CMakeLists.txt
  lldb/test/Shell/ScriptInterpreter/Lua/lua.test
  lldb/test/Shell/lit.cfg.py
  lldb/test/Shell/lit.site.cfg.py.in
  lldb/unittests/ScriptInterpreter/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp

Index: lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
@@ -0,0 +1,62 @@
+//===-- LuaTests.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Target/Platform.h"
+#include "lldb/Utility/Reproducer.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+using namespace lldb;
+
+namespace {
+class ScriptInterpreterTest : public ::testing::Test {
+public:
+  void SetUp() override {
+llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None));
+FileSystem::Initialize();
+HostInfo::Initialize();
+
+// Pretend Linux is the host platform.
+platform_linux::PlatformLinux::Initialize();
+ArchSpec arch("powerpc64-pc-linux");
+Platform::SetHostPlatform(
+platform_linux::PlatformLinux::CreateInstance(true, &arch));
+  }
+  void TearDown() override {
+platform_linux::PlatformLinux::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+Reproducer::Terminate();
+  }
+};
+} // namespace
+
+TEST_F(ScriptInterpreterTest, Plugin) {
+  EXPECT_EQ(ScriptInterpreterLua::GetPluginNameStatic(), "script-lua");
+  EXPECT_EQ(ScriptInterpreterLua::GetPluginDescriptionStatic(),
+"Lua script interpreter");
+}
+
+TEST_F(ScriptInterpreterTest, ExecuteOneLine) {
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);
+
+  ScriptInterpreterLua script_interpreter(*debugger_sp);
+  CommandReturnObject result;
+  EXPECT_TRUE(script_interpreter.ExecuteOneLine("foo = 1", &result));
+  EXPECT_FALSE(script_interpreter.ExecuteOneLine("nil = foo", &result));
+  EXPECT_TRUE(result.GetErrorData().startswith(
+  "error: lua failed attempting to evaluate 'nil = foo'"));
+}
Index: lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_lldb_unittest(ScriptInterpreterLuaTests
+  LuaTests.cpp
+
+  LINK_LIBS
+lldbHost
+lldbPluginScriptInterpreterLua
+lldbPluginPlatformLinux
+LLVMTestingSupport
+  LINK_COMPONENTS
+Support
+  )
\ No newline at end of file
Index: lldb/unittests/ScriptInterpreter/CMakeLists.txt
===
--- lldb/unittests/ScriptInterpreter/CMakeLists.txt
+++ lldb/unittests/ScriptInterpreter/CMakeLists.txt
@@ -1,3 +1,6 @@
 if (LLDB_ENABLE_PYTHON)
   add_subdirectory(Python)
 endif()
+if (LLDB_ENABLE_LUA)
+  add_subdirectory(Lua)
+endif()
Index: lldb/test/Shell/lit.site.cfg.py.in
===
--- lldb/test/Shell/lit.site.cfg.py.in
+++ lldb/test/Shell/lit.site.cfg.py.in
@@ -19,6 +19,7 @@
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.lldb_bitness = 64 if @LLDB_IS_64_BITS@ else 32
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
+config.lldb_enable_lua = @LLDB_ENABLE_LUA@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 # The shell tests use their own module caches.
 config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-shell")
Index: lldb/test/Shell/lit.cfg.py
===
--- lldb/test/Shell/lit.cfg.py
+++ lldb/test/Shell/lit.cfg.py
@@ -103,6 +103,9 @@
 if config.lldb_enable_python:
 config.available_features.add('python')
 
+if config.lldb_enable_lua:
+config.available_features.add('lua')
+
 if config.lldb_enable_lzma:
 config.available_features.add('lzma')
 
Index: lldb/test

[Lldb-commits] [PATCH] D71235: [lldb/Lua] Generate Lua Bindings and Make Them Available to the Script Interpreter

2019-12-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 234638.
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

- Rebase
- Move wrapper to API
- Add test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71235/new/

https://reviews.llvm.org/D71235

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/lldb_lua.swig
  lldb/source/API/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/test/Shell/ScriptInterpreter/Lua/bindings.test

Index: lldb/test/Shell/ScriptInterpreter/Lua/bindings.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/bindings.test
@@ -0,0 +1,6 @@
+# REQUIRES: lua
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+debugger = lldb.SBDebugger.Create()
+print(string.format("debugger is valid: %s", debugger:IsValid()))
+# CHECK: debugger is valid: true
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -26,6 +26,10 @@
 
 #include 
 
+extern "C" {
+int luaopen_lldb(lua_State *L);
+}
+
 using namespace lldb;
 using namespace lldb_private;
 
@@ -34,6 +38,7 @@
   Lua() : m_lua_state(luaL_newstate()) {
 assert(m_lua_state);
 luaL_openlibs(m_lua_state);
+luaopen_lldb(m_lua_state);
   }
   ~Lua() {
 assert(m_lua_state);
Index: lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -1,3 +1,5 @@
+find_package(Lua REQUIRED)
+
 add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN
   ScriptInterpreterLua.cpp
 
Index: lldb/source/API/CMakeLists.txt
===
--- lldb/source/API/CMakeLists.txt
+++ lldb/source/API/CMakeLists.txt
@@ -9,6 +9,11 @@
   set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp)
 endif()
 
+if(LLDB_ENABLE_LUA)
+  get_target_property(lldb_scripts_dir swig_wrapper_lua BINARY_DIR)
+  set(lldb_lua_wrapper ${lldb_scripts_dir}/LLDBWrapLua.cpp)
+endif()
+
 if(LLDB_BUILD_FRAMEWORK)
   set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR})
   set(option_framework FRAMEWORK)
@@ -85,6 +90,7 @@
   SBUnixSignals.cpp
   SystemInitializerFull.cpp
   ${lldb_python_wrapper}
+  ${lldb_lua_wrapper}
 
   LINK_LIBS
 lldbBase
@@ -130,6 +136,19 @@
   endif ()
 endif()
 
+if(lldb_lua_wrapper)
+  add_dependencies(liblldb swig_wrapper_lua)
+  target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR})
+
+  if (MSVC)
+set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
+  else()
+set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
+  endif()
+
+  set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON)
+endif()
+
 set_target_properties(liblldb
   PROPERTIES
   VERSION ${LLDB_VERSION}
Index: lldb/scripts/lldb_lua.swig
===
--- /dev/null
+++ lldb/scripts/lldb_lua.swig
@@ -0,0 +1,18 @@
+/*
+   lldb.swig
+
+   This is the input file for SWIG, to create the appropriate C++ wrappers and
+   functions for various scripting languages, to enable them to call the
+   liblldb Script Bridge functions.
+*/
+
+%module lldb
+
+%include "./headers.swig"
+
+%{
+using namespace lldb_private;
+using namespace lldb;
+%}
+
+%include "./interfaces.swig"
Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -27,31 +27,57 @@
   set(DARWIN_EXTRAS "")
 endif()
 
-add_custom_command(
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
-  DEPENDS ${SWIG_SOURCES}
-  DEPENDS ${SWIG_INTERFACES}
-  DEPENDS ${SWIG_HEADERS}
-  COMMAND ${SWIG_EXECUTABLE} 
-  -c++
-  -shadow
-  -python
-  -features autodoc
-  -threads
-  -I${LLDB_SOURCE_DIR}/include
-  -I${CMAKE_CURRENT_SOURCE_DIR}
-  -D__STDC_LIMIT_MACROS
-  -D__STDC_CONSTANT_MACROS
-  ${DARWIN_EXTRAS}
-  -outdir ${CMAKE_CURRENT_BINARY_DIR}
-  -o ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  ${LLDB_SOURCE_DIR}/scripts/lldb.swig
-  VERBATIM
-  COMMENT "Builds LLDB Python wrapper")
-
-add_custom_target(swig_wrapper ALL DEPENDS
-  ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
-  ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
+set(SWIG_COMMON_FLAGS
+  -c++
+  -features autodoc
+  -I${LLDB_SOURCE_DIR}/include
+  -I${CMAKE_CURRENT_SOURCE_DIR}
+  -D__STDC_LIMIT_MACROS
+  -D

[Lldb-commits] [lldb] 56ab485 - [lldb/Scripting] Simplify code by removing the #if.

2019-12-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2019-12-18T16:46:38-08:00
New Revision: 56ab485a311d065f9417e0cff903e1f33495f4cc

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

LOG: [lldb/Scripting] Simplify code by removing the #if.

The "none" script interpreter does not depend on Python so it doesn't
make sense to have it withing the if-block. The only goal seems to be to
have a slightly different error for when there's no script interpreter,
but as per the comment this doesn't make sense for more than one
scripting language. I think the existing error is perfectly clear, so I
just removed this altogether.

Added: 


Modified: 
lldb/source/Interpreter/CommandObjectScript.cpp

Removed: 




diff  --git a/lldb/source/Interpreter/CommandObjectScript.cpp 
b/lldb/source/Interpreter/CommandObjectScript.cpp
index fe365a5496f8..d61d0cac9762 100644
--- a/lldb/source/Interpreter/CommandObjectScript.cpp
+++ b/lldb/source/Interpreter/CommandObjectScript.cpp
@@ -32,7 +32,6 @@ CommandObjectScript::~CommandObjectScript() {}
 
 bool CommandObjectScript::DoExecute(llvm::StringRef command,
 CommandReturnObject &result) {
-#if LLDB_ENABLE_PYTHON
   if (m_interpreter.GetDebugger().GetScriptLanguage() ==
   lldb::eScriptLanguageNone) {
 result.AppendError(
@@ -49,9 +48,9 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
 return false;
   }
 
-  DataVisualization::ForceUpdate(); // script might change Python code we use
-// for formatting.. make sure we keep up to
-// date with it
+  // Script might change Python code we use for formatting. Make sure we keep
+  // up to date with it.
+  DataVisualization::ForceUpdate();
 
   if (command.empty()) {
 script_interpreter->ExecuteInterpreterLoop();
@@ -66,11 +65,4 @@ bool CommandObjectScript::DoExecute(llvm::StringRef command,
 result.SetStatus(eReturnStatusFailed);
 
   return result.Succeeded();
-#else
-  // if we ever support languages other than Python this simple #ifdef won't
-  // work
-  result.AppendError("your copy of LLDB does not support scripting.");
-  result.SetStatus(eReturnStatusFailed);
-  return false;
-#endif
 }



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