[Lldb-commits] [lldb] 92211bf - [LLDB] Fix address computation for inline function

2019-12-20 Thread Johannes Altmanninger via lldb-commits

Author: Johannes Altmanninger
Date: 2019-12-20T09:04:45+01:00
New Revision: 92211bf0f15ba46b5eeb88b7ea580ff539dcdd4e

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

LOG: [LLDB] Fix address computation for inline function

Summary:
Fixes PR41237 - SIGSEGV on call expression evaluation when debugging clang

When linking multiple compilation units that define the same functions,
the functions is merged but their debug info is not. This ignores debug
info entries for functions in a non-executable sections; those are
functions that were definitely dropped by the linker.

Reviewers: spyffe, clayborg, jasonmolenda

Reviewed By: clayborg

Subscribers: labath, aprantl, lldb-commits

Tags: #lldb

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

Added: 
lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll

Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 658158d94a2b..502d1af668c9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2282,9 +2282,12 @@ bool SymbolFileDWARF::ResolveFunction(const DWARFDIE 
&orig_die,
   addr = sc.function->GetAddressRange().GetBaseAddress();
 }
 
-if (addr.IsValid()) {
-  sc_list.Append(sc);
-  return true;
+
+if (auto section_sp = addr.GetSection()) {
+  if (section_sp->GetPermissions() & ePermissionsExecutable) {
+sc_list.Append(sc);
+return true;
+  }
 }
   }
 

diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test 
b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
new file mode 100644
index ..56397c949efb
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
@@ -0,0 +1,6 @@
+# REQUIRES: lld
+; RUN: llc %S/inline-function-address.ll -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t -shared
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll 
b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
new file mode 100644
index ..233e92007108
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
@@ -0,0 +1,28 @@
+; REQUIRES: lld
+; RUN: llc %s -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t
+; "foo" is defined in both compilation units, but there should be only one 
meaningful debuginfo entry
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
+
+$foo = comdat any
+define void @foo() comdat !dbg !6 {
+entry:
+  ret void
+}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, isOptimized: 
false, runtimeVersion: 0, emissionKind: FullDebug, enums: !{}, imports: !{}, 
splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "inline-function-address.h", directory: "")
+!2 = !DIFile(filename: "inline-function-address.c", directory: "")
+!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!4 = !DISubroutineType(types: !{})
+!5 = !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: 
DIFlagPrototyped, spFlags: 0)
+!6 = distinct !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !5)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8, !9}
+!llvm.ident = !{}
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}



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


[Lldb-commits] [PATCH] D71487: [LLDB] Fix address computation for inline function

2019-12-20 Thread Johannes Altmanninger via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG92211bf0f15b: [LLDB] Fix address computation for inline 
function (authored by johannes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71487

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
  lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll


Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
@@ -0,0 +1,28 @@
+; REQUIRES: lld
+; RUN: llc %s -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t
+; "foo" is defined in both compilation units, but there should be only one 
meaningful debuginfo entry
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
+
+$foo = comdat any
+define void @foo() comdat !dbg !6 {
+entry:
+  ret void
+}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, isOptimized: 
false, runtimeVersion: 0, emissionKind: FullDebug, enums: !{}, imports: !{}, 
splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "inline-function-address.h", directory: "")
+!2 = !DIFile(filename: "inline-function-address.c", directory: "")
+!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!4 = !DISubroutineType(types: !{})
+!5 = !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: 
DIFlagPrototyped, spFlags: 0)
+!6 = distinct !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !5)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8, !9}
+!llvm.ident = !{}
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
@@ -0,0 +1,6 @@
+# REQUIRES: lld
+; RUN: llc %S/inline-function-address.ll -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t -shared
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2282,9 +2282,12 @@
   addr = sc.function->GetAddressRange().GetBaseAddress();
 }
 
-if (addr.IsValid()) {
-  sc_list.Append(sc);
-  return true;
+
+if (auto section_sp = addr.GetSection()) {
+  if (section_sp->GetPermissions() & ePermissionsExecutable) {
+sc_list.Append(sc);
+return true;
+  }
 }
   }
 


Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
@@ -0,0 +1,28 @@
+; REQUIRES: lld
+; RUN: llc %s -filetype=obj -o %t.o
+; RUN: ld.lld %t.o %t.o -o %t
+; "foo" is defined in both compilation units, but there should be only one meaningful debuginfo entry
+; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | FileCheck %s
+; CHECK: Function: {{.*}} "foo"
+; CHECK-NOT: Function: {{.*}} "foo"
+
+$foo = comdat any
+define void @foo() comdat !dbg !6 {
+entry:
+  ret void
+}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !{}, imports: !{}, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "inline-function-address.h", directory: "")
+!2 = !DIFile(filename: "inline-function-address.c", directory: "")
+!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!4 = !DISubroutineType(types: !{})
+!5 = !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: DIFlagPrototyped, spFlags: 0)
+!6 = distinct !DISubprogram(name: "foo", file: !1, line: 12, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !5)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7, !8, !9}
+!llvm.ident = !{}
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{i32 1, !"wchar_size", i32 4}
Index: lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/inline-func

[Lldb-commits] [lldb] 4cc5659 - [lldb] Remove XFAIL from TestDeadStrip.py

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T10:04:25+01:00
New Revision: 4cc5659a7a1f2fa3dcb3256fd3c3d07b2833b586

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

LOG: [lldb] Remove XFAIL from TestDeadStrip.py

Fixed by 92211b.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py
index 8dd54d153323..cb610697807d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip/TestDeadStrip.py
@@ -14,8 +14,6 @@ class DeadStripTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
-@expectedFailureAll(oslist=no_match(lldbplatformutil.getDarwinOSTriples()),
-bugnumber="llvm.org/pr24778 llvm.org/pr25087 llvm.org/pr27865")
 def test(self):
 """Test breakpoint works correctly with dead-code stripping."""
 self.build()



___
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-20 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Looks fine to me. Just remove the redundant panel searching code, and please 
make sure this works correctly from a clean build, per the inline comment.




Comment at: lldb/cmake/modules/FindCursesAndPanel.cmake:8
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+  set(CURSES_PANEL_FOUND TRUE)
+else()

It's not fully clear to me what will happen when this code is run for the first 
time (when `CURSES_INCLUDE_DIRS`, etc. is not defined yet). Who will set 
`CURSES_PANEL_FOUND` in that case? Could you make sure this works correctly 
when run for the first time on a fully clean build?

I don't know whether this is the standard way of writing find_package files, 
but I'd consider just removing the caching and letting `find_package(Curses)` 
and  `find_library(panel)` just run every time -- they already contain some 
internal caching so we're not saving much here anyway...



Comment at: lldb/cmake/modules/LLDBConfig.cmake:497
 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)

mgorny wrote:
> Isn't this redundant now?
yep. it sure is.


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] D71630: [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests

2019-12-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 234839.
teemperor added a comment.
Herald added a subscriber: mgorny.

- Add test
- Move SubsystemRAIICase to ::detail

I'll wait with landing this until HostInfo's Initialize/Terminate are fixed 
(calling Terminate and Initialize is currently breaking the whole thing)


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

https://reviews.llvm.org/D71630

Files:
  lldb/unittests/Core/MangledTest.cpp
  lldb/unittests/Editline/EditlineTest.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  lldb/unittests/Expression/CppModuleConfigurationTest.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/Host/HostInfoTest.cpp
  lldb/unittests/Host/MainLoopTest.cpp
  lldb/unittests/Interpreter/TestCompletion.cpp
  lldb/unittests/Language/Highlighting/HighlighterTest.cpp
  lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
  lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
  lldb/unittests/Symbol/TestClangASTImporter.cpp
  lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
  lldb/unittests/Symbol/TestLineEntry.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
  lldb/unittests/Target/ModuleCacheTest.cpp
  lldb/unittests/TestingSupport/SubsystemRAII.h
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/SubsystemRAIITest.cpp

Index: lldb/unittests/Utility/SubsystemRAIITest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/SubsystemRAIITest.cpp
@@ -0,0 +1,99 @@
+//===-- SubsystemRAIITest.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-spi.h"
+#include "gtest/gtest.h"
+
+#include "TestingSupport/SubsystemRAII.h"
+
+using namespace lldb_private;
+
+namespace {
+
+enum class SystemState {
+  /// Start state of the subsystem.
+  Start,
+  /// Initialize has been called but Terminate hasn't been called yet.
+  Initialized,
+  /// Terminate has been called.
+  Terminated
+};
+
+struct TestSubsystem {
+  static SystemState state;
+  static void Initialize() {
+assert(state == SystemState::Start);
+state = SystemState::Initialized;
+  }
+  static void Terminate() {
+assert(state == SystemState::Initialized);
+state = SystemState::Terminated;
+  }
+};
+} // namespace
+
+SystemState TestSubsystem::state = SystemState::Start;
+
+TEST(SubsystemRAIITest, NormalSubsystem) {
+  // Tests that SubsystemRAII handles Initialize functions that return void.
+  EXPECT_EQ(SystemState::Start, TestSubsystem::state);
+  {
+SubsystemRAII subsystem;
+EXPECT_EQ(SystemState::Initialized, TestSubsystem::state);
+  }
+  EXPECT_EQ(SystemState::Terminated, TestSubsystem::state);
+}
+
+static const char *SubsystemErrorString = "Initialize failed";
+
+namespace {
+struct TestSubsystemWithError {
+  static SystemState state;
+  static bool will_fail;
+  static llvm::Error Initialize() {
+assert(state == SystemState::Start);
+state = SystemState::Initialized;
+if (will_fail)
+  return llvm::make_error(
+  SubsystemErrorString, llvm::inconvertibleErrorCode());
+return llvm::Error::success();
+  }
+  static void Terminate() {
+assert(state == SystemState::Initialized);
+state = SystemState::Terminated;
+  }
+  /// Reset the subsystem to the default state for testing.
+  static void Reset() { state = SystemState::Start; }
+};
+} // namespace
+
+SystemState TestSubsystemWithError::state = SystemState::Start;
+bool TestSubsystemWithError::will_fail = false;
+
+TEST(SubsystemRAIITest, SubsystemWithErrorSuccess) {
+  // Tests that SubsystemRAII handles llvm::success() returned from
+  // Initialize.
+  TestSubsystemWithError::Reset();
+  EXPECT_EQ(SystemState::Start, TestSubsystemWithError::state);
+  {
+TestSubsystemWithError::will_fail = false;
+SubsystemRAII subsystem;
+EXPECT_EQ(SystemState::Initialized, TestSubsystemWithError::state);
+  }
+  EXPECT_EQ(SystemState::Terminated, TestSubsystemWithError::state);
+}
+
+TEST(SubsystemRAIITest, SubsystemWithErrorFailure) {
+  // Tests that SubsystemRAII handles any errors returned from
+  // Initialize.
+  TestSubsystemWithError::Reset();
+  EXPECT_EQ(SystemState::Start, TestSubsystemWithError::state);
+  TestSubsystemWithError::will_fail = true;
+  EXPECT_FATAL_FAILURE(SubsystemRAII subsystem,
+   SubsystemErrorString);
+}
Index: lldb/unittests/Utility/CMakeLists.txt
===
--- lldb/unittests/Utility/CMakeLists.txt
+++ lldb/unittests/Utility/CMakeLists.txt
@@ -32,6 +32,7 @@
   StringLexerTest.cpp
   StringListTest.cpp
 

[Lldb-commits] [lldb] 29bd219 - [lldb] Added test for objc_direct calls with categories

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

Author: Raphael Isemann
Date: 2019-12-20T11:07:30+01:00
New Revision: 29bd2194979c50097edb39a4beb714bff8c153a1

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

LOG: [lldb] Added test for objc_direct calls with categories

As pointed out in D71694 this wasn't tested before in LLDB.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m 
b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m
index 1a199acdda45..6799f22500c9 100644
--- a/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m
+++ b/lldb/packages/Python/lldbsuite/test/lang/objc/objc_direct-methods/main.m
@@ -24,6 +24,7 @@ -(int) entryPoint
 //%self.expect("expr [self directCallNSStringArg: str]", 
substrs=['@"some string"'])
 //%self.expect("expr [self directCallIdArg: (id)str]", 
substrs=['@"some string appendix"'])
 //%self.expect("expr [self directCallConflictingName]", 
substrs=["correct function"])
+//%self.expect("expr [self directCallWithCategory]", 
substrs=["called function with category"])
 }
 
 // Declare several objc_direct functions we can test.
@@ -61,6 +62,17 @@ -(const char *) directCallConflictingName  
__attribute__((objc_direct))
 }
 @end
 
+
+@interface Foo (Cat)
+@end
+
+@implementation Foo (Cat)
+-(const char *) directCallWithCategory  __attribute__((objc_direct))
+{
+  return "called function with category";
+}
+@end
+
 int main()
 {
   Foo *foo = [[Foo alloc] init];
@@ -75,5 +87,6 @@ int main()
  //%self.expect("expr [foo directCallNSStringArg: str]", 
substrs=['@"some string"'])
  //%self.expect("expr [foo directCallIdArg: (id)str]", 
substrs=['@"some string appendix"'])
  //%self.expect("expr [foo directCallConflictingName]", 
substrs=["correct function"])
+ //%self.expect("expr [foo directCallWithCategory]", 
substrs=["called function with category"])
   return 0;
 }



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


[Lldb-commits] [PATCH] D71487: [LLDB] Fix address computation for inline function

2019-12-20 Thread Johannes Altmanninger via Phabricator via lldb-commits
johannes added a comment.

I'm having some troubles fixing this build failure: 
http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/1866/

`ninja check-lldb-api` fails but when I try to execute the offending test 
locally with a command equivalent to the one in the buildbot log, I get below 
error. I've tried to rebuild lldb*.so etc without success.

  $ llvm-project/lldb/test/API/dotest.py --arch=x86_64 -s b/lldb-test-traces -S 
nm -u CXXFLAGS -u CFLAGS --executable b/bin/lldb --compiler b/bin/clang 
--dsymutil b/bin/dsymutil --filecheck b/bin/FileCheck --env 
ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy --env LLVM_LIBS_DIR=b/lib 
--build-dir b/lldb-test-build.noindex --lldb-module-cache-dir 
b/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir 
b/lldb-test-build.noindex/module-cache-clang/lldb-api 
llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip -p 
TestDeadStrip.py
  LLDB library dir: /home/builduser/build-ld/bin
  LLDB import library dir: /home/builduser/build-ld/bin
  lldb version 10.0.0 (g...@github.com:llvm/llvm-project revision 
ea8a86cc8a18fd001e9670705dae3b59f6a4d974)
clang revision 92211bf0f15ba46b5eeb88b7ea580ff539dcdd4e
llvm revision 92211bf0f15ba46b5eeb88b7ea580ff539dcdd4e
  Traceback (most recent call last):
File 
"/home/builduser/build-ld/lib/python3.8/site-packages/lldb/__init__.py", line 
38, in 
  import _lldb
  ModuleNotFoundError: No module named '_lldb'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
File "llvm-project/lldb/test/API/dotest.py", line 7, in 
  lldbsuite.test.run_suite()
File 
"/home/builduser/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", 
line 956, in run_suite
  import lldb
File 
"/home/builduser/build-ld/lib/python3.8/site-packages/lldb/__init__.py", line 
41, in 
  from . import _lldb
  ImportError: 
/home/builduser/build-ld/lib/python3.8/site-packages/lldb/_lldb.so: undefined 
symbol: _ZN5clang17ExternalASTSource2IDE

There's also another build failure on Windows, I will fix that by adding 
`REQUIRES: linux` since the tests are using `ld.lld`:
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11870/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71487



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


[Lldb-commits] [PATCH] D71748: [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times

2019-12-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: labath.
Herald added subscribers: lldb-commits, JDevlieghere, abidh.
Herald added a project: LLDB.

HostInfo's state isn't actually fully rested after calling ::Terminate. 
Currently we only reset the
values of all the `HostInfoBaseFields` but not all the variables with static 
storage that
keep track of whether the fields need to be initialised. This breaks random 
unit tests as running
them twice (or running multiple test instances in one run) will cause that the 
second time
we ask HostInfo for any information we get the default value back for any field.

This patch moves all the once_flag's into the `HostInfoBaseFields` so that they 
also get reseted
by ::Terminate and removes all the `success` bools. We should also rewrite half 
this code but
I would prefer if my tests aren't broken over the holidays so let's just put 
some duct tape on it
for now.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D71748

Files:
  lldb/source/Host/common/HostInfoBase.cpp

Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -47,18 +47,28 @@
 }
   }
 
+  llvm::once_flag m_host_triple_once;
   std::string m_host_triple;
 
+  llvm::once_flag m_host_arch_once;
   ArchSpec m_host_arch_32;
   ArchSpec m_host_arch_64;
 
+  llvm::once_flag m_lldb_so_dir_once;
   FileSpec m_lldb_so_dir;
+  llvm::once_flag m_lldb_support_exe_dir_once;
   FileSpec m_lldb_support_exe_dir;
+  llvm::once_flag m_lldb_headers_dir_once;
   FileSpec m_lldb_headers_dir;
+  llvm::once_flag m_lldb_clang_resource_dir_once;
   FileSpec m_lldb_clang_resource_dir;
+  llvm::once_flag m_lldb_system_plugin_dir_once;
   FileSpec m_lldb_system_plugin_dir;
+  llvm::once_flag m_lldb_user_plugin_dir_once;
   FileSpec m_lldb_user_plugin_dir;
+  llvm::once_flag m_lldb_process_tmp_dir_once;
   FileSpec m_lldb_process_tmp_dir;
+  llvm::once_flag m_lldb_global_tmp_dir_once;
   FileSpec m_lldb_global_tmp_dir;
 };
 
@@ -73,8 +83,7 @@
 }
 
 llvm::StringRef HostInfoBase::GetTargetTriple() {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_triple_once, []() {
 g_fields->m_host_triple =
 HostInfo::GetArchitecture().GetTriple().getTriple();
   });
@@ -82,8 +91,7 @@
 }
 
 const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_arch_once, []() {
 HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32,
  g_fields->m_host_arch_64);
   });
@@ -108,87 +116,76 @@
 }
 
 FileSpec HostInfoBase::GetShlibDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
