[Lldb-commits] [PATCH] D74585: Don't prefix error message from process launch with "process launch failed:" boilerplate in Target::Launch

2020-02-14 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG83bea6d99dd1: Remove process launch failed: 
message prefix in Target::Launch (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74585

Files:
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/Shell/Process/Windows/launch_failure.yaml


Index: lldb/test/Shell/Process/Windows/launch_failure.yaml
===
--- lldb/test/Shell/Process/Windows/launch_failure.yaml
+++ lldb/test/Shell/Process/Windows/launch_failure.yaml
@@ -7,7 +7,7 @@
 # RUN: yaml2obj %s > %t.exe
 # RUN: %lldb %t.exe -o run 2>&1 | FileCheck %s
 
-# CHECK: error: process launch failed: unknown error
+# CHECK: error: unknown error
 
 --- !COFF
 OptionalHeader:
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -72,7 +72,7 @@
 error = lldb.SBError()
 target.Launch(lldb.SBListener(), None, None, None, None, None,
 None, 0, True, error)
-self.assertEquals("process launch failed: 'A' packet returned an 
error: 71", error.GetCString())
+self.assertEquals("'A' packet returned an error: 71", 
error.GetCString())
 
 def test_read_registers_using_g_packets(self):
 """Test reading registers using 'g' packets (default behavior)"""
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2957,11 +2957,6 @@
   }
 }
 m_process_sp->RestoreProcessEvents();
-  } else {
-Status error2;
-error2.SetErrorStringWithFormat("process launch failed: %s",
-error.AsCString());
-error = error2;
   }
   return error;
 }
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -338,7 +338,7 @@
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -369,7 +369,7 @@
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }


Index: lldb/test/Shell/Process/Windows/launch_failure.yaml
===
--- lldb/test/Shell/Process/Windows/launch_failure.yaml
+++ lldb/test/Shell/Process/Windows/launch_failure.yaml
@@ -7,7 +7,7 @@
 # RUN: yaml2obj %s > %t.exe
 # RUN: %lldb %t.exe -o run 2>&1 | FileCheck %s
 
-# CHECK: error: process launch failed: unknown error
+# CHECK: error: unknown error
 
 --- !COFF
 OptionalHeader:
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -72,7 +72,7 @@
 error = lldb.SBError()
 target.Launch(lldb.SBListener(), None, None, None, None, None,
 None, 0, True, error)
-self.assertEquals("process launch failed: 'A' packet returned an error: 71", error.GetCString())
+self.assertEquals("'A' packet returned an error: 71", error.GetCString())
 
 def test_read_registers_using_g_packets(self):
 """Test reading registers using 'g' packets (default behavior)"""
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2957,11 +2957,6 @@
   }
 }
 m_process_sp->RestoreProcessEvents();
-  } else {
-Status error2;
-

[Lldb-commits] [lldb] 83bea6d - Remove 'process launch failed:' message prefix in Target::Launch

2020-02-14 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2020-02-14T18:42:38-08:00
New Revision: 83bea6d99dd17d893b7160e045700aef6173a49d

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

LOG: Remove 'process launch failed:' message prefix in Target::Launch

SB API clients can describe the failure message in a more natural
way for their UI, this doesn't add information for them.

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


Added: 


Modified: 
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Target/Target.cpp
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
lldb/test/Shell/Process/Windows/launch_failure.yaml

Removed: 




diff  --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp 
b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index cea87c4d90ad..1e6f56e7867f 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -369,7 +369,7 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo _info, 
Debugger ,
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }

diff  --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp 
b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
index 9942c339650e..16ec6c6122bd 100644
--- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -338,7 +338,7 @@ PlatformNetBSD::DebugProcess(ProcessLaunchInfo 
_info, Debugger ,
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index a8d4f24b1c72..9e41e90b6d7d 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -2957,11 +2957,6 @@ Status Target::Launch(ProcessLaunchInfo _info, 
Stream *stream) {
   }
 }
 m_process_sp->RestoreProcessEvents();
-  } else {
-Status error2;
-error2.SetErrorStringWithFormat("process launch failed: %s",
-error.AsCString());
-error = error2;
   }
   return error;
 }

diff  --git 
a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py 
b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
index 238a4559d6fb..9de0279bbfad 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -72,7 +72,7 @@ def A(self, packet):
 error = lldb.SBError()
 target.Launch(lldb.SBListener(), None, None, None, None, None,
 None, 0, True, error)
-self.assertEquals("process launch failed: 'A' packet returned an 
error: 71", error.GetCString())
+self.assertEquals("'A' packet returned an error: 71", 
error.GetCString())
 
 def test_read_registers_using_g_packets(self):
 """Test reading registers using 'g' packets (default behavior)"""

diff  --git a/lldb/test/Shell/Process/Windows/launch_failure.yaml 
b/lldb/test/Shell/Process/Windows/launch_failure.yaml
index be723ef7621d..88cb0edd9f90 100644
--- a/lldb/test/Shell/Process/Windows/launch_failure.yaml
+++ b/lldb/test/Shell/Process/Windows/launch_failure.yaml
@@ -7,7 +7,7 @@
 # RUN: yaml2obj %s > %t.exe
 # RUN: %lldb %t.exe -o run 2>&1 | FileCheck %s
 
-# CHECK: error: process launch failed: unknown error
+# CHECK: error: unknown error
 
 --- !COFF
 OptionalHeader:



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


[Lldb-commits] [PATCH] D74585: Don't prefix error message from process launch with "process launch failed:" boilerplate in Target::Launch

2020-02-14 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda updated this revision to Diff 244799.
jasonmolenda added a comment.

Updated the test to match the new output (how did I miss that??), also for 
consistency removed the other occurrences of "process launch failed: " across 
lldb, two of which were only in log messages.


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

https://reviews.llvm.org/D74585

Files:
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Target/Target.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
  lldb/test/Shell/Process/Windows/launch_failure.yaml


Index: lldb/test/Shell/Process/Windows/launch_failure.yaml
===
--- lldb/test/Shell/Process/Windows/launch_failure.yaml
+++ lldb/test/Shell/Process/Windows/launch_failure.yaml
@@ -7,7 +7,7 @@
 # RUN: yaml2obj %s > %t.exe
 # RUN: %lldb %t.exe -o run 2>&1 | FileCheck %s
 
-# CHECK: error: process launch failed: unknown error
+# CHECK: error: unknown error
 
 --- !COFF
 OptionalHeader:
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -72,7 +72,7 @@
 error = lldb.SBError()
 target.Launch(lldb.SBListener(), None, None, None, None, None,
 None, 0, True, error)
-self.assertEquals("process launch failed: 'A' packet returned an 
error: 71", error.GetCString())
+self.assertEquals("'A' packet returned an error: 71", 
error.GetCString())
 
 def test_read_registers_using_g_packets(self):
 """Test reading registers using 'g' packets (default behavior)"""
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2957,11 +2957,6 @@
   }
 }
 m_process_sp->RestoreProcessEvents();
-  } else {
-Status error2;
-error2.SetErrorStringWithFormat("process launch failed: %s",
-error.AsCString());
-error = error2;
   }
   return error;
 }
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
@@ -338,7 +338,7 @@
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -369,7 +369,7 @@
 } else
   LLDB_LOG(log, "not using process STDIO pty");
   } else {
-LLDB_LOG(log, "process launch failed: {0}", error);
+LLDB_LOG(log, "{0}", error);
 // FIXME figure out appropriate cleanup here.  Do we delete the target? Do
 // we delete the process?  Does our caller do that?
   }


Index: lldb/test/Shell/Process/Windows/launch_failure.yaml
===
--- lldb/test/Shell/Process/Windows/launch_failure.yaml
+++ lldb/test/Shell/Process/Windows/launch_failure.yaml
@@ -7,7 +7,7 @@
 # RUN: yaml2obj %s > %t.exe
 # RUN: %lldb %t.exe -o run 2>&1 | FileCheck %s
 
-# CHECK: error: process launch failed: unknown error
+# CHECK: error: unknown error
 
 --- !COFF
 OptionalHeader:
Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
@@ -72,7 +72,7 @@
 error = lldb.SBError()
 target.Launch(lldb.SBListener(), None, None, None, None, None,
 None, 0, True, error)
-self.assertEquals("process launch failed: 'A' packet returned an error: 71", error.GetCString())
+self.assertEquals("'A' packet returned an error: 71", error.GetCString())
 
 def test_read_registers_using_g_packets(self):
 """Test reading registers using 'g' packets (default behavior)"""
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2957,11 +2957,6 @@
   }
 }
 m_process_sp->RestoreProcessEvents();
-  } else {
-

[Lldb-commits] [PATCH] D74659: [lldb/FileSystem] Rename CreateDataBuffer -> CreateWritableDataBuffer, NFC

2020-02-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D74659



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


[Lldb-commits] [PATCH] D74660: WIP: [lldb/FileSystem] Add & use CreateReadonlyDataBuffer where possible

2020-02-14 Thread Vedant Kumar via Phabricator via lldb-commits
vsk added subscribers: rupprecht, labath.
vsk added a comment.

+ @labath @rupprecht, my tentative plan is to fix this by having ObjectFileELF 
make a copy into a heap-allocated buffer when applying relocations. Please lmk 
if that's problematic (although, that seems like a slightly lazier version of 
what we do today, so hopefully it's all right).


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

https://reviews.llvm.org/D74660



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


[Lldb-commits] [PATCH] D74660: WIP: [lldb/FileSystem] Add & use CreateReadonlyDataBuffer where possible

2020-02-14 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: JDevlieghere, jingham.
vsk added a project: LLDB.
Herald added a subscriber: aprantl.
vsk added subscribers: rupprecht, labath.
vsk added a comment.

+ @labath @rupprecht, my tentative plan is to fix this by having ObjectFileELF 
make a copy into a heap-allocated buffer when applying relocations. Please lmk 
if that's problematic (although, that seems like a slightly lazier version of 
what we do today, so hopefully it's all right).


Add FileSystem::CreateReadonlyDataBuffer to allow lldb to open files
using mmap() (i.e. without any heap allocation).

There's no functionality change intended here. We've been getting
reports of lldb using 2GB+ of heap memory while debugging Xcode [1], and
I think this should help with that.

This is WIP because `ObjectFileELF::RelocateDebugSections` mutates a buffer
obtained from ObjectFile. `SymbolFile/DWARF/parallel-indexing-stress.s` is the
only failing test, everything else passes with the current patch (on Darwin).

rdar://53785446

[1] `heap` report from two different users:

Count Bytes   Avg SizeSymbol
11404 2143015136  187917.8   (anonymous 
namespace)::MemoryBufferMem  C++ LLDB
11948 2537624624  212389.1   (anonymous 
namespace)::MemoryBufferMem  C++ LLDB


https://reviews.llvm.org/D74660

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/include/lldb/Utility/DataBufferLLVM.h
  lldb/source/API/SBSection.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/linux/Host.cpp
  lldb/source/Host/netbsd/Host.cpp
  lldb/source/Interpreter/OptionValueFileSpec.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/source/Utility/DataBufferLLVM.cpp
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -43,7 +43,7 @@
   void SetUpData(const char *minidump_filename) {
 std::string filename = GetInputFilePath(minidump_filename);
 auto BufferPtr =
-FileSystem::Instance().CreateWritableDataBuffer(filename, -1, 0);
+FileSystem::Instance().CreateReadonlyDataBuffer(filename, -1, 0);
 ASSERT_NE(BufferPtr, nullptr);
 llvm::Expected expected_parser =
 MinidumpParser::Create(BufferPtr);
Index: lldb/source/Utility/DataBufferLLVM.cpp
===
--- lldb/source/Utility/DataBufferLLVM.cpp
+++ lldb/source/Utility/DataBufferLLVM.cpp
@@ -14,8 +14,7 @@
 
 using namespace lldb_private;
 
-DataBufferLLVM::DataBufferLLVM(
-std::unique_ptr MemBuffer)
+DataBufferLLVM::DataBufferLLVM(std::unique_ptr MemBuffer)
 : Buffer(std::move(MemBuffer)) {
   assert(Buffer != nullptr &&
  "Cannot construct a DataBufferLLVM with a null buffer");
@@ -24,7 +23,8 @@
 DataBufferLLVM::~DataBufferLLVM() {}
 
 uint8_t *DataBufferLLVM::GetBytes() {
-  return reinterpret_cast(Buffer->getBufferStart());
+  return const_cast(
+  reinterpret_cast(Buffer->getBufferStart()));
 }
 
 const uint8_t *DataBufferLLVM::GetBytes() const {
Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -75,7 +75,7 @@
 // container plug-ins can use these bytes to see if they can parse this
 // file.
 if (file_size > 0) {
-  data_sp = FileSystem::Instance().CreateWritableDataBuffer(
+  data_sp = FileSystem::Instance().CreateReadonlyDataBuffer(
   file->GetPath(), 512, file_offset);
   data_offset = 0;
 }
@@ -119,7 +119,7 @@
 }
 // We failed to find any cached object files in the container plug-
 // ins, so lets read the first 512 bytes and try again below...
-data_sp = FileSystem::Instance().CreateWritableDataBuffer(
+data_sp = FileSystem::Instance().CreateReadonlyDataBuffer(
 archive_file.GetPath(), 512, file_offset);
   }
 }
@@ -208,7 +208,7 @@
lldb::offset_t file_offset,
lldb::offset_t file_size,
ModuleSpecList ) {
-  DataBufferSP data_sp = FileSystem::Instance().CreateWritableDataBuffer(
+  DataBufferSP data_sp = 

[Lldb-commits] [PATCH] D74659: [lldb/FileSystem] Rename CreateDataBuffer -> CreateWritableDataBuffer, NFC

2020-02-14 Thread Vedant Kumar via Phabricator via lldb-commits
vsk created this revision.
vsk added reviewers: JDevlieghere, jingham.
vsk added a project: LLDB.

Some clients of lldb::FileSystem look like they are unintentionally
heap-allocating file contents.

This patch renames the CreateDataBuffer API to allow clients to express
intention more clearly. As a follow-up I propose adding a 'Readonly' API
that can use mmap().

rdar://53785446


https://reviews.llvm.org/D74659

Files:
  lldb/include/lldb/Host/FileSystem.h
  lldb/source/API/SBSection.cpp
  lldb/source/Commands/CommandObjectMemory.cpp
  lldb/source/Core/SourceManager.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/common/Host.cpp
  lldb/source/Host/linux/Host.cpp
  lldb/source/Host/netbsd/Host.cpp
  lldb/source/Interpreter/OptionValueFileSpec.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
  lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Symbol/ObjectFile.cpp
  lldb/unittests/Process/minidump/MinidumpParserTest.cpp

Index: lldb/unittests/Process/minidump/MinidumpParserTest.cpp
===
--- lldb/unittests/Process/minidump/MinidumpParserTest.cpp
+++ lldb/unittests/Process/minidump/MinidumpParserTest.cpp
@@ -42,7 +42,8 @@
 
   void SetUpData(const char *minidump_filename) {
 std::string filename = GetInputFilePath(minidump_filename);
-auto BufferPtr = FileSystem::Instance().CreateDataBuffer(filename, -1, 0);
+auto BufferPtr =
+FileSystem::Instance().CreateWritableDataBuffer(filename, -1, 0);
 ASSERT_NE(BufferPtr, nullptr);
 llvm::Expected expected_parser =
 MinidumpParser::Create(BufferPtr);
Index: lldb/source/Symbol/ObjectFile.cpp
===
--- lldb/source/Symbol/ObjectFile.cpp
+++ lldb/source/Symbol/ObjectFile.cpp
@@ -75,8 +75,8 @@
 // container plug-ins can use these bytes to see if they can parse this
 // file.
 if (file_size > 0) {
-  data_sp = FileSystem::Instance().CreateDataBuffer(file->GetPath(),
-512, file_offset);
+  data_sp = FileSystem::Instance().CreateWritableDataBuffer(
+  file->GetPath(), 512, file_offset);
   data_offset = 0;
 }
   }
@@ -119,7 +119,7 @@
 }
 // We failed to find any cached object files in the container plug-
 // ins, so lets read the first 512 bytes and try again below...
-data_sp = FileSystem::Instance().CreateDataBuffer(
+data_sp = FileSystem::Instance().CreateWritableDataBuffer(
 archive_file.GetPath(), 512, file_offset);
   }
 }
@@ -208,8 +208,8 @@
lldb::offset_t file_offset,
lldb::offset_t file_size,
ModuleSpecList ) {
-  DataBufferSP data_sp =
-  FileSystem::Instance().CreateDataBuffer(file.GetPath(), 512, file_offset);
+  DataBufferSP data_sp = FileSystem::Instance().CreateWritableDataBuffer(
+  file.GetPath(), 512, file_offset);
   if (data_sp) {
 if (file_size == 0) {
   const lldb::offset_t actual_file_size =
@@ -684,7 +684,8 @@
 
 DataBufferSP ObjectFile::MapFileData(const FileSpec , uint64_t Size,
  uint64_t Offset) {
-  return FileSystem::Instance().CreateDataBuffer(file.GetPath(), Size, Offset);
+  return FileSystem::Instance().CreateWritableDataBuffer(file.GetPath(), Size,
+ Offset);
 }
 
 void llvm::format_provider::format(
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -141,8 +141,8 @@
   lldb::ProcessSP process_sp;
   // Read enough data for the Minidump header
   constexpr size_t header_size = sizeof(Header);
-  auto DataPtr = FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(),
- header_size, 0);
+  auto DataPtr = FileSystem::Instance().CreateWritableDataBuffer(
+  crash_file->GetPath(), header_size, 0);
   if (!DataPtr)
 return nullptr;
 
@@ -150,8 +150,8 @@
   if (identify_magic(toStringRef(DataPtr->GetData())) != llvm::file_magic::minidump)
 return nullptr;
 
-  auto AllData =
-  FileSystem::Instance().CreateDataBuffer(crash_file->GetPath(), -1, 0);
+  auto AllData = FileSystem::Instance().CreateWritableDataBuffer(
+ 

[Lldb-commits] [PATCH] D74657: [lldb/Target] Add process crash-info command

2020-02-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 244793.
mib added a comment.

Run clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74657

Files:
  lldb/bindings/interface/SBProcess.i
  lldb/include/lldb/API/SBProcess.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Target/Process.h
  lldb/packages/Python/lldbsuite/test/commands/process/crash-info/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/process/crash-info/TestProcessCrashInfo.py
  lldb/packages/Python/lldbsuite/test/commands/process/crash-info/main.c
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/DynamicCheckerFunctions.h"
@@ -36,6 +37,7 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/AssertFrameRecognizer.h"
@@ -1095,6 +1097,112 @@
   return nullptr;
 }
 
+StructuredData::ArraySP Process::FetchCrashInfo() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  StructuredData::ArraySP array_sp = std::make_shared();
+
+  for (ModuleSP module : GetTarget().GetImages().Modules()) {
+SectionList *sections = module->GetSectionList();
+
+std::string module_name = module->GetSpecificationDescription();
+
+if (!sections) {
+  LLDB_LOG(log, "Module {0} doesn't have any section!", module_name);
+  continue;
+}
+
+ConstString section_name("__crash_info");
+SectionSP crash_info = sections->FindSectionByName(section_name);
+if (!crash_info) {
+  LLDB_LOG(log, "Module {0} doesn't have section {1}!", module_name,
+   section_name);
+  continue;
+}
+
+addr_t load_addr = crash_info->GetLoadBaseAddress(());
+
+if (load_addr == LLDB_INVALID_ADDRESS)
+  continue;
+
+CrashInfoExtractor extractor = {};
+extractor.load_addr = load_addr;
+
+if (!ExtractCrashInfoAnnotations(extractor)) {
+  LLDB_LOG(log, "{Couldn't extract crash info from Module {0}: {1}}",
+   module_name, extractor.error.AsCString());
+  continue;
+}
+
+StructuredData::DictionarySP entry_sp =
+std::make_shared();
+
+entry_sp->AddStringItem("image", module->GetFileSpec().GetPath(false));
+entry_sp->AddStringItem("uuid", module->GetUUID().GetAsString());
+entry_sp->AddStringItem("message", extractor.message);
+entry_sp->AddStringItem("message2", extractor.message2);
+entry_sp->AddIntegerItem("abort-cause", extractor.annotations.abort_cause);
+
+array_sp->AddItem(entry_sp);
+  }
+
+  return array_sp;
+}
+
+bool Process::ExtractCrashInfoAnnotations(CrashInfoExtractor ) {
+  CrashInfoAnnotations annotations;
+  size_t expected_size = sizeof(CrashInfoAnnotations);
+  size_t bytes_read = ReadMemoryFromInferior(extractor.load_addr, ,
+ expected_size, extractor.error);
+
+  if (expected_size != bytes_read || extractor.error.Fail())
+return false;
+
+  // initial support added for version 5
+  if (annotations.version < 5) {
+extractor.error.SetErrorString(
+"Annotation version lower than 5 unsupported!");
+return false;
+  }
+
+  if (!annotations.message) {
+extractor.error.SetErrorString("No message available.");
+return false;
+  }
+
+  std::string message;
+  bytes_read =
+  ReadCStringFromMemory(annotations.message, message, extractor.error);
+
+  if (message.empty() || bytes_read != message.size() ||
+  extractor.error.Fail()) {
+extractor.error.SetErrorString("Failed to read the message from memory.");
+return false;
+  }
+
+  // Remove trailing newline from message
+  if (message[message.size() - 1] == '\n')
+message.pop_back();
+
+  extractor.annotations = annotations;
+  extractor.message = message;
+
+  if (annotations.message2) {
+std::string message2;
+bytes_read =
+ReadCStringFromMemory(annotations.message2, message2, extractor.error);
+
+if (!message2.empty() && bytes_read == message2.size() &&
+extractor.error.Success()) {
+  if (message2[message2.size() - 1] == '\n')
+message2.pop_back();
+  extractor.message2 = message2;
+}
+  }
+
+  return true;
+}
+
 bool Process::SetExitStatus(int status, const char *cstr) {
   // Use a mutex to protect setting the exit status.
   std::lock_guard 

[Lldb-commits] [PATCH] D74657: [lldb/Target] Add process crash-info command

2020-02-14 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, friss, jingham.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently, in macOS, when a process crashes, lldb halts inside the 
implementation
disassembly without yielding any useful information. The only way to get more
information is to detach from the process, then wait
for ReportCrash to generate a report, find the report, then see what error
message was included in it. Instead of waiting for this to happen, lldb could
locate the error_string and make it available to the user.

This patch addresses this issue by introducing the command `process crash-info`.

When invoked, lldb will iterate over each of the target's images, extract their
`__crash_info` section and generated a StructuredData::Array (mostly a JSON
Array) containing, in each entry, the module spec, its UUID, the crash messages
and the abort cause.

This crash information can also be fetched using the SB API or lldb-rpc protocol
using SBProcess::GetCrashInfo().

rdar://37736535

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74657

Files:
  lldb/bindings/interface/SBProcess.i
  lldb/include/lldb/API/SBProcess.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/Target/Process.h
  lldb/packages/Python/lldbsuite/test/commands/process/crash-info/Makefile
  
lldb/packages/Python/lldbsuite/test/commands/process/crash-info/TestProcessCrashInfo.py
  lldb/packages/Python/lldbsuite/test/commands/process/crash-info/main.c
  lldb/source/API/SBProcess.cpp
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Target/Process.cpp

Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -19,6 +19,7 @@
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
 #include "lldb/Core/StreamFile.h"
 #include "lldb/Expression/DiagnosticManager.h"
 #include "lldb/Expression/DynamicCheckerFunctions.h"
@@ -36,6 +37,7 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Symbol/Function.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Target/ABI.h"
 #include "lldb/Target/AssertFrameRecognizer.h"
@@ -1095,6 +1097,112 @@
   return nullptr;
 }
 
+StructuredData::ArraySP Process::FetchCrashInfo() {
+  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  StructuredData::ArraySP array_sp = std::make_shared();
+
+  for (ModuleSP module : GetTarget().GetImages().Modules()) {
+SectionList *sections = module->GetSectionList();
+
+std::string module_name = module->GetSpecificationDescription();
+
+if (!sections) {
+  LLDB_LOG(log, "Module {0} doesn't have any section!", module_name);
+  continue;
+}
+
+ConstString section_name("__crash_info");
+SectionSP crash_info = sections->FindSectionByName(section_name);
+if (!crash_info) {
+  LLDB_LOG(log, "Module {0} doesn't have section {1}!", module_name,
+   section_name);
+  continue;
+}
+
+addr_t load_addr = crash_info->GetLoadBaseAddress(());
+
+if (load_addr == LLDB_INVALID_ADDRESS)
+  continue;
+
+CrashInfoExtractor extractor = {};
+extractor.load_addr = load_addr;
+
+if (!ExtractCrashInfoAnnotations(extractor)) {
+  LLDB_LOG(log, "{Couldn't extract crash info from Module {0}: {1}}",
+   module_name, extractor.error.AsCString());
+  continue;
+}
+
+StructuredData::DictionarySP entry_sp =
+std::make_shared();
+
+entry_sp->AddStringItem("image", module->GetFileSpec().GetPath(false));
+entry_sp->AddStringItem("uuid", module->GetUUID().GetAsString());
+entry_sp->AddStringItem("message", extractor.message);
+entry_sp->AddStringItem("message2", extractor.message2);
+entry_sp->AddIntegerItem("abort-cause", extractor.annotations.abort_cause);
+
+array_sp->AddItem(entry_sp);
+  }
+
+  return array_sp;
+}
+
+bool Process::ExtractCrashInfoAnnotations(CrashInfoExtractor ) {
+  CrashInfoAnnotations annotations;
+  size_t expected_size = sizeof(CrashInfoAnnotations);
+  size_t bytes_read = ReadMemoryFromInferior(extractor.load_addr, ,
+ expected_size, extractor.error);
+
+  if (expected_size != bytes_read || extractor.error.Fail())
+return false;
+
+  // initial support added for version 5
+  if (annotations.version < 5) {
+extractor.error.SetErrorString(
+"Annotation version lower than 5 unsupported!");
+return false;
+  }
+
+  if (!annotations.message) {
+extractor.error.SetErrorString("No message available.");
+return false;
+  }
+
+  std::string message;
+  bytes_read =
+  ReadCStringFromMemory(annotations.message, message, extractor.error);

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Hey Héctor, this is generating a lot of traffic on the lldb-commits mailing 
list. Phabricator is not really designed to iterate quickly. It's not really a 
problem per se, but I figured I'd let you know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-14 Thread Paolo Severini via Phabricator via lldb-commits
paolosev added a comment.

In D72751#1869268 , @labath wrote:

> yeah, go for it.


Hi @labath, can I ask you the favor to land this patch for me?  I have rebased 
it because the logic of SystemInitializers have changed with new macros.

I asked commit access and I should have obtained it, but when I try to land 
this patch either with 'arc land' or with 'git push' I get a permission error:

  git push --dry-run
  Password for 'https://paolosevm...@github.com':
  remote: Permission to llvm/llvm-project.git denied to paolosevMSFT.
  fatal: unable to access 
'https://paolosevm...@github.com/llvm/llvm-project.git/': The requested URL 
returned error: 403

Maybe there is something I have not understood in the process...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244779.
diazhector98 added a comment.

Adding test for priority


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,8 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
+
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1369,6 +1373,14 @@
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  }
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,52 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def checkIfPathIsSame(self,lines, path_env_variable):
+for line in lines:
+print(line)
+if line.startswith('PATH='):
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+return
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why things aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=True)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+self.checkIfPathIsSame(lines, path_env_variable)
+
+@skipIfWindows
+@skipIfDarwin
+def test_environment_variable_priority(self):
+"""
+Tests the environment variables priority
+ 

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244782.
diazhector98 added a comment.

Removing print


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,8 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
+
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1369,6 +1373,14 @@
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  }
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,51 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def checkIfPathIsSame(self,lines, path_env_variable):
+for line in lines:
+if line.startswith('PATH='):
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+return
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why things aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=True)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+self.checkIfPathIsSame(lines, path_env_variable)
+
+@skipIfWindows
+@skipIfDarwin
+def test_environment_variable_priority(self):
+"""
+Tests the 

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244781.
diazhector98 added a comment.

Add Makefile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,8 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
+
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1369,6 +1373,14 @@
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  }
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,52 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def checkIfPathIsSame(self,lines, path_env_variable):
+for line in lines:
+print(line)
+if line.startswith('PATH='):
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+return
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why things aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=True)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+self.checkIfPathIsSame(lines, path_env_variable)
+
+@skipIfWindows
+@skipIfDarwin
+def test_environment_variable_priority(self):
+"""
+   

[Lldb-commits] [PATCH] D74598: [lldb/gdb-remote] Add support for the qOffsets packet

2020-02-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

> This patch does not implement full scope of the qOffsets packet (which 
> supports having different biases for code, data and bss sections). This is 
> because the relevant lldb interfaces (e.g., Module::SetLoadAddress) do not 
> support passing different values for different sections, and it's not clear 
> how would such a thing apply to typical object files.

While Module::SetLoadAddress doesn't, the Target interfaces do in fact support 
this fully. You specify the section and the section load address. Look at the 
macOS dynamic loader, it does this. All shared libraries in the macOS dyld 
shared cache have all the the __TEXT segments put next to each other so that 
the OS can load one large read + execute mapping, all the modifiable data 
sections in __DATA are relocated as well along with other segments. The 
Module::SetLoadAddress() interface was put in Module to make it easy to slide 
full binaries.




Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:3552
+  return llvm::None;
+if (offset && *offset != cur_offset)
+  return llvm::None;

Too a bit to understand what this was doing. Might be worth a comment here or 
in the header that says something like:

```
We only handle offsets where all sections in a file are offset by the same 
amount. If any sections is slid by a different amount, we return no value.
```



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h:428
 
+  /// qOffsets
+  llvm::Optional GetExecutableOffset();

Might be nice to document that we only handle when a binary has all its 
sections slid by the same amount somewhere. 



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h:429
+  /// qOffsets
+  llvm::Optional GetExecutableOffset();
+

It would be nice to have two functions here:
1 - "llvm::SmallVector GetQOffsets();" which will return raw 
qOffsets calls results
2 - "llvm::Optional GetExecutableOffset();" which calls above 
function and then does it thing where it tries to get a single rigid slide for 
the entire executable binary or fails.



Comment at: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp:1116
+}
+  }
+

We could fall back eventually to try and parse the full results of qOffsets 
directly here and try to slide. Doesn't need to be done now, but a TODO comment 
might be nice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74598



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


[Lldb-commits] [PATCH] D74585: Don't prefix error message from process launch with "process launch failed:" boilerplate in Target::Launch

2020-02-14 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.

fine with me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74585



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


[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244771.
diazhector98 added a comment.

Comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the debugger environment when launching a process. Only works for binaries launched directly by LLDB.",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,8 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
+
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1369,6 +1373,14 @@
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  }
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,33 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=False)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+self.assertTrue(found, 'PATH environment variable not found')
+
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244770.
diazhector98 added a comment.

Continue repair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,8 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
+
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1369,6 +1373,14 @@
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  }
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
 
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,33 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=False)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+self.assertTrue(found, 'PATH environment variable not found')
+
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 +570,7 @@
disableSTDIO=False, 

[Lldb-commits] [lldb] 4f2cccc - [lldb/Editline] Fix mistake in HistoryOperation mapping

2020-02-14 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-14T14:07:29-08:00
New Revision: 4f25ce89855bfc5cc44f9bb45fec745e7de9

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

LOG: [lldb/Editline] Fix mistake in HistoryOperation mapping

In 0e9b0b6d11e882efec8505d97c4b65e1562e6715 I introduced the
HistoryOperation enum to navigate the history. While this fixed the
behavior of HistoryOperation::Older and HistoryOperation::Newer, it
confused the mapping for HistoryOperation::Oldest and
HistoryOperation::Newest.

I tried to write a PExpect test to make sure this doesn't regress, but
I'm unable to prime the history in such a way that it recalls a known
element. I suspect this is an LLDB bug, but the  most recent entry
doesn't get update with entries from the current session. I considered
spoofing the home directory but that needs to happen before libLLDB is
loaded and you'll need to account for the widechar support. If anyone
has another suggestion I'd love to hear it.

Added: 


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

Removed: 




diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index 6d82a9826b39..f73255d32240 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -99,18 +99,24 @@ bool IsOnlySpaces(const EditLineStringType ) {
 
 static int GetOperation(HistoryOperation op) {
   // The naming used by editline for the history operations is counter
-  // intuitive to how it's used here.
+  // intuitive to how it's used in LLDB's editline implementation.
+  //
+  //  - The H_LAST returns the oldest entry in the history.
   //
   //  - The H_PREV operation returns the previous element in the history, which
   //is newer than the current one.
   //
+  //  - The H_CURR returns the current entry in the history.
+  //
   //  - The H_NEXT operation returns the next element in the history, which is
   //older than the current one.
   //
+  //  - The H_FIRST returns the most recent entry in the history.
+  //
   // The naming of the enum entries match the semantic meaning.
   switch(op) {
 case HistoryOperation::Oldest:
-  return H_FIRST;
+  return H_LAST;
 case HistoryOperation::Older:
   return H_NEXT;
 case HistoryOperation::Current:
@@ -118,7 +124,7 @@ static int GetOperation(HistoryOperation op) {
 case HistoryOperation::Newer:
   return H_PREV;
 case HistoryOperation::Newest:
-  return H_LAST;
+  return H_FIRST;
   }
   llvm_unreachable("Fully covered switch!");
 }



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


[Lldb-commits] [PATCH] D74650: [lldb] WIP: idea for keeping filenames in raw form when coming from DWARF

2020-02-14 Thread Konrad Wilhelm Kleine via Phabricator via lldb-commits
kwk created this revision.
kwk added a reviewer: labath.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

PLEASE DO NOT REVIEW YET. This is for brainstorming an idea with @labath


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74650

Files:
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Utility/FileSpec.cpp

Index: lldb/source/Utility/FileSpec.cpp
===
--- lldb/source/Utility/FileSpec.cpp
+++ lldb/source/Utility/FileSpec.cpp
@@ -68,8 +68,9 @@
 FileSpec::FileSpec() : m_style(GetNativeStyle()) {}
 
 // Default constructor that can take an optional full path to a file on disk.
-FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) {
-  SetFile(path, style);
+FileSpec::FileSpec(llvm::StringRef path, Style style, bool normalize)
+: m_style(style) {
+  SetFile(path, style, normalize);
 }
 
 FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple )
@@ -171,7 +172,7 @@
 // Update the contents of this object with a new path. The path will be split
 // up into a directory and filename and stored as uniqued string values for
 // quick comparison and efficient memory usage.
-void FileSpec::SetFile(llvm::StringRef pathname, Style style) {
+void FileSpec::SetFile(llvm::StringRef pathname, Style style, bool normalize) {
   m_filename.Clear();
   m_directory.Clear();
   m_is_resolved = false;
@@ -183,11 +184,11 @@
   llvm::SmallString<128> resolved(pathname);
 
   // Normalize the path by removing ".", ".." and other redundant components.
-  if (needsNormalization(resolved))
+  if (normalize && needsNormalization(resolved))
 llvm::sys::path::remove_dots(resolved, true, m_style);
 
   // Normalize back slashes to forward slashes
-  if (m_style == Style::windows)
+  if (normalize && m_style == Style::windows)
 std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
   if (resolved.empty()) {
@@ -213,6 +214,10 @@
   return SetFile(path, triple.isOSWindows() ? Style::windows : Style::posix);
 }
 
+bool FileSpec::IsNormalized() const {
+  return *this == FileSpec(GetPath(), m_style, true);
+}
+
 // Convert to pointer operator. This allows code to check any FileSpec objects
 // to see if they contain anything valid using code such as:
 //
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -213,7 +213,7 @@
 remapped_file = std::move(*file_path);
 
 // Unconditionally add an entry, so the indices match up.
-support_files.EmplaceBack(remapped_file, style);
+support_files.EmplaceBack(remapped_file, style, false);
   }
 
   return support_files;
Index: lldb/include/lldb/Utility/FileSpec.h
===
--- lldb/include/lldb/Utility/FileSpec.h
+++ lldb/include/lldb/Utility/FileSpec.h
@@ -70,8 +70,12 @@
   /// \param[in] style
   /// The style of the path
   ///
+  /// \param[in] normalize
+  /// Whether or not to cleanup the filepath or not.
+  ///
   /// \see FileSpec::SetFile (const char *path)
-  explicit FileSpec(llvm::StringRef path, Style style = Style::native);
+  explicit FileSpec(llvm::StringRef path, Style style = Style::native,
+bool normalize = true);
 
   explicit FileSpec(llvm::StringRef path, const llvm::Triple );
 
@@ -348,7 +352,10 @@
   ///
   /// \param[in] style
   /// The style for the given path.
-  void SetFile(llvm::StringRef path, Style style);
+  ///
+  /// \param[in] normalize
+  /// Whether or not to cleanup the filepath or not.
+  void SetFile(llvm::StringRef path, Style style, bool normalize = true);
 
   /// Change the file specified with a new path.
   ///
@@ -363,6 +370,10 @@
   /// The triple which is used to set the Path style.
   void SetFile(llvm::StringRef path, const llvm::Triple );
 
+  /// \returns \c true if the normalized FileSpec is the same as this; otherwise
+  /// \c false is returned.
+  bool IsNormalized() const;
+
   bool IsResolved() const { return m_is_resolved; }
 
   /// Set if the file path has been resolved or not.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244769.
diazhector98 added a comment.

Continue repair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,33 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=False)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+self.assertTrue(found, 'PATH environment variable not found')
+
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 +570,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -605,6 +605,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',
 'type': 'request',
@@ -912,7 +914,8 @@
   initCommands=options.initCmds,
   preRunCommands=options.preRunCmds,
   stopCommands=options.stopCmds,
-  exitCommands=options.exitCmds)
+  exitCommands=options.exitCmds,
+  inheritEnvironment=options.inheritEnvironment)
 
 if response['success']:
 if options.sourceBreakpoints:
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- 

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244767.
diazhector98 added a comment.

Continue repair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
\ No newline at end of file
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,33 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=False)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment variable not the same")
+self.assertTrue(found, 'PATH environment variable not found')
+
\ No newline at end of file
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 +570,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -605,6 +605,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',
 'type': 'request',
@@ -912,7 +914,8 @@
   initCommands=options.initCmds,
   preRunCommands=options.preRunCmds,
   stopCommands=options.stopCmds,
-  exitCommands=options.exitCmds)
+  exitCommands=options.exitCmds
+  inheritEnvironment=options.inheritEnvironment)
 
 if response['success']:
 if options.sourceBreakpoints:
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244763.
diazhector98 added a comment.

Continued repair


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/package.json


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
"description": 
"Additional environment variables.",
"default": []
},
+   "inheritEnvironment": {
+   "type": 
"boolean",
+   "description": 
"Inherit the VSCode Environment Variables",
+   "default": false
+   },
"stopOnEntry": {
"type": 
"boolean",
"description": 
"Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; 
env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
\ No newline at end of file
Index: 
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ 
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,33 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings 
aren't working on build bots
+def test_environment_variable(self):
+"""
+Tests the environment variables
+"""
+program = self.getBuildArtifact("a.out")
+path_env_variable = 'PATH='+os.environ['PATH']
+self.build_and_launch(program, inheritEnvironment=False)
+self.continue_to_exit()
+output = self.get_stdout().encode('utf-8')
+lines = output.splitlines()
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment 
variable not the same")
+self.assertTrue(found, 'PATH environment variable not found')
+
\ No newline at end of file


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,14 @@
+#include 
+#include 
+#include 
+#include 
+
+extern char **environ;
+
+int main(int argc, char const *argv[], char const *envp[]) {
+char** env_var_pointer = environ;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer) {
+printf("%s\n", env_variable);
+}
+return 0;
+}
\ No newline at end of file
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244749.
diazhector98 added a comment.

Adding the test files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/tools/lldb-vscode/package.json


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
"description": 
"Additional environment variables.",
"default": []
},
+   "inheritEnvironment": {
+   "type": 
"boolean",
+   "description": 
"Inherit the VSCode Environment Variables",
+   "default": false
+   },
"stopOnEntry": {
"type": 
"boolean",
"description": 
"Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,3 @@
+int main(int argc, char const *argv[]) {
+
+}
Index: 
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ 
lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,21 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings 
aren't working on build bots
+def test_completions(self):
+"""
+Tests the environment variables
+"""


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/main.cpp
@@ -0,0 +1,3 @@
+int main(int argc, char const *argv[]) {
+
+}
Index: lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
===
--- /dev/null
+++ lldb/test/API/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
@@ -0,0 +1,21 @@
+"""
+Test lldb-vscode completions request
+"""
+
+
+import lldbvscode_testcase
+import unittest2
+import vscode
+from lldbsuite.test import lldbutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+
+
+class TestVSCode_variables(lldbvscode_testcase.VSCodeTestCaseBase):
+
+@skipIfWindows
+@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+def test_completions(self):
+"""
+Tests the environment variables
+"""
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244748.
diazhector98 added a comment.

Add change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74636

Files:
  lldb/tools/lldb-vscode/package.json


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
"description": 
"Additional environment variables.",
"default": []
},
+   "inheritEnvironment": {
+   "type": 
"boolean",
+   "description": 
"Inherit the VSCode Environment Variables",
+   "default": false
+   },
"stopOnEntry": {
"type": 
"boolean",
"description": 
"Automatically stop after launch.",


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74637: Unify DIERef vs. user_id_t

2020-02-14 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: aprantl.

As discussed  in D73206 
 there is both `DIERef` and `user_id_t` and 
sometimes (for DWZ) we need to encode Main CU into them and sometimes we cannot 
as it is unavailable at that point and at the same time not even needed.
I have also noticed `DIERef` and `user_id_t` in fact contain the same 
information which can be seen in SymbolFileDWARF::GetUID 
.
(Offtopic: Moreover `UserID` is also another form of `user_id_t`.)
SB* API/ABI is already using `user_id_t` and it needs to encode Main CU for 
DWZ. Therefore what about making `DIERef` the identifier not containing Main CU 
and `user_id_t` the identifier containing Main CU?
@labath also said:

> I think it would be good to have only one kind of "user id". What are the 
> cases where you need a main-cu-less user id?

This patch does that in a small scale, is it the proper way forward?
(Personally I think the non-MainCU and plus-MainCU forms should be the same, 
either both `user_id_t` or both `DIERef` - and to drop the other form 
completely - but that can be always easily refactored any time.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74637

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -498,7 +498,7 @@
   bool m_fetched_external_modules : 1;
   lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
 
-  typedef std::set DIERefSet;
+  typedef std::set DIERefSet;
   typedef llvm::StringMap NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr m_ranges;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2385,9 +2385,9 @@
   dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
   }
 
-  for (lldb::user_id_t uid :
+  for (DIERef die_ref :
m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
-DWARFDIE die = GetDIE(uid);
+DWARFDIE die = GetDIE(die_ref);
 mangled_names.push_back(ConstString(die.GetMangledName()));
   }
 }
@@ -3035,7 +3035,7 @@
.AsCString(""));
   if (scope_qualified_name.size()) {
 m_function_scope_qualified_name_map[scope_qualified_name].insert(
-die.GetID());
+*die.GetDIERef());
   }
 }
   }
Index: lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
@@ -44,6 +44,16 @@
 
   dw_offset_t die_offset() const { return m_die_offset; }
 
+  bool operator<(DIERef other) const {
+if (m_dwo_num_valid != other.m_dwo_num_valid)
+  return m_dwo_num_valid < other.m_dwo_num_valid;
+if (m_dwo_num_valid && (m_dwo_num != other.m_dwo_num))
+  return m_dwo_num < other.m_dwo_num;
+if (m_section != other.m_section)
+  return m_section < other.m_section;
+return m_die_offset < other.m_die_offset;
+  }
+
 private:
   uint32_t m_dwo_num : 30;
   uint32_t m_dwo_num_valid : 1;


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -498,7 +498,7 @@
   bool m_fetched_external_modules : 1;
   lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type;
 
-  typedef std::set DIERefSet;
+  typedef std::set DIERefSet;
   typedef llvm::StringMap NameToOffsetMap;
   NameToOffsetMap m_function_scope_qualified_name_map;
   std::unique_ptr m_ranges;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2385,9 +2385,9 @@
   dwo->GetMangledNamesForFunction(scope_qualified_name, mangled_names);
   }
 
-  for (lldb::user_id_t uid :
+  for (DIERef die_ref :
m_function_scope_qualified_name_map.lookup(scope_qualified_name)) {
-DWARFDIE die = 

[Lldb-commits] [PATCH] D74636: [DO NOT REVIEW] Add inheritEnvironment option

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 created this revision.
diazhector98 added a reviewer: wallace.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74636

Files:
  lldb/tools/lldb-vscode/package.json


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
"description": 
"Additional environment variables.",
"default": []
},
+   "inheritEnvironment": {
+   "type": 
"boolean",
+   "description": 
"Inherit the VSCode Environment Variables",
+   "default": false
+   },
"stopOnEntry": {
"type": 
"boolean",
"description": 
"Automatically stop after launch.",


Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-02-14 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 244727.
tatyana-krasnukha added a reviewer: jingham.
tatyana-krasnukha added a comment.

Just realized that BreakpointResolverScripted::CreateImplementationIfNeeded 
should work when m_breakpoint == nullptr.
GetBreakpoint with assertion is not suitable here, so I pass the breakpoint as 
a parameter.


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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -621,7 +621,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -154,17 +154,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint ) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP ) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint();
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -181,7 +181,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP , ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint ) override {
+  CopyForBreakpoint(lldb::BreakpointSP ) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(, m_kernel_name));
+new RSBreakpointResolver(breakpoint, m_kernel_name));
 return ret_sp;
   }
 
@@ 

[Lldb-commits] [PATCH] D74607: [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

2020-02-14 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor marked an inline comment as done.
teemperor added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:1133
 
-if (parent_decl_ctx && GetDeclContextContainingUID(
-   result->getSymIndexId()) != *parent_decl_ctx)
+if (GetDeclContextContainingUID(result->getSymIndexId()) != 
parent_decl_ctx)
   continue;

shafik wrote:
>  `!parent_decl_ctx.IsValid() && 
> GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx` 
> seems like a more accurate replacement  especially if 
> `GetDeclContextContainingUID` can also return an invalid result, I think. 
I think the negation at the start is a typo? With the negation it would mean 
that with a valid `parent_decl_ctx` the continue would never be evaluated. But 
the intend seems to be to only parse variables that are in the DeclContext. So 
with the negation, specifying any `parent_decl_ctx`would disable the filter and 
we would parse all variables in all DeclContexts?

But yeah, I think this makes sense. In theory 
`DeclContextMatchesThisSymbolFile` seems to early-exit on the error cases that 
would cause `GetDeclContextContainingUID` to return an invalid DeclContext and 
the function has an assert for an valid result at the end, but I think the 
`IPDBSession` error case could return an invalid DeclContext in this function. 
Let's just play safe and keep the check.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74607



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


[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244723.
diazhector98 added a comment.

Comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  
lldb/test/API/testcases/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  lldb/test/API/testcases/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/test/API/testcases/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,7 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1364,13 +1367,24 @@
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
-  if (!args.empty())
+  if (!args.empty()) 
 g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  } 
+
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  
 
   auto flags = g_vsc.launch_info.GetLaunchFlags();
 
Index: lldb/test/API/testcases/tools/lldb-vscode/vscode.py
===
--- lldb/test/API/testcases/tools/lldb-vscode/vscode.py
+++ lldb/test/API/testcases/tools/lldb-vscode/vscode.py
@@ -111,7 +111,6 @@
 self.exit_status = None
 self.initialize_body = None
 self.thread_stop_reasons = {}
-self.breakpoint_events = []
 self.sequence = 1
 self.threads = None
 self.recv_thread.start()
@@ -187,7 +186,7 @@
 self.output[category] = output
 self.output_condition.notify()
 self.output_condition.release()
-# no need to add 'output' event packets to our packets list
+# no need to add 'output' packets to our packets list
 return keepGoing
 elif event == 'process':
 # When a new process is attached or launched, remember the
@@ -201,13 +200,6 @@
 self._process_stopped()
 tid = body['threadId']
 self.thread_stop_reasons[tid] = body
-elif event == 'breakpoint':
-# Breakpoint events come in when a breakpoint has locations
-# added or removed. Keep track of them so we can look for them
-# in tests.
-self.breakpoint_events.append(packet)
-# no need to add 'breakpoint' event packets to our packets list
-return keepGoing
 elif packet_type == 'response':
 if packet['command'] == 'disconnect':
 keepGoing = False
@@ -570,7 +562,7 @@
 

[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244721.
diazhector98 added a comment.

- Comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,7 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1364,13 +1367,24 @@
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
-  if (!args.empty())
+  if (!args.empty()) 
 g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
+
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  } 
+
   if (!envs.empty())
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  
 
   auto flags = g_vsc.launch_info.GetLaunchFlags();
 
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 +570,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -605,6 +605,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',
 'type': 'request',
@@ -912,7 +914,9 @@
   initCommands=options.initCmds,
   preRunCommands=options.preRunCmds,
   stopCommands=options.stopCmds,
-  exitCommands=options.exitCmds)
+  exitCommands=options.exitCmds
+  inheritEnvironment=options.inheritEnvironment
+  )
 
 if response['success']:
 if options.sourceBreakpoints:
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
===
--- 

[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244719.
diazhector98 added a comment.

- Merge branch 'master' of https://github.com/llvm/llvm-project


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1327,6 +1329,7 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1364,13 +1367,24 @@
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
-  if (!args.empty())
+  if (!args.empty()) 
 g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
-  if (!envs.empty())
+
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  } 
+
+  if (!envs.empty()) {
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  }
 
   auto flags = g_vsc.launch_info.GetLaunchFlags();
 
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -570,7 +570,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -605,6 +605,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',
 'type': 'request',
@@ -912,7 +914,9 @@
   initCommands=options.initCmds,
   preRunCommands=options.preRunCmds,
   stopCommands=options.stopCmds,
-  exitCommands=options.exitCmds)
+  exitCommands=options.exitCmds
+  inheritEnvironment=options.inheritEnvironment
+  )
 
 if response['success']:
 if options.sourceBreakpoints:
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py

[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244717.
diazhector98 added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,11 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+#include  // std::this_thread::sleep_for
+#include  // std::chrono::seconds
+
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -1340,6 +1345,7 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1387,13 +1393,26 @@
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
-  if (!args.empty())
+  if (!args.empty()) 
 g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
-  if (!envs.empty())
+
+  // if arguments has launchWithDebuggerEnvironment
+  // then append current environment to g_vsc.launch_info
+  if (launchWithDebuggerEnvironment) {
+  // if (true) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  } 
+  if (!envs.empty()) {
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  }
 
   auto flags = g_vsc.launch_info.GetLaunchFlags();
 
@@ -2228,6 +2247,8 @@
 //   }]
 // }
 void request_stepIn(const llvm::json::Object ) {
+
+  return;
   llvm::json::Object response;
   FillResponse(request, response);
   auto arguments = request.getObject("arguments");
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -562,7 +562,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -597,6 +597,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',
 'type': 'request',
@@ -891,6 +893,7 @@
   stopCommands=options.stopCmds,
   exitCommands=options.exitCmds)
 else:
+print('Options.Envs: ', options.envs)
 response = 

[Lldb-commits] [PATCH] D74607: [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

2020-02-14 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik accepted this revision.
shafik added a comment.

This is a great change, it makes the code more consistent. LGTM besides the few 
comments I made.




Comment at: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:1133
 
-if (parent_decl_ctx && GetDeclContextContainingUID(
-   result->getSymIndexId()) != *parent_decl_ctx)
+if (GetDeclContextContainingUID(result->getSymIndexId()) != 
parent_decl_ctx)
   continue;

 `!parent_decl_ctx.IsValid() && 
GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx` seems 
like a more accurate replacement  especially if `GetDeclContextContainingUID` 
can also return an invalid result, I think. 



Comment at: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:1326
 
-if (parent_decl_ctx &&
-GetDeclContextContainingUID(id) != *parent_decl_ctx)
+if (GetDeclContextContainingUID(id) != parent_decl_ctx)
   continue;

Same comment as above.



Comment at: lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp:1549
 
-if (parent_decl_ctx && GetDeclContextContainingUID(
-   result->getSymIndexId()) != *parent_decl_ctx)
+if (GetDeclContextContainingUID(result->getSymIndexId()) != 
parent_decl_ctx)
   continue;

same here.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74607



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


[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread walter erquinigo via Phabricator via lldb-commits
wallace added inline comments.



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py:31-35
+found = False
+for line in lines:
+if line.startswith('PATH='):
+found = True
+self.assertTrue(path_env_variable == line, "PATH environment 
variable not the same")

this becomes more readable if you make it a function. That way you avoid having 
the mutable found variable and you can stop the for loop as soon as you return



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp:10
+char** env_var_pointer = environ;
+// std::vector vscode_env_variables;
+int count = 0;

remove this comment



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py:315
 self.assertTrue(os.path.exists(program), 'executable must exist')
-
 self.launch(program, args, cwd, env, stopOnEntry, disableASLR,

try not to delete existing blank lines



Comment at: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py:905
   stopCommands=options.stopCmds,
-  exitCommands=options.exitCmds)
+  exitCommands=options.exitCmds
+  
inheritEnvironment=options.inheritEnvironment

I think you need a comma here



Comment at: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py:906-907
+  exitCommands=options.exitCmds
+  
inheritEnvironment=options.inheritEnvironment
+  )
 

put the ) in line 906



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1408-1410
+  if (!envs.empty()) {
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  }

in llvm, you don't need to use { } for one line ifs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579



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


[Lldb-commits] [PATCH] D74579: [don't review]Creating environment variable test for lldbd

2020-02-14 Thread Héctor Luis Díaz Aceves via Phabricator via lldb-commits
diazhector98 updated this revision to Diff 244701.
diazhector98 added a comment.

Working on comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74579

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/TestVSCode_environmentVariables.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/environmentVariables/main.cpp
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -84,6 +84,11 @@
 "description": "Additional environment variables.",
 "default": []
 			},
+			"inheritEnvironment": {
+"type": "boolean",
+"description": "Inherit the VSCode Environment Variables",
+"default": false
+			},
 			"stopOnEntry": {
 "type": "boolean",
 "description": "Automatically stop after launch.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -49,6 +49,8 @@
 #include "LLDBUtils.h"
 #include "VSCode.h"
 
+extern char **environ;
+
 #if defined(_WIN32)
 #ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
@@ -951,9 +953,17 @@
   for (size_t i = 0; i < count; i++) {
 std::string match = matches.GetStringAtIndex(i);
 std::string description = descriptions.GetStringAtIndex(i);
-
+
 llvm::json::Object item;
-EmplaceSafeString(item, "text", match);
+
+llvm::StringRef match_ref = match;
+for(llvm::StringRef commit_point: {".", "->"}) {
+  if (match_ref.contains(commit_point)){
+match_ref = match_ref.rsplit(commit_point).second;
+  }
+}
+EmplaceSafeString(item, "text", match_ref);
+
 if (description.empty())
   EmplaceSafeString(item, "label", match);
 else
@@ -1332,6 +1342,7 @@
   auto launchCommands = GetStrings(arguments, "launchCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
   const auto debuggerRoot = GetString(arguments, "debuggerRoot");
+  bool launchWithDebuggerEnvironment = GetBoolean(arguments, "inheritEnvironment", false);
 
   // This is a hack for loading DWARF in .o files on Mac where the .o files
   // in the debug map of the main executable have relative paths which require
@@ -1379,13 +1390,24 @@
   // Extract any extra arguments and append them to our program arguments for
   // when we launch
   auto args = GetStrings(arguments, "args");
-  if (!args.empty())
+  if (!args.empty()) 
 g_vsc.launch_info.SetArguments(MakeArgv(args).data(), true);
 
   // Pass any environment variables along that the user specified.
   auto envs = GetStrings(arguments, "env");
-  if (!envs.empty())
+
+  if (launchWithDebuggerEnvironment) {
+char** env_var_pointer = environ;
+std::vector vscode_env_variables;
+for (char* env_variable = *env_var_pointer; env_variable; env_variable=*++env_var_pointer){
+  vscode_env_variables.push_back(env_variable);
+}
+envs.insert(std::end(envs), std::begin(vscode_env_variables), std::end(vscode_env_variables));
+  } 
+
+  if (!envs.empty()) {
 g_vsc.launch_info.SetEnvironmentEntries(MakeArgv(envs).data(), true);
+  }
 
   auto flags = g_vsc.launch_info.GetLaunchFlags();
 
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
===
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -562,7 +562,7 @@
disableSTDIO=False, shellExpandArguments=False,
trace=False, initCommands=None, preRunCommands=None,
stopCommands=None, exitCommands=None, sourcePath=None,
-   debuggerRoot=None, launchCommands=None):
+   debuggerRoot=None, launchCommands=None, inheritEnvironment=False):
 args_dict = {
 'program': program
 }
@@ -597,6 +597,8 @@
 args_dict['debuggerRoot'] = debuggerRoot
 if launchCommands:
 args_dict['launchCommands'] = launchCommands
+if inheritEnvironment:
+args_dict['inheritEnvironment'] = inheritEnvironment
 command_dict = {
 'command': 'launch',

[Lldb-commits] [PATCH] D73067: [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin

2020-02-14 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 244700.
JDevlieghere added a comment.

Address code review feedback


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

https://reviews.llvm.org/D73067

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
  lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
  lldb/source/Plugins/Language/ClangCommon/CMakeLists.txt
  lldb/source/Plugins/Language/ObjC/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/CMakeLists.txt
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/OperatingSystem/CMakeLists.txt
  lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Plugins.def.in
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  lldb/tools/lldb-test/CMakeLists.txt
  lldb/tools/lldb-test/SystemInitializerTest.cpp
  lldb/unittests/Disassembler/CMakeLists.txt
  lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
  lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt

Index: lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
@@ -5,7 +5,7 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
+lldbPluginDisassemblerLLVMC
 lldbPluginInstructionPPC64
 lldbPluginProcessUtility
   LINK_COMPONENTS
Index: lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
@@ -5,7 +5,7 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
+lldbPluginDisassemblerLLVMC
 lldbPluginInstructionARM64
 lldbPluginProcessUtility
   LINK_COMPONENTS
Index: lldb/unittests/Disassembler/CMakeLists.txt
===
--- lldb/unittests/Disassembler/CMakeLists.txt
+++ lldb/unittests/Disassembler/CMakeLists.txt
@@ -6,7 +6,7 @@
   lldbCore
   lldbSymbol
   lldbTarget
-  lldbPluginDisassemblerLLVM
+  lldbPluginDisassemblerLLVMC
   lldbPluginProcessUtility
 LINK_COMPONENTS
   Support
Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -17,81 +17,8 @@
 
 #include 
 
-LLDB_PLUGIN_DECLARE(ABIAArch64);
-LLDB_PLUGIN_DECLARE(ABIARM);
-LLDB_PLUGIN_DECLARE(ABISysV_arc);
-LLDB_PLUGIN_DECLARE(ABISysV_hexagon);
-LLDB_PLUGIN_DECLARE(ABIMips);
-LLDB_PLUGIN_DECLARE(ABIPowerPC);
-LLDB_PLUGIN_DECLARE(ABISysV_s390x);
-LLDB_PLUGIN_DECLARE(ABIX86);
-LLDB_PLUGIN_DECLARE(ObjectFileBreakpad)
-LLDB_PLUGIN_DECLARE(ObjectFileELF)
-LLDB_PLUGIN_DECLARE(ObjectFileMachO)
-LLDB_PLUGIN_DECLARE(ObjectFilePECOFF)
-LLDB_PLUGIN_DECLARE(ObjectFileWasm)
-LLDB_PLUGIN_DECLARE(ObjectContainerBSDArchive)
-LLDB_PLUGIN_DECLARE(ObjectContainerUniversalMachO)
-LLDB_PLUGIN_DECLARE(ScriptInterpreterNone)
-LLDB_PLUGIN_DECLARE(PlatformFreeBSD)
-LLDB_PLUGIN_DECLARE(PlatformLinux)
-LLDB_PLUGIN_DECLARE(PlatformNetBSD)
-LLDB_PLUGIN_DECLARE(PlatformOpenBSD)
-LLDB_PLUGIN_DECLARE(PlatformWindows)
-LLDB_PLUGIN_DECLARE(PlatformAndroid)
-LLDB_PLUGIN_DECLARE(PlatformMacOSX)
-LLDB_PLUGIN_DECLARE(TypeSystemClang)
-LLDB_PLUGIN_DECLARE(ArchitectureArm)
-LLDB_PLUGIN_DECLARE(ArchitectureMips)

[Lldb-commits] [lldb] bba9ba8 - [lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)

2020-02-14 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-14T09:58:24-08:00
New Revision: bba9ba8d953816fd7697cdb647b81510bfa85d71

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

LOG: [lldb/Plugin] s/LLDB_PLUGIN/LLDB_PLUGIN_DEFINE/ (NFC)

Rename LLDB_PLUGIN to LLDB_PLUGIN_DEFINE as Pavel suggested in D73067 to
avoid name conflict.

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
lldb/source/Plugins/ABI/ARM/ABIARM.cpp
lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
lldb/source/Plugins/ABI/ARM/ABISysV_arm.cpp
lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
lldb/source/Plugins/ABI/Mips/ABIMips.cpp
lldb/source/Plugins/ABI/Mips/ABISysV_mips.cpp
lldb/source/Plugins/ABI/Mips/ABISysV_mips64.cpp
lldb/source/Plugins/ABI/PowerPC/ABIPowerPC.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
lldb/source/Plugins/ABI/X86/ABIMacOSX_i386.cpp
lldb/source/Plugins/ABI/X86/ABISysV_i386.cpp
lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
lldb/source/Plugins/ABI/X86/ABIX86.cpp
lldb/source/Plugins/Architecture/Arm/ArchitectureArm.cpp
lldb/source/Plugins/Architecture/Mips/ArchitectureMips.cpp
lldb/source/Plugins/Architecture/PPC64/ArchitecturePPC64.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
lldb/source/Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp

lldb/source/Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.cpp

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

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

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

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp

lldb/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp

lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
lldb/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/wasm/ObjectFileWasm.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp

[Lldb-commits] [PATCH] D74475: [lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in the test suite

2020-02-14 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

In D74475#1875674 , @JDevlieghere 
wrote:

> Yup, looks like that was it, the bot is green again: 
> http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13740


Thanks for taking care of it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74475



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


[Lldb-commits] [PATCH] D72158: [DebugInfo] Make most debug line prologue errors non-fatal to parsing

2020-02-14 Thread James Henderson via Phabricator via lldb-commits
jhenderson marked an inline comment as done.
jhenderson added inline comments.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:323-325
+// Treat this error as unrecoverable - we cannot be sure what any of
+// the data represents including the length field, so cannot skip it or 
make
+// any reasonable assumptions.

labath wrote:
> BTW, I think this error should be recoverable too. I believe the reason why 
> the length field comes *before* the version number is specifically so that 
> one can skip over contributions with unsupported (future) version numbers.
> 
> While it's hard to say what the future versions of dwarf will look like, I 
> would expect that the committee will try very hard to avoid  making changes 
> in the length field. I think they'd use one of the 
> DW_LENGTH_lo_reserved..DW_LENGTH_hi_reserved-1 constants for severely 
> incompatible changes.
"Unrecoverable" here means don't try to parse this table, but do allow parsing 
the next. I think the comment might be slightly misleading in this regard. 
FWIW, a version of 0 or 1 probably doesn't have a leading length, so it is 
definitely unrecoverable. For versions > 5, which are now checked, we don't 
know what the structure of the header is, so although we could take a guess, 
we'd almost certainly get it wrong and produce invalid (possibly very invalid) 
output. I don't have a strong opinion as to whether that should be an 
unrecoverable error or not (currently it is).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72158



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


[Lldb-commits] [PATCH] D74557: [lldb] Make BreakpointResolver hold weak_ptr instead of raw pointer to breakpoint

2020-02-14 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha updated this revision to Diff 244645.
tatyana-krasnukha added a comment.

Moved assertion into GetBreakpoint().

> Were there any places you found where it was legit to ask for the Breakpoint 
> for a resolver and not have one?

I didn't find any, however, it seems to be possible in theory as 
BreakpointResolver is allowed to be constructed with `nullptr` instead of 
breakpoint (it is expected to call SetBreakpoint later).


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

https://reviews.llvm.org/D74557

Files:
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Target/LanguageRuntime.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Breakpoint/BreakpointResolver.cpp
  lldb/source/Breakpoint/BreakpointResolverAddress.cpp
  lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -621,7 +621,7 @@
 const bool hardware = request_hardware || GetRequireHardwareBreakpoints();
 bp_sp.reset(new Breakpoint(*this, filter_sp, resolver_sp, hardware,
resolve_indirect_symbols));
-resolver_sp->SetBreakpoint(bp_sp.get());
+resolver_sp->SetBreakpoint(bp_sp);
 AddBreakpoint(bp_sp, internal);
   }
   return bp_sp;
Index: lldb/source/Target/LanguageRuntime.cpp
===
--- lldb/source/Target/LanguageRuntime.cpp
+++ lldb/source/Target/LanguageRuntime.cpp
@@ -154,17 +154,17 @@
   }
 
 protected:
-  BreakpointResolverSP CopyForBreakpoint(Breakpoint ) override {
+  BreakpointResolverSP CopyForBreakpoint(BreakpointSP ) override {
 BreakpointResolverSP ret_sp(
 new ExceptionBreakpointResolver(m_language, m_catch_bp, m_throw_bp));
-ret_sp->SetBreakpoint();
+ret_sp->SetBreakpoint(breakpoint);
 return ret_sp;
   }
 
   bool SetActualResolver() {
-ProcessSP process_sp;
-if (m_breakpoint) {
-  process_sp = m_breakpoint->GetTarget().GetProcessSP();
+BreakpointSP breakpoint_sp = GetBreakpoint();
+if (breakpoint_sp) {
+  ProcessSP process_sp = breakpoint_sp->GetTarget().GetProcessSP();
   if (process_sp) {
 bool refreash_resolver = !m_actual_resolver_sp;
 if (m_language_runtime == nullptr) {
@@ -181,7 +181,7 @@
 
 if (refreash_resolver && m_language_runtime) {
   m_actual_resolver_sp = m_language_runtime->CreateExceptionResolver(
-  m_breakpoint, m_catch_bp, m_throw_bp);
+  breakpoint_sp, m_catch_bp, m_throw_bp);
 }
   } else {
 m_actual_resolver_sp.reset();
Index: lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
===
--- lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
+++ lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
@@ -58,7 +58,7 @@
 // for .expand kernels as a fallback.
 class RSBreakpointResolver : public BreakpointResolver {
 public:
-  RSBreakpointResolver(Breakpoint *bp, ConstString name)
+  RSBreakpointResolver(const lldb::BreakpointSP , ConstString name)
   : BreakpointResolver(bp, BreakpointResolver::NameResolver),
 m_kernel_name(name) {}
 
@@ -77,9 +77,9 @@
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
 
   lldb::BreakpointResolverSP
-  CopyForBreakpoint(Breakpoint ) override {
+  CopyForBreakpoint(lldb::BreakpointSP ) override {
 lldb::BreakpointResolverSP ret_sp(
-new RSBreakpointResolver(, m_kernel_name));

[Lldb-commits] [PATCH] D72158: [DebugInfo] Make most debug line prologue errors non-fatal to parsing

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp:323-325
+// Treat this error as unrecoverable - we cannot be sure what any of
+// the data represents including the length field, so cannot skip it or 
make
+// any reasonable assumptions.

BTW, I think this error should be recoverable too. I believe the reason why the 
length field comes *before* the version number is specifically so that one can 
skip over contributions with unsupported (future) version numbers.

While it's hard to say what the future versions of dwarf will look like, I 
would expect that the committee will try very hard to avoid  making changes in 
the length field. I think they'd use one of the 
DW_LENGTH_lo_reserved..DW_LENGTH_hi_reserved-1 constants for severely 
incompatible changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72158



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


[Lldb-commits] [PATCH] D74607: [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

2020-02-14 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.

Yes, please.

Bonus points to anyone who can replace the default-constructed 
CompilerDeclContext with llvm::None.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74607



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


[Lldb-commits] [PATCH] D74607: [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

2020-02-14 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added reviewers: labath, mib.
Herald added subscribers: lldb-commits, JDevlieghere, abidh, arphaman.
Herald added a project: LLDB.

All of our lookup APIs either use `CompilerDeclContext &` or 
`CompilerDeclContext *` semi-randomly it seems.
This leads to us constantly converting between those two types (and doing 
nullptr checks when going from
pointer to reference). It also leads to the confusing situation where we have 
two possible ways to express
that we don't have a CompilerDeclContex: either a nullptr or an invalid 
CompilerDeclContext (aka a default
constructed CompilerDeclContext).

This moves all APIs to use references and gets rid of all the nullptr checks 
and conversions.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74607

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/source/API/SBModule.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/AddressResolverName.cpp
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Core/SourceManager.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -395,7 +395,8 @@
   if (Context.empty())
 return CompilerDeclContext();
   VariableList List;
-  Symfile.FindGlobalVariables(ConstString(Context), nullptr, UINT32_MAX, List);
+  Symfile.FindGlobalVariables(ConstString(Context), CompilerDeclContext(),
+  UINT32_MAX, List);
   if (List.Empty())
 return make_string_error("Context search didn't find a match.");
   if (List.GetSize() > 1)
@@ -442,8 +443,8 @@
 Expected ContextOr = getDeclContext(Symfile);
 if (!ContextOr)
   return ContextOr.takeError();
-CompilerDeclContext *ContextPtr =
-ContextOr->IsValid() ? &*ContextOr : nullptr;
+const CompilerDeclContext  =
+ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
 List.Clear();
 Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(),
@@ -498,8 +499,8 @@
   Expected ContextOr = getDeclContext(Symfile);
   if (!ContextOr)
 return ContextOr.takeError();
-  CompilerDeclContext *ContextPtr =
-  ContextOr->IsValid() ? &*ContextOr : nullptr;
+  const CompilerDeclContext  =
+  ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
   CompilerDeclContext Result =
   Symfile.FindNamespace(ConstString(Name), ContextPtr);
@@ -516,8 +517,8 @@
   Expected ContextOr = getDeclContext(Symfile);
   if (!ContextOr)
 return ContextOr.takeError();
-  CompilerDeclContext *ContextPtr =
-  ContextOr->IsValid() ? &*ContextOr : nullptr;
+  const CompilerDeclContext  =
+  ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
   LanguageSet languages;
   if (!Language.empty())
@@ -566,8 +567,8 @@
 Expected ContextOr = getDeclContext(Symfile);
 if (!ContextOr)
   return ContextOr.takeError();
-CompilerDeclContext *ContextPtr =
-ContextOr->IsValid() ? &*ContextOr : nullptr;
+const CompilerDeclContext  =
+ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
 Symfile.FindGlobalVariables(ConstString(Name), ContextPtr, UINT32_MAX, List);
   }
Index: lldb/source/Symbol/SymbolFile.cpp
===
--- lldb/source/Symbol/SymbolFile.cpp
+++ lldb/source/Symbol/SymbolFile.cpp
@@ -105,7 +105,7 @@
 }
 
 void SymbolFile::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext 

[Lldb-commits] [PATCH] D74244: [lldb] Delete register info definitions in the x86_64 ABI classes

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 244624.
labath marked 3 inline comments as done.
labath added a comment.

- make functions work on lowercase names
- handle singular registers in the remapping function


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74244

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABISysV_x86_64.h
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.cpp
  lldb/source/Plugins/ABI/X86/ABIWindows_x86_64.h
  lldb/source/Plugins/ABI/X86/ABIx86_64.h
  lldb/source/Target/ABI.cpp
  lldb/unittests/Target/ABITest.cpp
  lldb/unittests/Target/CMakeLists.txt

Index: lldb/unittests/Target/CMakeLists.txt
===
--- lldb/unittests/Target/CMakeLists.txt
+++ lldb/unittests/Target/CMakeLists.txt
@@ -1,4 +1,5 @@
 add_lldb_unittest(TargetTests
+  ABITest.cpp
   ExecutionContextTest.cpp
   MemoryRegionInfoTest.cpp
   ModuleCacheTest.cpp
Index: lldb/unittests/Target/ABITest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/ABITest.cpp
@@ -0,0 +1,26 @@
+//===-- ABITest.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 "lldb/Target/ABI.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+TEST(MCBasedABI, MapRegisterName) {
+  auto map = [](std::string name) {
+MCBasedABI::MapRegisterName(name, "foo", "bar");
+return name;
+  };
+  EXPECT_EQ("bar", map("foo"));
+  EXPECT_EQ("bar0", map("foo0"));
+  EXPECT_EQ("bar47", map("foo47"));
+  EXPECT_EQ("foo47x", map("foo47x"));
+  EXPECT_EQ("fooo47", map("fooo47"));
+  EXPECT_EQ("bar47", map("bar47"));
+}
+
Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -228,3 +228,43 @@
   if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
 info.kinds[eRegisterKindGeneric] = abi_info.kinds[eRegisterKindGeneric];
 }
+
+void MCBasedABI::AugmentRegisterInfo(RegisterInfo ) {
+  uint32_t eh, dwarf;
+  std::tie(eh, dwarf) = GetEHAndDWARFNums(info.name);
+
+  if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
+info.kinds[eRegisterKindEHFrame] = eh;
+  if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
+info.kinds[eRegisterKindDWARF] = dwarf;
+  if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
+info.kinds[eRegisterKindGeneric] = GetGenericNum(info.name);
+}
+
+std::pair
+MCBasedABI::GetEHAndDWARFNums(llvm::StringRef name) {
+  std::string mc_name = GetMCName(name.str());
+  llvm::transform(mc_name, mc_name.begin(), std::toupper);
+  int eh = -1;
+  int dwarf = -1;
+  for (unsigned reg = 0; reg < m_mc_register_info_up->getNumRegs(); ++reg) {
+if (m_mc_register_info_up->getName(reg) == mc_name) {
+  eh = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/true);
+  dwarf = m_mc_register_info_up->getDwarfRegNum(reg, /*isEH=*/false);
+  break;
+}
+  }
+  return std::pair(eh == -1 ? LLDB_INVALID_REGNUM : eh,
+   dwarf == -1 ? LLDB_INVALID_REGNUM
+   : dwarf);
+}
+
+void MCBasedABI::MapRegisterName(std::string , llvm::StringRef from_prefix,
+ llvm::StringRef to_prefix) {
+  llvm::StringRef name_ref = name;
+  if (!name_ref.consume_front(from_prefix))
+return;
+  uint64_t _;
+  if (name_ref.empty() || to_integer(name_ref, _, 10))
+name = (to_prefix + name_ref).str();
+}
Index: lldb/source/Plugins/ABI/X86/ABIx86_64.h
===
--- /dev/null
+++ lldb/source/Plugins/ABI/X86/ABIx86_64.h
@@ -0,0 +1,26 @@
+//===-- ABIx86_64.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-exception
+//
+//===--===//
+
+#ifndef LLDB_PLUGIN_ABI_X86_ABIX86_64_H
+#define LLDB_PLUGIN_ABI_X86_ABIX86_64_H
+
+#include "lldb/Target/ABI.h"
+#include "lldb/lldb-private.h"
+
+class ABIx86_64 : public lldb_private::MCBasedABI {
+protected:
+  std::string GetMCName(std::string name) override {
+MapRegisterName(name, "stmm", "st");
+return name;
+  }
+
+private:
+  using lldb_private::MCBasedABI::MCBasedABI;
+};
+
+#endif // LLDB_PLUGIN_ABI_X86_ABIX86_64_H
Index: 

[Lldb-commits] [PATCH] D74244: [lldb] Delete register info definitions in the x86_64 ABI classes

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
labath marked 6 inline comments as done.
labath added inline comments.



Comment at: lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp:938
+  .Case("R8", LLDB_REGNUM_GENERIC_ARG5)
+  .Case("r9", LLDB_REGNUM_GENERIC_ARG6)
+  .Default(LLDB_INVALID_REGNUM);

tatyana-krasnukha wrote:
> Typo? It should be uppercase, I think.
Thanks for catching that. After some consideration, I've decided it would be 
less confusing if this function (and GetMCName)  worked on lowercase register 
names like everything else lldb. In the new version of this patch I've moved 
the uppercase transformation closer to the point where we interface with the MC 
layer.



Comment at: lldb/source/Target/ABI.cpp:249
+  int eh = -1;
+  int dwarf = -1;
+  for (unsigned reg = 0; reg < m_mc_register_info_up->getNumRegs(); ++reg) {

jasonmolenda wrote:
> Would it be simpler to assign these to `LLDB_INVALID_REGNUM` at the 
> beginning, instead of -1 and setting it later?
Not really, because the MC interface uses -1 to denote registers which don't 
have a dwarf number. (In fact some of the things in the MC list are not even 
really registers, but more like combinations of registers that are sometimes 
handy when grouped (`Q0_Q1`, etc.)



Comment at: lldb/source/Target/ABI.cpp:267
+  if (name_ref.consume_front(from_prefix) && to_integer(name_ref, _, 10))
+name = (to_prefix + name_ref).str();
+}

jasonmolenda wrote:
> will `to_integer` bit work with an all-letter reg like `cpsr`?
We didn't need this functionality yet because we weren't renaming any singular 
registers, but I've now added code to handle this too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74244



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


[Lldb-commits] [lldb] a57ad00 - [lldb] Print result when expect_expr unexpectedly succeeds

2020-02-14 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-14T12:57:10+01:00
New Revision: a57ad008b449a95249a42582370a5f0fefccbf03

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

LOG: [lldb] Print result when expect_expr unexpectedly succeeds

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index fa93cce73be5..784d6ecd2ddf 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2397,7 +2397,7 @@ def expect_expr(
 eval_result = frame.EvaluateExpression(expr)
 
 if error_msg:
-self.assertFalse(eval_result.IsValid())
+self.assertFalse(eval_result.IsValid(), "Unexpected success with 
result: '" + str(eval_result) + "'")
 self.assertEqual(error_msg, eval_result.GetError().GetCString())
 return
 



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


[Lldb-commits] [PATCH] D74598: [lldb/gdb-remote] Add support for the qOffsets packet

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
labath created this revision.
labath added reviewers: clayborg, jasonmolenda.
Herald added a project: LLDB.

This packet is necessary to make lldb work with the remote-gdb stub in
user mode qemu when running position-independent binaries. It reports
the relative position (load bias) of the loaded executable wrt. the
addresses in the file itself.

Lldb needs to know this information in order to correctly set the load
address of the executable. Normally, lldb would be able to find this out
on its own by following the breadcrumbs in the process auxiliary vector,
but we can't do this here because qemu does not support the
qXfer:auxv:read packet.

This patch does not implement full scope of the qOffsets packet (which
supports having different biases for code, data and bss sections). This
is because the relevant lldb interfaces (e.g., Module::SetLoadAddress)
do not support passing different values for different sections, and it's
not clear how would such a thing apply to typicall object files. And
qemu will always
(https://github.com/qemu/qemu/blob/master/linux-user/elfload.c#L2436)
return the same value for code and data offsets. In fact, even gdb
ignores the offset for the bss sections, and uses the "data" offset
instead.  So, until the we need more of this packet, I think it's best
to stick to the simplest solution possible. This patch simply rejects
replies with non-uniform offsets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74598

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py
  lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
  lldb/test/API/functionalities/gdb_remote_client/qOffsets.yaml
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
===
--- lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
@@ -552,3 +552,24 @@
   incorrect_custom_params2);
   ASSERT_FALSE(result4.get().Success());
 }
+
+TEST_F(GDBRemoteCommunicationClientTest, GetOffsets) {
+  const auto  = [&](llvm::StringRef response) {
+std::future> result = std::async(
+std::launch::async, [&] { return client.GetExecutableOffset(); });
+
+HandlePacket(server, "qOffsets", response);
+return result.get();
+  };
+  EXPECT_EQ(addr_t(0x1234), GetExecutableOffset("Text=1234;Data=1234"));
+  EXPECT_EQ(addr_t(0x1234),
+GetExecutableOffset("Text=1234;Data=1234;Bss=1234"));
+  EXPECT_EQ(addr_t(0x1234), GetExecutableOffset("TextSeg=1234;DataSeg=1234"));
+
+  EXPECT_EQ(llvm::None, GetExecutableOffset("E05"));
+  EXPECT_EQ(llvm::None, GetExecutableOffset("Text=bogus"));
+
+  // NB: These are technically correct responses, but we don't handle them yet.
+  EXPECT_EQ(llvm::None, GetExecutableOffset("Text=1234;Data=4321"));
+  EXPECT_EQ(llvm::None, GetExecutableOffset("TextSeg=1234;DataSeg=4321"));
+}
Index: lldb/test/API/functionalities/gdb_remote_client/qOffsets.yaml
===
--- /dev/null
+++ lldb/test/API/functionalities/gdb_remote_client/qOffsets.yaml
@@ -0,0 +1,19 @@
+!ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_AARCH64
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x1000
+AddressAlign:0x4
+Content: "c3c3c3c3"
+  - Name:.note.ABI-tag
+Type:SHT_NOTE
+Flags:   [ SHF_ALLOC ]
+Address: 0x1004
+AddressAlign:0x4
+Content: 04001100474e550003000700
Index: lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
===
--- lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
+++ lldb/test/API/functionalities/gdb_remote_client/gdbclientutils.py
@@ -172,6 +172,8 @@
 return self.qHostInfo()
 if packet == "qGetWorkingDir":
 return self.qGetWorkingDir()
+if packet == "qOffsets":
+return self.qOffsets();
 if packet == "qsProcessInfo":
 return self.qsProcessInfo()
 if packet.startswith("qfProcessInfo"):
@@ -188,6 +190,9 @@
 def qGetWorkingDir(self):
 return "2f"
 
+def qOffsets(self):
+return ""
+
 def qHostInfo(self):
 return "ptrsize:8;endian:little;"
 
Index: lldb/test/API/functionalities/gdb_remote_client/TestqOffsets.py

[Lldb-commits] [PATCH] D73782: [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9dc84e9b02d1: [lldb/DWARF] Dont hold a unique 
SymbolFileDWARFDwo in a DWARFUnit (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73782

Files:
  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

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -29,10 +29,7 @@
 
   ~SymbolFileDWARFDwo() override = default;
 
-  DWARFCompileUnit *GetCompileUnit();
-
-  DWARFUnit *
-  GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) override;
+  DWARFCompileUnit *GetDWOCompileUnitForHash(uint64_t hash);
 
   size_t GetObjCMethodDIEOffsets(lldb_private::ConstString class_name,
  DIEArray _die_offsets) override;
@@ -68,10 +65,11 @@
 
   SymbolFileDWARF () { return m_base_symbol_file; }
 
-  DWARFCompileUnit *ComputeCompileUnit();
+  /// If this file contains exactly one compile unit, this function will return
+  /// it. Otherwise it returns nullptr.
+  DWARFCompileUnit *FindSingleCompileUnit();
 
   SymbolFileDWARF _base_symbol_file;
-  DWARFCompileUnit *m_cu = nullptr;
 };
 
 #endif // SymbolFileDWARFDwo_SymbolFileDWARFDwo_h_
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -49,13 +49,17 @@
   SymbolFileDWARF::LoadSectionData(sect_type, data);
 }
 
-DWARFCompileUnit *SymbolFileDWARFDwo::GetCompileUnit() {
-  if (!m_cu)
-m_cu = ComputeCompileUnit();
-  return m_cu;
+DWARFCompileUnit *SymbolFileDWARFDwo::GetDWOCompileUnitForHash(uint64_t hash) {
+  DWARFCompileUnit *cu = FindSingleCompileUnit();
+  if (!cu)
+return nullptr;
+  if (hash !=
+  cu->GetUnitDIEOnly().GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0))
+return nullptr;
+  return cu;
 }
 
-DWARFCompileUnit *SymbolFileDWARFDwo::ComputeCompileUnit() {
+DWARFCompileUnit *SymbolFileDWARFDwo::FindSingleCompileUnit() {
   DWARFDebugInfo *debug_info = DebugInfo();
   if (!debug_info)
 return nullptr;
@@ -79,11 +83,6 @@
   return cu;
 }
 
-DWARFUnit *
-SymbolFileDWARFDwo::GetDWARFCompileUnit(lldb_private::CompileUnit *comp_unit) {
-  return GetCompileUnit();
-}
-
 SymbolFileDWARF::DIEToTypePtr ::GetDIEToType() {
   return GetBaseSymbolFile().GetDIEToType();
 }
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -270,7 +270,7 @@
 
   lldb::user_id_t GetUID(DIERef ref);
 
-  std::unique_ptr
+  std::shared_ptr
   GetDwoSymbolFileForCompileUnit(DWARFUnit _cu,
  const DWARFDebugInfoEntry _die);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1556,7 +1556,7 @@
   return {};
 }
 
-std::unique_ptr
+std::shared_ptr
 SymbolFileDWARF::GetDwoSymbolFileForCompileUnit(
 DWARFUnit , const DWARFDebugInfoEntry _die) {
   // If this is a Darwin-style debug map (non-.dSYM) symbol file,
@@ -1611,7 +1611,7 @@
   if (dwo_obj_file == nullptr)
 return nullptr;
 
-  return std::make_unique(*this, dwo_obj_file,
+  return std::make_shared(*this, dwo_obj_file,
   dwarf_cu->GetID());
 }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -277,7 +277,7 @@
   }
 
   SymbolFileDWARF _dwarf;
-  std::unique_ptr m_dwo_symbol_file;
+  std::shared_ptr m_dwo;
   DWARFUnitHeader m_header;
   const DWARFAbbreviationDeclarationSet *m_abbrevs = nullptr;
   void *m_user_data = nullptr;
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -188,7 +188,7 @@
   // simultaneously. We also don't need to do that as 

[Lldb-commits] [lldb] 9dc84e9 - [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit

2020-02-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-14T11:09:45+01:00
New Revision: 9dc84e9b02d1e402503906099d42fbae4da7d8d9

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

LOG: [lldb/DWARF] Don't hold a unique SymbolFileDWARFDwo in a DWARFUnit

This is the second dwp preparatory patch. When a SymbolFileDWARFDwo will
hold more than one split unit, it will not be able to be uniquely owned
by a single DWARFUnit. I achieve this by changing the
unique_ptr member of DWARFUnit to
shared_ptr. The shared_ptr points to a DWARFUnit, but it is
in fact holding the entire SymbolFileDWARFDwo alive. This is the same
method used by llvm DWARFUnit (except that is uses the DWARFContext
class).

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

Added: 


Modified: 
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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index e4a89160969e..1e8c465979b5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -188,7 +188,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
   // simultaneously. We also don't need to do that as the dwo file will
   // contain a superset of information. So, we don't even attempt to parse
   // any remaining DIEs.
-  if (m_dwo_symbol_file) {
+  if (m_dwo) {
 m_die_array.front().SetHasChildren(false);
 break;
   }
@@ -249,10 +249,8 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 
   m_die_array.shrink_to_fit();
 
-  if (m_dwo_symbol_file) {
-DWARFUnit *dwo_cu = m_dwo_symbol_file->GetCompileUnit();
-dwo_cu->ExtractDIEsIfNeeded();
-  }
+  if (m_dwo)
+m_dwo->ExtractDIEsIfNeeded();
 }
 
 // This is used when a split dwarf is enabled.
@@ -339,12 +337,14 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
   if (m_is_dwo)
 return;
 
-  std::unique_ptr dwo_symbol_file =
+  std::shared_ptr dwo_symbol_file =
   m_dwarf.GetDwoSymbolFileForCompileUnit(*this, cu_die);
   if (!dwo_symbol_file)
 return;
 
-  DWARFUnit *dwo_cu = dwo_symbol_file->GetCompileUnit();
+  uint64_t main_dwo_id =
+  cu_die.GetAttributeValueAsUnsigned(this, DW_AT_GNU_dwo_id, 0);
+  DWARFUnit *dwo_cu = dwo_symbol_file->GetDWOCompileUnitForHash(main_dwo_id);
   if (!dwo_cu)
 return; // Can't fetch the compile unit from the dwo file.
   dwo_cu->SetUserData(this);
@@ -353,16 +353,6 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
   if (!dwo_cu_die.IsValid())
 return; // Can't fetch the compile unit DIE from the dwo file.
 
-  uint64_t main_dwo_id =
-  cu_die.GetAttributeValueAsUnsigned(this, DW_AT_GNU_dwo_id, 0);
-  uint64_t sub_dwo_id =
-  dwo_cu_die.GetAttributeValueAsUnsigned(DW_AT_GNU_dwo_id, 0);
-  if (main_dwo_id != sub_dwo_id)
-return; // The 2 dwo ID isn't match. Don't use the dwo file as it belongs 
to
-  // a 
diff erectn compilation.
-
-  m_dwo_symbol_file = std::move(dwo_symbol_file);
-
   // Here for DWO CU we want to use the address base set in the skeleton unit
   // (DW_AT_addr_base) if it is available and use the DW_AT_GNU_addr_base
   // otherwise. We do that because pre-DWARF v5 could use the DW_AT_GNU_*
@@ -376,21 +366,22 @@ void DWARFUnit::AddUnitDIE(const DWARFDebugInfoEntry 
_die) {
 
   if (GetVersion() <= 4 && gnu_ranges_base)
 dwo_cu->SetRangesBase(*gnu_ranges_base);
-  else if (m_dwo_symbol_file->GetDWARFContext()
+  else if (dwo_symbol_file->GetDWARFContext()
.getOrLoadRngListsData()
.GetByteSize() > 0)
 dwo_cu->SetRangesBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
 
-  if (GetVersion() >= 5 && m_dwo_symbol_file->GetDWARFContext()
-   .getOrLoadLocListsData()
-   .GetByteSize() > 0)
+  if (GetVersion() >= 5 &&
+  dwo_symbol_file->GetDWARFContext().getOrLoadLocListsData().GetByteSize() 
>
+  0)
 
dwo_cu->SetLoclistsBase(llvm::DWARFListTableHeader::getHeaderSize(DWARF32));
   dwo_cu->SetBaseAddress(GetBaseAddress());
 
-  for (size_t i = 0; i < m_dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
-DWARFUnit *unit = m_dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);
+  for (size_t i = 0; i < dwo_symbol_file->DebugInfo()->GetNumUnits(); ++i) {
+DWARFUnit *unit = dwo_symbol_file->DebugInfo()->GetUnitAtIndex(i);
 SetDwoStrOffsetsBase(unit);
   }
+  m_dwo = 

[Lldb-commits] [PATCH] D74551: [lldb/dotest] Remove the "exclusive test subdir" concept

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07211d951d58: [lldb/dotest] Remove the exclusive test 
subdir concept (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74551

Files:
  lldb/packages/Python/lldbsuite/test/configuration.py
  lldb/packages/Python/lldbsuite/test/dotest.py


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1051,15 +1051,7 @@
 "netbsd" in target_platform or
 "windows" in target_platform)
 
-# Collect tests from the specified testing directories. If a test
-# subdirectory filter is explicitly specified, limit the search to that
-# subdirectory.
-exclusive_test_subdir = 
configuration.get_absolute_path_to_exclusive_test_subdir()
-if exclusive_test_subdir:
-dirs_to_search = [exclusive_test_subdir]
-else:
-dirs_to_search = configuration.testdirs
-for testdir in dirs_to_search:
+for testdir in configuration.testdirs:
 for (dirpath, dirnames, filenames) in os.walk(testdir):
 visit('Test', dirpath, filenames)
 
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -117,11 +117,6 @@
 # The clang module cache directory used by clang.
 clang_module_cache_dir = None
 
-# The only directory to scan for tests. If multiple test directories are
-# specified, and an exclusive test subdirectory is specified, the latter option
-# takes precedence.
-exclusive_test_subdir = None
-
 # Test results handling globals
 results_filename = None
 results_formatter_name = None
@@ -153,37 +148,6 @@
 return False
 
 
-def get_absolute_path_to_exclusive_test_subdir():
-"""
-If an exclusive test subdirectory is specified, return its absolute path.
-Otherwise return None.
-"""
-test_directory = os.path.dirname(os.path.realpath(__file__))
-
-if not exclusive_test_subdir:
-return
-
-if len(exclusive_test_subdir) > 0:
-test_subdir = os.path.join(test_directory, exclusive_test_subdir)
-if os.path.isdir(test_subdir):
-return test_subdir
-
-print('specified test subdirectory {} is not a valid directory\n'
-.format(test_subdir))
-
-
-def get_absolute_path_to_root_test_dir():
-"""
-If an exclusive test subdirectory is specified, return its absolute path.
-Otherwise, return the absolute path of the root test directory.
-"""
-test_subdir = get_absolute_path_to_exclusive_test_subdir()
-if test_subdir:
-return test_subdir
-
-return os.path.dirname(os.path.realpath(__file__))
-
-
 def get_filecheck_path():
 """
 Get the path to the FileCheck testing tool.