+  llvm::call_once(g_fields->m_lldb_so_dir_once, []() {
+if (!HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir))
+  g_fields->m_lldb_so_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "shlib dir -> `{0}`", g_fields->m_lldb_so_dir);
   });
-  return success ? g_fields->m_lldb_so_dir : FileSpec();
+  return g_fields->m_lldb_so_dir;
 }
 
 FileSpec HostInfoBase::GetSupportExeDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success =
-HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir);
+  llvm::call_once(g_fields->m_lldb_support_exe_dir_once, []() {
+if (!HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir))
+  g_fields->m_lldb_support_exe_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "support exe dir -> `{0}`", g_fields->m_lldb_support_exe_dir);
   });
-  return success ? g_fields->m_lldb_support_exe_dir : FileSpec();
+  return g_fields->m_lldb_support_exe_dir;
 }
 
 FileSpec HostInfoBase::GetHeaderDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir);
+  llvm::call_once(g_fields->m_lldb_headers_dir_once, []() {
+if (!HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir))
+  g_fields->m_lldb_headers_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "header dir -> `{0}`", g_fields->m_lldb_headers_dir);
   });
-  return success ? g_fields->m_lldb_headers_dir : FileSpec();
+  return g_fields->m_lldb_headers_dir;
 }
 
 FileSpec HostInfoBase::GetSystemPluginDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = fa

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

2019-12-20 Thread Raphael “Teemperor” Isemann via lldb-commits
Fixed by https://reviews.llvm.org/D71748. Will land this today.

> On 18. Dec 2019, at 23:03, Raphael “Teemperor” Isemann  
> wrote:
> 
> 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

[Lldb-commits] [PATCH] D71699: [lldb] Increase the rate at which ConstString's memory allocator scales the memory chunks it allocates

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

(This patch is otherwise ready to land)


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71699



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


[Lldb-commits] [PATCH] D71699: [lldb] Increase the rate at which ConstString's memory allocator scales the memory chunks it allocates

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

@llunak can you test how this affects your runtime for the use case you wanted 
this for?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71699



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


[Lldb-commits] [PATCH] D71487: [LLDB] Fix address computation for inline function

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D71487#1792391 , @johannes wrote:

> I'm having some troubles fixing this build failure: 
>  http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/1866/
>
> `ninja check-lldb-api` fails but when I try to execute the offending test 
> locally with a command equivalent to the one in the buildbot log, I get below 
> error. I've tried to rebuild lldb*.so etc without success.
>
>   $ llvm-project/lldb/test/API/dotest.py --arch=x86_64 -s b/lldb-test-traces 
> -S nm -u CXXFLAGS -u CFLAGS --executable b/bin/lldb --compiler b/bin/clang 
> --dsymutil b/bin/dsymutil --filecheck b/bin/FileCheck --env 
> ARCHIVER=/usr/bin/ar --env OBJCOPY=/usr/bin/objcopy --env LLVM_LIBS_DIR=b/lib 
> --build-dir b/lldb-test-build.noindex --lldb-module-cache-dir 
> b/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir 
> b/lldb-test-build.noindex/module-cache-clang/lldb-api 
> llvm-project/lldb/packages/Python/lldbsuite/test/functionalities/dead-strip 
> -p TestDeadStrip.py
>   LLDB library dir: /home/builduser/build-ld/bin
>   LLDB import library dir: /home/builduser/build-ld/bin
>   lldb version 10.0.0 (g...@github.com:llvm/llvm-project revision 
> ea8a86cc8a18fd001e9670705dae3b59f6a4d974)
> clang revision 92211bf0f15ba46b5eeb88b7ea580ff539dcdd4e
> llvm revision 92211bf0f15ba46b5eeb88b7ea580ff539dcdd4e
>   Traceback (most recent call last):
> File 
> "/home/builduser/build-ld/lib/python3.8/site-packages/lldb/__init__.py", line 
> 38, in 
>   import _lldb
>   ModuleNotFoundError: No module named '_lldb'
>  
>   During handling of the above exception, another exception occurred:
>  
>   Traceback (most recent call last):
> File "llvm-project/lldb/test/API/dotest.py", line 7, in 
>   lldbsuite.test.run_suite()
> File 
> "/home/builduser/llvm-project/lldb/packages/Python/lldbsuite/test/dotest.py", 
> line 956, in run_suite
>   import lldb
> File 
> "/home/builduser/build-ld/lib/python3.8/site-packages/lldb/__init__.py", line 
> 41, in 
>   from . import _lldb
>   ImportError: 
> /home/builduser/build-ld/lib/python3.8/site-packages/lldb/_lldb.so: undefined 
> symbol: _ZN5clang17ExternalASTSource2IDE
>
>
>


I've already fixed that (the "problem" was that the test was passing now), but 
for future reference, the problem here appears to be that you're doing a shared 
library build (-DBUILD_SHARED_LIBS=ON). In that case you'll need to set 
LD_LIBRARY_PATH to for python to find dependent libraries correctly.

> There's also another build failure on Windows, I will fix that by adding 
> `REQUIRES: linux` since the tests are using `ld.lld`:
>  http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11870/

A better fix for that would be to explicitly specify the target to llc (`llc 
-mtriple x86_64-pc-linux`), as ld.lld works fine on windows too. You should add 
`REQUIRES: x86` to catch the cases where people don't enable the X86 target, 
but that's better since everyone can enable the x86 target (and most do), but 
not everyone runs a linux machine...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71487



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


[Lldb-commits] [PATCH] D71748: [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Yeah, this code could use a rewrite, but this is definitely better...


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71748



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


[Lldb-commits] [PATCH] D68464: [lldb][modern-type-lookup] Ask the ExternalASTMerger to lookup namespaces instead of using the old mechanism

2019-12-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor abandoned this revision.
teemperor added a comment.

modern-type-lookup has been removed, closing this.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D68464



___
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-20 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added inline comments.
This revision is now accepted and ready to land.



Comment at: lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt:14-15
+
+target_include_directories(ScriptInterpreterLuaTests PRIVATE 
${LUA_INCLUDE_DIR})
+target_link_libraries(ScriptInterpreterLuaTests PRIVATE ${LUA_LIBRARIES})

I think you wouldn't need these if the other CMakeLists file would use PUBLIC 
keyword for headers, and INTERFACE for libraries.



Comment at: lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp:53
+TEST_F(ScriptInterpreterTest, ExecuteOneLine) {
+  DebuggerSP debugger_sp = Debugger::CreateInstance();
+  ASSERT_TRUE(debugger_sp);

JDevlieghere wrote:
> labath wrote:
> > I'm not actually opposed to this (and it's nice to know that this could 
> > work if we need it), but why do this as a unit test? It seems like this 
> > could be tested equally well with a `script` command through the lldb 
> > driver. I was imagining the unit tests would be most useful for the lower 
> > level functionality -- roughly corresponding to the `Lua` class. Right now 
> > that class is pretty simple and doesn't really need a unit test, but I 
> > expect it will become more complex over time...
> Yes, I just wanted to show that it's possible :-) I've also included a test 
> for the Lua class. 
Ok, that's cool.


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

https://reviews.llvm.org/D71234



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


[Lldb-commits] [lldb] b237179 - [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times

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

Author: Raphael Isemann
Date: 2019-12-20T12:52:06+01:00
New Revision: b2371791fc74b2ecad7f608ff8592ec512d098e6

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

LOG: [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate 
multiple times

Summary:
HostInfo's state isn't actually fully rested after calling ::Terminate. 
Currently we only reset the
values of all the `HostInfoBaseFields` but not all the variables with static 
storage that
keep track of whether the fields need to be initialised. This breaks random 
unit tests as running
them twice (or running multiple test instances in one run) will cause that the 
second time
we ask HostInfo for any information we get the default value back for any field.

This patch moves all the once_flag's into the `HostInfoBaseFields` so that they 
also get reseted
by ::Terminate and removes all the `success` bools. We should also rewrite half 
this code but
I would prefer if my tests aren't broken over the holidays so let's just put 
some duct tape on it
for now.

Reviewers: labath

Reviewed By: labath

Subscribers: abidh, JDevlieghere, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/source/Host/common/HostInfoBase.cpp

Removed: 




diff  --git a/lldb/source/Host/common/HostInfoBase.cpp 
b/lldb/source/Host/common/HostInfoBase.cpp
index 3765f36fc79a..c69f705fa60a 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -47,18 +47,28 @@ struct HostInfoBaseFields {
 }
   }
 
+  llvm::once_flag m_host_triple_once;
   std::string m_host_triple;
 
+  llvm::once_flag m_host_arch_once;
   ArchSpec m_host_arch_32;
   ArchSpec m_host_arch_64;
 
+  llvm::once_flag m_lldb_so_dir_once;
   FileSpec m_lldb_so_dir;
+  llvm::once_flag m_lldb_support_exe_dir_once;
   FileSpec m_lldb_support_exe_dir;
+  llvm::once_flag m_lldb_headers_dir_once;
   FileSpec m_lldb_headers_dir;
+  llvm::once_flag m_lldb_clang_resource_dir_once;
   FileSpec m_lldb_clang_resource_dir;
+  llvm::once_flag m_lldb_system_plugin_dir_once;
   FileSpec m_lldb_system_plugin_dir;
+  llvm::once_flag m_lldb_user_plugin_dir_once;
   FileSpec m_lldb_user_plugin_dir;
+  llvm::once_flag m_lldb_process_tmp_dir_once;
   FileSpec m_lldb_process_tmp_dir;
+  llvm::once_flag m_lldb_global_tmp_dir_once;
   FileSpec m_lldb_global_tmp_dir;
 };
 
@@ -73,8 +83,7 @@ void HostInfoBase::Terminate() {
 }
 
 llvm::StringRef HostInfoBase::GetTargetTriple() {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_triple_once, []() {
 g_fields->m_host_triple =
 HostInfo::GetArchitecture().GetTriple().getTriple();
   });
@@ -82,8 +91,7 @@ llvm::StringRef HostInfoBase::GetTargetTriple() {
 }
 
 const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_arch_once, []() {
 HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32,
  g_fields->m_host_arch_64);
   });
@@ -108,87 +116,76 @@ llvm::Optional 
HostInfoBase::ParseArchitectureKi
 }
 
 FileSpec HostInfoBase::GetShlibDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
+  llvm::call_once(g_fields->m_lldb_so_dir_once, []() {
+if (!HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir))
+  g_fields->m_lldb_so_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "shlib dir -> `{0}`", g_fields->m_lldb_so_dir);
   });
-  return success ? g_fields->m_lldb_so_dir : FileSpec();
+  return g_fields->m_lldb_so_dir;
 }
 
 FileSpec HostInfoBase::GetSupportExeDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success =
-HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir);
+  llvm::call_once(g_fields->m_lldb_support_exe_dir_once, []() {
+if 
(!HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir))
+  g_fields->m_lldb_support_exe_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "support exe dir -> `{0}`", 
g_fields->m_lldb_support_exe_dir);
   });
-  return success ? g_fields->m_lldb_support_exe_dir : FileSpec();
+  return g_fields->m_lldb_support_exe_dir;
 }
 
 FileSpec HostInfoBase::GetHeaderDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_f

[Lldb-commits] [PATCH] D71748: [lldb] Make that we can call HostInfo::Initialize and HostInfo::Terminate multiple times

2019-12-20 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2371791fc74: [lldb] Make that we can call 
HostInfo::Initialize and HostInfo::Terminate… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71748

Files:
  lldb/source/Host/common/HostInfoBase.cpp

Index: lldb/source/Host/common/HostInfoBase.cpp
===
--- lldb/source/Host/common/HostInfoBase.cpp
+++ lldb/source/Host/common/HostInfoBase.cpp
@@ -47,18 +47,28 @@
 }
   }
 
+  llvm::once_flag m_host_triple_once;
   std::string m_host_triple;
 
+  llvm::once_flag m_host_arch_once;
   ArchSpec m_host_arch_32;
   ArchSpec m_host_arch_64;
 
+  llvm::once_flag m_lldb_so_dir_once;
   FileSpec m_lldb_so_dir;
+  llvm::once_flag m_lldb_support_exe_dir_once;
   FileSpec m_lldb_support_exe_dir;
+  llvm::once_flag m_lldb_headers_dir_once;
   FileSpec m_lldb_headers_dir;
+  llvm::once_flag m_lldb_clang_resource_dir_once;
   FileSpec m_lldb_clang_resource_dir;
+  llvm::once_flag m_lldb_system_plugin_dir_once;
   FileSpec m_lldb_system_plugin_dir;
+  llvm::once_flag m_lldb_user_plugin_dir_once;
   FileSpec m_lldb_user_plugin_dir;
+  llvm::once_flag m_lldb_process_tmp_dir_once;
   FileSpec m_lldb_process_tmp_dir;
+  llvm::once_flag m_lldb_global_tmp_dir_once;
   FileSpec m_lldb_global_tmp_dir;
 };
 
@@ -73,8 +83,7 @@
 }
 
 llvm::StringRef HostInfoBase::GetTargetTriple() {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_triple_once, []() {
 g_fields->m_host_triple =
 HostInfo::GetArchitecture().GetTriple().getTriple();
   });
@@ -82,8 +91,7 @@
 }
 
 const ArchSpec &HostInfoBase::GetArchitecture(ArchitectureKind arch_kind) {
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, []() {
+  llvm::call_once(g_fields->m_host_arch_once, []() {
 HostInfo::ComputeHostArchitectureSupport(g_fields->m_host_arch_32,
  g_fields->m_host_arch_64);
   });
@@ -108,87 +116,76 @@
 }
 
 FileSpec HostInfoBase::GetShlibDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir);
+  llvm::call_once(g_fields->m_lldb_so_dir_once, []() {
+if (!HostInfo::ComputeSharedLibraryDirectory(g_fields->m_lldb_so_dir))
+  g_fields->m_lldb_so_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "shlib dir -> `{0}`", g_fields->m_lldb_so_dir);
   });
-  return success ? g_fields->m_lldb_so_dir : FileSpec();
+  return g_fields->m_lldb_so_dir;
 }
 
 FileSpec HostInfoBase::GetSupportExeDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success =
-HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir);
+  llvm::call_once(g_fields->m_lldb_support_exe_dir_once, []() {
+if (!HostInfo::ComputeSupportExeDirectory(g_fields->m_lldb_support_exe_dir))
+  g_fields->m_lldb_support_exe_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "support exe dir -> `{0}`", g_fields->m_lldb_support_exe_dir);
   });
-  return success ? g_fields->m_lldb_support_exe_dir : FileSpec();
+  return g_fields->m_lldb_support_exe_dir;
 }
 
 FileSpec HostInfoBase::GetHeaderDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir);
+  llvm::call_once(g_fields->m_lldb_headers_dir_once, []() {
+if (!HostInfo::ComputeHeaderDirectory(g_fields->m_lldb_headers_dir))
+  g_fields->m_lldb_headers_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "header dir -> `{0}`", g_fields->m_lldb_headers_dir);
   });
-  return success ? g_fields->m_lldb_headers_dir : FileSpec();
+  return g_fields->m_lldb_headers_dir;
 }
 
 FileSpec HostInfoBase::GetSystemPluginDir() {
-  static llvm::once_flag g_once_flag;
-  static bool success = false;
-  llvm::call_once(g_once_flag, []() {
-success = HostInfo::ComputeSystemPluginsDirectory(
-g_fields->m_lldb_system_plugin_dir);
+  llvm::call_once(g_fields->m_lldb_system_plugin_dir_once, []() {
+if (!HostInfo::ComputeSystemPluginsDirectory(g_fields->m_lldb_system_plugin_dir))
+  g_fields->m_lldb_system_plugin_dir = FileSpec();
 Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST);
 LLDB_LOG(log, "system plugin dir -> `{0}`",
  g_fields->m_lldb_system_plugin_dir);
   });
-  return success ? g_fields->m_lldb_system_plugin_dir : FileSpec();
+  return g_fields->m_lldb_system_p

[Lldb-commits] [lldb] 04329db - [lldb] Fix test using lld on non-linux systems

2019-12-20 Thread Johannes Altmanninger via lldb-commits

Author: Johannes Altmanninger
Date: 2019-12-20T13:27:40+01:00
New Revision: 04329dbfa6c219997ab72567842d81778f9f7f47

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

LOG: [lldb] Fix test using lld on non-linux systems

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll

Removed: 




diff  --git 
a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test 
b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
index 56397c949efb..5aa7759c5ed7 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
+++ b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address-shared.test
@@ -1,5 +1,5 @@
-# REQUIRES: lld
-; RUN: llc %S/inline-function-address.ll -filetype=obj -o %t.o
+# REQUIRES: lld, x86
+; RUN: llc -mtriple x86_64-pc-linux %S/inline-function-address.ll 
-filetype=obj -o %t.o
 ; RUN: ld.lld %t.o %t.o -o %t -shared
 ; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s
 ; CHECK: Function: {{.*}} "foo"

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll 
b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
index 233e92007108..fde90d269a1d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
+++ b/lldb/test/Shell/SymbolFile/DWARF/inline-function-address.ll
@@ -1,5 +1,5 @@
-; REQUIRES: lld
-; RUN: llc %s -filetype=obj -o %t.o
+; REQUIRES: lld, x86
+; RUN: llc -mtriple x86_64-pc-linux %s -filetype=obj -o %t.o
 ; RUN: ld.lld %t.o %t.o -o %t
 ; "foo" is defined in both compilation units, but there should be only one 
meaningful debuginfo entry
 ; RUN: lldb-test symbols --find=function --name=foo --function-flags=full %t | 
FileCheck %s



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

The main reason I don't want the Architecture class in ArchSpec is to keep the 
dependency graph of lldb-server clean (it's not very clean to begin with, but 
at least I want to avoid making it worse). lldb-server should not know anything 
about the Target class (that's a liblldb concept), but it has plenty of reasons 
to play around with ArchSpecs. If ArchSpec contained an Architecture instance, 
then lldb-server would end up transitively 
(Architecture::GetBreakableLoadAddress and friends) depending on Target. That's 
why I think we need two repositories for architecture-specific code. ArchSpec 
could be the home for the shared liblldb+lldb-server stuff (which will end up 
being low level code only, because lldb-server is low-level). The home for the 
second stuff might as well be the Architecture class. The &~1 logic seems 
sufficiently low-level to fall into the first category -- even though 
lldb-server does not seem to need it right now, it's not hard to imagine it 
needing that in the future.

A secondary issue is the inheritance. ArchSpec is currently a simple, (mostly) 
trivially copyable class. Introducing inheritance would complicate that. It's 
true that virtual dispatch can be cleaner than a switch, but I think this only 
applies if the logic inside the switch cases is complicated. And even then the 
code can be made relatively clean with a bit of care (and llvm is does not seem 
to be afraid of switches in general).  In this particular case, I think that 
the logic is actually so simple that the virtual dispatch would only obscure 
what is going on.

If, in the future, we end up needing to put some more complicated code here, we 
can revisit this decision (in that case, I'd probably argue for creating some 
sort of a different entity to hold this functionality), but for now, I don't 
see a reason to complicate the ArchSpec design on account of this.

I can see how, from the perspective of someone maintaining a downstream target, 
having everything architecture-specific in a single place would be appealing, 
but I wouldn't want to put this objective too high on the priority list. 
Otherwise, I fear that this entity (whatever it would end up being called) will 
end up being a central nexus for everything in lldb. For example there's a lot 
of arm-specific code in ObjectFileELF. Some of that could be restructured to be 
independent of elf, but doing that for everything would be tricky, and so we 
may end up with everything depending on ELF.


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D70840#1791292 , @mstorsjo wrote:

> And irrespectively if the ArchSpec vs Architecture design, can you (either of 
> you) comment on the updated form of the patch?


The code still seems somewhat schizophrenic to me. :/ The line tables are fixed 
up super late, but DW_AT_low_pc is adjusted very early. The line table 
adjustment happens even after sorting, which means the fixup could alter the 
sort order. It probably wouldn't matter in practice, as everything would just 
get decremented by one, but it still seems like a bad design. And adjusting the 
low_pc so early will complicate the move to the llvm dwarf parser.

I think I'd most prefer some middle ground where the fixup happens after the 
lowest extraction layers are finished, but before the data hits the "generic" 
code. It's possible that no such place exists right now, but it might be 
possible to create something with a bit of refactoring...


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D71630: [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests

2019-12-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 234860.
teemperor added a comment.

- Migrated more tests to SubsystemRAII


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

https://reviews.llvm.org/D71630

Files:
  lldb/unittests/Core/MangledTest.cpp
  lldb/unittests/Editline/EditlineTest.cpp
  lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
  lldb/unittests/Expression/ClangParserTest.cpp
  lldb/unittests/Expression/CppModuleConfigurationTest.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/Host/ConnectionFileDescriptorTest.cpp
  lldb/unittests/Host/HostInfoTest.cpp
  lldb/unittests/Host/MainLoopTest.cpp
  lldb/unittests/Host/SocketAddressTest.cpp
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Interpreter/TestCompletion.cpp
  lldb/unittests/Language/Highlighting/HighlighterTest.cpp
  lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
  lldb/unittests/ObjectFile/PECOFF/TestPECallFrameInfo.cpp
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp
  lldb/unittests/Symbol/LocateSymbolFileTest.cpp
  lldb/unittests/Symbol/TestClangASTContext.cpp
  lldb/unittests/Symbol/TestClangASTImporter.cpp
  lldb/unittests/Symbol/TestDWARFCallFrameInfo.cpp
  lldb/unittests/Symbol/TestLineEntry.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
  lldb/unittests/Target/ModuleCacheTest.cpp
  lldb/unittests/TestingSupport/SubsystemRAII.h
  lldb/unittests/Utility/CMakeLists.txt
  lldb/unittests/Utility/SubsystemRAIITest.cpp

Index: lldb/unittests/Utility/SubsystemRAIITest.cpp
===
--- /dev/null
+++ lldb/unittests/Utility/SubsystemRAIITest.cpp
@@ -0,0 +1,99 @@
+//===-- SubsystemRAIITest.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-spi.h"
+#include "gtest/gtest.h"
+
+#include "TestingSupport/SubsystemRAII.h"
+
+using namespace lldb_private;
+
+namespace {
+
+enum class SystemState {
+  /// Start state of the subsystem.
+  Start,
+  /// Initialize has been called but Terminate hasn't been called yet.
+  Initialized,
+  /// Terminate has been called.
+  Terminated
+};
+
+struct TestSubsystem {
+  static SystemState state;
+  static void Initialize() {
+assert(state == SystemState::Start);
+state = SystemState::Initialized;
+  }
+  static void Terminate() {
+assert(state == SystemState::Initialized);
+state = SystemState::Terminated;
+  }
+};
+} // namespace
+
+SystemState TestSubsystem::state = SystemState::Start;
+
+TEST(SubsystemRAIITest, NormalSubsystem) {
+  // Tests that SubsystemRAII handles Initialize functions that return void.
+  EXPECT_EQ(SystemState::Start, TestSubsystem::state);
+  {
+SubsystemRAII subsystem;
+EXPECT_EQ(SystemState::Initialized, TestSubsystem::state);
+  }
+  EXPECT_EQ(SystemState::Terminated, TestSubsystem::state);
+}
+
+static const char *SubsystemErrorString = "Initialize failed";
+
+namespace {
+struct TestSubsystemWithError {
+  static SystemState state;
+  static bool will_fail;
+  static llvm::Error Initialize() {
+assert(state == SystemState::Start);
+state = SystemState::Initialized;
+if (will_fail)
+  return llvm::make_error(
+  SubsystemErrorString, llvm::inconvertibleErrorCode());
+return llvm::Error::success();
+  }
+  static void Terminate() {
+assert(state == SystemState::Initialized);
+state = SystemState::Terminated;
+  }
+  /// Reset the subsystem to the default state for testing.
+  static void Reset() { state = SystemState::Start; }
+};
+} // namespace
+
+SystemState TestSubsystemWithError::state = SystemState::Start;
+bool TestSubsystemWithError::will_fail = false;
+
+TEST(SubsystemRAIITest, SubsystemWithErrorSuccess) {
+  // Tests that SubsystemRAII handles llvm::success() returned from
+  // Initialize.
+  TestSubsystemWithError::Reset();
+  EXPECT_EQ(SystemState::Start, TestSubsystemWithError::state);
+  {
+TestSubsystemWithError::will_fail = false;
+SubsystemRAII subsystem;
+EXPECT_EQ(SystemState::Initialized, TestSubsystemWithError::state);
+  }
+  EXPECT_EQ(SystemState::Terminated, TestSubsystemWithError::state);
+}
+
+TEST(SubsystemRAIITest, SubsystemWithErrorFailure) {
+  // Tests that SubsystemRAII handles any errors returned from
+  // Initialize.
+  TestSubsystemWithError::Reset();
+  EXPECT_EQ(SystemState::Start, TestSubsystemWithError::state);
+  TestSubsystemWithError::will_fail = true;
+  EXPECT_FATAL_FAILURE(SubsystemRAII subsystem,
+   SubsystemErrorString);
+}
Index: lldb/unittests/Utility/CMakeLists.txt
==

[Lldb-commits] [PATCH] D71750: [lldb/DWARF] Add is_dwo member to DWARFUnit

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a project: LLDB.

A skeleton unit can easily be detected by checking the m_dwo_symbol_file
member, but we cannot tell a split unit from a normal unit from the
"inside", which is sometimes useful.

This patch adds a m_is_dwo member to enable this, and align the code
with llvm::DWARFUnit. Right now it's only used to avoid creating a split
unit inside another split unit (which removes one override from
SymbolFileDWARFDwo and brings us a step closer to deleting it), but my
main motivation is fixing the handling of location lists in mixed v4&v5
files. This comes in a separate patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71750

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -47,12 +47,6 @@
   DWARFDIE
   GetDIE(const DIERef &die_ref) override;
 
-  std::unique_ptr
-  GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
- const DWARFDebugInfoEntry &cu_die) override {
-return nullptr;
-  }
-
   DWARFCompileUnit *GetBaseCompileUnit() override { return &m_base_dwarf_cu; }
 
   llvm::Optional GetDwoNum() override { return GetID() >> 32; }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -287,7 +287,7 @@
 
   lldb::user_id_t GetUID(DIERef ref);
 
-  virtual std::unique_ptr
+  std::unique_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit &dwarf_cu,
  const DWARFDebugInfoEntry &cu_die);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -249,7 +249,7 @@
   DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
 const DWARFUnitHeader &header,
 const DWARFAbbreviationDeclarationSet &abbrevs,
-DIERef::Section section);
+DIERef::Section section, bool is_dwo);
 
   llvm::Error ExtractHeader(SymbolFileDWARF &dwarf,
 const lldb_private::DWARFDataExtractor &data,
@@ -316,6 +316,7 @@
   llvm::Optional m_loclist_table_header;
 
   const DIERef::Section m_section;
+  bool m_is_dwo;
 
 private:
   void ParseProducerInfo();
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -32,9 +32,9 @@
 DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
  const DWARFUnitHeader &header,
  const DWARFAbbreviationDeclarationSet &abbrevs,
- DIERef::Section section)
+ DIERef::Section section, bool is_dwo)
 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
-  m_cancel_scopes(false), m_section(section) {}
+  m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo) {}
 
 DWARFUnit::~DWARFUnit() = default;
 
@@ -336,6 +336,9 @@
 }
   }
 
+  if (m_is_dwo)
+return;
+
   std::unique_ptr dwo_symbol_file =
   m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
   if (!dwo_symbol_file)
@@ -888,11 +891,12 @@
 return llvm::make_error(
 "No abbrev exists at the specified offset.");
 
+  bool is_dwo = dwarf.GetDWARFContext().isDwo();
   if (expected_header->IsTypeUnit())
-return DWARFUnitSP(
-new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs, section));
-  return DWARFUnitSP(
-  new DWARFCompileUnit(dwarf, uid, *expected_header, *abbrevs, section));
+return DWARFUnitSP(new DWARFTypeUnit(dwarf, uid, *expected_header, *abbrevs,
+ section, is_dwo));
+  return DWARFUnitSP(new DWARFCompileUnit(dwarf, uid, *expected_header,
+  *abbrevs, section, is_dwo));
 }
 
 const lldb_private::DWARFDataExtractor &DWARFUnit::GetData() const {
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
===
--- lldb/source/Plugins/SymbolFi

[Lldb-commits] [PATCH] D70840: [LLDB] [DWARF] Strip out the thumb bit from addresses on ARM

2019-12-20 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

In D70840#1792498 , @labath wrote:

> In D70840#1791292 , @mstorsjo wrote:
>
> > And irrespectively if the ArchSpec vs Architecture design, can you (either 
> > of you) comment on the updated form of the patch?
>
>
> The code still seems somewhat schizophrenic to me. :/ The line tables are 
> fixed up super late,


This bit was based on suggestions by @clayborg here; it could be moved earlier 
as well, there's not much restrictions on where that one is done.

> but DW_AT_low_pc is adjusted very early. The line table adjustment happens 
> even after sorting, which means the fixup could alter the sort order. It 
> probably wouldn't matter in practice, as everything would just get 
> decremented by one, but it still seems like a bad design. And adjusting the 
> low_pc so early will complicate the move to the llvm dwarf parser.
> 
> I think I'd most prefer some middle ground where the fixup happens after the 
> lowest extraction layers are finished, but before the data hits the "generic" 
> code. It's possible that no such place exists right now, but it might be 
> possible to create something with a bit of refactoring...

The main issue with DW_AT_low_pc/DW_AT_high_pc, is that they're used in many 
different places - it's not just a straightforward process of "read data from 
storage into intermediate representations", but there's different accessor 
methods that all end up going to the original source, fetching the data. 
`GetDIENamesAndRanges` is one of the methods that reads data and outputs arrays 
and ranges, and those could be considered to handle later after extracting. 
`GetAttributeAddressRange` is one that is used in different contexts, where it 
might be possible to move the fixing up to a higher layer. But then there's 
cases like `LookupAddress` which seems to fetch the raw data from storage, just 
to do `if ((lo_pc <= address) && (address < hi_pc))` to see if the info for the 
desired address is found.

But I guess it could be moved a few steps further out at least; for 
`LookupAddress` it could be done at the very end after fetching all the 
addresses, before doing the comparison, for `GetAttributeAddressRange` (which 
also is used by `LookupAddress`) it could be done right before returning, and 
with `GetDIENamesAndRanges` it could even be done by the caller.

The problem with the interface of the `DWARFDebugInfoEntry` class is that 
there's a lot of public methods, that provide access to data both at a high and 
low level of abstraction. Currently not all of the public methods are called 
from outside of the object, but the current implementation (where it's done 
immediately after loading values) was an attempt to safeguard all possible 
access patterns, even the ones not currently exercised. If we only do it in 
certain places, we could later end up with new code accessing the lower level 
methods, bypassing the fixups.


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

https://reviews.llvm.org/D70840



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


[Lldb-commits] [PATCH] D71751: [lldb/DWARF] Fix mixed v4+v5 location lists

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a project: LLDB.
labath added a parent revision: D71750: [lldb/DWARF] Add is_dwo member to 
DWARFUnit.

Our code was expecting that a single (symbol) file contains only one
kind of location lists. This is not correct (on non-apple platforms, at
least) as a file can compile units with different dwarf versions.

This patch moves the deteremination of location list flavour down to the
compile unit level, fixing this problem. I have also tried to rougly
align the code with the llvm DWARFUnit. Fully matching the API is not
possible because of how lldb's DWARFExpression lives separately from the
rest of the DWARF code, but this is at least a step in the right
direction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71751

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s

Index: lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/debug_loc_and_loclists.s
@@ -0,0 +1,154 @@
+# Test that we can handle DWARF 4 and 5 location lists in the same object file
+# (but different compile units).
+
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t -o "image lookup -v -s loc" -o "image lookup -v -s loclists" \
+# RUN:   -o exit | FileCheck %s
+
+
+# CHECK-LABEL: image lookup -v -s loc
+# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = DW_OP_reg5 RDI,
+
+# CHECK-LABEL: image lookup -v -s loclists
+# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = DW_OP_reg0 RAX,
+
+
+loc:
+nop
+.Lloc_end:
+
+loclists:
+nop
+.Lloclists_end:
+
+.section.debug_loc,"",@progbits
+.Lloc_list:
+.quad loc-loc
+.quad .Lloc_end-loc
+.short 1
+.byte   85  # super-register DW_OP_reg5
+.quad 0
+.quad 0
+
+.section.debug_loclists,"",@progbits
+.long   .Ldebug_loclist_table_end0-.Ldebug_loclist_table_start0 # Length
+.Ldebug_loclist_table_start0:
+.short  5   # Version
+.byte   8   # Address size
+.byte   0   # Segment selector size
+.long   0   # Offset entry count
+
+.Lloclists_list:
+.byte   4   # DW_LLE_offset_pair
+.uleb128 loclists-loclists
+.uleb128 .Lloclists_end-loclists
+.uleb128 1
+.byte   80  # super-register DW_OP_reg0
+.byte   0   # DW_LLE_end_of_list
+.Ldebug_loclist_table_end0:
+
+.section.debug_abbrev,"",@progbits
+.byte   1   # Abbreviation Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   19  # DW_AT_language
+.byte   5   # DW_FORM_data2
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   2   # Abbreviation Code
+.byte   46  # DW_TAG_subprogram
+.byte   1   # DW_CHILDREN_yes
+.byte   17  # DW_AT_low_pc
+.byte   1   # DW_FORM_addr
+.byte   18  # DW_AT_high_pc
+.byte   6   # DW_FORM_data4
+.byte   3   # DW_AT_name
+.byte   8   # DW_FORM_string
+.byte   73  # DW_AT_type
+.byte   16  # DW_FORM_ref_addr
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   3   # Abbreviation Code
+.byte   5   # DW_TAG_formal_parameter
+.byte   0   # DW_CHILDREN_no
+.byte   2  

[Lldb-commits] [PATCH] D71699: [lldb] Increase the rate at which ConstString's memory allocator scales the memory chunks it allocates

2019-12-20 Thread Luboš Luňák via Phabricator via lldb-commits
llunak accepted this revision.
llunak added a comment.
This revision is now accepted and ready to land.

I'm back at using gdb for the time being, so I'd have to build code with 
debuginfo suitable for lldb, which would take some time. But given that this is 
more or less the same as I did before, I don't see why this shouldn't work 
similarly. Thank you for getting these changes in.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D71699



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


[Lldb-commits] [lldb] 5f78b1d - [lldb] Add tests for ClangASTImporter's DeportType and DeportDecl methods

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

Author: Raphael Isemann
Date: 2019-12-20T14:47:15+01:00
New Revision: 5f78b1d648240ba188d08ac1ce62fb7f68d41149

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

LOG: [lldb] Add tests for ClangASTImporter's DeportType and DeportDecl methods

Added: 


Modified: 
lldb/unittests/Symbol/TestClangASTImporter.cpp

Removed: 




diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp 
b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index 2a5900c8da55..11749a4189c3 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -43,6 +43,22 @@ class TestClangASTImporter : public testing::Test {
 lldb::AccessType::eAccessPublic, name, 0,
 lldb::LanguageType::eLanguageTypeC);
   }