Index: lldb/packages/Python/lldbsuite/test/dotest.py
===
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1051,15 +1051,7 @@
 "netbsd" in target_platform or
 "windows" in target_platform)
 
-# Collect tests from the specified testing directories. If a test
-# subdirectory filter is explicitly specified, limit the search to that
-# subdirectory.
-exclusive_test_subdir = configuration.get_absolute_path_to_exclusive_test_subdir()
-if exclusive_test_subdir:
-dirs_to_search = [exclusive_test_subdir]
-else:
-dirs_to_search = configuration.testdirs
-for testdir in dirs_to_search:
+for testdir in configuration.testdirs:
 for (dirpath, dirnames, filenames) in os.walk(testdir):
 visit('Test', dirpath, filenames)
 
Index: lldb/packages/Python/lldbsuite/test/configuration.py
===
--- lldb/packages/Python/lldbsuite/test/configuration.py
+++ lldb/packages/Python/lldbsuite/test/configuration.py
@@ -117,11 +117,6 @@
 # The clang module cache directory used by clang.
 clang_module_cache_dir = None
 
-# The only directory to scan for tests. If multiple test directories are
-# specified, and an exclusive test subdirectory is specified, the latter option
-# takes precedence.
-exclusive_test_subdir = None
-
 # Test results handling globals
 results_filename = None
 results_formatter_name = None