+
+  /// Create a record with the given name and a field with the given type
+  /// and name.
+  CompilerType createRecordWithField(ClangASTContext &ast,
+ llvm::StringRef record_name,
+ CompilerType field_type,
+ llvm::StringRef field_name) {
+CompilerType t = createRecord(ast, record_name);
+
+ClangASTContext::StartTagDeclarationDefinition(t);
+ast.AddFieldToRecordType(t, field_name, field_type,
+ lldb::AccessType::eAccessPublic, 7);
+ClangASTContext::CompleteTagDeclarationDefinition(t);
+
+return t;
+  }
 };
 
 TEST_F(TestClangASTImporter, CanImportInvalidType) {
@@ -58,7 +74,9 @@ TEST_F(TestClangASTImporter, ImportInvalidType) {
 TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
   // Tests that the ClangASTImporter::CopyDecl can copy TagDecls.
   std::unique_ptr source_ast = createAST();
-  CompilerType source_type = createRecord(*source_ast, "Source");
+  CompilerType source_type = createRecordWithField(
+  *source_ast, "Source",
+  source_ast->GetBasicType(lldb::BasicType::eBasicTypeChar), "a_field");
   clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type);
 
   std::unique_ptr target_ast = createAST();
@@ -72,6 +90,8 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
   clang::TagDecl *imported_tag_decl = llvm::cast(imported);
   EXPECT_EQ(source->getQualifiedNameAsString(),
 imported_tag_decl->getQualifiedNameAsString());
+  // We did a minimal import of the tag decl.
+  EXPECT_TRUE(imported_tag_decl->hasExternalLexicalStorage());
 
   // Check that origin was set for the imported declaration.
   ClangASTImporter::DeclOrigin origin = importer.GetDeclOrigin(imported);
@@ -83,7 +103,9 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
 TEST_F(TestClangASTImporter, CopyTypeTagDecl) {
   // Tests that the ClangASTImporter::CopyType can copy TagDecls types.
   std::unique_ptr source_ast = createAST();
-  CompilerType source_type = createRecord(*source_ast, "Source");
+  CompilerType source_type = createRecordWithField(
+  *source_ast, "Source",
+  source_ast->GetBasicType(lldb::BasicType::eBasicTypeChar), "a_field");
   clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type);
 
   std::unique_ptr target_ast = createAST();
@@ -96,6 +118,8 @@ TEST_F(TestClangASTImporter, CopyTypeTagDecl) {
   clang::TagDecl *imported_tag_decl = ClangUtil::GetAsTagDecl(imported);
   EXPECT_EQ(source->getQualifiedNameAsString(),
 imported_tag_decl->getQualifiedNameAsString());
+  // We did a minimal import of the tag decl.
+  EXPECT_TRUE(imported_tag_decl->hasExternalLexicalStorage());
 
   // Check that origin was set for the imported declaration.
   ClangASTImporter::DeclOrigin origin =
@@ -105,6 +129,57 @@ TEST_F(TestClangASTImporter, CopyTypeTagDecl) {
   EXPECT_EQ(origin.decl, source);
 }
 
+TEST_F(TestClangASTImporter, DeportDeclTagDecl) {
+  // Tests that the ClangASTImporter::DeportDecl completely copies TagDecls.
+  std::unique_ptr source_ast = createAST();
+  CompilerType source_type = createRecordWithField(
+  *source_ast, "Source",
+  source_ast->GetBasicType(lldb::BasicType::eBasicTypeChar), "a_field");
+  clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type);
+
+  std::unique_ptr target_ast = createAST();
+
+  ClangASTImporter importer;
+  clang::Decl *imported = importer.DeportDecl(
+  target_ast->getASTContext(), source_ast->getASTContext(), source);
+  ASSERT_NE(nullptr, imported);
+
+  // Check that we got the correct decl by just comparing their qualified name.
+  clang::TagDecl *imported_tag_decl = llvm::cast(imported);
+  EXPECT_EQ(source->getQualifiedNameAsString(),
+imported_tag_decl->getQualifiedNameAsString());
+  // The record should be completed as we deported it.
+  EXPECT_FALSE(imported_tag_decl->hasExternalLexicalStorage());
+
+  // Deporting

[Lldb-commits] [lldb] b04b92c - [lldb/pexpect] Force-set the TERM environment variable

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T15:19:41+01:00
New Revision: b04b92c3a4640417f2074e7e903df8c2b76eadfd

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

LOG: [lldb/pexpect] Force-set the TERM environment variable

In some environments (typically, buildbots), this variable may not be
available. This can cause tests to behave differently.

Explicitly set the variable to "vt100" to ensure consistent test
behavior. It should not matter that we do not inherit the process TERM
variable, as the child process runs in a new virtual terminal anyway.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py 
b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
index 13552dca7b9a..d599bc397622 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbpexpect.py
@@ -1,6 +1,7 @@
 from __future__ import absolute_import
 
 # System modules
+import os
 import sys
 
 # Third-party modules
@@ -29,6 +30,7 @@ def expect_prompt(self):
 def launch(self, executable=None, extra_args=None, timeout=30, 
dimensions=None):
 logfile = getattr(sys.stdout, 'buffer',
   sys.stdout) if self.TraceOn() else None
+
 args = ['--no-lldbinit', '--no-use-colors']
 for cmd in self.setUpCommands():
 args += ['-O', cmd]
@@ -36,9 +38,13 @@ def launch(self, executable=None, extra_args=None, 
timeout=30, dimensions=None):
 args += ['--file', executable]
 if extra_args is not None:
 args.extend(extra_args)
+
+env = dict(os.environ)
+env["TERM"]="vt100"
+
 self.child = pexpect.spawn(
 lldbtest_config.lldbExec, args=args, logfile=logfile,
-timeout=timeout, dimensions=dimensions)
+timeout=timeout, dimensions=dimensions, env=env)
 self.expect_prompt()
 for cmd in self.setUpCommands():
 self.child.expect_exact(cmd)



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


[Lldb-commits] [lldb] 05c3b36 - [lldb] Fix a -Wreturn-type warning on gcc

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T15:19:41+01:00
New Revision: 05c3b36bc9a35a8aa3ddd6a912ddceab90c39b4d

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

LOG: [lldb] Fix a -Wreturn-type warning on gcc

Added: 


Modified: 
lldb/source/Target/ThreadPlanStepRange.cpp

Removed: 




diff  --git a/lldb/source/Target/ThreadPlanStepRange.cpp 
b/lldb/source/Target/ThreadPlanStepRange.cpp
index 1db29652aa8b..d1c56165da50 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -250,6 +250,7 @@ bool ThreadPlanStepRange::StopOthers() {
   case lldb::eAllThreads:
 return false;
   }
+  llvm_unreachable("Unhandled run mode!");
 }
 
 InstructionList *ThreadPlanStepRange::GetInstructionsForAddress(



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


[Lldb-commits] [PATCH] D71761: [lldb] Add a setting to not install the main executable

2019-12-20 Thread Daniel Kiss via Phabricator via lldb-commits
danielkiss created this revision.
danielkiss added reviewers: omjavaid, JDevlieghere, srhines.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add setting target.auto-install-main-executable that controls whether
the main executable should be automatically installed when connected to
a remote platform even if it does not have an explicit install path
specified. The default is true as the current behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71761

Files:
  lldb/include/lldb/Target/Target.h
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
  
lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
  lldb/source/Target/Target.cpp
  lldb/source/Target/TargetProperties.td

Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -154,6 +154,9 @@
   def RequireHardwareBreakpoints: Property<"require-hardware-breakpoint", "Boolean">,
 DefaultFalse,
 Desc<"Require all breakpoints to be hardware breakpoints.">;
+  def AutoInstallMainExecutable: Property<"auto-install-main-executable", "Boolean">,
+DefaultTrue,
+Desc<"Always install the main executable when connected to a remote platform.">;
 }
 
 let Definition = "process" in {
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2691,8 +2691,10 @@
   if (platform_sp) {
 if (platform_sp->IsRemote()) {
   if (platform_sp->IsConnected()) {
-// Install all files that have an install path, and always install the
-// main executable when connected to a remote platform
+// Install all files that have an install path when connected to a
+// remote platform. If target.auto-install-main-executable is set then
+// also install the main executable even if it does not have an explicit
+// install path specified.
 const ModuleList &modules = GetImages();
 const size_t num_images = modules.GetSize();
 for (size_t idx = 0; idx < num_images; ++idx) {
@@ -2703,10 +2705,8 @@
 if (local_file) {
   FileSpec remote_file(module_sp->GetRemoteInstallFileSpec());
   if (!remote_file) {
-if (is_main_executable) // TODO: add setting for always
-// installing main executable???
-{
-  // Always install the main executable
+if (is_main_executable && GetAutoInstallMainExecutable()) {
+  // Automatically install the main executable.
   remote_file = platform_sp->GetRemoteWorkingDirectory();
   remote_file.AppendPathComponent(
   module_sp->GetFileSpec().GetFilename().GetCString());
@@ -3975,6 +3975,12 @@
   m_collection_sp->SetPropertyAtIndexAsBoolean(nullptr, idx, b);
 }
 
+bool TargetProperties::GetAutoInstallMainExecutable() const {
+  const uint32_t idx = ePropertyAutoInstallMainExecutable;
+  return m_collection_sp->GetPropertyAtIndexAsBoolean(
+  nullptr, idx, g_target_properties[idx].default_uint_value != 0);
+}
+
 void TargetProperties::Arg0ValueChangedCallback(void *target_property_ptr,
 OptionValue *) {
   TargetProperties *this_ =
Index: lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/main.cpp
@@ -0,0 +1,8 @@
+#include 
+
+const char* build = BUILD;
+
+int main(int argc, char **argv) {
+  printf("argc: %d\n", argc);
+  return argv[0][0];
+}
Index: lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/commands/target/auto-install-main-executable/TestAutoInstallMainExecutable.py
@@ -0,0 +1,137 @@
+"""
+Test target commands: target.auto-install-main-executable.
+"""
+
+import time
+import gdbremote_testcase
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestAutoInstallMainExecutable(gdbremote_testcase.GdbRemoteTestCaseBase):
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+super(TestAutoInstallMainExecutable, self).setUp()
+self._initial_platform = lldb.DBG.GetSelectedPlatform()
+
+def tearDown(self):
+lldb.DBG.SetS

[Lldb-commits] [lldb] a9c8453 - [lldb] Put the headers in unittests/TestingSupport/ into modules

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

Author: Raphael Isemann
Date: 2019-12-20T15:43:53+01:00
New Revision: a9c845395f827055b951532451df1ea50184c21d

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

LOG: [lldb] Put the headers in unittests/TestingSupport/ into modules

Added: 
lldb/unittests/TestingSupport/module.modulemap

Modified: 


Removed: 




diff  --git a/lldb/unittests/TestingSupport/module.modulemap 
b/lldb/unittests/TestingSupport/module.modulemap
new file mode 100644
index ..542c0b11c78f
--- /dev/null
+++ b/lldb/unittests/TestingSupport/module.modulemap
@@ -0,0 +1,11 @@
+
+module lldb_TestingSupport {
+  requires cplusplus
+  module TestUtilities { header "TestUtilities.h" export * }
+  module MockTildeExpressionResolver { header "MockTildeExpressionResolver.h" 
export * }
+}
+
+module lldb_TestingSupport_Host {
+  requires cplusplus
+  module NativeProcessTestUtils { header "Host/NativeProcessTestUtils.h" 
export * }
+}



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


[Lldb-commits] [lldb] aaa34bc - [lldb][NFC] Move utility functions from ClangASTImporter and ClangExpressionDeclMap to own header

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

Author: Raphael Isemann
Date: 2019-12-20T16:13:24+01:00
New Revision: aaa34bc0bd1aeb7271ba0ce2c4f3dfba5dbae8e2

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

LOG: [lldb][NFC] Move utility functions from ClangASTImporter and 
ClangExpressionDeclMap to own header

Added: 
lldb/unittests/TestingSupport/Symbol/ClangTestUtils.h

Modified: 
lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
lldb/unittests/Symbol/TestClangASTImporter.cpp
lldb/unittests/TestingSupport/module.modulemap

Removed: 




diff  --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp 
b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
index 6fac168462b3..36d45fe5a58f 100644
--- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
+++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
@@ -7,7 +7,7 @@
 
//===--===//
 
 #include "Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h"
-#include "TestingSupport/TestUtilities.h"
+#include "TestingSupport/Symbol/ClangTestUtils.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
@@ -78,7 +78,7 @@ struct ClangExpressionDeclMapTest : public testing::Test {
   void SetUp() override {
 importer = std::make_shared();
 decl_map = std::make_unique(importer);
-target_ast = createAST();
+target_ast = clang_utils::createAST();
 decl_map->InstallASTContext(*target_ast, *target_ast->getFileManager());
   }
 
@@ -87,21 +87,6 @@ struct ClangExpressionDeclMapTest : public testing::Test {
 decl_map.reset();
 target_ast.reset();
   }
-
-  clang::DeclarationName getDeclarationName(ClangASTContext &ast,
-llvm::StringRef name) {
-clang::IdentifierInfo &II = ast.getIdentifierTable()->get(name);
-return ast.getASTContext()->DeclarationNames.getIdentifier(&II);
-  }
-
-  CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
-CompilerType t = 
ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(),
-lldb::AccessType::eAccessPublic, name, 0,
-lldb::LanguageType::eLanguageTypeC);
-ClangASTContext::StartTagDeclarationDefinition(t);
-ClangASTContext::CompleteTagDeclarationDefinition(t);
-return t;
-  }
 };
 } // namespace
 
@@ -110,7 +95,8 @@ TEST_F(ClangExpressionDeclMapTest, 
TestUnknownIdentifierLookup) {
 
   // Setup a NameSearchContext for 'foo'.
   llvm::SmallVector decls;
-  clang::DeclarationName name = getDeclarationName(*target_ast, "foo");
+  clang::DeclarationName name =
+  clang_utils::getDeclarationName(*target_ast, "foo");
   const clang::DeclContext *dc = target_ast->GetTranslationUnitDecl();
   NameSearchContext search(*decl_map, decls, name, dc);
 
@@ -127,12 +113,13 @@ TEST_F(ClangExpressionDeclMapTest, 
TestPersistentDeclLookup) {
   // to the scratch AST context.
   llvm::StringRef decl_name = "$persistent_class";
   CompilerType persistent_type =
-  createRecord(*decl_map->m_scratch_context, decl_name);
+  clang_utils::createRecord(*decl_map->m_scratch_context, decl_name);
   decl_map->AddPersistentDeclForTest(ClangUtil::GetAsTagDecl(persistent_type));
 
   // Setup a NameSearchContext for $persistent_class;
   llvm::SmallVector decls;
-  clang::DeclarationName name = getDeclarationName(*target_ast, decl_name);
+  clang::DeclarationName name =
+  clang_utils::getDeclarationName(*target_ast, decl_name);
   const clang::DeclContext *dc = target_ast->GetTranslationUnitDecl();
   NameSearchContext search(*decl_map, decls, name, dc);
 

diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp 
b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index 11749a4189c3..126484e8d047 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -8,6 +8,7 @@
 
 #include "gtest/gtest.h"
 
+#include "TestingSupport/Symbol/ClangTestUtils.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Symbol/ClangASTContext.h"
@@ -73,22 +74,19 @@ TEST_F(TestClangASTImporter, ImportInvalidType) {
 
 TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
   // Tests that the ClangASTImporter::CopyDecl can copy TagDecls.
-  std::unique_ptr source_ast = createAST();
-  CompilerType source_type = createRecordWithField(
-  *source_ast, "Source",
-  source_ast->GetBasicType(lldb::BasicType::eBasicTypeChar), "a_field");
-  clang::TagDecl *source = ClangUtil::GetAsTagDecl(source_type);
+  clang_utils::SourceASTWithRecord source;
 
   std::unique_ptr target_ast = createAST();
 
   ClangASTImporter importer;
-  clang::Decl *imported = importer.

[Lldb-commits] [PATCH] D70846: Expression eval lookup speedup by not returning methods in ManualDWARFIndex::GetFunctions

2019-12-20 Thread Levon Ter-Grigoryan via Phabricator via lldb-commits
PatriosTheGreat updated this revision to Diff 234899.

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

https://reviews.llvm.org/D70846

Files:
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp


Index: lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
@@ -21,7 +21,7 @@
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method 
%t | \
 // RUN:   FileCheck --check-prefix=METHOD %s
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t 
| \
-// RUN:   FileCheck --check-prefix=FULL %s
+// RUN:   FileCheck --check-prefix=FULL-APPLE %s
 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full 
%t | \
 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
 // RUN: lldb-test symbols --name=foo --context=context --find=function 
--function-flags=base %t | \
@@ -55,14 +55,16 @@
 // METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
 // METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = 
"_ZZ5ffbarvEN4sbaz3fooEv"
 
-// FULL: Found 7 functions:
-// FULL-DAG: name = "foo()", mangled = "_Z3foov"
-// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi"
-// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
-// FULL-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
-// FULL-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
-// FULL-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
-// FULL-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
+// FULL-APPLE: Found 7 functions:
+// FULL-APPLE-DAG: name = "foo()", mangled = "_Z3foov"
+// FULL-APPLE-DAG: name = "foo(int)", mangled = "_Z3fooi"
+// FULL-APPLE-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
+// FULL-APPLE-DAG: name = "bar::baz::foo()", mangled = "_ZN3bar3baz3fooEv"
+// FULL-APPLE-DAG: name = "sbar::foo()", mangled = "_ZN4sbar3fooEv"
+// FULL-APPLE-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
+// FULL-APPLE-DAG: name = "ffbar()::sbaz::foo()", mangled = 
"_ZZ5ffbarvEN4sbaz3fooEv"
+
+// FULL: Found 0 functions:
 
 // FULL-MANGLED: Found 1 functions:
 // FULL-MANGLED-DAG: name = "foo(int)", mangled = "_Z3fooi"
Index: lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -401,8 +401,6 @@
 
   if (name_type_mask & eFunctionNameTypeFull) {
 DIEArray offsets;
-m_set.function_basenames.Find(name, offsets);
-m_set.function_methods.Find(name, offsets);
 m_set.function_fullnames.Find(name, offsets);
 for (const DIERef &die_ref: offsets) {
   DWARFDIE die = dwarf.GetDIE(die_ref);
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
@@ -1273,7 +1273,7 @@
 // TODO Fix FindFunctions so that it doesn't return
 //   instance methods for eFunctionNameTypeBase.
 
-target->GetImages().FindFunctions(name, eFunctionNameTypeFull,
+target->GetImages().FindFunctions(name, eFunctionNameTypeFull | 
eFunctionNameTypeBase,
   include_symbols, include_inlines,
   sc_list);
   }


Index: lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
@@ -21,7 +21,7 @@
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
 // RUN:   FileCheck --check-prefix=METHOD %s
 // RUN: lldb-test symbols --name=foo --find=function --function-flags=full %t | \
-// RUN:   FileCheck --check-prefix=FULL %s
+// RUN:   FileCheck --check-prefix=FULL-APPLE %s
 // RUN: lldb-test symbols --name=_Z3fooi --find=function --function-flags=full %t | \
 // RUN:   FileCheck --check-prefix=FULL-MANGLED %s
 // RUN: lldb-test symbols --name=foo --context=context --find=function --function-flags=base %t | \
@@ -55,14 +55,16 @@
 // METHOD-DAG: name = "sbar::foo(int)", mangled = "_ZN4sbar3fooEi"
 // METHOD-DAG: name = "ffbar()::sbaz::foo()", mangled = "_ZZ5ffbarvEN4sbaz3fooEv"
 
-// FULL: Found 7 functions:
-// FULL-DAG: name = "foo()", mangled = "_Z3foov"
-// FULL-DAG: name = "foo(int)", mangled = "_Z3fooi"
-// FULL-DAG: name = "bar::foo()", mangled = "_ZN3bar3fooEv"
-// FULL-DAG: name = "bar:

[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: JDevlieghere, aprantl, clayborg.
Herald added a reviewer: jdoerfert.
Herald added a project: LLDB.

This code is handling debug info paths starting with /proc/self/cwd,
which is one of the mechanisms people use to obtain "relocatable" debug
info (the idea being that one starts the debugger with an appropriate
cwd and things "just work").

Instead of resolving the symlinks inside DWARFUnit, we can do the same
thing more elegantly by hooking into the existing Module path remapping
code. Since llvm::DWARFUnit does not support any similar functionality,
doing things this way is also a step towards unifying llvm and lldb
dwarf parsers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71770

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -453,6 +453,17 @@
 void SymbolFileDWARF::InitializeObject() {
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
 
+  Module &module = *GetObjectFile()->GetModule();
+
+  for (const FileSpec &symlink : GetSymlinkPaths()) {
+FileSpec resolved;
+Status status = FileSystem::Instance().Readlink(symlink, resolved);
+if (status.Success())
+  module.GetSourceMappingList().Append(ConstString(symlink.GetPath()),
+   ConstString(resolved.GetPath()),
+   /*notify=*/true);
+  }
+
   if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
 DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
 LoadSectionData(eSectionTypeDWARFAppleNames, apple_names);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -751,25 +751,6 @@
   return path;
 }
 
-static FileSpec resolveCompDir(const FileSpec &path) {
-  bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
-0, path, /*full*/ true) != UINT32_MAX;
-
-  if (!is_symlink)
-return path;
-
-  namespace fs = llvm::sys::fs;
-  if (fs::get_file_type(path.GetPath(), false) != fs::file_type::symlink_file)
-return path;
-
-  FileSpec resolved_symlink;
-  const auto error = FileSystem::Instance().Readlink(path, resolved_symlink);
-  if (error.Success())
-return resolved_symlink;
-
-  return path;
-}
-
 void DWARFUnit::ComputeCompDirAndGuessPathStyle() {
   m_comp_dir = FileSpec();
   const DWARFDebugInfoEntry *die = GetUnitDIEPtrOnly();
@@ -781,7 +762,7 @@
   if (!comp_dir.empty()) {
 FileSpec::Style comp_dir_style =
 FileSpec::GuessPathStyle(comp_dir).getValueOr(FileSpec::Style::native);
-m_comp_dir = resolveCompDir(FileSpec(comp_dir, comp_dir_style));
+m_comp_dir = FileSpec(comp_dir, comp_dir_style);
   } else {
 // Try to detect the style based on the DW_AT_name attribute, but just 
store
 // the detected style in the m_comp_dir field.


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -453,6 +453,17 @@
 void SymbolFileDWARF::InitializeObject() {
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
 
+  Module &module = *GetObjectFile()->GetModule();
+
+  for (const FileSpec &symlink : GetSymlinkPaths()) {
+FileSpec resolved;
+Status status = FileSystem::Instance().Readlink(symlink, resolved);
+if (status.Success())
+  module.GetSourceMappingList().Append(ConstString(symlink.GetPath()),
+   ConstString(resolved.GetPath()),
+   /*notify=*/true);
+  }
+
   if (!GetGlobalPluginProperties()->IgnoreFileIndexes()) {
 DWARFDataExtractor apple_names, apple_namespaces, apple_types, apple_objc;
 LoadSectionData(eSectionTypeDWARFAppleNames, apple_names);
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -751,25 +751,6 @@
   return path;
 }
 
-static FileSpec resolveCompDir(const FileSpec &path) {
-  bool is_symlink = SymbolFileDWARF::GetSymlinkPaths().FindFileIndex(
-0, path, /*full*/ true) != UINT32_MAX;
-
-  if (!is_symlink)
-return path;
-
-  namespace fs = llvm::sys::fs;
-  if (fs::get_file_type(path.GetPath(), false) != fs::file_type::sym

[Lldb-commits] [lldb] ca567ad - [lldb/cmake] Remove support for LLDB_DISABLE_CURSES

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T16:50:06+01:00
New Revision: ca567ad6ffc1fbbd5e354ab80e426c052d027811

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

LOG: [lldb/cmake] Remove support for LLDB_DISABLE_CURSES

The buildbot which necessitated this is fixed.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 063c1fdaa376..e5573197540d 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -29,12 +29,7 @@ set(default_enable_lua OFF) # Experimental
 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()
+# Temporarily support the old LLDB_DISABLE_* variables
 if (DEFINED LLDB_DISABLE_PYTHON)
   if (LLDB_DISABLE_PYTHON)
 set(default_enable_python OFF)



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


[Lldb-commits] [lldb] 32a3428 - [lldb] Fix an unused variable warning

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T16:51:25+01:00
New Revision: 32a34289597c7b0cc60b6c90b4222b44bef302d5

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

LOG: [lldb] Fix an unused variable warning

Added: 


Modified: 
lldb/source/Core/FormatEntity.cpp

Removed: 




diff  --git a/lldb/source/Core/FormatEntity.cpp 
b/lldb/source/Core/FormatEntity.cpp
index 5d4dba073743..7aa1eced34f3 100644
--- a/lldb/source/Core/FormatEntity.cpp
+++ b/lldb/source/Core/FormatEntity.cpp
@@ -1762,7 +1762,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
   return false;
 s.PutCString(name);
 
-if (Block *inline_block = sc->block->GetContainingInlinedBlock()) {
+if (sc->block->GetContainingInlinedBlock()) {
   if (const InlineFunctionInfo *inline_info =
   sc->block->GetInlinedFunctionInfo()) {
 s.PutCString(" [inlined] ");



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


[Lldb-commits] [lldb] 40aa418 - [lldb/cmake] Delete LLDB_LINKER_SUPPORTS_GROUPS

2019-12-20 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2019-12-20T16:58:58+01:00
New Revision: 40aa418223f36e0b9bfa457606e0d8f50aa4fe66

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

LOG: [lldb/cmake] Delete LLDB_LINKER_SUPPORTS_GROUPS

The variable is unused.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index e5573197540d..3424cd89cb79 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -18,12 +18,6 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
 "`CMakeFiles'. Please delete them.")
 endif()
 
-set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES 
"Darwin")
-  # The Darwin linker doesn't understand --start-group/--end-group.
-  set(LLDB_LINKER_SUPPORTS_GROUPS ON)
-endif()
-
 set(default_enable_python ON)
 set(default_enable_lua OFF) # Experimental
 set(default_enable_libedit ON)



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


[Lldb-commits] [PATCH] D71232: [lldb/Lua] Add Boilerplate for a Lua Script Interpreter

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:62
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." 
${default_enable_python})
+option(LLDB_ENABLE_PYTHON "Enable Lua scripting integration." 
${default_enable_lua})
 option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." 
${default_enable_libedit})

Umm... I guess this wanted to be LLDB_ENABLE_LUA ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71232



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


[Lldb-commits] [PATCH] D71482: [lldb/CMake] Rename LLDB_DISABLE_PYTHON to LLDB_ENABLE_PYTHON

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/cmake/modules/LLDBConfig.cmake:43
+  else()
+set(default_enable_python ON)
+  endif()

labath wrote:
> JDevlieghere wrote:
> > mgorny wrote:
> > > JDevlieghere wrote:
> > > > mgorny wrote:
> > > > > JDevlieghere wrote:
> > > > > > mgorny wrote:
> > > > > > > I know that the same thing is done above but… what's the point of 
> > > > > > > setting it to `ON` again?
> > > > > > It's just setting the default to the old value. If the value was 
> > > > > > set, we should honor it, both if it was `OFF` or `ON`.
> > > > > But it's already set to `ON` a few lines above.
> > > > Do you mean the `DEFINED`? That just checks if the variable exists, not 
> > > > its value. 
> > > No, I mean you have:
> > > 
> > > ```
> > > set(default_enable_python ON)
> > > #...
> > > if (DEFINED LLDB_DISABLE_PYTHON)
> > >   #...
> > >   else()
> > > set(default_enable_python ON)
> > > ```
> > > 
> > > This is superfluous since the default is already `ON`.
> > Got it, thanks. Simplified the code. 
> Yeah, I added the curses stuff without too much optimization to keep the 
> debian bot working until the master restarts (so the configuration change 
> takes effect). I don't think we have any bots using LLDB_DISABLE_PYTHON, so 
> this probably wasn't even needed, but this all isn't very important -- the 
> code will be gone in a few days anyway...
Btw, I've just removed the LLDB_DISABLE_CURSES blurb. If you don't know of any 
reason to keep LLDB_DISABLE_PYTHON python around (I don't) then I think that 
can go too...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71482



___
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-20 Thread Jordan Rupprecht via lldb-commits
Nice, thanks!

On Fri, Dec 20, 2019 at 2:53 AM Raphael “Teemperor” Isemann <
teempe...@gmail.com> wrote:

> Fixed by https://reviews.llvm.org/D71748. Will land this today.
>
> On 18. Dec 2019, at 23:03, Raphael “Teemperor” Isemann <
> teempe...@gmail.com> wrote:
>
> 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 <
> 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.

[Lldb-commits] [lldb] 6be76f4 - [lldb][NFC] Remove redundant ASTContext args to CopyDecl/DeportDecl

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

Author: Raphael Isemann
Date: 2019-12-20T18:45:14+01:00
New Revision: 6be76f491fcbb2a8476e58cb8d3310155c71e74a

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

LOG: [lldb][NFC] Remove redundant ASTContext args to CopyDecl/DeportDecl

We already pass a Decl here and the additional ASTContext needs to
match the Decl. We might as well just pass the Decl and then extract
the ASTContext from that.

Added: 


Modified: 
lldb/include/lldb/Symbol/ClangASTImporter.h
lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Symbol/ClangASTImporter.cpp
lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp
lldb/unittests/Symbol/TestClangASTImporter.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/ClangASTImporter.h 
b/lldb/include/lldb/Symbol/ClangASTImporter.h
index 9c0a95beb1e8..faec3a77b56f 100644
--- a/lldb/include/lldb/Symbol/ClangASTImporter.h
+++ b/lldb/include/lldb/Symbol/ClangASTImporter.h
@@ -50,13 +50,11 @@ class ClangASTImporter {
 
   CompilerType CopyType(ClangASTContext &dst, const CompilerType &src_type);
 
-  clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx,
-clang::Decl *decl);
+  clang::Decl *CopyDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
 
   CompilerType DeportType(ClangASTContext &dst, const CompilerType &src_type);
 
-  clang::Decl *DeportDecl(clang::ASTContext *dst_ctx,
-  clang::ASTContext *src_ctx, clang::Decl *decl);
+  clang::Decl *DeportDecl(clang::ASTContext *dst_ctx, clang::Decl *decl);
 
   /// Sets the layout for the given RecordDecl. The layout will later be
   /// used by Clang's during code generation. Not calling this function for

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 24dc7268976d..6d6830c740d1 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -453,8 +453,7 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
 ConstString name_cs(name.str().c_str());
 
 Decl *D_scratch = m_target.GetClangASTImporter()->DeportDecl(
-ClangASTContext::GetScratch(m_target)->getASTContext(), m_ast_context,
-decl);
+ClangASTContext::GetScratch(m_target)->getASTContext(), decl);
 
 if (!D_scratch) {
   Log 
*log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index f37fe21b5545..e326d239cb55 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -1823,9 +1823,8 @@ NamespaceDecl *ClangASTSource::AddNamespace(
 }
 
 clang::Decl *ClangASTSource::CopyDecl(Decl *src_decl) {
-  clang::ASTContext &from_context = src_decl->getASTContext();
   if (m_ast_importer_sp) {
-return m_ast_importer_sp->CopyDecl(m_ast_context, &from_context, src_decl);
+return m_ast_importer_sp->CopyDecl(m_ast_context, src_decl);
   } else {
 lldbassert(0 && "No mechanism for copying a decl!");
 return nullptr;

diff  --git a/lldb/source/Symbol/ClangASTImporter.cpp 
b/lldb/source/Symbol/ClangASTImporter.cpp
index d856443b268a..7bdbe2bcc1dc 100644
--- a/lldb/source/Symbol/ClangASTImporter.cpp
+++ b/lldb/source/Symbol/ClangASTImporter.cpp
@@ -65,10 +65,10 @@ CompilerType ClangASTImporter::CopyType(ClangASTContext 
&dst_ast,
 }
 
 clang::Decl *ClangASTImporter::CopyDecl(clang::ASTContext *dst_ast,
-clang::ASTContext *src_ast,
 clang::Decl *decl) {
   ImporterDelegateSP delegate_sp;
 
+  clang::ASTContext *src_ast = &decl->getASTContext();
   delegate_sp = GetDelegate(dst_ast, src_ast);
 
   ASTImporterDelegate::CxxModuleScope std_scope(*delegate_sp, dst_ast);
@@ -320,10 +320,10 @@ CompilerType ClangASTImporter::DeportType(ClangASTContext 
&dst,
 }
 
 clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
-  clang::ASTContext *src_ctx,
   clang::Decl *decl) {
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
 
+  clang::ASTContext *src_ctx = &decl->getASTContext();
   LLDB_LOGF(log,
 "[ClangASTImporter] DeportDecl called on (%sDecl*)%p from "
 "(ASTContext*)%p to (ASTContext*)%p",
@@ -337,7 +337,7 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext

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

2019-12-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: lldb/cmake/modules/FindCursesAndPanel.cmake:8
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+  set(CURSES_PANEL_FOUND TRUE)
+else()

labath wrote:
> It's not fully clear to me what will happen when this code is run for the 
> first time (when `CURSES_INCLUDE_DIRS`, etc. is not defined yet). Who will 
> set `CURSES_PANEL_FOUND` in that case? Could you make sure this works 
> correctly when run for the first time on a fully clean build?
> 
> I don't know whether this is the standard way of writing find_package files, 
> but I'd consider just removing the caching and letting `find_package(Curses)` 
> and  `find_library(panel)` just run every time -- they already contain some 
> internal caching so we're not saving much here anyway...
I inspired myself on other FindPackage code. I have to admit that I don't know 
how it works exactly, but it behaves the way you expect. I did a clean build to 
verify. 


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] D71575: [LLDB] Add ObjectFileWasm plugin for WebAssembly debugging

2019-12-20 Thread Paolo Severini via Phabricator via lldb-commits
paolosev updated this revision to Diff 234920.
paolosev marked 7 inline comments as done.

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());
+  ASSERT_TRUE(platform_sp)

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

2019-12-20 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:45
+
+/// Reads a LEB128 variable-length unsigned integer, limited to 7 bits.
+llvm::Optional GetVaruint7(DataExtractor §ion_header_data,

aprantl wrote:
> The LLVM coding style requests that doxygen comments should be on the 
> declaration in the header file and not in the implementation.
This function is not declared in the header. Probably it doesn't need a doxygen 
comment.


Repository:
  rG LLVM Github Monorepo

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] D71514: Minor fixes of signed pointers for 32-bit hosts on top of D71498

2019-12-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

I will merge this with D71498 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71514



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


[Lldb-commits] [lldb] a805e0f - [lldb][NFC] Remove utility methods in TestClangASTImporter

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

Author: Raphael Isemann
Date: 2019-12-20T19:39:49+01:00
New Revision: a805e0fb18ca3b85712a587b72e5048e78d8f1da

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

LOG: [lldb][NFC] Remove utility methods in TestClangASTImporter

We have a central header for all these methods so we can
just use those for creating ClangASTContexts.

Added: 


Modified: 
lldb/unittests/Symbol/TestClangASTImporter.cpp

Removed: 




diff  --git a/lldb/unittests/Symbol/TestClangASTImporter.cpp 
b/lldb/unittests/Symbol/TestClangASTImporter.cpp
index ce4bdab6cfb8..9a03f854db1a 100644
--- a/lldb/unittests/Symbol/TestClangASTImporter.cpp
+++ b/lldb/unittests/Symbol/TestClangASTImporter.cpp
@@ -33,33 +33,6 @@ class TestClangASTImporter : public testing::Test {
 HostInfo::Terminate();
 FileSystem::Terminate();
   }
-
-protected:
-  std::unique_ptr createAST() {
-return std::make_unique(HostInfo::GetTargetTriple());
-  }
-
-  CompilerType createRecord(ClangASTContext &ast, llvm::StringRef name) {
-return ast.CreateRecordType(ast.getASTContext()->getTranslationUnitDecl(),
-lldb::AccessType::eAccessPublic, name, 0,
-lldb::LanguageType::eLanguageTypeC);
-  }
-
-  /// Create a record with the given name and a field with the given type
-  /// and name.
-  CompilerType createRecordWithField(ClangASTContext &ast,
- llvm::StringRef record_name,
- CompilerType field_type,
- llvm::StringRef field_name) {
-CompilerType t = createRecord(ast, record_name);
-
-ClangASTContext::StartTagDeclarationDefinition(t);
-ast.AddFieldToRecordType(t, field_name, field_type,
- lldb::AccessType::eAccessPublic, 7);
-ClangASTContext::CompleteTagDeclarationDefinition(t);
-
-return t;
-  }
 };
 
 TEST_F(TestClangASTImporter, CanImportInvalidType) {
@@ -76,7 +49,7 @@ TEST_F(TestClangASTImporter, CopyDeclTagDecl) {
   // Tests that the ClangASTImporter::CopyDecl can copy TagDecls.
   clang_utils::SourceASTWithRecord source;
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   clang::Decl *imported =
@@ -101,7 +74,7 @@ TEST_F(TestClangASTImporter, CopyTypeTagDecl) {
   // Tests that the ClangASTImporter::CopyType can copy TagDecls types.
   clang_utils::SourceASTWithRecord source;
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   CompilerType imported = importer.CopyType(*target_ast, source.record_type);
@@ -126,7 +99,7 @@ TEST_F(TestClangASTImporter, DeportDeclTagDecl) {
   // Tests that the ClangASTImporter::DeportDecl completely copies TagDecls.
   clang_utils::SourceASTWithRecord source;
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   clang::Decl *imported =
@@ -148,7 +121,7 @@ TEST_F(TestClangASTImporter, DeportTypeTagDecl) {
   // Tests that the ClangASTImporter::CopyType can deport TagDecl types.
   clang_utils::SourceASTWithRecord source;
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   CompilerType imported = importer.DeportType(*target_ast, source.record_type);
@@ -173,7 +146,7 @@ TEST_F(TestClangASTImporter, MetadataPropagation) {
   const lldb::user_id_t metadata = 123456;
   source.ast->SetMetadataAsUserID(source.record_decl, metadata);
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   clang::Decl *imported =
@@ -195,14 +168,14 @@ TEST_F(TestClangASTImporter, 
MetadataPropagationIndirectImport) {
   const lldb::user_id_t metadata = 123456;
   source.ast->SetMetadataAsUserID(source.record_decl, metadata);
 
-  std::unique_ptr temporary_ast = createAST();
+  std::unique_ptr temporary_ast = clang_utils::createAST();
 
   ClangASTImporter importer;
   clang::Decl *temporary_imported =
   importer.CopyDecl(temporary_ast->getASTContext(), source.record_decl);
   ASSERT_NE(nullptr, temporary_imported);
 
-  std::unique_ptr target_ast = createAST();
+  std::unique_ptr target_ast = clang_utils::createAST();
   clang::Decl *imported =
   importer.CopyDecl(target_ast->getASTContext(), temporary_imported);
   ASSERT_NE(nullptr, imported);
@@ -219,7 +192,7 @@ TEST_F(TestClangASTImporter, 
MetadataPropagationAfterCopying) {
   clang_utils::SourceASTWithRecord source;
   const lldb::user_id_t metadata = 123456;
 
-  std::unique_ptr target_ast = createAST();
+  std:

[Lldb-commits] [lldb] 810c3cf - ThreadPlanTracer::TracingStarted can't call virtual methods on Thread.

2019-12-20 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2019-12-20T10:56:39-08:00
New Revision: 810c3cfa664b38b27bc30afaadab3d775cb17922

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

LOG: ThreadPlanTracer::TracingStarted can't call virtual methods on Thread.

TracingStarted gets called in the Thread constructor, which means you can't
call a virtual method of the class.  So delay setting up the 
m_register_values
till you need them.  NFC as lldb just crashes if you don't do this.

The thread tracing is an only occasionally useful feature, and it only sort
of works.  I'm not adding tests etc. at this point, I'm just poking at it a
bit.  If I get it working better I'll write tests and so forth.

Added: 


Modified: 
lldb/source/Target/ThreadPlanTracer.cpp

Removed: 




diff  --git a/lldb/source/Target/ThreadPlanTracer.cpp 
b/lldb/source/Target/ThreadPlanTracer.cpp
index 5782fe8e6443..b50c1636b7ff 100644
--- a/lldb/source/Target/ThreadPlanTracer.cpp
+++ b/lldb/source/Target/ThreadPlanTracer.cpp
@@ -115,10 +115,6 @@ TypeFromUser ThreadPlanAssemblyTracer::GetIntPointerType() 
{
 ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() = default;
 
 void ThreadPlanAssemblyTracer::TracingStarted() {
-  RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
-
-  if (m_register_values.empty())
-m_register_values.resize(reg_ctx->GetRegisterCount());
 }
 
 void ThreadPlanAssemblyTracer::TracingEnded() { m_register_values.clear(); }
@@ -208,6 +204,11 @@ void ThreadPlanAssemblyTracer::Log() {
 }
   }
 
+  if (m_register_values.empty()) {
+RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
+m_register_values.resize(reg_ctx->GetRegisterCount());
+  }
+
   RegisterValue reg_value;
   for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount();
reg_num < num_registers; ++reg_num) {



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


[Lldb-commits] [lldb] 2a42a5a - In 'thread step-out' command, only insert a breakpoint in executable memory.

2019-12-20 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2019-12-20T11:02:24-08:00
New Revision: 2a42a5a2f4144cd99812ad0d230480f94a1d1c92

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

LOG: In 'thread step-out' command, only insert a breakpoint in executable 
memory.

Previously, if the current function had a nonstandard stack layout/ABI, and had 
a valid
data pointer in the location where the return address is usually located, data 
corruption
would occur when the breakpoint was written. This could lead to an incorrectly 
reported
crash or silent corruption of the program's state. Now, if the above check 
fails, the command safely aborts.

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

Added: 
lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Modified: 
lldb/include/lldb/Target/ThreadPlanStepOut.h
lldb/source/Target/ThreadPlanStepOut.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlanStepOut.h 
b/lldb/include/lldb/Target/ThreadPlanStepOut.h
index 00984db2dca9..576b416c3f2c 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -72,6 +72,7 @@ class ThreadPlanStepOut : public ThreadPlan, public 
ThreadPlanShouldStopHere {
   std::vector m_stepped_past_frames;
   lldb::ValueObjectSP m_return_valobj_sp;
   bool m_calculate_return_value;
+  StreamString m_constructor_errors;
 
   friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut(
   bool abort_other_plans, SymbolContext *addr_context, bool first_insn,

diff  --git a/lldb/source/Target/ThreadPlanStepOut.cpp 
b/lldb/source/Target/ThreadPlanStepOut.cpp
index d7dae446b229..f15a343aaa38 100644
--- a/lldb/source/Target/ThreadPlanStepOut.cpp
+++ b/lldb/source/Target/ThreadPlanStepOut.cpp
@@ -126,6 +126,25 @@ ThreadPlanStepOut::ThreadPlanStepOut(
 if (m_return_addr == LLDB_INVALID_ADDRESS)
   return;
 
+// Perform some additional validation on the return address.
+uint32_t permissions = 0;
+if (!m_thread.GetProcess()->GetLoadAddressPermissions(m_return_addr,
+  permissions)) {
+  m_constructor_errors.Printf("Return address (0x%" PRIx64
+  ") permissions not found.",
+  m_return_addr);
+  LLDB_LOGF(log, "ThreadPlanStepOut(%p): %s", static_cast(this),
+m_constructor_errors.GetData());
+  return;
+} else if (!(permissions & ePermissionsExecutable)) {
+  m_constructor_errors.Printf("Return address (0x%" PRIx64
+  ") did not point to executable memory.",
+  m_return_addr);
+  LLDB_LOGF(log, "ThreadPlanStepOut(%p): %s", static_cast(this),
+m_constructor_errors.GetData());
+  return;
+}
+
 Breakpoint *return_bp = m_thread.CalculateTarget()
 ->CreateBreakpoint(m_return_addr, true, false)
 .get();
@@ -238,8 +257,13 @@ bool ThreadPlanStepOut::ValidatePlan(Stream *error) {
   }
 
   if (m_return_bp_id == LLDB_INVALID_BREAK_ID) {
-if (error)
+if (error) {
   error->PutCString("Could not create return address breakpoint.");
+  if (m_constructor_errors.GetSize() > 0) {
+error->PutCString(" ");
+error->PutCString(m_constructor_errors.GetString());
+  }
+}
 return false;
   }
 

diff  --git a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s 
b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
new file mode 100644
index ..d18ea24fba4d
--- /dev/null
+++ b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -0,0 +1,20 @@
+.text
+.globl  asm_main
+asm_main:
+sub $0x8, %rsp
+movq $0, (%rsp)
+push %rsp
+jmp _nonstandard_stub
+
+# Takes a single pointer argument via the stack, which is nonstandard for x64.
+# Executing 'thread step-out' here will initially attempt to write a
+# breakpoint to that stack address, but should fail because of the executable
+# memory check.
+_nonstandard_stub:
+mov (%rsp), %rdi
+mov (%rdi), %rsi
+add $1, %rsi
+mov %rsi, (%rdi)
+
+add $0x10, %rsp
+ret

diff  --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
new file mode 100644
index ..96490faa2de8
--- /dev/null
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -0,0 +1,17 @@
+# Test that `thread step-out` fails when the "return address"
+# points to non-executable memory.
+
+# REQUIRES: target-x86_64, native
+
+#

[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Jim Ingham via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2a42a5a2f414 (authored by jingham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372

Files:
  lldb/include/lldb/Target/ThreadPlanStepOut.h
  lldb/source/Target/ThreadPlanStepOut.cpp
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- /dev/null
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -0,0 +1,17 @@
+# Test that `thread step-out` fails when the "return address"
+# points to non-executable memory.
+
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/thread-step-out-ret-addr-check.s -o %t
+# RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
+
+breakpoint set -n nonstandard_stub
+# CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+thread step-out
+# CHECK: Could not create return address breakpoint.
+# CHECK: Return address (0x{{[a-f0-9]*}}) did not point to executable memory.
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- /dev/null
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -0,0 +1,20 @@
+.text
+.globl  asm_main
+asm_main:
+sub $0x8, %rsp
+movq $0, (%rsp)
+push %rsp
+jmp _nonstandard_stub
+
+# Takes a single pointer argument via the stack, which is nonstandard for x64.
+# Executing 'thread step-out' here will initially attempt to write a
+# breakpoint to that stack address, but should fail because of the executable
+# memory check.
+_nonstandard_stub:
+mov (%rsp), %rdi
+mov (%rdi), %rsi
+add $1, %rsi
+mov %rsi, (%rdi)
+
+add $0x10, %rsp
+ret
Index: lldb/source/Target/ThreadPlanStepOut.cpp
===
--- lldb/source/Target/ThreadPlanStepOut.cpp
+++ lldb/source/Target/ThreadPlanStepOut.cpp
@@ -126,6 +126,25 @@
 if (m_return_addr == LLDB_INVALID_ADDRESS)
   return;
 
+// Perform some additional validation on the return address.
+uint32_t permissions = 0;
+if (!m_thread.GetProcess()->GetLoadAddressPermissions(m_return_addr,
+  permissions)) {
+  m_constructor_errors.Printf("Return address (0x%" PRIx64
+  ") permissions not found.",
+  m_return_addr);
+  LLDB_LOGF(log, "ThreadPlanStepOut(%p): %s", static_cast(this),
+m_constructor_errors.GetData());
+  return;
+} else if (!(permissions & ePermissionsExecutable)) {
+  m_constructor_errors.Printf("Return address (0x%" PRIx64
+  ") did not point to executable memory.",
+  m_return_addr);
+  LLDB_LOGF(log, "ThreadPlanStepOut(%p): %s", static_cast(this),
+m_constructor_errors.GetData());
+  return;
+}
+
 Breakpoint *return_bp = m_thread.CalculateTarget()
 ->CreateBreakpoint(m_return_addr, true, false)
 .get();
@@ -238,8 +257,13 @@
   }
 
   if (m_return_bp_id == LLDB_INVALID_BREAK_ID) {
-if (error)
+if (error) {
   error->PutCString("Could not create return address breakpoint.");
+  if (m_constructor_errors.GetSize() > 0) {
+error->PutCString(" ");
+error->PutCString(m_constructor_errors.GetString());
+  }
+}
 return false;
   }
 
Index: lldb/include/lldb/Target/ThreadPlanStepOut.h
===
--- lldb/include/lldb/Target/ThreadPlanStepOut.h
+++ lldb/include/lldb/Target/ThreadPlanStepOut.h
@@ -72,6 +72,7 @@
   std::vector m_stepped_past_frames;
   lldb::ValueObjectSP m_return_valobj_sp;
   bool m_calculate_return_value;
+  StreamString m_constructor_errors;
 
   friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOut(
   bool abort_other_plans, SymbolContext *addr_context, bool first_insn,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

I committed this (2a42a5a2f4144cd99812ad0d230480f94a1d1c92 
) but I 
forgot to attribute the patch to Mark in the commit message.  My apologies!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


[Lldb-commits] [lldb] 2861324 - [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype

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

Author: Jonas Devlieghere
Date: 2019-12-20T11:19:47-08:00
New Revision: 2861324208e13846eb306f01b32448f94177cc3b

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

LOG: [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype

This implements a very elementary Lua script interpreter. It supports
running a single command as well as running interactively. It uses
editline if available. It's still missing a bunch of stuff though. Some
things that I intentionally ingored for now are that I/O isn't properly
hooked up (so every print goes to stdout) and the non-editline support
which is not handling a bunch of corner cases. The latter is a matter of
reusing existing code in the Python interpreter.

Discussion on the mailing list:
http://lists.llvm.org/pipermail/lldb-dev/2019-December/015812.html

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

Added: 
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
lldb/test/Shell/ScriptInterpreter/Lua/lua.test
lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp

Modified: 
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/lit.cfg.py
lldb/test/Shell/lit.site.cfg.py.in
lldb/unittests/ScriptInterpreter/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3424cd89cb79..16465ded0522 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -113,6 +113,9 @@ if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
 
+if (LLDB_ENABLE_LUA)
+  find_package(Lua REQUIRED)
+endif()
 
 if (LLDB_ENABLE_LIBEDIT)
   find_package(LibEdit REQUIRED)

diff  --git a/lldb/include/lldb/Core/IOHandler.h 
b/lldb/include/lldb/Core/IOHandler.h
index cf00329f7a0b..9ab5eaaecb66 100644
--- a/lldb/include/lldb/Core/IOHandler.h
+++ b/lldb/include/lldb/Core/IOHandler.h
@@ -52,6 +52,7 @@ class IOHandler {
 REPL,
 ProcessIO,
 PythonInterpreter,
+LuaInterpreter,
 PythonCode,
 Other
   };

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
index 51161638a3d0..498bd9783951 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/CMakeLists.txt
@@ -1,7 +1,11 @@
 add_lldb_library(lldbPluginScriptInterpreterLua PLUGIN
+  Lua.cpp
   ScriptInterpreterLua.cpp
 
   LINK_LIBS
 lldbCore
 lldbInterpreter
-  )
\ No newline at end of file
+  )
+
+target_include_directories(lldbPluginScriptInterpreterLua PUBLIC 
${LUA_INCLUDE_DIR})
+target_link_libraries(lldbPluginScriptInterpreterLua INTERFACE 
${LUA_LIBRARIES})

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
new file mode 100644
index ..a908ef086735
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp
@@ -0,0 +1,27 @@
+//===-- Lua.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 "Lua.h"
+#include "llvm/Support/FormatVariadic.h"
+
+using namespace lldb_private;
+
+llvm::Error Lua::Run(llvm::StringRef buffer) {
+  int error =
+  luaL_loadbuffer(m_lua_state, buffer.data(), buffer.size(), "buffer") ||
+  lua_pcall(m_lua_state, 0, 0, 0);
+  if (!error)
+return llvm::Error::success();
+
+  llvm::Error e = llvm::make_error(
+  llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)),
+  llvm::inconvertibleErrorCode());
+  // Pop error message from the stack.
+  lua_pop(m_lua_state, 1);
+  return e;
+}

diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h 
b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
new file mode 100644
index ..50b7ade4dc46
--- /dev/null
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
@@ -0,0 +1,39 @@
+//===-- ScriptInterpreterLua.h --*- 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-ex

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

2019-12-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2861324208e1: [lldb/Lua] Implement a Simple Lua Script 
Interpreter Prototype (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D71234?vs=234798&id=234934#toc

Repository:
  rG LLVM Github Monorepo

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/Lua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/Lua.h
  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
  lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp

Index: lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.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/LuaTests.cpp
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Lua/LuaTests.cpp
@@ -0,0 +1,26 @@
+//===-- 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/ScriptInterpreter/Lua/Lua.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(LuaTest, RunValid) {
+  Lua lua;
+  llvm::Error error = lua.Run("foo = 1");
+  EXPECT_FALSE(static_cast(error));
+}
+
+TEST(LuaTest, RunInvalid) {
+  Lua lua;
+  llvm::Error error = lua.Run("nil = foo");
+  EXPECT_TRUE(static_cast(error));
+  EXPECT_EQ(llvm::toString(std::move(error)),
+"[string \"buffer\"]:1: unexpected symbol near 'nil'\n");
+}
Index: lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/ScriptInterpreter/Lua/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_lldb_unittest(ScriptInterpreterLuaTests
+  LuaTests.cpp
+  ScriptInterpreterTests.cpp
+
+  LINK_LIBS
+lldbHost
+lldbPluginScriptInterpret

[Lldb-commits] [PATCH] D71770: [lldb] Don't process symlinks deep inside DWARFUnit

2019-12-20 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Does the mean these mappings will show up in the settings command?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71770



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


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

2019-12-20 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:45
+
+/// Reads a LEB128 variable-length unsigned integer, limited to 7 bits.
+llvm::Optional GetVaruint7(DataExtractor §ion_header_data,

paolosev wrote:
> aprantl wrote:
> > The LLVM coding style requests that doxygen comments should be on the 
> > declaration in the header file and not in the implementation.
> This function is not declared in the header. Probably it doesn't need a 
> doxygen comment.
If it isn't declared in a header, then it should be either static or in an 
anonymous namespace.
Using a doxygen comment is still preferred, since many IDEs will use that to 
display online help.


Repository:
  rG LLVM Github Monorepo

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] [lldb] 44b4b83 - Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

2019-12-20 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2019-12-20T13:11:17-08:00
New Revision: 44b4b833ad76fc61e43473c581a557f72a4ed8f4

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

LOG: Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot

This is a purely cosmetic change that is NFC in terms of the binary
output. I bugs me that I called the attribute DW_AT_LLVM_isysroot
since the "i" is an artifact of GCC command line option syntax
(-isysroot is in the category of -i options) and doesn't carry any
useful information otherwise.

This attribute only appears in Clang module debug info.

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

Added: 


Modified: 
clang/test/Modules/debug-info-moduleimport.m
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
llvm/include/llvm-c/DebugInfo.h
llvm/include/llvm/BinaryFormat/Dwarf.def
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/DebugInfoMetadata.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/test/Assembler/dimodule.ll
llvm/test/CodeGen/X86/load-combine-dbg.ll
llvm/test/DebugInfo/X86/DIModule.ll
llvm/test/DebugInfo/X86/DIModuleContext.ll
llvm/test/DebugInfo/X86/clang-module.ll
llvm/unittests/IR/MetadataTest.cpp

Removed: 




diff  --git a/clang/test/Modules/debug-info-moduleimport.m 
b/clang/test/Modules/debug-info-moduleimport.m
index 16820baebe68..df8a66bebfb6 100644
--- a/clang/test/Modules/debug-info-moduleimport.m
+++ b/clang/test/Modules/debug-info-moduleimport.m
@@ -15,7 +15,7 @@
 // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "DebugObjC",
 // CHECK-SAME:  configMacros: "\22-DGREETING=Hello World\22 \22-UNDEBUG\22",
 // CHECK-SAME:  includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs",
-// CHECK-SAME:  isysroot: "/tmp/..")
+// CHECK-SAME:  sysroot: "/tmp/..")
 // CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m
 
 // RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t \

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 502d1af668c9..466d5ddd23db 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -977,7 +977,7 @@ bool SymbolFileDWARF::ParseImportedModules(
   DW_AT_LLVM_include_path, nullptr))
 module.search_path = ConstString(include_path);
   if (const char *sysroot = module_die.GetAttributeValueAsString(
-  DW_AT_LLVM_isysroot, nullptr))
+  DW_AT_LLVM_sysroot, nullptr))
 module.sysroot = ConstString(sysroot);
   imported_modules.push_back(module);
 }

diff  --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 731f32741e19..e933fe4b3f92 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -283,15 +283,15 @@ LLVMDIBuilderCreateFile(LLVMDIBuilderRef Builder, const 
char *Filename,
  * \param ConfigMacrosLen The length of the C string passed to \c ConfigMacros.
  * \param IncludePath The path to the module map file.
  * \param IncludePathLen  The length of the C string passed to \c IncludePath.
- * \param ISysRootThe Clang system root (value of -isysroot).
- * \param ISysRootLen The length of the C string passed to \c ISysRoot.
+ * \param SysRoot The Clang system root (value of -isysroot).
+ * \param SysRootLen  The length of the C string passed to \c SysRoot.
  */
 LLVMMetadataRef
 LLVMDIBuilderCreateModule(LLVMDIBuilderRef Builder, LLVMMetadataRef 
ParentScope,
   const char *Name, size_t NameLen,
   const char *ConfigMacros, size_t ConfigMacrosLen,
   const char *IncludePath, size_t IncludePathLen,
-  const char *ISysRoot, size_t ISysRootLen);
+  const char *SysRoot, size_t SysRootLen);
 
 /**
  * Creates a new descriptor for a namespace with the specified parent scope.

diff  --git a/llvm/include/llvm/BinaryFormat/Dwarf.def 
b/llvm/include/llvm/BinaryFormat/Dwarf.def
index 8b1b14de6f09..cf3eaf433e5d 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.def
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.def
@@ -405,7 +405,7 @@ HANDLE_DW_AT(0x3b31, BORLAND_closure, 0, BORLAND)
 // LLVM project extensions.
 HANDLE_DW_AT(0x3e00, LLVM_include_path, 0, LLVM)
 HANDLE_DW_AT(0x3e01, LLVM_config_macros, 0, LLVM)
-HANDLE_DW_AT(0x3e02, LLVM_isysroot, 0, LLVM)
+HANDLE_DW_AT(0x3e02, LLVM_sysroot, 0, LLVM)
 HANDLE

[Lldb-commits] [PATCH] D63540: Fix lookup of symbols with the same address range but different binding

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

@jankratochvil  @labath

Some new information below:

ProcessGDBRemote::DoAllocateMemory fails when it is called for expression 
evaluation preparation. This happens when both lldb and lldb-server are running 
on 32-bit arm host (various distros verified). If we debug using lldb-server 
running remotely and lldb is hosted locally on an x86-64 machine then problem 
does not appear.

Further more this does appear to be related to symbols size zeroing as failure 
happens due to failing InferiorCallMmap resulting in failure of 
ProcessGDBRemote::DoAllocateMemory. I am not aware of the exact problem but 
size zeroing somewhere causes corruption in thread plan prepared for expression 
eval with mmap.

I have been trying to debug this issue but actual hardware does not have enough 
resources to support a debug symbol build and all I have is logging and thats 
why have not reached a conclusion so far. But I am willing to further 
collaborate to get this issue fixed as it is important for lldb on arm 32 and 
could be a problem on other architectures which are not being tested actively 
right now.

Below is a log for your reference below if you can point out anything that I 
can go look out for specifically. PS: your might see some extra log messages 
which i have added for debugging here n there to see actual point of failure.

**Correct - log )** https://pastebin.ubuntu.com/p/8Z4wB5W6fM/

**Failing - log )** https://pastebin.ubuntu.com/p/g6ngkqS7p3/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63540



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


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

Hey, Mark... The test you added is failing on the Debian bots, e.g.:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/1903

Could you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It looks like this also caused a failure on the Windows LLDB bot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11896


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


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

2019-12-20 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:40
+
+  const uint32_t *version = reinterpret_cast(
+  data_sp->GetBytes() + sizeof(llvm::wasm::WasmMagic));

This looks like it will cause problems on big endian hosts..



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:252
+
+  ModuleSpec spec(file, ArchSpec("wasm32-unknown-unknown-wasm"));
+  specs.Append(spec);

I take it that wasm files don't have anything like a build id, uuid or 
something similar?



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp:334-351
+  if (section_type != eSectionTypeOther) {
+SectionSP section_sp(
+new Section(GetModule(), // Module to which this section belongs.
+this, // ObjectFile to which this section belongs and
+  // should read section data from.
+section_type,  // Section ID.
+ConstString(sect_info.name),   // Section name.

It would be nice to merge these two section-creating blocks..



Comment at: lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.h:116
+
+  typedef struct section_info {
+lldb::offset_t offset;

We don't use this typedef style (except possibly in some old code which we 
shouldn't emulate).



Comment at: lldb/unittests/ObjectFile/wasm/TestObjectFileWasm.cpp:1
+//===-- TestObjectFileWasm.cpp 
===//
+//

Overall, these tests would be better off as "lit" tests. Something along the 
lines of:
```
yaml2obj %s >%t
lldb-test object-file %t | FileCheck %t
```
You can look at existing tests in `test/Shell/ObjectFile` for inspiration. Is 
there anything you test here that "lldb-test object-file" does not print out?


Repository:
  rG LLVM Github Monorepo

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] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: jingham, labath, clayborg, mossberg.
jankratochvil added a project: LLDB.
Herald added a subscriber: kristof.beyls.

D71372  introduced: 
`Unwind/thread-step-out-ret-addr-check.test` failing on Fedora 30 Linux x86_64.

One problem is the underscored `_nonstandard_stub` in the `.s` file but not in 
the LLDB command:

  (lldb) breakpoint set -n nonstandard_stub
  Breakpoint 1: no locations (pending).
  WARNING:  Unable to resolve breakpoint to any actual locations.
  (lldb) process launch
  Process 21919 exited with status = 0 (0x)
  Process 21919 launched: 
'/home/jkratoch/redhat/llvm-monorepo-clangassert/tools/lldb/test/Unwind/Output/thread-step-out-ret-addr-check.test.tmp'
 (x86_64)
  (lldb) thread step-out
  error: invalid thread
  (lldb) _

Another problem is that Fedora Linux has executable stack by default and all 
programs indicate non-executable stack by `PT_GNU_STACK`, after fixing the 
underscore I was getting:

  (lldb) thread step-out
  Process 22294 exited with status = 0 (0x)
  (lldb) _

Is the `.section` harmless for non-Linux platforms or will it need some 
conditional compilation? (`#ifdef` is not available in `.s` file)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71784

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
  lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -7,7 +7,7 @@
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub
-# CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
+# CHECK: Breakpoint 1: where = {{.*`_?}}nonstandard_stub
 
 process launch
 # CHECK: stop reason = breakpoint 1.1
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -10,6 +10,7 @@
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
+nonstandard_stub:
 _nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
@@ -18,3 +19,5 @@
 
 add $0x10, %rsp
 ret
+
+.section .note.GNU-stack,"",@progbits


Index: lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
===
--- lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -7,7 +7,7 @@
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
 
 breakpoint set -n nonstandard_stub
-# CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
+# CHECK: Breakpoint 1: where = {{.*`_?}}nonstandard_stub
 
 process launch
 # CHECK: stop reason = breakpoint 1.1
Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -10,6 +10,7 @@
 # Executing 'thread step-out' here will initially attempt to write a
 # breakpoint to that stack address, but should fail because of the executable
 # memory check.
+nonstandard_stub:
 _nonstandard_stub:
 mov (%rsp), %rdi
 mov (%rdi), %rsi
@@ -18,3 +19,5 @@
 
 add $0x10, %rsp
 ret
+
+.section .note.GNU-stack,"",@progbits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Jim Ingham via lldb-commits
Yes, and Fedora Linux too.  Jan added a partial fix but that doesn't get the 
test passing IIUC.

I think Mark only had a Darwin machine to test this on.

I'm going to limit the test to darwin for now to give Mark a chance to analyze 
the failures.

Jim


> On Dec 20, 2019, at 1:25 PM, Stella Stamenova via Phabricator 
>  wrote:
> 
> stella.stamenova added a comment.
> 
> It looks like this also caused a failure on the Windows LLDB bot:
> 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11896
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D71372/new/
> 
> https://reviews.llvm.org/D71372
> 
> 
> 

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


[Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Mark Mossberg via Phabricator via lldb-commits
mossberg added a comment.

Took a quick look, and I think the good news is that the failure looks fairly 
superficial.

> clang-10: warning: argument unused during compilation: 
> '-fmodules-cache-path=/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-shell'
>  [-Wunused-command-line-argument]
>  
> /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test:10:10:
>  error: CHECK: expected string not found in input
> 
> 1. CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub

The failing check was the one merely to see if the breakpoint was set, which I 
don't believe is related to the actual code changes that were made. Will 
continue to look. I also will also look at D71784 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71372



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


[Lldb-commits] [lldb] 41d7c22 - [lldb/CMake] Change how we deal with optional dependencies

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

Author: Jonas Devlieghere
Date: 2019-12-20T14:13:28-08:00
New Revision: 41d7c227b38cce397e0402765593158f4bdf2dee

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

LOG: [lldb/CMake] Change how we deal with optional dependencies

Recently there has been some discussion about how we deal with optional
dependencies in LLDB. The approach in LLVM is to make things work out of
the box. If the dependency isn't there, we move on silently.

That's not true for LLDB. Unless you explicitly disable the dependency
with LLDB_ENABLE_*, you'll get a configuration-time error. The
historical reason for this is that LLDB's dependencies have a much
broader impact, think about Python for example which is required to run
the test suite.

The current approach can be frustrating from a user experience
perspective. Sometimes you just want to ensure LLDB builds with a change
in clang.

This patch changes the optional dependencies (with the exception of
Python) to a new scheme. The LLDB_ENABLE_* now takes three values: On,
Off or Auto, with the latter being the default. On and Off behave the
same as today, forcing the dependency to be enabled or disabled. If the
dependency is set to On but is not found, it results in a configuration
time warning. For Auto we detect if the dependency is there and either
enable or disable it depending on whether it's found.

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

PS: The reason Python isn't included yet is because it's so pervasive
that I plan on doing that in a separate patch.

Added: 
lldb/cmake/modules/FindCursesAndPanel.cmake

Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/FindCursesAndPanel.cmake 
b/lldb/cmake/modules/FindCursesAndPanel.cmake
new file mode 100644
index ..25709ddf5ff9
--- /dev/null
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -0,0 +1,16 @@
+#.rst:
+# FindCursesAndPanel
+# ---
+#
+# Find the curses and panel library as a whole.
+
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+  set(CURSES_PANEL_FOUND TRUE)
+else()
+  find_package(Curses QUIET)
+  find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" 
QUIET)
+  if(CURSES_FOUND AND PANEL_LIBRARIES)
+mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
+  endif()
+endif()
+

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 16465ded0522..586d1cbb25e5 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -18,39 +18,43 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
 "`CMakeFiles'. Please delete them.")
 endif()
 
-set(default_enable_python ON)
-set(default_enable_lua OFF) # Experimental
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
-
-# Temporarily support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_PYTHON)
-  if (LLDB_DISABLE_PYTHON)
-set(default_enable_python OFF)
-  endif()
+set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES 
"Darwin")
+  # The Darwin linker doesn't understand --start-group/--end-group.
+  set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit 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})
+  set(${variable} ${${found}} PARENT_SCOPE)
+endfunction()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." 
CursesAndPanel CURSES_PANEL_FOUND)
+add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support." 
LibLZMA LIBLZMA_FOUND)
+add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support." Lua 
LUA_FOUND)
 
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
-elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+set(default_enable_python ON)
+
+if(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
-  set(default_enable_lua OFF)
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
-  set(default_enable_lua OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting int

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

2019-12-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
Closed by commit rG41d7c227b38c: [lldb/CMake] Change how we deal with optional 
dependencies (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D71306?vs=234789&id=234979#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71306

Files:
  lldb/cmake/modules/FindCursesAndPanel.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/test/CMakeLists.txt

Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -145,6 +145,7 @@
 llvm_canonicalize_cmake_booleans(
   LLDB_ENABLE_PYTHON
   LLDB_ENABLE_LUA
+  LLDB_ENABLE_LZMA
   LLVM_ENABLE_ZLIB
   LLVM_ENABLE_SHARED_LIBS
   LLDB_IS_64_BITS)
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -18,39 +18,43 @@
 "`CMakeFiles'. Please delete them.")
 endif()
 
-set(default_enable_python ON)
-set(default_enable_lua OFF) # Experimental
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
-
-# Temporarily support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_PYTHON)
-  if (LLDB_DISABLE_PYTHON)
-set(default_enable_python OFF)
-  endif()
+set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
+  # The Darwin linker doesn't understand --start-group/--end-group.
+  set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit 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})
+  set(${variable} ${${found}} PARENT_SCOPE)
+endfunction()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." CursesAndPanel CURSES_PANEL_FOUND)
+add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support." LibLZMA LIBLZMA_FOUND)
+add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support." Lua LUA_FOUND)
 
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
-elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
+set(default_enable_python ON)
+
+if(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
-  set(default_enable_lua OFF)
-  set(default_enable_libedit OFF)
-  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
-  set(default_enable_lua OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python})
-option(LLDB_ENABLE_PYTHON "Enable Lua scripting integration." ${default_enable_lua})
-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)
@@ -113,15 +117,9 @@
   add_definitions( -DHAVE_ROUND )
 endif()
 
-if (LLDB_ENABLE_LUA)
-  find_package(Lua REQUIRED)
-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)
@@ -137,7 +135,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
@@ -398,12 +395,9 @@
 set(LLDB_VERSION "${LLDB_VERSION_MAJOR}.${LLDB_VERSION_MINOR}.${LLDB_VERSION_PATCH}${LLDB_VERSION_SUFFIX}")
 message(STATUS "LLDB version: ${LLDB_VERSION}")
 
-find_package(LibLZMA)
-cmake_dependent_option(LLDB_ENABLE_LZMA "Support LZMA compression" ON "LIBLZMA_FOUND" OFF)
 if (LLDB_ENABLE_LZMA)
   include_directories(${LIBLZMA_I

[Lldb-commits] [lldb] 05b2c6a - Temporarily restrict the test for D71372 to darwin till we fix it on other systems.

2019-12-20 Thread Jim Ingham via lldb-commits

Author: Jim Ingham
Date: 2019-12-20T14:31:41-08:00
New Revision: 05b2c6a52cc79916beb4cad820a4b5e0ddfd2c4e

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

LOG: Temporarily restrict the test for D71372 to darwin till we fix it on other 
systems.

Added: 


Modified: 
lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test

Removed: 




diff  --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test 
b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
index 96490faa2de8..53436cd55af1 100644
--- a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -1,7 +1,7 @@
 # Test that `thread step-out` fails when the "return address"
 # points to non-executable memory.
 
-# REQUIRES: target-x86_64, native
+# REQUIRES: target-x86_64, system-darwin
 
 # RUN: %clang_host %p/Inputs/call-asm.c 
%p/Inputs/thread-step-out-ret-addr-check.s -o %t
 # RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s



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


Re: [Lldb-commits] [PATCH] D71372: [lldb] Add additional validation on return address in 'thread step-out'

2019-12-20 Thread Jim Ingham via lldb-commits
Okay, I pushed a change to the test to only run on darwin.  When you have a 
patch for the other systems, we can take that out again.

Jim


> On Dec 20, 2019, at 2:08 PM, Mark Mossberg via Phabricator 
>  wrote:
> 
> mossberg added a comment.
> 
> Took a quick look, and I think the good news is that the failure looks fairly 
> superficial.
> 
>> clang-10: warning: argument unused during compilation: 
>> '-fmodules-cache-path=/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-shell'
>>  [-Wunused-command-line-argument]
>> /home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test:10:10:
>>  error: CHECK: expected string not found in input
>> 
>> 1. CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
> 
> The failing check was the one merely to see if the breakpoint was set, which 
> I don't believe is related to the actual code changes that were made. Will 
> continue to look. I also will also look at D71784 
> .
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D71372/new/
> 
> https://reviews.llvm.org/D71372
> 
> 
> 

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


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-20 Thread Mark Mossberg via Phabricator via lldb-commits
mossberg added a comment.

Thanks for looking into this @jankratochvil!

> Another problem is that Fedora Linux has executable stack by default and all 
> programs indicate non-executable stack by PT_GNU_STACK, after fixing the 
> underscore I was getting:
> 
> (lldb) thread step-out
>  Process 22294 exited with status = 0 (0x)
>  (lldb) _
>  Is the .section harmless for non-Linux platforms or will it need some 
> conditional compilation? (#ifdef is not available in .s file)

Ok, I guess I was incorrectly assuming the stack should be non-executable by 
default on all platforms. In this case, let's rewrite the test to have a 
variable that is actually in the .data section (therefore guaranteed to be 
non-executable), and pass a pass a pointer to it to `nonstandard_stub`. The 
core requirement is that the pointer passed to `nonstandard_stub` must simply 
point to some kind of non-executable memory. I can do this.




Comment at: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s:13
 # memory check.
+nonstandard_stub:
 _nonstandard_stub:

Maybe we can just remove the underscore version, and simply use 
`nonstandard_stub` if it will work everywhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784



___
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-20 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

This broke the Windows LLDB bot:

http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/11903


Repository:
  rG LLVM Github Monorepo

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] D71789: [lldb] Refactor thread-step-out-ret-addr-check test to use .data instead of stack variable

2019-12-20 Thread Mark Mossberg via Phabricator via lldb-commits
mossberg created this revision.
mossberg added reviewers: jingham, jankratochvil, labath, clayborg, 
stella.stamenova.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Original diff: D71372 
Related diff: D71784 

D71784  shows that we cannot assume the stack 
is not executable across platforms. Refactor the test to use a variable from 
the .data section which should be guaranteed non-executable.

I would appreciate guidance regarding the `var@GOTPCREL(%rip)`. Directly 
referencing `var` would not assemble on my darwin machine due to an error about 
absolute addressing, and I used this to workaround it. I'm not sure if it's 
even portable to other platforms?

@jankratochvil Would you be able to test this on a Fedora machine, please?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71789

Files:
  lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s


Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -1,14 +1,13 @@
 .text
 .globl  asm_main
 asm_main:
-sub $0x8, %rsp
-movq $0, (%rsp)
-push %rsp
+mov var@GOTPCREL(%rip), %rcx
+push %rcx
 jmp _nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
-# breakpoint to that stack address, but should fail because of the executable
+# breakpoint to that .data address, but should fail because of the executable
 # memory check.
 _nonstandard_stub:
 mov (%rsp), %rdi
@@ -18,3 +17,7 @@
 
 add $0x10, %rsp
 ret
+
+.data
+var:
+.long 0


Index: lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
===
--- lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
+++ lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -1,14 +1,13 @@
 .text
 .globl  asm_main
 asm_main:
-sub $0x8, %rsp
-movq $0, (%rsp)
-push %rsp
+mov var@GOTPCREL(%rip), %rcx
+push %rcx
 jmp _nonstandard_stub
 
 # Takes a single pointer argument via the stack, which is nonstandard for x64.
 # Executing 'thread step-out' here will initially attempt to write a
-# breakpoint to that stack address, but should fail because of the executable
+# breakpoint to that .data address, but should fail because of the executable
 # memory check.
 _nonstandard_stub:
 mov (%rsp), %rdi
@@ -18,3 +17,7 @@
 
 add $0x10, %rsp
 ret
+
+.data
+var:
+.long 0
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D71784: Fedora Linux fails `Unwind/thread-step-out-ret-addr-check.test`

2019-12-20 Thread Mark Mossberg via Phabricator via lldb-commits
mossberg added a comment.

The Windows failure (https://reviews.llvm.org/D71372#1793371) seems like it may 
also be caused by the underscore symbol issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71784



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


[Lldb-commits] [lldb] fe86289 - Revert "[lldb/CMake] Change how we deal with optional dependencies"

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

Author: Jonas Devlieghere
Date: 2019-12-20T15:35:43-08:00
New Revision: fe86289bf19b165e34f66d9411469131a77d0110

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

LOG: Revert "[lldb/CMake] Change how we deal with optional dependencies"

This is failing on both the Windows and Debian bot.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/test/CMakeLists.txt

Removed: 
lldb/cmake/modules/FindCursesAndPanel.cmake



diff  --git a/lldb/cmake/modules/FindCursesAndPanel.cmake 
b/lldb/cmake/modules/FindCursesAndPanel.cmake
deleted file mode 100644
index 25709ddf5ff9..
--- a/lldb/cmake/modules/FindCursesAndPanel.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-#.rst:
-# FindCursesAndPanel
-# ---
-#
-# Find the curses and panel library as a whole.
-
-if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
-  set(CURSES_PANEL_FOUND TRUE)
-else()
-  find_package(Curses QUIET)
-  find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" 
QUIET)
-  if(CURSES_FOUND AND PANEL_LIBRARIES)
-mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
-  endif()
-endif()
-

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 586d1cbb25e5..16465ded0522 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -18,43 +18,39 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
 "`CMakeFiles'. Please delete them.")
 endif()
 
-set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
-if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES 
"Darwin")
-  # The Darwin linker doesn't understand --start-group/--end-group.
-  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()
+set(default_enable_python ON)
+set(default_enable_lua OFF) # Experimental
+set(default_enable_libedit ON)
+set(default_enable_curses ON)
+
+# Temporarily support the old LLDB_DISABLE_* variables
+if (DEFINED LLDB_DISABLE_PYTHON)
+  if (LLDB_DISABLE_PYTHON)
+set(default_enable_python OFF)
   endif()
+endif()
 
-  find_package(${package} ${maybe_required})
-  set(${variable} ${${found}} PARENT_SCOPE)
-endfunction()
-
-add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
libedit_FOUND)
-add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." 
CursesAndPanel CURSES_PANEL_FOUND)
-add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support." 
LibLZMA LIBLZMA_FOUND)
-add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support." Lua 
LUA_FOUND)
-
-set(default_enable_python ON)
+if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
+  set(default_disable_libedit ON)
+endif()
 
-if(CMAKE_SYSTEM_NAME MATCHES "Android")
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_enable_libedit OFF)
+  set(default_enable_curses OFF)
+elseif(CMAKE_SYSTEM_NAME MATCHES "Android")
   set(default_enable_python OFF)
+  set(default_enable_lua OFF)
+  set(default_enable_libedit OFF)
+  set(default_enable_curses OFF)
 elseif(IOS)
   set(default_enable_python OFF)
+  set(default_enable_lua OFF)
 endif()
 
 option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." 
${default_enable_python})
+option(LLDB_ENABLE_PYTHON "Enable Lua scripting integration." 
${default_enable_lua})
+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)
@@ -117,9 +113,15 @@ if ((NOT MSVC) OR MSVC12)
   add_definitions( -DHAVE_ROUND )
 endif()
 
-# Check if we libedit capable of handling wide characters (built with
-# '--enable-widec').
+if (LLDB_ENABLE_LUA)
+  find_package(Lua REQUIRED)
+endif()
+
 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)
@@ -135,6 +137,7 @@ if (LLDB_ENABLE_LIBEDIT)
   set(CMAKE_EXTRA_IN

[Lldb-commits] [lldb] 94b1bc0 - Re-land "[lldb/CMake] Change how we deal with optional dependencies"

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

Author: Jonas Devlieghere
Date: 2019-12-20T20:05:04-08:00
New Revision: 94b1bc0fb86a081caae0a919c0ecdb732a84e8ad

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

LOG: Re-land "[lldb/CMake] Change how we deal with optional dependencies"

Recently there has been some discussion about how we deal with optional
dependencies in LLDB. The approach in LLVM is to make things work out of
the box. If the dependency isn't there, we move on silently.

That's not true for LLDB. Unless you explicitly disable the dependency
with LLDB_ENABLE_*, you'll get a configuration-time error. The
historical reason for this is that LLDB's dependencies have a much
broader impact, think about Python for example which is required to run
the test suite.

The current approach can be frustrating from a user experience
perspective. Sometimes you just want to ensure LLDB builds with a change
in clang.

This patch changes the optional dependencies (with the exception of
Python) to a new scheme. The LLDB_ENABLE_* now takes three values: On,
Off or Auto, with the latter being the default. On and Off behave the
same as today, forcing the dependency to be enabled or disabled. If the
dependency is set to On but is not found, it results in a configuration
time warning. For Auto we detect if the dependency is there and either
enable or disable it depending on whether it's found.

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

PS: The reason Python isn't included yet is because it's so pervasive
that I plan on doing that in a separate patch.

Added: 
lldb/cmake/modules/FindCursesAndPanel.cmake

Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/source/Core/CMakeLists.txt
lldb/test/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/FindCursesAndPanel.cmake 
b/lldb/cmake/modules/FindCursesAndPanel.cmake
new file mode 100644
index ..aaadf214bf54
--- /dev/null
+++ b/lldb/cmake/modules/FindCursesAndPanel.cmake
@@ -0,0 +1,24 @@
+#.rst:
+# FindCursesAndPanel
+# ---
+#
+# Find the curses and panel library as a whole.
+
+if(CURSES_INCLUDE_DIRS AND CURSES_LIBRARIES AND PANEL_LIBRARIES)
+  set(CURSESANDPANEL_FOUND TRUE)
+else()
+  find_package(Curses QUIET)
+  find_library(PANEL_LIBRARIES NAMES panel DOC "The curses panel library" 
QUIET)
+  include(FindPackageHandleStandardArgs)
+  find_package_handle_standard_args(CursesAndPanel
+FOUND_VAR
+  CURSESANDPANEL_FOUND
+REQUIRED_VARS
+  CURSES_INCLUDE_DIRS
+  CURSES_LIBRARIES
+  PANEL_LIBRARIES)
+  if(CURSES_FOUND AND PANEL_LIBRARIES)
+mark_as_advanced(CURSES_INCLUDE_DIRS CURSES_LIBRARIES PANEL_LIBRARIES)
+  endif()
+endif()
+

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 16465ded0522..3fc466b8f35c 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -18,39 +18,43 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
 "`CMakeFiles'. Please delete them.")
 endif()
 
-set(default_enable_python ON)
-set(default_enable_lua OFF) # Experimental
-set(default_enable_libedit ON)
-set(default_enable_curses ON)
-
-# Temporarily support the old LLDB_DISABLE_* variables
-if (DEFINED LLDB_DISABLE_PYTHON)
-  if (LLDB_DISABLE_PYTHON)
-set(default_enable_python OFF)
-  endif()
+set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
+if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES 
"Darwin")
+  # The Darwin linker doesn't understand --start-group/--end-group.
+  set(LLDB_LINKER_SUPPORTS_GROUPS ON)
 endif()
 
-if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT)
-  set(default_disable_libedit ON)
-endif()
+macro(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})
+  set(${variable} "${${found}}")
+endmacro()
+
+add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
libedit_FOUND)
+add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." 
CursesAndPanel CURSESANDPANEL_FOUND)
+add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support." 
LibLZMA LIBLZMA_FOUND)
+add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support." Lua 
LUA_FOUND)
 
-if(CMAKE_SYSTEM_NAME MATCHES "Windows")
-  set(def

[Lldb-commits] [lldb] c51ad1f - [lldb/CMake] Don't use return() from macro()

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

Author: Jonas Devlieghere
Date: 2019-12-20T20:53:33-08:00
New Revision: c51ad1f836bffb4e431eb9f948ee3a32902ba6d2

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

LOG: [lldb/CMake] Don't use return() from macro()

> A macro is executed as if the macro body were pasted in place of the
> calling statement. This has the consequence that a return() in a macro
> body does not just terminate execution of the macro

After converting from a function() to a macro(), the return() became
invalid. This modifies the control flow to elude the return.

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3fc466b8f35c..c34ef76cb652 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -29,16 +29,19 @@ macro(add_optional_dependency variable description package 
found)
   string(TOUPPER "${${variable}}" ${variable})
 
   if("${${variable}}" STREQUAL "AUTO")
+set(find_package TRUE)
 set(maybe_required)
   elseif(${${variable}})
+set(find_package TRUE)
 set(maybe_required REQUIRED)
   else()
-set(${variable} OFF PARENT_SCOPE)
-return()
+set(${variable} FALSE PARENT_SCOPE)
   endif()
 
-  find_package(${package} ${maybe_required})
-  set(${variable} "${${found}}")
+  if(${find_package})
+find_package(${package} ${maybe_required})
+set(${variable} "${${found}}")
+  endif()
 endmacro()
 
 add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit 
libedit_FOUND)



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


[Lldb-commits] [lldb] 6cc3ee1 - [lldb] Expose more optional dependencies through GetBuildConfiguration()

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

Author: Jonas Devlieghere
Date: 2019-12-20T21:01:08-08:00
New Revision: 6cc3ee17a018d916459a4f59a77c75d0b7e191a0

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

LOG: [lldb] Expose more optional dependencies through GetBuildConfiguration()

Expose all the externally-observable optional dependencies through
SBDebugger::GetBuildConfiguration().

Added: 


Modified: 
lldb/source/API/SBDebugger.cpp

Removed: 




diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 769f688b5b78..b7ac8047f8e5 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -686,6 +686,18 @@ SBStructuredData SBDebugger::GetBuildConfiguration() {
   AddBoolConfigEntry(
   *config_up, "curses", LLDB_ENABLE_CURSES,
   "A boolean value that indicates if curses support is enabled in LLDB");
+  AddBoolConfigEntry(
+  *config_up, "editline", LLDB_ENABLE_LIBEDIT,
+  "A boolean value that indicates if editline support is enabled in LLDB");
+  AddBoolConfigEntry(
+  *config_up, "lzma", LLDB_ENABLE_LZMA,
+  "A boolean value that indicates if lzma support is enabled in LLDB");
+  AddBoolConfigEntry(
+  *config_up, "python", LLDB_ENABLE_PYTHON,
+  "A boolean value that indicates if python support is enabled in LLDB");
+  AddBoolConfigEntry(
+  *config_up, "lua", LLDB_ENABLE_LUA,
+  "A boolean value that indicates if lua support is enabled in LLDB");
   AddLLVMTargets(*config_up);
 
   SBStructuredData data;



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


[Lldb-commits] [lldb] a32f8dd - [lldb/test] Skip editline tests when LLDB_ENABLE_LIBEDIT is off.

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

Author: Jonas Devlieghere
Date: 2019-12-20T21:01:23-08:00
New Revision: a32f8dd195866c2be95d7e71f311a805a6fed4cd

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

LOG: [lldb/test] Skip editline tests when LLDB_ENABLE_LIBEDIT is off.

Add a new decorator that checks if LLDB was build with editline support
and mark the relevant tests as skipped when that's not the case.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py

lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
index 1275595a7931..9b2b71230e52 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-completion/TestMultilineCompletion.py
@@ -15,6 +15,7 @@ class MultilineCompletionTest(PExpectTest):
 # under ASAN on a loaded machine..
 @skipIfAsan
 @skipIfRemote  # test is written to explicitly "run" the binary
+@skipIfEditlineSupportMissing
 def test_basic_completion(self):
 """Test that we can complete a simple multiline expression"""
 self.build()

diff  --git 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py
 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py
index 712111209215..743e79945364 100644
--- 
a/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py
+++ 
b/lldb/packages/Python/lldbsuite/test/commands/expression/multiline-navigation/TestMultilineNavigation.py
@@ -17,6 +17,7 @@ class TestCase(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
+@skipIfEditlineSupportMissing
 def test_nav_arrow_up(self):
 """Tests that we can navigate back to the previous line with the up 
arrow"""
 self.launch()
@@ -38,6 +39,7 @@ def test_nav_arrow_up(self):
 self.quit()
 
 @skipIfAsan
+@skipIfEditlineSupportMissing
 def test_nav_arrow_down(self):
 """Tests that we can navigate to the next line with the down arrow"""
 self.launch()

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 7009767f63a6..ec17cb7c2569 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -808,6 +808,9 @@ def skipIfCursesSupportMissing(func):
 def skipIfXmlSupportMissing(func):
 return _get_bool_config_skip_if_decorator("xml")(func)
 
+def skipIfEditlineSupportMissing(func):
+return _get_bool_config_skip_if_decorator("editline")(func)
+
 def skipIfLLVMTargetMissing(target):
 config = lldb.SBDebugger.GetBuildConfiguration()
 targets = config.GetValueForKey("targets").GetValueForKey("value")

diff  --git 
a/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
 
b/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
index b48585146374..610bf019436a 100644
--- 
a/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
+++ 
b/lldb/packages/Python/lldbsuite/test/iohandler/completion/TestIOHandlerCompletion.py
@@ -16,6 +16,7 @@ class IOHandlerCompletionTest(PExpectTest):
 # PExpect uses many timeouts internally and doesn't play well
 # under ASAN on a loaded machine..
 @skipIfAsan
+@skipIfEditlineSupportMissing
 def test_completion(self):
 self.launch(dimensions=(100,500))
 

diff  --git a/lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py 
b/lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
index cf82f5d8ab1e..8e1652a50416 100644
--- a/lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
+++ b/lldb/packages/Python/lldbsuite/test/terminal/TestEditline.py
@@ -16,6 +16,7 @@ class EditlineTest(PExpectTest):
 mydir = TestBase.compute_mydir(__file__)
 
 @skipIfAsan
+@skipIfEditlineSupportMissing
 def test_left_right_arrow(self):
 """Test that ctrl+left/right arrow navigates words correctly.
 




[Lldb-commits] [lldb] 3fa39c3 - [lldb/test] Update !DIModule for isysroot rename

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

Author: Jonas Devlieghere
Date: 2019-12-20T21:11:50-08:00
New Revision: 3fa39c3a79a3b1a88d2da0b3992089e9134fb87f

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

LOG: [lldb/test] Update !DIModule for isysroot rename

The isysroot field in DIModule was renamed to sysroot but the test in
LLDB wasn't updated. This fixes that.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll 
b/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll
index 6097345bd993..8589d0fe27c2 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll
+++ b/lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll
@@ -39,8 +39,8 @@ target triple = "x86_64-apple-macosx10.14.0"
 ; This simulates the debug info for a Clang module.
 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: 
"clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, 
nameTableKind: GNU, retainedTypes: !{!11})
 !3 = !DIFile(filename: "t.c", directory: "/")
-!8 = !DIModule(scope: !9, name: "SubModule", includePath: "", isysroot: "/")
-!9 = !DIModule(scope: null, name: "CModule", includePath: "", isysroot: "/")
+!8 = !DIModule(scope: !9, name: "SubModule", includePath: "", sysroot: "/")
+!9 = !DIModule(scope: null, name: "CModule", includePath: "", sysroot: "/")
 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: 
"FromSubmodule", scope: !8, file: !3, line: 1, size: 96, elements: !13)
 !13 = !{!14, !16, !17}
 !14 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !3, 
line: 2, baseType: !15, size: 32)



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