@@ -153,37 +148,6 @@
 return False
 
 
-def get_absolute_path_to_exclusive_test_subdir():
-"""
-If an exclusive test subdirectory is specified, return its absolute path.
-Otherwise return None.
-"""
-test_directory = os.path.dirname(os.path.realpath(__file__))
-
-if not 

[Lldb-commits] [PATCH] D50525: [WIP] Move lldb-mi interpreter tests to LIT

2020-02-14 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov abandoned this revision.
apolyakov added a comment.
Herald added a subscriber: JDevlieghere.

Abandoned since the patch is outdated too much.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D50525



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


[Lldb-commits] [PATCH] D60968: WIP, RFC: Add an example of how LLDB python plug-in could look like

2020-02-14 Thread Alexander Polyakov via Phabricator via lldb-commits
apolyakov abandoned this revision.
apolyakov added a comment.

Abandoned since for now, it will require a lot of changes to the codebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60968



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


[Lldb-commits] [lldb] 07211d9 - [lldb/dotest] Remove the "exclusive test subdir" concept

2020-02-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-14T10:24:12+01:00
New Revision: 07211d951d584b19951ad8dedbaf7c728297f4b5

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

LOG: [lldb/dotest] Remove the "exclusive test subdir" concept

Summary:
This was added in 2018 (r339929), when we were still using the
hand-rolled test runner.

It does not seem to be relevant anymore. In fact as far as I can tell,
it's a big no-op now as the exclusive_test_subdir variable is never set.

Reviewers: vsk, JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/configuration.py
lldb/packages/Python/lldbsuite/test/dotest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/configuration.py 
b/lldb/packages/Python/lldbsuite/test/configuration.py
index faf31e7dbcf8..ce6f46ae476f 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -117,11 +117,6 @@
 # The clang module cache directory used by clang.
 clang_module_cache_dir = None
 
-# The only directory to scan for tests. If multiple test directories are
-# specified, and an exclusive test subdirectory is specified, the latter option
-# takes precedence.
-exclusive_test_subdir = None
-
 # Test results handling globals
 results_filename = None
 results_formatter_name = None
@@ -153,37 +148,6 @@ def shouldSkipBecauseOfCategories(test_categories):
 return False
 
 
-def get_absolute_path_to_exclusive_test_subdir():
-"""
-If an exclusive test subdirectory is specified, return its absolute path.
-Otherwise return None.
-"""
-test_directory = os.path.dirname(os.path.realpath(__file__))
-
-if not exclusive_test_subdir:
-return
-
-if len(exclusive_test_subdir) > 0:
-test_subdir = os.path.join(test_directory, exclusive_test_subdir)
-if os.path.isdir(test_subdir):
-return test_subdir
-
-print('specified test subdirectory {} is not a valid directory\n'
-.format(test_subdir))
-
-
-def get_absolute_path_to_root_test_dir():
-"""
-If an exclusive test subdirectory is specified, return its absolute path.
-Otherwise, return the absolute path of the root test directory.
-"""
-test_subdir = get_absolute_path_to_exclusive_test_subdir()
-if test_subdir:
-return test_subdir
-
-return os.path.dirname(os.path.realpath(__file__))
-
-
 def get_filecheck_path():
 """
 Get the path to the FileCheck testing tool.

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 4863004c0b72..5dddc996eda5 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1051,15 +1051,7 @@ def run_suite():
 "netbsd" in target_platform or
 "windows" in target_platform)
 
-# Collect tests from the specified testing directories. If a test
-# subdirectory filter is explicitly specified, limit the search to that
-# subdirectory.
-exclusive_test_subdir = 
configuration.get_absolute_path_to_exclusive_test_subdir()
-if exclusive_test_subdir:
-dirs_to_search = [exclusive_test_subdir]
-else:
-dirs_to_search = configuration.testdirs
-for testdir in dirs_to_search:
+for testdir in configuration.testdirs:
 for (dirpath, dirnames, filenames) in os.walk(testdir):
 visit('Test', dirpath, filenames)
 



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


[Lldb-commits] [lldb] 189c701 - [lldb] Remove accidentally checked-in debugging code

2020-02-14 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-14T10:21:35+01:00
New Revision: 189c701332eb2d80c0bf6bf132abeb4e1ec9e6ce

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

LOG: [lldb] Remove accidentally checked-in debugging code

Added: 


Modified: 

lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py
 
b/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py
index e99297c35e32..e9d826073f21 100644
--- 
a/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py
+++ 
b/lldb/test/API/tools/lldb-vscode/breakpoint-events/TestVSCode_breakpointEvents.py
@@ -116,7 +116,3 @@ def test_breakpoint_events(self):
 "breakpoint event is has a line number")
 self.assertTrue("foo.cpp" in breakpoint['source']['path'],
 "breakpoint event path contains foo.cpp")
-
-output = self.get_console() # REMOVE PRIOR TO CHECKIN
-with open("/tmp/b", "w") as f:
-f.write(output)



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


[Lldb-commits] [PATCH] D73067: [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin

2020-02-14 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I think this is great. Just a bit of polishing...




Comment at: lldb/include/lldb/Core/PluginManager.h:25-29
 #define LLDB_PLUGIN(PluginName)
\
   namespace lldb_private { 
\
   void lldb_initialize_##PluginName() { PluginName::Initialize(); }
\
   void lldb_terminate_##PluginName() { PluginName::Terminate(); }  
\
   }

This macro should forward to the "ADV" (advanced?) one.



Comment at: lldb/source/API/SystemInitializerFull.cpp:27-28
 
-LLDB_PLUGIN_DECLARE(ABIAArch64);
-LLDB_PLUGIN_DECLARE(ABIARM);
-LLDB_PLUGIN_DECLARE(ABISysV_arc);
-LLDB_PLUGIN_DECLARE(ABISysV_hexagon);
-LLDB_PLUGIN_DECLARE(ABIMips);
-LLDB_PLUGIN_DECLARE(ABIPowerPC);
-LLDB_PLUGIN_DECLARE(ABISysV_s390x);
-LLDB_PLUGIN_DECLARE(ABIX86);
-LLDB_PLUGIN_DECLARE(ObjectFileBreakpad);
-LLDB_PLUGIN_DECLARE(ObjectFileELF);
-LLDB_PLUGIN_DECLARE(ObjectFileMachO);
-LLDB_PLUGIN_DECLARE(ObjectFilePECOFF);
-LLDB_PLUGIN_DECLARE(ObjectFileWasm);
-LLDB_PLUGIN_DECLARE(ObjectContainerBSDArchive);
-LLDB_PLUGIN_DECLARE(ObjectContainerUniversalMachO);
-LLDB_PLUGIN_DECLARE(ScriptInterpreterNone);
-#if LLDB_ENABLE_PYTHON
-LLDB_PLUGIN_DECLARE(OperatingSystemPython)
-LLDB_PLUGIN_DECLARE(ScriptInterpreterPython)
-#endif
-#if LLDB_ENABLE_LUA
-LLDB_PLUGIN_DECLARE(ScriptInterpreterLua)
-#endif
-LLDB_PLUGIN_DECLARE(PlatformFreeBSD)
-LLDB_PLUGIN_DECLARE(PlatformLinux)
-LLDB_PLUGIN_DECLARE(PlatformNetBSD)
-LLDB_PLUGIN_DECLARE(PlatformOpenBSD)
-LLDB_PLUGIN_DECLARE(PlatformWindows)
-LLDB_PLUGIN_DECLARE(PlatformAndroid)
-LLDB_PLUGIN_DECLARE(PlatformMacOSX)
-LLDB_PLUGIN_DECLARE(TypeSystemClang)
-LLDB_PLUGIN_DECLARE(ArchitectureArm)
-LLDB_PLUGIN_DECLARE(ArchitectureMips)
-LLDB_PLUGIN_DECLARE(ArchitecturePPC64)
-LLDB_PLUGIN_DECLARE(DisassemblerLLVMC)
-LLDB_PLUGIN_DECLARE(JITLoaderGDB)
-LLDB_PLUGIN_DECLARE(ProcessElfCore)
-LLDB_PLUGIN_DECLARE(ProcessMachCore)
-LLDB_PLUGIN_DECLARE(ProcessMinidump)
-LLDB_PLUGIN_DECLARE(MemoryHistoryASan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeASan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeTSan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeUBSan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeMainThreadChecker)
-LLDB_PLUGIN_DECLARE(SymbolVendorELF)
-LLDB_PLUGIN_DECLARE(SymbolFileBreakpad)
-LLDB_PLUGIN_DECLARE(SymbolFileDWARF)
-LLDB_PLUGIN_DECLARE(SymbolFilePDB)
-LLDB_PLUGIN_DECLARE(SymbolFileSymtab)
-LLDB_PLUGIN_DECLARE(SymbolVendorWasm)
-LLDB_PLUGIN_DECLARE(UnwindAssemblyInstEmulation)
-LLDB_PLUGIN_DECLARE(UnwindAssembly_x86)
-LLDB_PLUGIN_DECLARE(EmulateInstructionARM)
-LLDB_PLUGIN_DECLARE(EmulateInstructionARM64)
-LLDB_PLUGIN_DECLARE(EmulateInstructionMIPS)
-LLDB_PLUGIN_DECLARE(EmulateInstructionMIPS64)
-LLDB_PLUGIN_DECLARE(EmulateInstructionPPC64)
-LLDB_PLUGIN_DECLARE(ItaniumABILanguageRuntime)
-LLDB_PLUGIN_DECLARE(AppleObjCRuntime)
-LLDB_PLUGIN_DECLARE(SystemRuntimeMacOSX)
-LLDB_PLUGIN_DECLARE(RenderScriptRuntime)
-LLDB_PLUGIN_DECLARE(CPlusPlusLanguage)
-LLDB_PLUGIN_DECLARE(ObjCLanguage)
-LLDB_PLUGIN_DECLARE(ObjCPlusPlusLanguage)
-#if defined(_WIN32)
-LLDB_PLUGIN_DECLARE(ProcessWindows)
-#endif
-#if defined(__FreeBSD__)
-LLDB_PLUGIN_DECLARE(ProcessFreeBSD)
-#endif
-#if defined(__APPLE__)
-LLDB_PLUGIN_DECLARE(SymbolVendorMacOSX)
-LLDB_PLUGIN_DECLARE(ProcessKDP)
-LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
-#endif
-LLDB_PLUGIN_DECLARE(StructuredDataDarwinLog)
-LLDB_PLUGIN_DECLARE(PlatformRemoteGDBServer)
-LLDB_PLUGIN_DECLARE(ProcessGDBRemote)
-LLDB_PLUGIN_DECLARE(DynamicLoaderMacOSXDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderPOSIXDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderStatic)
-LLDB_PLUGIN_DECLARE(DynamicLoaderWindowsDYLD)
+#undef LLDB_PLUGIN
+#define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
+#include "Plugins/Plugins.def"

I don't like this recycling of the name LLDB_PLUGIN. Maybe rename this to 
LLDB_PLUGIN_OP, or the "other" macro to LLDB_PLUGIN_DEFINE ?



Comment at: lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp:58
 
-LLDB_PLUGIN(ABISysV_arc)
+LLDB_PLUGIN(ABISysV_arc, ABIARC)
 

missing _ADV. You might want to double check that the build with all targets 
enabled still works.



Comment at: lldb/source/Plugins/Plugins.def.in:12
+|* Clients of this file should define the LLDB_PLUGIN macro to be a   
*|
+|* function-like macro with a single parameter (the name of the plugin)   
*|
+|* including this file will then enumerate all of the targets.
*|

Maybe also mention `LLDB_SCRIPT_PLUGIN` ?



Comment at: lldb/tools/lldb-test/CMakeLists.txt:28
+
+target_include_directories(lldb-test PRIVATE ${LLDB_PLUGINS_INCLUDES})
+target_include_directories(lldb-test PRIVATE ${LLDB_SOURCE_DIR}/source)

It looks like you're including the `def` file as `Plugins/Plugins.def` in 
SystemInitializerFull. Can we do the same thing here and