[Lldb-commits] [lldb] r342875 - Add NativeProcessProtocol unit tests

2018-09-24 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Sep 24 05:11:04 2018
New Revision: 342875

URL: http://llvm.org/viewvc/llvm-project?rev=342875&view=rev
Log:
Add NativeProcessProtocol unit tests

Summary:
NativeProcessProtocol is an abstract class, but it still contains a
significant amount of code. Some of that code is tested via tests of
specific derived classes, but these tests don't run everywhere, as they
are OS and arch-specific. They are also relatively high-level, which
means some functionalities (particularly the failure cases) are
hard/impossible to test.

In this approach, I replace the abstract methods with mocks, which
allows me to inject failures into the lowest levels of breakpoint
setting code and test the class behavior in this situation.

Reviewers: zturner, teemperor

Subscribers: mgorny, lldb-commits

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

Added:
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
Modified:
lldb/trunk/unittests/Host/CMakeLists.txt

Modified: lldb/trunk/unittests/Host/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/CMakeLists.txt?rev=342875&r1=342874&r2=342875&view=diff
==
--- lldb/trunk/unittests/Host/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Host/CMakeLists.txt Mon Sep 24 05:11:04 2018
@@ -3,6 +3,7 @@ set (FILES
   HostInfoTest.cpp
   HostTest.cpp
   MainLoopTest.cpp
+  NativeProcessProtocolTest.cpp
   SocketAddressTest.cpp
   SocketTest.cpp
   SymbolsTest.cpp
@@ -22,4 +23,5 @@ add_lldb_unittest(HostTests
 lldbCore
 lldbHost
 lldbUtilityHelpers
+LLVMTestingSupport
   )

Added: lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp?rev=342875&view=auto
==
--- lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp (added)
+++ lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Mon Sep 24 05:11:04 
2018
@@ -0,0 +1,154 @@
+//===-- NativeProcessProtocolTest.cpp ---*- C++ 
-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "lldb/Host/common/NativeProcessProtocol.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+
+using namespace lldb_private;
+using namespace lldb;
+using namespace testing;
+
+namespace {
+class MockDelegate : public NativeProcessProtocol::NativeDelegate {
+public:
+  MOCK_METHOD1(InitializeDelegate, void(NativeProcessProtocol *Process));
+  MOCK_METHOD2(ProcessStateChanged,
+   void(NativeProcessProtocol *Process, StateType State));
+  MOCK_METHOD1(DidExec, void(NativeProcessProtocol *Process));
+};
+
+class MockProcess : public NativeProcessProtocol {
+public:
+  MockProcess(NativeDelegate &Delegate, const ArchSpec &Arch,
+  lldb::pid_t Pid = 1)
+  : NativeProcessProtocol(Pid, -1, Delegate), Arch(Arch) {}
+
+  MOCK_METHOD1(Resume, Status(const ResumeActionList &ResumeActions));
+  MOCK_METHOD0(Halt, Status());
+  MOCK_METHOD0(Detach, Status());
+  MOCK_METHOD1(Signal, Status(int Signo));
+  MOCK_METHOD0(Kill, Status());
+  MOCK_METHOD3(AllocateMemory,
+   Status(size_t Size, uint32_t Permissions, addr_t &Addr));
+  MOCK_METHOD1(DeallocateMemory, Status(addr_t Addr));
+  MOCK_METHOD0(GetSharedLibraryInfoAddress, addr_t());
+  MOCK_METHOD0(UpdateThreads, size_t());
+  MOCK_CONST_METHOD0(GetAuxvData,
+ llvm::ErrorOr>());
+  MOCK_METHOD2(GetLoadedModuleFileSpec,
+   Status(const char *ModulePath, FileSpec &Spec));
+  MOCK_METHOD2(GetFileLoadAddress,
+   Status(const llvm::StringRef &FileName, addr_t &Addr));
+
+  const ArchSpec &GetArchitecture() const override { return Arch; }
+  Status SetBreakpoint(lldb::addr_t Addr, uint32_t Size,
+   bool Hardware) override {
+if (Hardware)
+  return SetHardwareBreakpoint(Addr, Size);
+else
+  return SetSoftwareBreakpoint(Addr, Size);
+  }
+
+  // Redirect base class Read/Write Memory methods to functions whose 
signatures
+  // are more mock-friendly.
+  Status ReadMemory(addr_t Addr, void *Buf, size_t Size,
+size_t &BytesRead) override;
+  Status WriteMemory(addr_t Addr, const void *Buf, size_t Size,
+ size_t &BytesWritten) override;
+
+  MOCK_METHOD2(ReadMemory,
+   llvm::Expected>(addr_t Addr, size_t Size));
+  MOCK_METHOD2(WriteMemory,
+   llvm::Expected(addr_t Addr,
+  llvm::ArrayRef Data));
+
+  using NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode;
+
+private:
+  ArchSpec Arch;
+};
+} // namespace
+

[Lldb-commits] [lldb] r343016 - XFAIL some tests in TestTargetCreateDeps on linux

2018-09-25 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Sep 25 12:52:04 2018
New Revision: 343016

URL: http://llvm.org/viewvc/llvm-project?rev=343016&view=rev
Log:
XFAIL some tests in TestTargetCreateDeps on linux

On linux, we do not support automatic loading of dependent modules, so
the module list will always contain just one module (until the target is
launched).

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py?rev=343016&r1=343015&r2=343016&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/target_create_deps/TestTargetCreateDeps.py
 Tue Sep 25 12:52:04 2018
@@ -30,12 +30,14 @@ class TargetDependentsTestCase(TestBase)
 self.expect(
 "image list", msg, matching=should_match, substrs=['[  1]'])
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_implicit_default_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
 self.runCmd("target create  " + exe, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(False)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_default_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
@@ -48,6 +50,7 @@ class TargetDependentsTestCase(TestBase)
 self.runCmd("target create -dtrue " + exe, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(True)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_false_exe(self):
 """Test default behavior"""
 exe = self.getBuildArtifact("a.out")
@@ -81,6 +84,7 @@ class TargetDependentsTestCase(TestBase)
 self.runCmd("target create -dtrue " + lib, CURRENT_EXECUTABLE_SET)
 self.has_exactly_one_image(True)
 
+@expectedFailureAll(oslist=["linux"]) #linux does not support loading 
dependent files
 def test_dependents_explicit_false_lib(self):
 ctx = self.platformContext
 dylibName = ctx.shlib_prefix + 'load_a.' + ctx.shlib_extension


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


[Lldb-commits] [lldb] r343076 - Fix a memory read bug in lldb-server

2018-09-26 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Sep 26 00:31:41 2018
New Revision: 343076

URL: http://llvm.org/viewvc/llvm-project?rev=343076&view=rev
Log:
Fix a memory read bug in lldb-server

NativeProcessProtocol::ReadMemoryWithoutTrap had a bug, where it failed
to properly remove inserted breakpoint opcodes if the memory read
partially overlapped the trap opcode. This could not happen on x86
because it has a one-byte breakpoint instruction, but it could happen on
arm, which has a 4-byte breakpoint instruction (in arm mode).

Since triggerring this condition would only be possible on an arm
machine (and even then it would be a bit tricky). I test this using a
NativeProcessProtocol unit test.

Modified:
lldb/trunk/source/Host/common/NativeBreakpointList.cpp
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/source/Host/common/NativeBreakpointList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeBreakpointList.cpp?rev=343076&r1=343075&r2=343076&view=diff
==
--- lldb/trunk/source/Host/common/NativeBreakpointList.cpp (original)
+++ lldb/trunk/source/Host/common/NativeBreakpointList.cpp Wed Sep 26 00:31:41 
2018
@@ -210,20 +210,31 @@ Status NativeBreakpointList::GetBreakpoi
 
 Status NativeBreakpointList::RemoveTrapsFromBuffer(lldb::addr_t addr, void 
*buf,
size_t size) const {
+  auto data = llvm::makeMutableArrayRef(static_cast(buf), size);
   for (const auto &map : m_breakpoints) {
-lldb::addr_t bp_addr = map.first;
-// Breapoint not in range, ignore
-if (bp_addr < addr || addr + size <= bp_addr)
-  continue;
 const auto &bp_sp = map.second;
 // Not software breakpoint, ignore
 if (!bp_sp->IsSoftwareBreakpoint())
   continue;
 auto software_bp_sp = std::static_pointer_cast(bp_sp);
-auto opcode_addr = static_cast(buf) + bp_addr - addr;
-auto saved_opcodes = software_bp_sp->m_saved_opcodes;
+
+lldb::addr_t bp_addr = map.first;
 auto opcode_size = software_bp_sp->m_opcode_size;
-::memcpy(opcode_addr, saved_opcodes, opcode_size);
+
+// Breapoint not in range, ignore
+if (bp_addr + opcode_size < addr || addr + size <= bp_addr)
+  continue;
+
+auto saved_opcodes =
+llvm::makeArrayRef(software_bp_sp->m_saved_opcodes, opcode_size);
+if (bp_addr < addr) {
+  saved_opcodes = saved_opcodes.drop_front(addr - bp_addr);
+  bp_addr = addr;
+}
+auto bp_data = data.drop_front(bp_addr - addr);
+std::copy_n(saved_opcodes.begin(),
+std::min(saved_opcodes.size(), bp_data.size()),
+bp_data.begin());
   }
   return Status();
 }

Modified: lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp?rev=343076&r1=343075&r2=343076&view=diff
==
--- lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp (original)
+++ lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Wed Sep 26 00:31:41 
2018
@@ -70,10 +70,22 @@ public:
   llvm::ArrayRef Data));
 
   using NativeProcessProtocol::GetSoftwareBreakpointTrapOpcode;
+  llvm::Expected> ReadMemoryWithoutTrap(addr_t Addr,
+ size_t Size);
 
 private:
   ArchSpec Arch;
 };
+
+class FakeMemory {
+public:
+  FakeMemory(llvm::ArrayRef Data) : Data(Data) {}
+  llvm::Expected> Read(addr_t Addr, size_t Size);
+  llvm::Expected Write(addr_t Addr, llvm::ArrayRef Chunk);
+
+private:
+  std::vector Data;
+};
 } // namespace
 
 Status MockProcess::ReadMemory(addr_t Addr, void *Buf, size_t Size,
@@ -101,6 +113,37 @@ Status MockProcess::WriteMemory(addr_t A
   return Status();
 }
 
+llvm::Expected>
+MockProcess::ReadMemoryWithoutTrap(addr_t Addr, size_t Size) {
+  std::vector Data(Size, 0);
+  size_t BytesRead;
+  Status ST = NativeProcessProtocol::ReadMemoryWithoutTrap(
+  Addr, Data.data(), Data.size(), BytesRead);
+  if (ST.Fail())
+return ST.ToError();
+  Data.resize(BytesRead);
+  return std::move(Data);
+}
+
+llvm::Expected> FakeMemory::Read(addr_t Addr,
+  size_t Size) {
+  if (Addr >= Data.size())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Address out of range.");
+  Size = std::min(Size, Data.size() - Addr);
+  return std::vector(&Data[Addr], &Data[Addr + Size]);
+}
+
+llvm::Expected FakeMemory::Write(addr_t Addr,
+ llvm::ArrayRef Chunk) {
+  if (Addr >= Data.size())
+return llvm::createStringError(llvm::inconvertibleErrorCode(),
+   "Address out of range.");
+  size_t Size = std::min(Chunk.size(), Data.size() - Addr);
+  std::cop

Re: [Lldb-commits] [lldb] r343087 - [unittest] Fix NativeProcessProtocolTest.cpp (NFC)

2018-09-26 Thread Pavel Labath via lldb-commits
Thanks.

On 26/09/18 12:09, Jonas Devlieghere via lldb-commits wrote:
> Author: jdevlieghere
> Date: Wed Sep 26 03:09:44 2018
> New Revision: 343087
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=343087&view=rev
> Log:
> [unittest] Fix NativeProcessProtocolTest.cpp (NFC)
> 
> Cast std::min's second argument to size_t to prevent conflicting types
> for parameter deduction.
> 
> Modified:
> lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
> 
> Modified: lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp?rev=343087&r1=343086&r2=343087&view=diff
> ==
> --- lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp (original)
> +++ lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Wed Sep 26 
> 03:09:44 2018
> @@ -130,7 +130,7 @@ llvm::Expected> Fak
>if (Addr >= Data.size())
>  return llvm::createStringError(llvm::inconvertibleErrorCode(),
> "Address out of range.");
> -  Size = std::min(Size, Data.size() - Addr);
> +  Size = std::min(Size, Data.size() - (size_t)Addr);
>return std::vector(&Data[Addr], &Data[Addr + Size]);
>  }
>  
> @@ -139,7 +139,7 @@ llvm::Expected FakeMemory::Write
>if (Addr >= Data.size())
>  return llvm::createStringError(llvm::inconvertibleErrorCode(),
> "Address out of range.");
> -  size_t Size = std::min(Chunk.size(), Data.size() - Addr);
> +  size_t Size = std::min(Chunk.size(), Data.size() - (size_t)Addr);
>std::copy_n(Chunk.begin(), Size, &Data[Addr]);
>return Size;
>  }
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> 

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


[Lldb-commits] [lldb] r343409 - Pull GetSoftwareBreakpointPCOffset into base class

2018-09-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sun Sep 30 08:58:52 2018
New Revision: 343409

URL: http://llvm.org/viewvc/llvm-project?rev=343409&view=rev
Log:
Pull GetSoftwareBreakpointPCOffset into base class

Summary:
This function encodes the knowledge of whether the PC points to the
breakpoint instruction of the one following it after the breakpoint is
"hit". This behavior mainly(*) depends on the architecture and not on the
OS, so it makes sense for it to be implemented in the base class, where
it can be shared between different implementations (Linux and NetBSD
atm).

(*) It is possible for an OS to expose a different API, perhaps by doing
some fixups in the kernel. In this case, the implementation can override
this function to implement custom behavior.

Reviewers: krytarowski, zturner

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=343409&r1=343408&r2=343409&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Sun Sep 30 
08:58:52 2018
@@ -451,6 +451,12 @@ protected:
   virtual llvm::Expected>
   GetSoftwareBreakpointTrapOpcode(size_t size_hint);
 
+  /// Return the offset of the PC relative to the software breakpoint that was 
hit. If an
+  /// architecture (e.g. arm) reports breakpoint hits before incrementing the 
PC, this offset
+  /// will be 0. If an architecture (e.g. intel) reports breakpoints hits 
after incrementing the
+  /// PC, this offset will be the size of the breakpoint opcode.
+  virtual size_t GetSoftwareBreakpointPCOffset();
+
   // ---
   /// Notify the delegate that an exec occurred.
   ///

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=343409&r1=343408&r2=343409&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Sun Sep 30 08:58:52 
2018
@@ -409,6 +409,29 @@ NativeProcessProtocol::GetSoftwareBreakp
   }
 }
 
+size_t NativeProcessProtocol::GetSoftwareBreakpointPCOffset() {
+  switch (GetArchitecture().GetMachine()) {
+  case llvm::Triple::x86:
+  case llvm::Triple::x86_64:
+  case llvm::Triple::systemz:
+// These architectures report increment the PC after breakpoint is hit.
+return cantFail(GetSoftwareBreakpointTrapOpcode(0)).size();
+
+  case llvm::Triple::arm:
+  case llvm::Triple::aarch64:
+  case llvm::Triple::mips64:
+  case llvm::Triple::mips64el:
+  case llvm::Triple::mips:
+  case llvm::Triple::mipsel:
+  case llvm::Triple::ppc64le:
+// On these architectures the PC doesn't get updated for breakpoint hits.
+return 0;
+
+  default:
+llvm_unreachable("CPU type not supported!");
+  }
+}
+
 Status NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr,
bool hardware) {
   if (hardware)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=343409&r1=343408&r2=343409&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Sun Sep 30 
08:58:52 2018
@@ -1502,40 +1502,6 @@ size_t NativeProcessLinux::UpdateThreads
   return m_threads.size();
 }
 
-Status NativeProcessLinux::GetSoftwareBreakpointPCOffset(
-uint32_t &actual_opcode_size) {
-  // FIXME put this behind a breakpoint protocol class that can be
-  // set per architecture.  Need ARM, MIPS support here.
-  static const uint8_t g_i386_opcode[] = {0xCC};
-  static const uint8_t g_s390x_opcode[] = {0x00, 0x01};
-
-  switch (m_arch.GetMachine()) {
-  case llvm::Triple::x86:
-  case llvm::Triple::x86_64:
-actual_opcode_size = static_cast(sizeof(g_i386_opcode));
-return Status();
-
-  case llvm::Triple::systemz:
-actual_opcode_size = static_cast(sizeof(g_s390x_opcode));
-return Status();
-
-  case llvm::Triple::arm:
-  case llvm::Triple::aarch64:
-  case llvm::Triple::mips64:
-  case llvm::Triple::mips64el:
-  c

[Lldb-commits] [lldb] r343411 - Fix NetBSD build for r343409

2018-09-30 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sun Sep 30 09:12:09 2018
New Revision: 343411

URL: http://llvm.org/viewvc/llvm-project?rev=343411&view=rev
Log:
Fix NetBSD build for r343409

Forgot to remove the method declaration from the header.

Modified:
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h

Modified: lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h?rev=343411&r1=343410&r2=343411&view=diff
==
--- lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h (original)
+++ lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h Sun Sep 30 
09:12:09 2018
@@ -112,7 +112,6 @@ private:
   void MonitorSIGTRAP(lldb::pid_t pid);
   void MonitorSignal(lldb::pid_t pid, int signal);
 
-  Status GetSoftwareBreakpointPCOffset(uint32_t &actual_opcode_size);
   Status FixupBreakpointPCAsNeeded(NativeThreadNetBSD &thread);
   Status PopulateMemoryRegionCache();
   void SigchldHandler();


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


[Lldb-commits] [lldb] r343683 - Pull FixupBreakpointPCAsNeeded into base class

2018-10-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Oct  3 05:29:33 2018
New Revision: 343683

URL: http://llvm.org/viewvc/llvm-project?rev=343683&view=rev
Log:
Pull FixupBreakpointPCAsNeeded into base class

Summary:
This function existed (with identical code) in both NativeProcessLinux
and NativeProcessNetBSD, and it is likely that it would be useful to any
future implementation of NativeProcessProtocol.

Therefore I move it to the base class.

Reviewers: krytarowski

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.h
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h

Modified: lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h?rev=343683&r1=343682&r2=343683&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h Wed Oct  3 
05:29:33 2018
@@ -457,6 +457,11 @@ protected:
   /// PC, this offset will be the size of the breakpoint opcode.
   virtual size_t GetSoftwareBreakpointPCOffset();
 
+  // Adjust the thread's PC after hitting a software breakpoint. On
+  // architectures where the PC points after the breakpoint instruction, this
+  // resets it to point to the breakpoint itself.
+  void FixupBreakpointPCAsNeeded(NativeThreadProtocol &thread);
+
   // ---
   /// Notify the delegate that an exec occurred.
   ///

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=343683&r1=343682&r2=343683&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Wed Oct  3 05:29:33 
2018
@@ -432,6 +432,68 @@ size_t NativeProcessProtocol::GetSoftwar
   }
 }
 
+void NativeProcessProtocol::FixupBreakpointPCAsNeeded(
+NativeThreadProtocol &thread) {
+  Log *log = GetLogIfAnyCategoriesSet(LIBLLDB_LOG_BREAKPOINTS);
+
+  Status error;
+
+  // Find out the size of a breakpoint (might depend on where we are in the
+  // code).
+  NativeRegisterContext &context = thread.GetRegisterContext();
+
+  uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
+  LLDB_LOG(log, "breakpoint size: {0}", breakpoint_size);
+  if (breakpoint_size == 0)
+return;
+
+  // First try probing for a breakpoint at a software breakpoint location: PC -
+  // breakpoint size.
+  const lldb::addr_t initial_pc_addr = context.GetPCfromBreakpointLocation();
+  lldb::addr_t breakpoint_addr = initial_pc_addr;
+  // Do not allow breakpoint probe to wrap around.
+  if (breakpoint_addr >= breakpoint_size)
+breakpoint_addr -= breakpoint_size;
+
+  // Check if we stopped because of a breakpoint.
+  NativeBreakpointSP breakpoint_sp;
+  error = m_breakpoint_list.GetBreakpoint(breakpoint_addr, breakpoint_sp);
+  if (!error.Success() || !breakpoint_sp) {
+// We didn't find one at a software probe location.  Nothing to do.
+LLDB_LOG(log,
+ "pid {0} no lldb breakpoint found at current pc with "
+ "adjustment: {1}",
+ GetID(), breakpoint_addr);
+return;
+  }
+
+  // If the breakpoint is not a software breakpoint, nothing to do.
+  if (!breakpoint_sp->IsSoftwareBreakpoint()) {
+LLDB_LOG(
+log,
+"pid {0} breakpoint found at {1:x}, not software, nothing to adjust",
+GetID(), breakpoint_addr);
+return;
+  }
+
+  //
+  // We have a software breakpoint and need to adjust the PC.
+  //
+
+  // Change the program counter.
+  LLDB_LOG(log, "pid {0} tid {1}: changing PC from {2:x} to {3:x}", GetID(),
+   thread.GetID(), initial_pc_addr, breakpoint_addr);
+
+  error = context.SetPC(breakpoint_addr);
+  if (error.Fail()) {
+// This can happen in case the process was killed between the time we read
+// the PC and when we are updating it. There's nothing better to do than to
+// swallow the error.
+LLDB_LOG(log, "pid {0} tid {1}: failed to set PC: {2}", GetID(),
+ thread.GetID(), error);
+  }
+}
+
 Status NativeProcessProtocol::RemoveBreakpoint(lldb::addr_t addr,
bool hardware) {
   if (hardware)

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/Nat

Re: [Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process

2018-10-29 Thread Pavel Labath via lldb-commits
On 26/10/18 18:34, Zachary Turner wrote:
> I was thinking about this some more and I’m not sure simple
> substitutions will suffice.
> 
> We can provide substitutions to abstract away the command line, but that
> doesn’t doesn’t really address the issue that we still need to have a
> way to then run the the test program with each of the build outputs. 
> Keep in mind that it might take more than one compiler and/or linker
> invocation to generate an output, and more than one lldb-test invocation
> for the checks.
> 
> The best idea I have for now is to split the check file into a common
> file that everyone can share, but the lldb-test lines can be copied.  So
> there is one .test file for windows, one for non windows, each with only
> RUN lines, both sharing a common check file.
> 
> I don’t think we should block this patch on coming up with something
> more complicated than this though 
> 

The substitutions won't help if you're planning to run multiple variants
of the same test (e.g. a DWARF and a PDB version) on all hosts. However,
if you always just want to run a single version of the test (e.g., for
the host), then it's enough to have a substitution which builds the
given version of the executable.

Given how the memory map tests are implemented right now (they require a
running process, and they don't care too much about the details of how
the debugee was built), this should be sufficient. I don't think we will
ever have two flavours of these tests run in the same instance of the
test suite, as it would require us the specify how to launch and debug
an executable on multiple hosts.

So, I'd recommend to stick with the substitution idea until we come up
with something better.

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


Re: [Lldb-commits] [PATCH] D52618: [Windows] A basic implementation of memory allocations in a debuggee process

2018-10-29 Thread Pavel Labath via lldb-commits
On 29/10/18 15:06, Zachary Turner wrote:
> Even in this exact case we have the multiple variants situation. If we
> use the substitutions method we would reduce the test coverage by half,
> which doesn’t seem like a good idea.

Which variants do you have in mind? This patch creates two tests: one
which has REQUIRES: windows, and another which has UNSUPPORTED: windows.
With the substitution we would have just one test, which runs everywhere
(but tests slightly different things).

> 
> Similarly, in the target variables tests i added to the native pdb
> plugin Jim was asking if I could also enable that exact same test for
> other platforms. But it’s not possible without a way to run multiple
> variants. And for tests where no running process is required I think
> it’s a worthy goal to try to do that.


I certainly don't disagree with that, but I think there may be room for
both approaches.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r346093 - NativeProcessProtocol: Simplify breakpoint setting code

2018-11-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sun Nov  4 02:58:08 2018
New Revision: 346093

URL: http://llvm.org/viewvc/llvm-project?rev=346093&view=rev
Log:
NativeProcessProtocol: Simplify breakpoint setting code

Summary:
A fairly simple operation as setting a breakpoint (writing a breakpoint
opcode) at a given address was going through three classes:
NativeProcessProtocol which called NativeBreakpointList, which then
called SoftwareBrekpoint, only to end up again in NativeProcessProtocol
to do the actual writing itself. This is unnecessarily complex and can
be simplified by moving all of the logic into NativeProcessProtocol
class itself, removing a lot of boilerplate.

One of the reeasons for this complexity was that (it seems)
NativeBreakpointList class was meant to hold both software and hardware
breakpoints. However, that never materialized, and hardware breakpoints
are stored in a separate map holding only hardware breakpoints.
Essentially, this patch makes software breakpoints follow that approach
by replacing the heavy SoftwareBraekpoint with a light struct of the
same name, which holds only the data necessary to describe one
breakpoint. The rest of the logic is in the main class. As, at the
lldb-server level, handling software and hardware breakpoints is very
different, this seems like a reasonable state of things.

Reviewers: krytarowski, zturner, clayborg

Subscribers: mgorny, lldb-commits

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

Removed:
lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h
lldb/trunk/include/lldb/Host/common/SoftwareBreakpoint.h
lldb/trunk/source/Host/common/NativeBreakpoint.cpp
lldb/trunk/source/Host/common/NativeBreakpointList.cpp
lldb/trunk/source/Host/common/SoftwareBreakpoint.cpp
Modified:
lldb/trunk/include/lldb/Host/common/NativeBreakpointList.h
lldb/trunk/include/lldb/Host/common/NativeProcessProtocol.h
lldb/trunk/include/lldb/lldb-private-forward.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Host/CMakeLists.txt
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Host/common/NativeThreadProtocol.cpp
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/trunk/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp

Removed: lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h?rev=346092&view=auto
==
--- lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeBreakpoint.h (removed)
@@ -1,56 +0,0 @@
-//===-- NativeBreakpoint.h --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef liblldb_NativeBreakpoint_h_
-#define liblldb_NativeBreakpoint_h_
-
-#include "lldb/lldb-types.h"
-
-namespace lldb_private {
-class NativeBreakpointList;
-
-class NativeBreakpoint {
-  friend class NativeBreakpointList;
-
-public:
-  // The assumption is that derived breakpoints are enabled when created.
-  NativeBreakpoint(lldb::addr_t addr);
-
-  virtual ~NativeBreakpoint();
-
-  Status Enable();
-
-  Status Disable();
-
-  lldb::addr_t GetAddress() const { return m_addr; }
-
-  bool IsEnabled() const { return m_enabled; }
-
-  virtual bool IsSoftwareBreakpoint() const = 0;
-
-protected:
-  const lldb::addr_t m_addr;
-  int32_t m_ref_count;
-
-  virtual Status DoEnable() = 0;
-
-  virtual Status DoDisable() = 0;
-
-private:
-  bool m_enabled;
-
-  // --- interface for
-  // NativeBreakpointList
-  // ---
-  void AddRef();
-  int32_t DecRef();
-};
-}
-
-#endif // ifndef liblldb_NativeBreakpoint_h_

Modified: lldb/trunk/include/lldb/Host/common/NativeBreakpointList.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/common/NativeBreakpointList.h?rev=346093&r1=346092&r2=346093&view=diff
==
--- lldb/trunk/include/lldb/Host/common/NativeBreakpointList.h (original)
+++ lldb/trunk/include/lldb/Host/common/NativeBreakpointList.h Sun Nov  4 
02:58:08 2018
@@ -10,13 +10,9 @@
 #ifndef liblldb_NativeBreakpointList_h_
 #define liblldb_NativeBreakpointList_h_
 
-#include "lldb/Utility/Status.h"
 #include "lldb/lldb-private-forward.h"
-// #include "lldb/Host/NativeBreakpoint.h"
-
-#include 
+#include "lldb/lldb-types.h"
 #include 
-#include 
 
 namespace lldb_private {
 
@@ -26,35 +22,6 @@ struct HardwareBreakpoint {
 };
 
 using HardwareBreakpointMap = std::map;
-
-class NativeBreakpointList {
-public:
- 

[Lldb-commits] [lldb] r346094 - Fix log statement in r346093

2018-11-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sun Nov  4 04:54:29 2018
New Revision: 346094

URL: http://llvm.org/viewvc/llvm-project?rev=346094&view=rev
Log:
Fix log statement in r346093

Thanks to Dávid Bolvanský for pointing that out.

Modified:
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp

Modified: lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/NativeProcessProtocol.cpp?rev=346094&r1=346093&r2=346094&view=diff
==
--- lldb/trunk/source/Host/common/NativeProcessProtocol.cpp (original)
+++ lldb/trunk/source/Host/common/NativeProcessProtocol.cpp Sun Nov  4 04:54:29 
2018
@@ -512,7 +512,7 @@ NativeProcessProtocol::EnableSoftwareBre
 addr);
   }
 
-  LLDB_LOG(log, "addr = {0:x}: SUCCESS");
+  LLDB_LOG(log, "addr = {0:x}: SUCCESS", addr);
   return SoftwareBreakpoint{1, saved_opcode_bytes, *expected_trap};
 }
 


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


[Lldb-commits] [lldb] r346233 - CPlusPlusLanguage: Use new demangler API to implement type substitution

2018-11-06 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Nov  6 07:41:37 2018
New Revision: 346233

URL: http://llvm.org/viewvc/llvm-project?rev=346233&view=rev
Log:
CPlusPlusLanguage: Use new demangler API to implement type substitution

Summary:
Now that llvm demangler supports more generic customization, we can
implement type substitution directly on top of this API. This will allow
us to remove the specialized hooks which were added to the demangler to
support this use case.

Reviewers: sgraenitz, erik.pilkington, JDevlieghere

Subscribers: lldb-commits

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

Modified:
lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=346233&r1=346232&r2=346233&view=diff
==
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
(original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Tue Nov  
6 07:41:37 2018
@@ -21,7 +21,7 @@
 
 // Other libraries and framework includes
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Demangle/Demangle.h"
+#include "llvm/Demangle/ItaniumDemangle.h"
 
 // Project includes
 #include "lldb/Core/PluginManager.h"
@@ -279,72 +279,89 @@ bool CPlusPlusLanguage::ExtractContextAn
   return false;
 }
 
-/// Given a mangled function `mangled`, replace all the primitive function type
-/// arguments of `search` with type `replace`.
-static ConstString SubsPrimitiveParmItanium(llvm::StringRef mangled,
-llvm::StringRef search,
-llvm::StringRef replace) {
-  class PrimitiveParmSubs {
-llvm::StringRef mangled;
-llvm::StringRef search;
-llvm::StringRef replace;
-ptrdiff_t read_pos;
-std::string output;
-std::back_insert_iterator writer;
-
-  public:
-PrimitiveParmSubs(llvm::StringRef m, llvm::StringRef s, llvm::StringRef r)
-: mangled(m), search(s), replace(r), read_pos(0),
-  writer(std::back_inserter(output)) {}
-
-void Substitute(llvm::StringRef tail) {
-  assert(tail.data() >= mangled.data() &&
- tail.data() < mangled.data() + mangled.size() &&
- "tail must point into range of mangled");
-
-  if (tail.startswith(search)) {
-auto reader = mangled.begin() + read_pos;
-ptrdiff_t read_len = tail.data() - (mangled.data() + read_pos);
-
-// First write the unmatched part of the original. Then write the
-// replacement string. Finally skip the search string in the original.
-writer = std::copy(reader, reader + read_len, writer);
-writer = std::copy(replace.begin(), replace.end(), writer);
-read_pos += read_len + search.size();
-  }
-}
+namespace {
+class NodeAllocator {
+  llvm::BumpPtrAllocator Alloc;
+
+public:
+  void reset() { Alloc.Reset(); }
+
+  template  T *makeNode(Args &&... args) {
+return new (Alloc.Allocate(sizeof(T), alignof(T)))
+T(std::forward(args)...);
+  }
 
-ConstString Finalize() {
-  // If we did a substitution, write the remaining part of the original.
-  if (read_pos > 0) {
-writer = std::copy(mangled.begin() + read_pos, mangled.end(), writer);
-read_pos = mangled.size();
-  }
+  void *allocateNodeArray(size_t sz) {
+return Alloc.Allocate(sizeof(llvm::itanium_demangle::Node *) * sz,
+  alignof(llvm::itanium_demangle::Node *));
+  }
+};
 
-  return ConstString(output);
-}
+/// Given a mangled function `Mangled`, replace all the primitive function type
+/// arguments of `Search` with type `Replace`.
+class TypeSubstitutor
+: public llvm::itanium_demangle::AbstractManglingParser {
+  /// Input character until which we have constructed the respective output
+  /// already
+  const char *Written;
+
+  llvm::StringRef Search;
+  llvm::StringRef Replace;
+  llvm::SmallString<128> Result;
+
+  /// Whether we have performed any substitutions.
+  bool Substituted;
+
+  void reset(llvm::StringRef Mangled, llvm::StringRef Search,
+ llvm::StringRef Replace) {
+AbstractManglingParser::reset(Mangled.begin(), Mangled.end());
+Written = Mangled.begin();
+this->Search = Search;
+this->Replace = Replace;
+Result.clear();
+Substituted = false;
+  }
+
+  void appendUnchangedInput() {
+Result += llvm::StringRef(Written, First - Written);
+Written = First;
+  }
 
-static void Callback(void *context, const char *match) {
-  ((PrimitiveParmSubs *)context)->Substitute(llvm::StringRef(match));
+public:
+  TypeSubstitutor() : AbstractManglingParser(nullptr, nullptr) {}
+
+  ConstString substitute(llvm::StringRef Mangled, llvm::StringRef F

Re: [Lldb-commits] [lldb] r346466 - Revert "[FileSystem] Make use of FS in TildeExpressionResolver"

2018-11-10 Thread Pavel Labath via lldb-commits
I think the right way to resolve this would be to move
"StandardTildeExpressionResolver" into the host module. The non-standard
TildeExpressionResolver is just an abstract class, so it does not need
the filesystem. This way, anyone wanting to use the resolver can just
depend on the interface, and the concrete class may not even have to be
a public one as it the FileSystem can just vend the interface.

Although, at this point it's a question whether we need the resolver
class in the first place. It was introduced so we could mock/test
resolution of paths with usernames in them. However that is something
you will also need to do for the repro feature, so it may make sense to
fold everything into the Filesystem class.


On 09/11/18 02:59, Jonas Devlieghere via lldb-commits wrote:
> Author: jdevlieghere
> Date: Thu Nov  8 17:59:28 2018
> New Revision: 346466
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=346466&view=rev
> Log:
> Revert "[FileSystem] Make use of FS in TildeExpressionResolver"
> 
> The whole point of this change was making it possible to resolve paths
> without depending on the FileSystem, which is not what I did here. Not
> sure what I was thinking...
> 
> Modified:
> lldb/trunk/include/lldb/Host/FileSystem.h
> lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h
> lldb/trunk/source/Commands/CommandCompletions.cpp
> lldb/trunk/source/Host/common/FileSystem.cpp
> lldb/trunk/source/Target/TargetList.cpp
> lldb/trunk/source/Utility/TildeExpressionResolver.cpp
> lldb/trunk/unittests/Host/FileSystemTest.cpp
> lldb/trunk/unittests/Interpreter/TestCompletion.cpp
> lldb/trunk/unittests/TestingSupport/MockTildeExpressionResolver.cpp
> lldb/trunk/unittests/TestingSupport/MockTildeExpressionResolver.h
> lldb/trunk/unittests/Utility/TildeExpressionResolverTest.cpp
> 
> Modified: lldb/trunk/include/lldb/Host/FileSystem.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=346466&r1=346465&r2=346466&view=diff
> ==
> --- lldb/trunk/include/lldb/Host/FileSystem.h (original)
> +++ lldb/trunk/include/lldb/Host/FileSystem.h Thu Nov  8 17:59:28 2018
> @@ -132,8 +132,7 @@ public:
>void *callback_baton);
>  
>std::error_code GetRealPath(const llvm::Twine &path,
> -  llvm::SmallVectorImpl &output,
> -  bool expand_tilde) const;
> +  llvm::SmallVectorImpl &output) const;
>  
>  private:
>static llvm::Optional &InstanceImpl();
> 
> Modified: lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h?rev=346466&r1=346465&r2=346466&view=diff
> ==
> --- lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h (original)
> +++ lldb/trunk/include/lldb/Utility/TildeExpressionResolver.h Thu Nov  8 
> 17:59:28 2018
> @@ -18,10 +18,8 @@ template  class SmallVectorI
>  }
>  
>  namespace lldb_private {
> -class FileSystem;
>  class TildeExpressionResolver {
>  public:
> -  TildeExpressionResolver(FileSystem &fs) : m_fs(fs) {}
>virtual ~TildeExpressionResolver();
>  
>/// Resolve a Tilde Expression contained according to bash rules.
> @@ -54,20 +52,14 @@ public:
>/// the username portion with the matched result.
>bool ResolveFullPath(llvm::StringRef Expr,
> llvm::SmallVectorImpl &Output);
> -
> -protected:
> -  FileSystem &m_fs;
>  };
>  
>  class StandardTildeExpressionResolver : public TildeExpressionResolver {
>  public:
> -  StandardTildeExpressionResolver(FileSystem &fs)
> -  : TildeExpressionResolver(fs) {}
> -
>bool ResolveExact(llvm::StringRef Expr,
>  llvm::SmallVectorImpl &Output) override;
>bool ResolvePartial(llvm::StringRef Expr, llvm::StringSet<> &Output) 
> override;
>  };
> -} // namespace lldb_private
> +}
>  
>  #endif // #ifndef LLDB_UTILITY_TILDE_EXPRESSION_RESOLVER_H
> 
> Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=346466&r1=346465&r2=346466&view=diff
> ==
> --- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
> +++ lldb/trunk/source/Commands/CommandCompletions.cpp Thu Nov  8 17:59:28 2018
> @@ -231,7 +231,7 @@ static int DiskFilesOrDirectories(const
>  static int DiskFilesOrDirectories(CompletionRequest &request,
>bool only_directories) {
>request.SetWordComplete(false);
> -  StandardTildeExpressionResolver resolver(FileSystem::Instance());
> +  StandardTildeExpressionResolver resolver;
>StringList matches;
>DiskFilesOrDirectories(

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

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

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

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

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

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

Reviewers: clayborg, jankratochvil, JDevlieghere

Subscribers: lldb-commits

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

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

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

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


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


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

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

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

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

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

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

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

Re: [Lldb-commits] [lldb] r347125 - Just don't even attempt to invoke sed on Windows.

2018-11-19 Thread Pavel Labath via lldb-commits

On 17/11/2018 02:27, Adrian Prantl via lldb-commits wrote:

Author: adrian
Date: Fri Nov 16 17:27:47 2018
New Revision: 347125

URL: http://llvm.org/viewvc/llvm-project?rev=347125&view=rev
Log:
Just don't even attempt to invoke sed on Windows.

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

Modified: lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules?rev=347125&r1=347124&r2=347125&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/make/Makefile.rules Fri Nov 16 
17:27:47 2018
@@ -253,7 +253,12 @@ ifeq "$(MAKE_DWO)" "YES"
  endif
  
  # Use a shared module cache when building in the default test build directory.

+ifeq "$(OS)" "Windows_NT"
+CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache
+else
+# FIXME: Get sed to work on Windows here.
  CLANG_MODULE_CACHE_DIR := $(shell echo "$(BUILDDIR)" | sed 
's/lldb-test-build.noindex.*/lldb-test-build.noindex\/module-cache-clang/')
+endif
  
  ifeq "$(findstring lldb-test-build.noindex, $(BUILDDIR))" ""

  CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/module-cache


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



Could we just have dotest pass the correct value for the module cache 
(or the root build dir, which would make the computation of the module 
cache dir trivial)?


This way you wouldn't even have to depend on the "default" build 
directory name.

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


Re: [Lldb-commits] [lldb] r347615 - [FileSystem] Ignore nanoseconds when comparing oso_mod_time

2018-11-27 Thread Pavel Labath via lldb-commits
Was it necessary to modify FileSystem to achieve this. It looks like you 
could have just as easily made the time_point_cast in 
SymbolFileDWARFDebugMap (next to a comment explaining why that was needed).


The extra nanosecond_precision argument looks fairly odd, and diverges 
from how the llvm interfaces for modification times operate.


On 27/11/2018 00:40, Jonas Devlieghere via lldb-commits wrote:

Author: jdevlieghere
Date: Mon Nov 26 15:40:52 2018
New Revision: 347615

URL: http://llvm.org/viewvc/llvm-project?rev=347615&view=rev
Log:
[FileSystem] Ignore nanoseconds when comparing oso_mod_time

After a recent change in LLVM the TimePoint encoding become more
precise, exceeding the precision of the TimePoint obtained from the
DebugMap. This patch adds a flag to the GetModificationTime helper in
the FileSystem to return the modification time with less precision.

Thanks to Davide for bisecting this failure on the LLDB bots.

Modified:
 lldb/trunk/include/lldb/Host/FileSystem.h
 lldb/trunk/source/Host/common/FileSystem.cpp
 lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp

Modified: lldb/trunk/include/lldb/Host/FileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/FileSystem.h?rev=347615&r1=347614&r2=347615&view=diff
==
--- lldb/trunk/include/lldb/Host/FileSystem.h (original)
+++ lldb/trunk/include/lldb/Host/FileSystem.h Mon Nov 26 15:40:52 2018
@@ -56,8 +56,12 @@ public:
  
/// Returns the modification time of the given file.

/// @{
-  llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const;
-  llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const;
+  llvm::sys::TimePoint<>
+  GetModificationTime(const FileSpec &file_spec,
+  bool nanosecond_precision = true) const;
+  llvm::sys::TimePoint<>
+  GetModificationTime(const llvm::Twine &path,
+  bool nanosecond_precision = true) const;
/// @}
  
/// Returns the on-disk size of the given file in bytes.


Modified: lldb/trunk/source/Host/common/FileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSystem.cpp?rev=347615&r1=347614&r2=347615&view=diff
==
--- lldb/trunk/source/Host/common/FileSystem.cpp (original)
+++ lldb/trunk/source/Host/common/FileSystem.cpp Mon Nov 26 15:40:52 2018
@@ -64,15 +64,22 @@ Optional &FileSystem::Instan
  }
  
  sys::TimePoint<>

-FileSystem::GetModificationTime(const FileSpec &file_spec) const {
-  return GetModificationTime(file_spec.GetPath());
+FileSystem::GetModificationTime(const FileSpec &file_spec,
+bool nanosecond_precision) const {
+  return GetModificationTime(file_spec.GetPath(), nanosecond_precision);
  }
  
-sys::TimePoint<> FileSystem::GetModificationTime(const Twine &path) const {

+sys::TimePoint<>
+FileSystem::GetModificationTime(const Twine &path,
+bool nanosecond_precision) const {
ErrorOr status = m_fs->status(path);
if (!status)
  return sys::TimePoint<>();
-  return status->getLastModificationTime();
+  if (nanosecond_precision)
+return status->getLastModificationTime();
+  else
+return std::chrono::time_point_cast(
+status->getLastModificationTime());
  }
  
  uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const {


Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=347615&r1=347614&r2=347615&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon 
Nov 26 15:40:52 2018
@@ -420,7 +420,8 @@ Module *SymbolFileDWARFDebugMap::GetModu
FileSpec oso_file(oso_path);
ConstString oso_object;
if (FileSystem::Instance().Exists(oso_file)) {
-auto oso_mod_time = 
FileSystem::Instance().GetModificationTime(oso_file);
+auto oso_mod_time = FileSystem::Instance().GetModificationTime(
+oso_file, /*nanosecond_precision=*/false);
  if (oso_mod_time != comp_unit_info->oso_mod_time) {
obj_file->GetModule()->ReportError(
"debug map object file '%s' has changed (actual time is "


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



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


[Lldb-commits] [lldb] r347846 - Remove getopt includes from the driver

2018-11-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Nov 29 02:45:41 2018
New Revision: 347846

URL: http://llvm.org/viewvc/llvm-project?rev=347846&view=rev
Log:
Remove getopt includes from the driver

They are not needed now that we use LLVMOption for command-line parsing
thank you, Jonas).  This also allows us to avoid linking of lldbHost
into the driver which was breaking liblldb encapsulation.

(Technically, there is still a lldb/Host/windows/windows.h include which
is needed on windows, but this is a header-only wrapper for ,
so it is not necessary to link lldbHost for that. But ideally, that
should go away too.)

Modified:
lldb/trunk/tools/driver/CMakeLists.txt
lldb/trunk/tools/driver/Platform.h

Modified: lldb/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/CMakeLists.txt?rev=347846&r1=347845&r2=347846&view=diff
==
--- lldb/trunk/tools/driver/CMakeLists.txt (original)
+++ lldb/trunk/tools/driver/CMakeLists.txt Thu Nov 29 02:45:41 2018
@@ -2,23 +2,12 @@ set(LLVM_TARGET_DEFINITIONS Options.td)
 tablegen(LLVM Options.inc -gen-opt-parser-defs)
 add_public_tablegen_target(LLDBOptionsTableGen)
 
-if ((CMAKE_SYSTEM_NAME MATCHES "Windows") OR
-(CMAKE_SYSTEM_NAME MATCHES "NetBSD" ))
-  # These targets do not have getopt support, so they rely on the one provided 
by
-  # liblldb. However, getopt is not a part of the liblldb interface, so we have
-  # to link against the constituent libraries manually. Note that this is
-  # extremely scary as it introduces ODR violations, and it should go away as
-  # soon as possible.
-  set(host_lib lldbHost)
-endif()
-
 add_lldb_tool(lldb
   Driver.cpp
   Platform.cpp
 
   LINK_LIBS
 liblldb
-${host_lib}
 
   LINK_COMPONENTS
 Option

Modified: lldb/trunk/tools/driver/Platform.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Platform.h?rev=347846&r1=347845&r2=347846&view=diff
==
--- lldb/trunk/tools/driver/Platform.h (original)
+++ lldb/trunk/tools/driver/Platform.h Thu Nov 29 02:45:41 2018
@@ -12,7 +12,6 @@
 
 #if defined(_WIN32)
 
-#include "lldb/Host/HostGetOpt.h"
 #include 
 #if defined(_MSC_VER)
 #include 
@@ -74,7 +73,6 @@ extern int tcsetattr(int fd, int optiona
 extern int tcgetattr(int fildes, struct termios *termios_p);
 
 #else
-#include "lldb/Host/HostGetOpt.h"
 #include 
 
 #include 


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


[Lldb-commits] [lldb] r347855 - Fix windows build broken by r347846

2018-11-29 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Nov 29 03:53:12 2018
New Revision: 347855

URL: http://llvm.org/viewvc/llvm-project?rev=347855&view=rev
Log:
Fix windows build broken by r347846

The changed order of includes caused compile errors on MSVC due to
snprintf macro definition. snprintf should available since VS2015, and
the rest of the code seems to be able to use snprintf just fine without
this macro, so this removes it from the lldb driver as well.

Modified:
lldb/trunk/tools/driver/Platform.h

Modified: lldb/trunk/tools/driver/Platform.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Platform.h?rev=347855&r1=347854&r2=347855&view=diff
==
--- lldb/trunk/tools/driver/Platform.h (original)
+++ lldb/trunk/tools/driver/Platform.h Thu Nov 29 03:53:12 2018
@@ -60,7 +60,6 @@ struct timeval {
   long tv_usec;
 };
 typedef long pid_t;
-#define snprintf _snprintf
 #define PATH_MAX MAX_PATH
 #endif
 


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


Re: [Lldb-commits] [PATCH] D53368: [Symbol] Search symbols with name and type in a symbol file

2018-12-03 Thread Pavel Labath via lldb-commits

On 29/11/2018 23:34, Greg Clayton wrote:




On Nov 29, 2018, at 10:55 AM, Pavel Labath via Phabricator 
 wrote:

labath added a comment.

I've recently started looking at adding a new symbol file format (breakpad 
symbols). While researching the best way to achieve that, I started comparing 
the operation of PDB and DWARF symbol files. I noticed a very important 
difference there, and I think that is the cause of our problems here. In the 
DWARF implementation, a symbol file is an overlay on top of an object file - it 
takes the data contained by the object file and presents it in a more 
structured way.

However, that is not the case with PDB (both implementations). These take the 
debug information from a completely different file, which is not backed by an 
ObjectFile instance, and then present that. Since the SymbolFile interface 
requires them to be backed by an object file, they both pretend they are backed 
by the original EXE file, but in reality the data comes from elsewhere.

If we had an ObjectFilePDB (which not also not ideal, though in a way it is a 
better fit to the current lldb organization), then this could expose the PDB 
symtab via the existing ObjectFile interface and we could reuse the existing 
mechanism for merging symtabs from two object files.

I am asking this because now I am facing a choice in how to implement breakpad 
symbols. I could go the PDB way, and read the symbols without an intervening 
object file, or I could create an ObjectFileBreakpad and then (possibly) a 
SymbolFileBreakpad sitting on top of that.

The drawbacks of the PDB approach I see are:

- I lose the ability to do matching of the (real) object file via symbol 
vendors. The PDB symbol files now basically implement their own little symbol 
vendors inside them, which is mostly fine if you just need to find the PDB next 
to the exe file. However, things could get a bit messy if you wanted to 
implement some more complex searching on multiple paths, or downloading them 
from the internet.
- I'll hit issues when attempting to unwind (which is the real meat of the 
breakpad symbols), because unwind info is currently provided via the ObjectFile 
interface (ObjectFile::GetUnwindTable).

The drawbacks of the ObjectFile approach are:

- more code  - it needs a new ObjectFile and a new SymbolFile class (possibly 
also a SymbolVendor)
- it will probably look a bit weird because Breakpad files (and PDBs) aren't 
really object files

I'd like to hear your thoughts on this, if you have any.


Since the Breakpad files contain symbol and debug info, I would make a 
ObjectFileBreakpad and SymbolFileBreakpad route. We might want to just load a 
break pad file and be able to symbolicate with it. Each symbol vendor will need 
to be able to use a breakpad file (since Breakpad produces files for all 
architectures), so we can build some functionality into the SymbolVendor base 
class for file formats that any file format (ELF, Mach-o, COFF) might want to 
use.





Just to close this, I've decided to try going the ObjectFile route (in 
D55214). It shouldn't take me long to reach the point where I need to 
vend symtab and unwind information to the rest of lldb, at which point 
we can decide whether that was the right move.


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


Re: [Lldb-commits] [lldb] r348186 - Skip TestDriverOptions on Windows

2018-12-04 Thread Pavel Labath via lldb-commits

On 03/12/2018 21:55, Jonas Devlieghere via lldb-commits wrote:
That wouldn't work because we try to create the directory which would 
succeeded in the temp dir. I'd have to be something you don't have 
access to, like the root or some network drive.




How about we change the behavior to only create the bottommost 
directory? E.g. if the user specifies "/X/Y/Z" as the path, then "/X/Y" 
has to exist, and "Z" will be created if not present (i.e. use mkdir, 
not mkdir -p). I think this is the behavior most users would expect 
anyway (I would be upset if a typo causes lldb to create a whole 
hierarchy some place I did not intend), and it will allow to test this 
via something like "%t/does_not_exist/repro_dir".


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


[Lldb-commits] [lldb] r348261 - Fix lldb-server unit tests for the MonitoringProcessLauncher refactor

2018-12-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec  4 06:04:27 2018
New Revision: 348261

URL: http://llvm.org/viewvc/llvm-project?rev=348261&view=rev
Log:
Fix lldb-server unit tests for the MonitoringProcessLauncher refactor

We now need to initialize the filesystem in these tests.

Modified:
lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h

Modified: lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h?rev=348261&r1=348260&r2=348261&view=diff
==
--- lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h (original)
+++ lldb/trunk/unittests/tools/lldb-server/tests/TestBase.h Tue Dec  4 06:04:27 
2018
@@ -11,6 +11,7 @@
 #define LLDB_SERVER_TESTS_TESTBASE_H
 
 #include "TestClient.h"
+#include "lldb/Host/FileSystem.h"
 #include "lldb/Host/HostInfo.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Testing/Support/Error.h"
@@ -20,7 +21,10 @@ namespace llgs_tests {
 
 class TestBase: public ::testing::Test {
 public:
-  static void SetUpTestCase() { lldb_private::HostInfo::Initialize(); }
+  static void SetUpTestCase() {
+lldb_private::FileSystem::Initialize();
+lldb_private::HostInfo::Initialize();
+  }
 
   static std::string getInferiorPath(llvm::StringRef Name) {
 llvm::SmallString<64> Path(LLDB_TEST_INFERIOR_PATH);


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


Re: [Lldb-commits] [lldb] r348319 - [build.py] Disable tests on non-Windows.

2018-12-05 Thread Pavel Labath via lldb-commits

On 05/12/2018 00:56, Zachary Turner via lldb-commits wrote:

Author: zturner
Date: Tue Dec  4 15:56:25 2018
New Revision: 348319

URL: http://llvm.org/viewvc/llvm-project?rev=348319&view=rev
Log:
[build.py] Disable tests on non-Windows.

This won't work until we get the GCC / clang builder implemented.

Modified:
 lldb/trunk/lit/BuildScript/modes.test
 lldb/trunk/lit/BuildScript/script-args.test

Modified: lldb/trunk/lit/BuildScript/modes.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/modes.test?rev=348319&r1=348318&r2=348319&view=diff
==
--- lldb/trunk/lit/BuildScript/modes.test (original)
+++ lldb/trunk/lit/BuildScript/modes.test Tue Dec  4 15:56:25 2018
@@ -1,3 +1,5 @@
+REQUIRES: system-windows
+
  RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o 
%t/foo.out foobar.c \
  RUN:| FileCheck --check-prefix=COMPILE %s
  


Modified: lldb/trunk/lit/BuildScript/script-args.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/script-args.test?rev=348319&r1=348318&r2=348319&view=diff
==
--- lldb/trunk/lit/BuildScript/script-args.test (original)
+++ lldb/trunk/lit/BuildScript/script-args.test Tue Dec  4 15:56:25 2018
@@ -1,3 +1,5 @@
+REQUIRES: system-windows
+
  RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o 
%t/foo.out foobar.c \
  RUN:| FileCheck %s
  RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any --outdir %t 
foo.c bar.c \


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



The toolchain-clang-cl.test fails for me too during printing of the 
execution environment for the compile commands. This happens because 
(unsurprisingly) we cannot find the VS installation, and the environment 
happens to be None.



Traceback (most recent call last):
  File "/home/pavelo/ll/lldb/lit/helper/build.py", line 723, in 
build(cmds)
  File "/home/pavelo/ll/lldb/lit/helper/build.py", line 621, in build
print_environment(env)
  File "/home/pavelo/ll/lldb/lit/helper/build.py", line 154, in 
print_environment

for e in env:
TypeError: 'NoneType' object is not iterable

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


Re: [Lldb-commits] [lldb] r348319 - [build.py] Disable tests on non-Windows.

2018-12-05 Thread Pavel Labath via lldb-commits

On 05/12/2018 16:03, Zachary Turner wrote:
If you can commit the same fix I did for the other two that would be 
great, otherwise I’ll get to it when i get into the office in ~2 hours



The thing is, I'm not sure if that's the right fix here. I mean, this 
script should be able to compile with clang-cl on linux, right?


The easiest way to fix this would be to check env is not None before 
printing it out, but it wasn't clear to me whether you intended for it 
to be (possibly) None at this point in the code, so I figured its best 
to let you figure that out.

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


Re: [Lldb-commits] [PATCH] D54942: [PDB] Make PDB lit tests use the new builder

2018-12-06 Thread Pavel Labath via lldb-commits

On 06/12/2018 09:25, Aleksandr Urakov via lldb-commits wrote:


I thought about what Stella have said, and it seems that I have found a 
good solution for this. We can use something like `tempfile` 
(https://docs.python.org/3.7/library/tempfile.html) for every internally 
generated file of the script. It will guarantee us the uniqueness of the 
file. But for the uniqueness of files named by script parameters the 
script user will remain responsible.


What do you think about the such approach?


Sounds good to me. That's pretty much what the real compiler driver does 
when you ask it to run in the "compile-and-link" mode.

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


[Lldb-commits] [lldb] r348474 - disable toolchain-clang-cl.test on non-windows

2018-12-06 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  6 01:39:09 2018
New Revision: 348474

URL: http://llvm.org/viewvc/llvm-project?rev=348474&view=rev
Log:
disable toolchain-clang-cl.test on non-windows

The recently added test fail on non-windows platforms.

Modified:
lldb/trunk/lit/BuildScript/toolchain-clang-cl.test

Modified: lldb/trunk/lit/BuildScript/toolchain-clang-cl.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/toolchain-clang-cl.test?rev=348474&r1=348473&r2=348474&view=diff
==
--- lldb/trunk/lit/BuildScript/toolchain-clang-cl.test (original)
+++ lldb/trunk/lit/BuildScript/toolchain-clang-cl.test Thu Dec  6 01:39:09 2018
@@ -1,4 +1,4 @@
-REQUIRES: lld
+REQUIRES: lld, system-windows
 
 RUN: %build -n --verbose --arch=32 --compiler=clang-cl --mode=compile-and-link 
-o %t/foo.exe foobar.c \
 RUN:| FileCheck --check-prefix=CHECK-32 %s


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


[Lldb-commits] [lldb] r348476 - Remove REQUIRES: darwin from a couple of MachO tests

2018-12-06 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  6 01:41:50 2018
New Revision: 348476

URL: http://llvm.org/viewvc/llvm-project?rev=348476&view=rev
Log:
Remove REQUIRES: darwin from a couple of MachO tests

lldb is able to parse MachO files also on other platforms nowadays.

Modified:
lldb/trunk/lit/Modules/lc_build_version.yaml
lldb/trunk/lit/Modules/lc_build_version_notools.yaml

Modified: lldb/trunk/lit/Modules/lc_build_version.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_build_version.yaml?rev=348476&r1=348475&r2=348476&view=diff
==
--- lldb/trunk/lit/Modules/lc_build_version.yaml (original)
+++ lldb/trunk/lit/Modules/lc_build_version.yaml Thu Dec  6 01:41:50 2018
@@ -1,6 +1,5 @@
 # RUN: yaml2obj %s > %t.out
 # RUN: lldb-test symbols %t.out | FileCheck %s
-# REQUIRES: system-darwin
 # Test that the deployment target is parsed from the load commands.
 # CHECK: x86_64-apple-macosx10.14.0
 --- !mach-o

Modified: lldb/trunk/lit/Modules/lc_build_version_notools.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/lc_build_version_notools.yaml?rev=348476&r1=348475&r2=348476&view=diff
==
--- lldb/trunk/lit/Modules/lc_build_version_notools.yaml (original)
+++ lldb/trunk/lit/Modules/lc_build_version_notools.yaml Thu Dec  6 01:41:50 
2018
@@ -1,6 +1,5 @@
 # RUN: yaml2obj %s > %t.out
 # RUN: lldb-test symbols %t.out | FileCheck %s
-# REQUIRES: system-darwin
 # Test that the deployment target is parsed from the load commands.
 # CHECK: x86_64-apple-macosx10.14.0
 --- !mach-o


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


[Lldb-commits] [lldb] r348479 - Make scripts/analyzer-project-deps compatible with python3

2018-12-06 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec  6 02:27:38 2018
New Revision: 348479

URL: http://llvm.org/viewvc/llvm-project?rev=348479&view=rev
Log:
Make scripts/analyzer-project-deps compatible with python3

Modified:
lldb/trunk/scripts/analyze-project-deps.py

Modified: lldb/trunk/scripts/analyze-project-deps.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/analyze-project-deps.py?rev=348479&r1=348478&r2=348479&view=diff
==
--- lldb/trunk/scripts/analyze-project-deps.py (original)
+++ lldb/trunk/scripts/analyze-project-deps.py Thu Dec  6 02:27:38 2018
@@ -90,7 +90,7 @@ def is_existing_cycle(path, cycles):
 # at the end), then A -> B -> C is also a cycle.  This is an important
 # optimization which reduces the search space by multiple orders of
 # magnitude.
-for i in xrange(0,len(path)):
+for i in range(0,len(path)):
 if any(is_sublist(x, path) for x in cycles):
 return True
 path = [path[-1]] + path[0:-1]
@@ -129,23 +129,23 @@ def expand(path_queue, path_lengths, cyc
 
 cycles = []
 
-path_queue = [[x] for x in src_map.iterkeys()]
+path_queue = [[x] for x in iter(src_map)]
 path_lens = [1] * len(path_queue)
 
-items = list(src_map.iteritems())
-items.sort(lambda A, B : cmp(A[0], B[0]))
+items = list(src_map.items())
+items.sort(key = lambda A : A[0])
 
 for (path, deps) in items:
-print path + ":"
-sorted_deps = list(deps.iteritems())
+print(path + ":")
+sorted_deps = list(deps.items())
 if args.show_counts:
-sorted_deps.sort(lambda A, B: cmp(A[1], B[1]))
+sorted_deps.sort(key = lambda A: (A[1], A[0]))
 for dep in sorted_deps:
-print "\t{} [{}]".format(dep[0], dep[1])
+print("\t{} [{}]".format(dep[0], dep[1]))
 else:
-sorted_deps.sort(lambda A, B: cmp(A[0], B[0]))
+sorted_deps.sort(key = lambda A: A[0])
 for dep in sorted_deps:
-print "\t{}".format(dep[0])
+print("\t{}".format(dep[0]))
 
 def iter_cycles(cycles):
 global src_map
@@ -161,16 +161,16 @@ def iter_cycles(cycles):
 yield (total, smallest, result)
 
 if args.discover_cycles:
-print "Analyzing cycles..."
+print("Analyzing cycles...")
 
 expand(path_queue, path_lens, cycles, src_map)
 
 average = sum([len(x)+1 for x in cycles]) / len(cycles)
 
-print "Found {} cycles.  Average cycle length = {}.".format(len(cycles), 
average)
+print("Found {} cycles.  Average cycle length = {}.".format(len(cycles), 
average))
 counted = list(iter_cycles(cycles))
 if args.show_counts:
-counted.sort(lambda A, B: cmp(A[0], B[0]))
+counted.sort(key = lambda A: A[0])
 for (total, smallest, cycle) in counted:
 sys.stdout.write("{} deps to break: ".format(total))
 sys.stdout.write(cycle[0][0])
@@ -180,9 +180,9 @@ if args.discover_cycles:
 else:
 for cycle in cycles:
 cycle.append(cycle[0])
-print " -> ".join(cycle)
+print(" -> ".join(cycle))
 
-print "Analyzing islands..."
+print("Analyzing islands...")
 islands = []
 outgoing_counts = defaultdict(int)
 incoming_counts = defaultdict(int)
@@ -195,14 +195,14 @@ if args.discover_cycles:
 disjoints = [x for x in islands if this_cycle.isdisjoint(x)]
 overlaps = [x for x in islands if not this_cycle.isdisjoint(x)]
 islands = disjoints + [set.union(this_cycle, *overlaps)]
-print "Found {} disjoint cycle islands...".format(len(islands))
+print("Found {} disjoint cycle islands...".format(len(islands)))
 for island in islands:
-print "Island ({} elements)".format(len(island))
+print("Island ({} elements)".format(len(island)))
 sorted = []
 for node in island:
 sorted.append((node, incoming_counts[node], outgoing_counts[node]))
-sorted.sort(lambda x, y: cmp(x[1]+x[2], y[1]+y[2]))
+sorted.sort(key = lambda x: x[1]+x[2])
 for (node, inc, outg) in sorted:
-print "  {} [{} in, {} out]".format(node, inc, outg)
+print("  {} [{} in, {} out]".format(node, inc, outg))
 sys.stdout.flush()
 pass


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


[Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec  7 06:20:27 2018
New Revision: 348592

URL: http://llvm.org/viewvc/llvm-project?rev=348592&view=rev
Log:
Introduce ObjectFileBreakpad

Summary:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 24B5D199F0F766FF5DC30 a.out
INFO CODE_ID B52499D1F0F766FF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

Added:
lldb/trunk/lit/Modules/Breakpad/
lldb/trunk/lit/Modules/Breakpad/Inputs/
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
lldb/trunk/lit/Modules/Breakpad/lit.local.cfg
lldb/trunk/source/Plugins/ObjectFile/Breakpad/
lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348592&r1=348591&r2=348592&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Dec  7 06:20:27 2018
@@ -817,4 +817,16 @@ private:
 
 } // namespace lldb_private
 
+namespace llvm {
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Type &type,
+ raw_ostream &OS, StringRef Style);
+};
+
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Strata &strata,
+ raw_ostream &OS, StringRef Style);
+};
+} // namespace llvm
+
 #endif // liblldb_ObjectFile_h_

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms?rev=348592&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms Fri Dec  7 
06:20:27 2018
@@ -0,0 +1,2 @@
+MODULE Linux x86_64 E5894855+C35D+0 linux.out
+PUBLIC 1000 0 _start

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms?rev=348592&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms Fri Dec  7 
06:20:27 2018
@@ -0,0 +1,2 @@
+MODULE Linux x86_64 E5894855C35DC linux.out
+PUBLIC 1000 0 _start

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms?rev=348592

Re: [Lldb-commits] [lldb] r348592 - Introduce ObjectFileBreakpad

2018-12-07 Thread Pavel Labath via lldb-commits

On 07/12/2018 19:39, Davide Italiano wrote:

Pavel, this broke the MacOS lldb cmake bot.

In particular, this test started failing.
lldb-Suite.macosx/function-starts.TestFunctionStarts.py
http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/

May I ask you to take a look?


That's interesting. I can't look at it right now. Could you please 
revert that for me, and I'll check it out later?

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


[Lldb-commits] [lldb] r348773 - Re-commit "Introduce ObjectFileBreakpad"

2018-12-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Dec 10 09:16:38 2018
New Revision: 348773

URL: http://llvm.org/viewvc/llvm-project?rev=348773&view=rev
Log:
Re-commit "Introduce ObjectFileBreakpad"

This re-commits r348592, which was reverted due to a failing test on
macos.

The issue was that I was passing a null pointer for the
"CreateMemoryInstance" callback when registering ObjectFileBreakpad,
which caused crashes when attemping to load modules from memory. The
correct thing to do is to pass a callback which always returns a null
pointer (as breakpad files are never loaded in inferior memory).

It turns out that there is only one test which exercises this code path,
and it's mac-only, so I've create a new test which should run everywhere
(except windows, as one cannot delete an executable which is being run).
Unfortunately, this test still fails on linux for other reasons, but at
least it gives us something to aim for.

The original commit message was:
This patch adds the scaffolding necessary for lldb to recognise symbol
files generated by breakpad. These (textual) files contain just enough
information to be able to produce a backtrace from a crash
dump. This information includes:
- UUID, architecture and name of the module
- line tables
- list of symbols
- unwind information

A minimal breakpad file could look like this:
MODULE Linux x86_64 24B5D199F0F766FF5DC30 a.out
INFO CODE_ID B52499D1F0F766FF5DC3
FILE 0 /tmp/a.c
FUNC 1010 10 0 _start
1010 4 4 0
1014 5 5 0
1019 5 6 0
101e 2 7 0
PUBLIC 1010 0 _start
STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
STACK CFI 1014 .cfa: $rbp 16 +

Even though this data would normally be considered "symbol" information,
in the current lldb infrastructure it is assumed every SymbolFile object
is backed by an ObjectFile instance. So, in order to better interoperate
with the rest of the code (particularly symbol vendors).

In this patch I just parse the breakpad header, which is enough to
populate the UUID and architecture fields of the ObjectFile interface.
The rough plan for followup patches is to expose the individual parts of
the breakpad file as ObjectFile "sections", which can then be used by
other parts of the codebase (SymbolFileBreakpad ?) to vend the necessary
information.

Reviewers: clayborg, zturner, lemo, amccarth

Subscribers: mgorny, fedor.sergeev, markmentovai, lldb-commits

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

Added:
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-2.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-3.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-linux.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-macosx.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/identification-windows.syms
lldb/trunk/lit/Modules/Breakpad/breakpad-identification.test
lldb/trunk/lit/Modules/Breakpad/lit.local.cfg

lldb/trunk/packages/Python/lldbsuite/test/functionalities/deleted-executable/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/deleted-executable/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/deleted-executable/TestDeletedExecutable.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/deleted-executable/main.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/CMakeLists.txt
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/API/SystemInitializerFull.cpp
lldb/trunk/source/Plugins/ObjectFile/CMakeLists.txt
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/tools/lldb-test/SystemInitializerTest.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348773&r1=348772&r2=348773&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Mon Dec 10 09:16:38 2018
@@ -817,4 +817,16 @@ private:
 
 } // namespace lldb_private
 
+namespace llvm {
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Type &type,
+ raw_ostream &OS, StringRef Style);
+};
+
+template <> struct format_provider {
+  static void format(const lldb_private::ObjectFile::Strata &strata,
+ raw_ostream &OS, StringRef Style);
+};
+} // namespace llvm
+
 #endif // liblldb_ObjectFile_h_

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/bad-module-id-1.syms?rev=348773&view=auto
==

[Lldb-commits] [lldb] r348780 - Fix r348773

2018-12-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Dec 10 10:17:53 2018
New Revision: 348780

URL: http://llvm.org/viewvc/llvm-project?rev=348780&view=rev
Log:
Fix r348773

It's not sufficient to implement the CreateMemoryInstance function, one
has to use it too.

Modified:
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp?rev=348780&r1=348779&r2=348780&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp 
(original)
+++ lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp Mon 
Dec 10 10:17:53 2018
@@ -153,7 +153,7 @@ llvm::Optional Header::parse(llv
 void ObjectFileBreakpad::Initialize() {
   PluginManager::RegisterPlugin(GetPluginNameStatic(),
 GetPluginDescriptionStatic(), CreateInstance,
-nullptr, GetModuleSpecifications);
+CreateMemoryInstance, GetModuleSpecifications);
 }
 
 void ObjectFileBreakpad::Terminate() {


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


Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-11 Thread Pavel Labath via lldb-commits

On 11/12/2018 01:08, Greg Clayton wrote:



On Dec 10, 2018, at 3:11 PM, Leonard Mosescu > wrote:


I can see how this works for the PDB, no-module-binary case. What 
about the PDB & module-binary case?


That would work fine because the symbol vendor will make an object file 
from the m_symfile_spec and use both the original binary + the symbol 
file to make symbols.


Maybe I missed the rationale, but I think that modeling the general 
case: module and symbols are separate files, is a better foundation 
for the particular case where the symbols are embedded in the binary file.


Yeah, my case should handle the following cases:
- Minidumps Placeholder modules only, no real binaries, add symbols by 
downloading them and using "target symbols add ..."
- Download real binaries up front and load them into LLDB, then load the 
core file. For any binaries we do have, we should grab them from the 
global module cache (GetTarget().GetSharedModule(...) in the current 
code) and they will use real object files, not placeholder files. 
"target symbols add ..." still works in this case




It sounds to me like it would be better to have a separate command 
(let's call it "target modules replace" for now) for adding an "object 
file" to a "placeholder" module, instead of repurposing "target symbols 
add" to do that.


This creates a strange loop between the symbol and object files -- 
normally we use the object file for symbol representation if the user 
hasn't specified a symbol file, and here, we would do the opposite.


With "target modules replace", one command would still be enough to set 
both the symbol and object files if they are the same, as the default 
use-symbols-from-object-file behavior would kick in. However, it would 
leave the "target symbols add" command free to add symbols from an 
external file.


Imagine the following scenario:
- I load a minidump, without any supporting files around
- I see that my object file is missing, I do some digging around, and 
manage to find the stripped object file for this module
- I do "target modules replace index_of_placeholder_module 
/path/to/elf.stripped"

- now my sections are there, but I still don't have symbols
- I do more digging and find the breakpad file
- I do "target symbols add /path/to/breakpad.syms"
- success. I now have both symbols and sections

Now this is probably not the most common scenario, but I think it can be 
used as a benchmark to see if the infrastructure is set up the right 
way. If things are set up correctly this should work out-of-the-box. 
With your setup, the scenario above might "just work" if I execute 
"target symbols add" twice (with different files), because the second 
"target symbols add" will do something different than the first one, but 
that sounds to me like another reason why these should be different 
commands.


Maybe there should be there should be some code to help the user and 
detect the situation when he is adding a symbol file to a placeholder 
module and the symbol file is able serve as a good object file too, but 
that code could live higher up than Module::GetObjectFile. It could 
perhaps be directly in the "target symbols add" command via something like:
if (module_I_am_about_to_add_symbols_to->IsPlaceholder() && 
symbol_file->ContainsGoodObjectFileRepresentation())

  TargetModulesReplace(module_I_am_about_to_add_symbols_to, symbol_file)
else
  the_module_I_am_about_to_add_symbols_to->SetSymbolFile(symbol_file)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r348849 - Rename ObjectFile::GetHeaderAddress to GetBaseAddress

2018-12-11 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 11 07:21:15 2018
New Revision: 348849

URL: http://llvm.org/viewvc/llvm-project?rev=348849&view=rev
Log:
Rename ObjectFile::GetHeaderAddress to GetBaseAddress

Summary:
This function was named such because in the case of MachO files, the
mach header is located at this address. However all (most?) usages of
this function were not interested in that fact, but the fact that this
address is used as the base address for expressing various relative
addresses in the object file.

For other object file formats, this name is not appropriate (and it's
probably the reason why this function was not implemented in these
classes). In the ELF case the ELF header will usually end up at this
address, but this is a result of the linker optimizing the file layout
and not a requirement of the spec. For COFF files, I believe the is no
header located at this address either.

Reviewers: clayborg, jasonmolenda, amccarth, lemo, stella.stamenova

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/source/API/SBModule.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp

lldb/trunk/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/trunk/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/trunk/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/trunk/source/Symbol/CompactUnwindInfo.cpp

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=348849&r1=348848&r2=348849&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Dec 11 07:21:15 2018
@@ -551,18 +551,16 @@ public:
   virtual lldb_private::Address GetEntryPointAddress() { return Address(); }
 
   //--
-  /// Returns the address that represents the header of this object file.
+  /// Returns base address of this object file.
   ///
-  /// The header address is defined as where the header for the object file is
-  /// that describes the content of the file. If the header doesn't appear in
-  /// a section that is defined in the object file, an address with no section
-  /// is returned that has the file offset set in the m_file_offset member of
-  /// the lldb_private::Address object.
-  ///
-  /// @return
-  /// Returns the entry address for this module.
+  /// This also sometimes referred to as the "preferred load address" or the
+  /// "image base address". Addresses within object files are often expressed
+  /// relative to this base. If this address corresponds to a specific section
+  /// (usually the first byte of the first section) then the returned address
+  /// will have this section set. Otherwise, the address will just have the
+  /// offset member filled in, indicating that this represents a file address.
   //--
-  virtual lldb_private::Address GetHeaderAddress() {
+  virtual lldb_private::Address GetBaseAddress() {
 return Address(m_memory_addr);
   }
 

Modified: lldb/trunk/source/API/SBModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=348849&r1=348848&r2=348849&view=diff
==
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Tue Dec 11 07:21:15 2018
@@ -587,7 +587,7 @@ lldb::SBAddress SBModule::GetObjectFileH
   if (module_sp) {
 ObjectFile *objfile_ptr = module_sp->GetObjectFile();
 if (objfile_ptr)
-  sb_addr.ref() = objfile_ptr->GetHeaderAddress();
+  sb_addr.ref() = objfile_ptr->GetBaseAddress();
   }
   return sb_addr;
 }

Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=348849&r1=348848&r2=348849&view=diff
==
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Dec 11 07:21:15 2018
@@ -2969,8 +2969,8 @@ static constexpr OptionDefinition g_targ
   { LLDB_OPT_SET_1, false, "address",'a', 
OptionParser::eRequiredArgument, nullptr, {}, 0, eArgTypeAddressOrExpression, 
"Display the image at this address." },
   { LLDB_OPT_SET_1, false, "arch",   'A', 
OptionParser::eOptionalArgument, nullptr, {}, 0, eArgTypeWidth,   
"Display the architecture when listing images." },
   { LLDB_OPT_SET_1, false, "triple", 't', 
OptionParser::eOptiona

Re: [Lldb-commits] [PATCH] D55356: Add a method to get the "base" file address of an object file

2018-12-11 Thread Pavel Labath via lldb-commits

On 11/12/2018 19:17, Jim Ingham wrote:

It the section isn't in the target's SectionLoadList, then GetLoadAddress 
should return LLDB_INVALID_ADDRESS.  I.e. this bit from 
Section::GetLoadBaseAddress:

 load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress(
 const_cast(this)->shared_from_this());

should return LLDB_INVALID_ADDRESS because the section isn't in the load list.

Are we putting sections in the target's section load list before we've actually 
seen them loaded.  I'm pretty sure we shouldn't do that.

Jim




The issue here is that the Address object in question is not backed by 
any section. It has a null section, and just an offset member.
In this case Address::GetLoadAddress just decides to return that address 
as a load address, which I imagine is correct in some situations, but in 
this case our intention was for this address to represent a file address 
(which would still need to be adjusted to account for where the module 
ended up being loaded).



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


Re: [Lldb-commits] [PATCH] D55356: Add a method to get the "base" file address of an object file

2018-12-11 Thread Pavel Labath via lldb-commits

On 11/12/2018 20:10, Jim Ingham via Phabricator wrote:

jingham added a comment.

In D55356#1327280 , @clayborg wrote:


In D55356#1327242 , @labath wrote:


In D55356#1327224 , @clayborg wrote:


In D55356#1327099 , @labath wrote:


Actually, this now causes an lldb-mi test to fail, but it's not clear to me if the 
problem is in the test, or this patch. This issue happens when lldb-mi is printing the 
"library loaded" message after a module gets added to a not-yet-running target. 
It tries to print the load address by first getting the base address and then converting 
that to a load address.

Before this patch, that would always fail, because well.. ELF and PECOFF had 
this function unimplemented, and for MachO the base address was 
section-relative, and so it wasn't resolved to a load address without the 
section being loaded. However, with this patch, in the ELF (and presumably 
PECOFF) case, the load address is not section-relative and so the 
`GetLoadAddress` function happily returns the address.

Is this the expected behavior here? (i.e., 
object_file->GetLoadAddress().GetLoadAddress(target) returning a valid value 
even though the target is not running)



Not unless someone has manually set the section load address in the test?



The test is not setting the load address manually. This simply falls out of how 
`Address::GetLoadAddress`  is implemented:

   addr_t Address::GetLoadAddress(Target *target) const {
 SectionSP section_sp(GetSection());
 if (section_sp) {
   ...
 } else {
   // We don't have a section so the offset is the load address
   return m_offset;
 }
   }


So, where's the bug here? It's not clear to me how to change 
`Address::GetLoadAddress` to do something different than what it is doing now.



So this is a bug really. When there is no section, we should specify what the m_offset is 
using lldb_private::AddressType in maybe a new ivar name "m_offset_type". Then 
GetBaseAddress() would specify eAddressTypeFile. And the above code would become:

  


addr_t Address::GetLoadAddress(Target *target) const {

   SectionSP section_sp(GetSection());
   if (section_sp) {
 ...
   } else if (m_offset_type == eAddressTypeLoad) {
 // We don't have a section so the offset is the load address
 return m_offset;
   }

}

   We just need to be careful and see if we can not make lldb_private::Address 
get any bigger byte size wise if we can at all avoid it.



I must be missing something.  If there's a file around so that we can express 
this address relative to the file, why would it ever not be expressed as a 
section + offset?  If there's not a file around, then what does it mean to say 
this address ie eAddressTypeFile but we don't know the file?




I think the issue here is the difference in how elf and MachO files are 
loaded. Elf has this strange dual view of the file, where the same data 
is represented both as "sections", and "segments". Sections are the 
thing we all know (.text, .data, .debug_info, etc.), and are used by 
most tools (lldb, linker, ...). However, this is *not* what the kernel 
uses when it loads a binary into memory. The loader uses "segments" instead.


It is segments who describe where will a piece of file be loaded into 
memory. Normally, segments span one or more sections, but this is not a 
requirement. And almost always segments will contain some additional 
data besides section content. This data is generally "junk" but it is 
there because it enables the linker to "pack" the elf file more efficiently.


A typical elf file might look something like
---
| elf header  |
---
| segment headers |
---
| .text   |
---
| other sections  |
---
| section headers |
---

The segment headers might say "load everything from the start of file to 
the end of .text section at address 0x4". So the load address of 
this file (and the base for all kinds of offsets) would be "0x4", 
but that does not correspond to any section (the file address of the 
.text section would probably be something like 0x40123).


So, it almost sounds to me like we would need some kind of a 
module-relative (in addition to section-relative) address. Then, this 
address would be represented as "module+0", and GetLoadAddress(target) 
could translate that the same way as it does section-relative addresses.


Though that may be overkill here. For my purposes it would be sufficient 
to just have a function which always returns an file address (regardless 
of whether it points to a section or not), and I can use it to compute 
offsets (kind of like my original patch did). We could keep the 
Module.GetBaseAddress returning LLDB_INVALID_ADDRESS for cases when the 
base address cannot be represent

Re: [Lldb-commits] [PATCH] D55356: Add a method to get the "base" file address of an object file

2018-12-11 Thread Pavel Labath via lldb-commits

On 11/12/2018 20:39, Jim Ingham wrote:

Sections can have parents.  In MachO the text and data sections are actually 
contained in the TEXT and DATA segments respectively.  LLDB represents this by 
having an lldb_private::Section for the segment, and then all the sections in 
that segment are children of the parent Section (the MachO segment).  All the 
code that looks up addresses expects to potentially traverse this hierarchy.

It seems to me that what you are describing should fit in the nesting model?

Jim
  


Hmm.. that's an interesting idea. I'll have to think about that.

Does MachO enforce somehow that every section is fully contained in one 
segment? Because while that is true for elf in general, it is not a 
requirement, and it is possible to create functional executables (though 
I think I would have to use a hex editor for that) where one segment 
contains only a half of some section. But that might not be a big issue, 
as I think most tools will choke on files like this, so if we do 
something suboptimal here, it shouldn't be too bad.


The other hickup I can think of is that sometimes (and this happens in 
perfectly valid files too) one section is present in multiple segments. 
For example .eh_frame will be present in a "LOAD" segment (so it ends up 
in memory), but it will also be present in a special "GNU_EH_FRAME" 
segment (not sure why, but I guess it's to make it easier for someone to 
find it). But I think I can get around that by only creating these 
"container" sections for LOAD segments.



The part I know nothing about is whether something similar could be done 
for PE/COFF files (and I'll need something like that there too). Adrian, 
Zachary, what is the relation ship between "image base" of an object 
file and its sections? Is there any way we could arrange so that the 
base address of a module always belongs to one of its sections?


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


Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-11 Thread Pavel Labath via lldb-commits

On 11/12/2018 20:34, Zachary Turner wrote:
I meant the location of the minidump.  So if you have C:\A\B\C\foo.dmp 
which is the dump file for bar.exe which crashed on another machine, 
then it would look for C:\A\B\C\bar.pdb.  That actually seems like 
fairly intuitive behavior to me, but maybe I'm in the minority :)


We can see what Pavel, Adrian, and others think though or if they have 
any other suggestions.




It sounds like there is a precedent for searching in CWD. I don't know 
how useful it is (I traced it back to r185366, but it is not mentioned 
there specifically), but it is there, and I guess it's not completely 
nonsensical from the POV of a command line user.


I guess we can just keep that there and not call it a hack (though, the 
fact that the searching happens inside SymbolFilePDB *is* a hack).


Searching in the minidump directory would also make sense somewhat, but 
I expect you would need more plumbing for that to happen (and I don't 
know of a precedent for that).


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


[Lldb-commits] [lldb] r348918 - build.py: Implement "gcc" builder

2018-12-12 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Dec 12 00:54:14 2018
New Revision: 348918

URL: http://llvm.org/viewvc/llvm-project?rev=348918&view=rev
Log:
build.py: Implement "gcc" builder

Summary:
This implements the gcc builder in build.py script to allow it to
compile host executables when running on a non-windows host. Where it
made sense, I tried to share code with the msvc builder by moving stuff
to the base class.

Reviewers: zturner

Subscribers: mehdi_amini, dexonsmith, lldb-commits

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

Added:
lldb/trunk/lit/BuildScript/toolchain-clang.test
Modified:
lldb/trunk/lit/Breakpoint/case-sensitive.test
lldb/trunk/lit/BuildScript/modes.test
lldb/trunk/lit/BuildScript/script-args.test
lldb/trunk/lit/helper/build.py   (contents, props changed)

Modified: lldb/trunk/lit/Breakpoint/case-sensitive.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Breakpoint/case-sensitive.test?rev=348918&r1=348917&r2=348918&view=diff
==
--- lldb/trunk/lit/Breakpoint/case-sensitive.test (original)
+++ lldb/trunk/lit/Breakpoint/case-sensitive.test Wed Dec 12 00:54:14 2018
@@ -1,6 +1,6 @@
 # REQUIRES: nowindows
 #
-# RUN: %clang %p/Inputs/case-sensitive.c -g -o %t
+# RUN: %build %p/Inputs/case-sensitive.c --nodefaultlib -o %t
 # RUN: lldb-test breakpoints %t %s | FileCheck %s
 
 breakpoint set -f case-sensitive.c -l 3

Modified: lldb/trunk/lit/BuildScript/modes.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/modes.test?rev=348918&r1=348917&r2=348918&view=diff
==
--- lldb/trunk/lit/BuildScript/modes.test (original)
+++ lldb/trunk/lit/BuildScript/modes.test Wed Dec 12 00:54:14 2018
@@ -1,5 +1,3 @@
-REQUIRES: system-windows
-
 RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o %t/foo.out 
foobar.c \
 RUN:| FileCheck --check-prefix=COMPILE %s
 
@@ -21,17 +19,17 @@ RUN:| FileCheck --check-prefix=BOTH-
 
 COMPILE: compiling foobar.c -> foo.out
 
-COMPILE-MULTI: compiling foo.c -> foo.obj
-COMPILE-MULTI: compiling bar.c -> bar.obj
+COMPILE-MULTI: compiling foo.c -> foo.o{{(bj)?}}
+COMPILE-MULTI: compiling bar.c -> bar.o{{(bj)?}}
 
 
 LINK: linking foobar.obj -> foo.exe
 
 LINK-MULTI: linking foo.obj+bar.obj -> foobar.exe
 
-BOTH: compiling foobar.c -> foobar.exe-foobar.obj
-BOTH: linking foobar.exe-foobar.obj -> foobar.exe
+BOTH: compiling foobar.c -> [[OBJFOO:foobar.exe-foobar.o(bj)?]]
+BOTH: linking [[OBJFOO]] -> foobar.exe
 
-BOTH-MULTI: compiling foo.c -> foobar.exe-foo.obj
-BOTH-MULTI: compiling bar.c -> foobar.exe-bar.obj
-BOTH-MULTI: linking foobar.exe-foo.obj+foobar.exe-bar.obj -> foobar.exe
+BOTH-MULTI: compiling foo.c -> [[OBJFOO:foobar.exe-foo.o(bj)?]]
+BOTH-MULTI: compiling bar.c -> [[OBJBAR:foobar.exe-bar.o(bj)?]]
+BOTH-MULTI: linking [[OBJFOO]]+[[OBJBAR]] -> foobar.exe

Modified: lldb/trunk/lit/BuildScript/script-args.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/script-args.test?rev=348918&r1=348917&r2=348918&view=diff
==
--- lldb/trunk/lit/BuildScript/script-args.test (original)
+++ lldb/trunk/lit/BuildScript/script-args.test Wed Dec 12 00:54:14 2018
@@ -1,5 +1,3 @@
-REQUIRES: system-windows
-
 RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any -o %t/foo.out 
foobar.c \
 RUN:| FileCheck %s
 RUN: %build -n --verbose --arch=32 --mode=compile --compiler=any --outdir %t 
foo.c bar.c \
@@ -31,4 +29,4 @@ MULTI-INPUT-NEXT:   Clean: True
 MULTI-INPUT-NEXT:   Verbose: True
 MULTI-INPUT-NEXT:   Dryrun: True
 MULTI-INPUT-NEXT:   Inputs: foo.c
-MULTI-INPUT-NEXT:   bar.c
\ No newline at end of file
+MULTI-INPUT-NEXT:   bar.c

Added: lldb/trunk/lit/BuildScript/toolchain-clang.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/BuildScript/toolchain-clang.test?rev=348918&view=auto
==
--- lldb/trunk/lit/BuildScript/toolchain-clang.test (added)
+++ lldb/trunk/lit/BuildScript/toolchain-clang.test Wed Dec 12 00:54:14 2018
@@ -0,0 +1,14 @@
+RUN: %build -n --verbose --arch=32 --compiler=clang --mode=compile-and-link -o 
%t/foo.exe foobar.c \
+RUN:| FileCheck --check-prefix=CHECK --check-prefix=CHECK-32 %s
+
+RUN: %build -n --verbose --arch=64 --compiler=clang --mode=compile-and-link -o 
%t/foo.exe foobar.c \
+RUN:| FileCheck --check-prefix=CHECK --check-prefix=CHECK-64 %s
+
+CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe-foobar.o
+CHECK: Cleaning {{.*}}toolchain-clang.test.tmp{{.}}foo.exe
+CHECK: compiling foobar.c -> foo.exe-foobar.o
+CHECK-32: {{.*}}clang++{{(.exe)?}} -m32 -g -O0 -c -o {{.*}}foo.exe-foobar.o 
{{.*}}foobar.c
+CHECK-64: {{.*}}clang++{{(.exe)?}} -m64 -g -O0 -c -o {{.*}}foo.exe-foobar.o 
{{.*}}foobar.c
+CHECK: linking foo.ex

Re: [Lldb-commits] [PATCH] D55356: Add a method to get the "base" file address of an object file

2018-12-12 Thread Pavel Labath via lldb-commits

On 11/12/2018 23:54, Zachary Turner wrote:



On Tue, Dec 11, 2018 at 11:57 AM Pavel Labath > wrote:


The part I know nothing about is whether something similar could be
done
for PE/COFF files (and I'll need something like that there too).
Adrian,
Zachary, what is the relation ship between "image base" of an object
file and its sections? Is there any way we could arrange so that the
base address of a module always belongs to one of its sections?


Historically, an image base of N was used as a way to tell the loader 
"map the file in so that byte 0 of the file is virtual address N in the 
process's address space".  as in *((char *)N) would be the first byte of 
the file in a running process.  Then, everything else in the file is 
written as an offset from N.  This includes section addresses.  So for 
example, if we use dumpbin on a simple executable we can see something 
like this:


Dump of file bin\count.exe

PE signature found

File Type: EXECUTABLE IMAGE

OPTIONAL HEADER VALUES
                   ...
        14000 image base (00014000 to 000140011FFF)
                   ...
SECTION HEADER #1
    .text name
     1000 virtual address (000140001000 to 0001400089AE)

So under this scheme, the first byte of the first section would be at 
virtual address 000140001000 in the running process.


Later, ASLR came along and threw a wrench in all of that, and so these 
days the image base is mostly meaningless.  The loader will probably 
never actually load your module at the address specified in image base.  
But the rest of the rules still hold true.  Wherever it *does* load your 
module, the first byte of .text will still be at offset 1000 from that.


So, if you want to return this value from the PE/COFF header, or even if 
you want to return the actual address that the module was loaded at, 
then no, it will never belong to any section (because the bytes at that 
address will be the PE/COFF file header).


Does this make sense?


I think it does.

I am aware that this address is not going to represent a valid address 
in target memory (the same is true for elf and macho targets), but what 
we're trying to ensure is that when we take this address, and ask the 
running target to give us the "load" address for it, it will return the 
actual place in memory (and conversely if the target is not running it 
should give us an invalid address instead of returning something bogus.


So, if I understand correctly, the PE/COFF file will always be loaded 
into one contiguous chunk of memory, ranging from ImageBase (modulo 
ASLR) to ImageBase+SizeOfImage. Then various sections are mapped into 
that range (according to their RVAs).


If that's the case, then we could model this as one big 
segment/container section/whateever, and the individual (loadable) 
sections would be sub-sections of that. Apart from solving my current 
problem, this should also improve the address lookup for these modules. 
E.g. right now if you ask lldb to lookup the address corresponding to 
the memory image of the header, it will say it does not belong anywhere, 
but that address is clearly associated with the module.


I'll try looking at what kind of changes are needed to make this happen. 
I'll start with the elf case, as I am more familiar with that (and it'll 
probably be more complicated).


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


[Lldb-commits] [lldb] r348924 - lldb-test: Add ability to dump subsections

2018-12-12 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Dec 12 04:35:25 2018
New Revision: 348924

URL: http://llvm.org/viewvc/llvm-project?rev=348924&view=rev
Log:
lldb-test: Add ability to dump subsections

Previously, lldb-test would only print top-level sections. However, in
lldb, sections can contain other sections. This teaches lldb-test to
print nested sections too.

Added:
lldb/trunk/lit/Modules/MachO/
lldb/trunk/lit/Modules/MachO/subsections.yaml
Modified:
lldb/trunk/tools/lldb-test/lldb-test.cpp

Added: lldb/trunk/lit/Modules/MachO/subsections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/subsections.yaml?rev=348924&view=auto
==
--- lldb/trunk/lit/Modules/MachO/subsections.yaml (added)
+++ lldb/trunk/lit/Modules/MachO/subsections.yaml Wed Dec 12 04:35:25 2018
@@ -0,0 +1,106 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+#CHECK: Showing 2 sections
+#CHECK-NEXT:  Index: 0
+#CHECK-NEXT:  Name: __PAGEZERO
+#CHECK-NEXT:  Type: container
+#CHECK-NEXT:  VM size: 4294967296
+#CHECK-NEXT:  File size: 0
+#CHECK-NEXT:  There are no subsections
+#
+#CHECK:   Index: 1
+#CHECK-NEXT:  Name: __TEXT
+#CHECK-NEXT:  Type: container
+#CHECK-NEXT:  VM size: 4096
+#CHECK-NEXT:  File size: 4096
+#CHECK-NEXT:  Showing 3 subsections
+#CHECK-NEXT:Index: 0
+#CHECK-NEXT:Name: __text
+#CHECK-NEXT:Type: code
+#CHECK-NEXT:VM size: 22
+#CHECK-NEXT:File size: 22
+#
+#CHECK: Index: 1
+#CHECK-NEXT:Name: __unwind_info
+#CHECK-NEXT:Type: compact-unwind
+#CHECK-NEXT:VM size: 76
+#CHECK-NEXT:File size: 76
+#
+#CHECK: Index: 2
+#CHECK-NEXT:Name: __eh_frame
+#CHECK-NEXT:Type: eh-frame
+#CHECK-NEXT:VM size: 104
+#CHECK-NEXT:File size: 104
+
+--- !mach-o
+FileHeader:  
+  magic:   0xFEEDFACF
+  cputype: 0x0107
+  cpusubtype:  0x0003
+  filetype:0x0002
+  ncmds:   12
+  sizeofcmds:  728
+  flags:   0x0085
+  reserved:0x
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 72
+segname: __PAGEZERO
+vmaddr:  0
+vmsize:  4294967296
+fileoff: 0
+filesize:0
+maxprot: 0
+initprot:0
+nsects:  0
+flags:   0
+  - cmd: LC_SEGMENT_64
+cmdsize: 312
+segname: __TEXT
+vmaddr:  4294967296
+vmsize:  4096
+fileoff: 0
+filesize:4096
+maxprot: 7
+initprot:5
+nsects:  3
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x00010F30
+size:22
+offset:  0x0F30
+align:   4
+reloff:  0x
+nreloc:  0
+flags:   0x8400
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__unwind_info
+segname: __TEXT
+addr:0x00010F48
+size:76
+offset:  0x0F48
+align:   2
+reloff:  0x
+nreloc:  0
+flags:   0x
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+  - sectname:__eh_frame
+segname: __TEXT
+addr:0x00010F98
+size:104
+offset:  0x0F98
+align:   3
+reloff:  0x
+nreloc:  0
+flags:   0x000B
+reserved1:   0x
+reserved2:   0x
+reserved3:   0x
+...

Modified: lldb/trunk/tools/lldb-test/lldb-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/lldb-test.cpp?rev=348924&r1=348923&r2=348924&view=diff
==
--- lldb/trunk/tools/lldb-test/lldb-test.cpp (original)
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp Wed Dec 12 04:35:25 2018
@@ -718,6 +718,37 @@ int opts::symbols::dumpSymbols(Debugger
   return HadErrors;
 }
 
+static void dumpSectionList(LinePrinter &Printer, const SectionList &List, 
bool is_subsection) {
+  size_t Count = List.GetNumSections(0);
+  if (Count == 0) {
+Printer.formatLine("There are no {0}sections", is_subsection ? "sub" : "");
+return;
+  }
+  Printer.formatLine("Showing {0} {1}sections", Count,
+ is_subsection ? "sub" : "");
+  for (size_t I = 0; I < Count; ++I) {
+auto S = List.GetSectionAtIndex(I);
+assert(S);
+AutoIndent Indent(Printer, 2);
+Printer.formatLine("In

[Lldb-commits] [lldb] r348928 - ELF: Simplify program header iteration

2018-12-12 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Dec 12 06:20:28 2018
New Revision: 348928

URL: http://llvm.org/viewvc/llvm-project?rev=348928&view=rev
Log:
ELF: Simplify program header iteration

Instead of GetProgramHeaderCount+GetProgramHeaderByIndex, expose an
ArrayRef of all program headers, to enable range-based iteration.
Instead of GetSegmentDataByIndex, expose GetSegmentData, taking a
program header (reference).

This makes the code simpler by enabling range-based loops and also
allowed to remove some null checks, as it became locally obvious that
some pointers can never be null.

Modified:
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=348928&r1=348927&r2=348928&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Dec 12 
06:20:28 2018
@@ -539,14 +539,13 @@ static uint32_t calc_gnu_debuglink_crc32
 
 uint32_t ObjectFileELF::CalculateELFNotesSegmentsCRC32(
 const ProgramHeaderColl &program_headers, DataExtractor &object_data) {
-  typedef ProgramHeaderCollConstIter Iter;
 
   uint32_t core_notes_crc = 0;
 
-  for (Iter I = program_headers.begin(); I != program_headers.end(); ++I) {
-if (I->p_type == llvm::ELF::PT_NOTE) {
-  const elf_off ph_offset = I->p_offset;
-  const size_t ph_size = I->p_filesz;
+  for (const ELFProgramHeader &H : program_headers) {
+if (H.p_type == llvm::ELF::PT_NOTE) {
+  const elf_off ph_offset = H.p_offset;
+  const size_t ph_size = H.p_filesz;
 
   DataExtractor segment_data;
   if (segment_data.SetData(object_data, ph_offset, ph_size) != ph_size) {
@@ -806,15 +805,11 @@ bool ObjectFileELF::SetLoadAddress(Targe
 if (section_list) {
   if (!value_is_offset) {
 bool found_offset = false;
-for (size_t i = 1, count = GetProgramHeaderCount(); i <= count; ++i) {
-  const elf::ELFProgramHeader *header = GetProgramHeaderByIndex(i);
-  if (header == nullptr)
+for (const ELFProgramHeader &H : ProgramHeaders()) {
+  if (H.p_type != PT_LOAD || H.p_offset != 0)
 continue;
 
-  if (header->p_type != PT_LOAD || header->p_offset != 0)
-continue;
-
-  value = value - header->p_vaddr;
+  value = value - H.p_vaddr;
   found_offset = true;
   break;
 }
@@ -1158,8 +1153,8 @@ size_t ObjectFileELF::GetProgramHeaderIn
 //--
 // ParseProgramHeaders
 //--
-size_t ObjectFileELF::ParseProgramHeaders() {
-  return GetProgramHeaderInfo(m_program_headers, m_data, m_header);
+bool ObjectFileELF::ParseProgramHeaders() {
+  return GetProgramHeaderInfo(m_program_headers, m_data, m_header) != 0;
 }
 
 lldb_private::Status
@@ -1705,27 +1700,6 @@ size_t ObjectFileELF::GetSectionHeaderIn
   return 0;
 }
 
-size_t ObjectFileELF::GetProgramHeaderCount() { return ParseProgramHeaders(); }
-
-const elf::ELFProgramHeader *
-ObjectFileELF::GetProgramHeaderByIndex(lldb::user_id_t id) {
-  if (!id || !ParseProgramHeaders())
-return NULL;
-
-  if (--id < m_program_headers.size())
-return &m_program_headers[id];
-
-  return NULL;
-}
-
-DataExtractor ObjectFileELF::GetSegmentDataByIndex(lldb::user_id_t id) {
-  const elf::ELFProgramHeader *segment_header = GetProgramHeaderByIndex(id);
-  if (segment_header == NULL)
-return DataExtractor();
-  return DataExtractor(m_data, segment_header->p_offset,
-   segment_header->p_filesz);
-}
-
 llvm::StringRef
 ObjectFileELF::StripLinkerSymbolAnnotations(llvm::StringRef symbol_name) const 
{
   size_t pos = symbol_name.find('@');
@@ -3181,11 +3155,9 @@ void ObjectFileELF::DumpELFProgramHeader
   s->PutCString(" ---    "
 "  - \n");
 
-  uint32_t idx = 0;
-  for (ProgramHeaderCollConstIter I = m_program_headers.begin();
-   I != m_program_headers.end(); ++I, ++idx) {
-s->Printf("[%2u] ", idx);
-ObjectFileELF::DumpELFProgramHeader(s, *I);
+  for (const auto &H : llvm::enumerate(m_program_headers)) {
+s->Format("[{0,2}] ", H.index());
+ObjectFileELF::DumpELFProgramHeader(s, H.value());
 s->EOL();
   }
 }
@@ -3305,18 +3277,13 @@ bool ObjectFileELF::GetArchitecture(Arch
   m_arch_spec.TripleOSIsUnspecifiedUnknown()) {
 // Core files don't have section headers yet they have PT_NOTE program
 // header

[Lldb-commits] [lldb] r348936 - ELF: Clean up section type computation

2018-12-12 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Dec 12 07:46:18 2018
New Revision: 348936

URL: http://llvm.org/viewvc/llvm-project?rev=348936&view=rev
Log:
ELF: Clean up section type computation

Move code into a separate function, and replace the if-else chain with
llvm::StringSwitch.

A slight behavioral change is that now I use the section flags
(SHF_TLS) instead of the section name to set the thread-specific
property. There is no explanation in the original commit introducing
this (r153537) as to why that was done this way, but the new behavior
should be more correct.

Modified:
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/lit/Modules/build-id-case.yaml
lldb/trunk/lit/Modules/compressed-sections.yaml
lldb/trunk/lit/Modules/elf-section-types.yaml
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/MachO/subsections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/subsections.yaml?rev=348936&r1=348935&r2=348936&view=diff
==
--- lldb/trunk/lit/Modules/MachO/subsections.yaml (original)
+++ lldb/trunk/lit/Modules/MachO/subsections.yaml Wed Dec 12 07:46:18 2018
@@ -5,6 +5,7 @@
 #CHECK-NEXT:  Index: 0
 #CHECK-NEXT:  Name: __PAGEZERO
 #CHECK-NEXT:  Type: container
+#CHECK-NEXT:  Thread specific: no
 #CHECK-NEXT:  VM size: 4294967296
 #CHECK-NEXT:  File size: 0
 #CHECK-NEXT:  There are no subsections
@@ -12,24 +13,28 @@
 #CHECK:   Index: 1
 #CHECK-NEXT:  Name: __TEXT
 #CHECK-NEXT:  Type: container
+#CHECK-NEXT:  Thread specific: no
 #CHECK-NEXT:  VM size: 4096
 #CHECK-NEXT:  File size: 4096
 #CHECK-NEXT:  Showing 3 subsections
 #CHECK-NEXT:Index: 0
 #CHECK-NEXT:Name: __text
 #CHECK-NEXT:Type: code
+#CHECK-NEXT:Thread specific: no
 #CHECK-NEXT:VM size: 22
 #CHECK-NEXT:File size: 22
 #
 #CHECK: Index: 1
 #CHECK-NEXT:Name: __unwind_info
 #CHECK-NEXT:Type: compact-unwind
+#CHECK-NEXT:Thread specific: no
 #CHECK-NEXT:VM size: 76
 #CHECK-NEXT:File size: 76
 #
 #CHECK: Index: 2
 #CHECK-NEXT:Name: __eh_frame
 #CHECK-NEXT:Type: eh-frame
+#CHECK-NEXT:Thread specific: no
 #CHECK-NEXT:VM size: 104
 #CHECK-NEXT:File size: 104
 

Modified: lldb/trunk/lit/Modules/build-id-case.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/build-id-case.yaml?rev=348936&r1=348935&r2=348936&view=diff
==
--- lldb/trunk/lit/Modules/build-id-case.yaml (original)
+++ lldb/trunk/lit/Modules/build-id-case.yaml Wed Dec 12 07:46:18 2018
@@ -6,8 +6,6 @@
 
 # CHECK: Name: .debug_frame
 # CHECK-NEXT: Type: dwarf-frame
-# CHECK-NEXT: VM size: 0
-# CHECK-NEXT: File size: 8
 
 --- !ELF
 FileHeader:

Modified: lldb/trunk/lit/Modules/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/compressed-sections.yaml?rev=348936&r1=348935&r2=348936&view=diff
==
--- lldb/trunk/lit/Modules/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/compressed-sections.yaml Wed Dec 12 07:46:18 2018
@@ -19,6 +19,7 @@ Sections:
 
 # CHECK: Name: .hello_elf
 # CHECK-NEXT: Type: regular
+# CHECK-NEXT: Thread specific: no
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 28
 # CHECK-NEXT: Data:
@@ -26,6 +27,7 @@ Sections:
 
 # CHECK: Name: .bogus
 # CHECK-NEXT: Type: regular
+# CHECK-NEXT: Thread specific: no
 # CHECK-NEXT: VM size: 0
 # CHECK-NEXT: File size: 8
 # CHECK-NEXT: Data: ()

Modified: lldb/trunk/lit/Modules/elf-section-types.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/elf-section-types.yaml?rev=348936&r1=348935&r2=348936&view=diff
==
--- lldb/trunk/lit/Modules/elf-section-types.yaml (original)
+++ lldb/trunk/lit/Modules/elf-section-types.yaml Wed Dec 12 07:46:18 2018
@@ -1,32 +1,36 @@
 # RUN: yaml2obj %s > %t
 # RUN: lldb-test object-file %t | FileCheck %s
 
-# CHECK: Name: .text
+# CHECK-LABEL: Name: .text
 # CHECK-NEXT: Type: code
 
-# CHECK: Name: .debug_info
+# CHECK-LABEL: Name: .debug_info
 # CHECK-NEXT: Type: dwarf-info
-# CHECK-NEXT: VM size: 0
-# CHECK-NEXT: File size: 8
 
-# CHECK: Name: .debug_types
+# CHECK-LABEL: Name: .debug_types
 # CHECK-NEXT: Type: dwarf-types
-# CHECK-NEXT: VM size: 0
-# CHECK-NEXT: File size: 8
 
-# CHECK: Name: .debug_names
+# CHECK-LABEL: Name: .debug_names
 # CHECK-NEXT: Type: dwarf-names
-# CHECK-NEXT: VM size: 0
-# CHECK-NEXT: File size: 8
 
-# CHECK: Name: .gnu_debugaltlink
+# CHECK-LABEL: Name: .gnu_debugaltlink
 # CHECK-NEXT: Type: dwarf-gnu-debugaltlink
-# CHECK-NEXT: VM size: 0
-# CHECK-NEXT: File size: 8
 
-# CHECK: Name: __codesection
+# CHECK-LABEL: Name: __codesection
 # CHECK-NEXT: Type: code
 
+# CHECK-LABEL: Name: .data
+

[Lldb-commits] [lldb] r349027 - Classify tests in lit/Modules

2018-12-13 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 13 04:13:29 2018
New Revision: 349027

URL: http://llvm.org/viewvc/llvm-project?rev=349027&view=rev
Log:
Classify tests in lit/Modules

We've recently developed a convention where the tests are placed into
subfolders according to the object file type. This applies that
convention to existing tests too.

Added:
lldb/trunk/lit/Modules/ELF/
lldb/trunk/lit/Modules/ELF/build-id-case.yaml
  - copied, changed from r348936, lldb/trunk/lit/Modules/build-id-case.yaml
lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
  - copied, changed from r348936, 
lldb/trunk/lit/Modules/compressed-sections.yaml
lldb/trunk/lit/Modules/ELF/duplicate-section.yaml
  - copied, changed from r348936, 
lldb/trunk/lit/Modules/elf-duplicate-section.yaml
lldb/trunk/lit/Modules/ELF/many-sections.s
  - copied, changed from r348936, lldb/trunk/lit/Modules/elf-many-sections.s
lldb/trunk/lit/Modules/ELF/section-types.yaml
  - copied, changed from r348936, 
lldb/trunk/lit/Modules/elf-section-types.yaml
lldb/trunk/lit/Modules/ELF/short-build-id.yaml
  - copied, changed from r348936, lldb/trunk/lit/Modules/short-build-id.yaml
lldb/trunk/lit/Modules/MachO/lc_build_version.yaml
  - copied, changed from r348936, 
lldb/trunk/lit/Modules/lc_build_version.yaml
lldb/trunk/lit/Modules/MachO/lc_build_version_notools.yaml
  - copied, changed from r348936, 
lldb/trunk/lit/Modules/lc_build_version_notools.yaml
lldb/trunk/lit/Modules/MachO/lc_version_min.yaml
  - copied, changed from r348936, lldb/trunk/lit/Modules/lc_version_min.yaml
Removed:
lldb/trunk/lit/Modules/build-id-case.yaml
lldb/trunk/lit/Modules/compressed-sections.yaml
lldb/trunk/lit/Modules/elf-duplicate-section.yaml
lldb/trunk/lit/Modules/elf-many-sections.s
lldb/trunk/lit/Modules/elf-section-types.yaml
lldb/trunk/lit/Modules/lc_build_version.yaml
lldb/trunk/lit/Modules/lc_build_version_notools.yaml
lldb/trunk/lit/Modules/lc_version_min.yaml
lldb/trunk/lit/Modules/short-build-id.yaml

Copied: lldb/trunk/lit/Modules/ELF/build-id-case.yaml (from r348936, 
lldb/trunk/lit/Modules/build-id-case.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/build-id-case.yaml?p2=lldb/trunk/lit/Modules/ELF/build-id-case.yaml&p1=lldb/trunk/lit/Modules/build-id-case.yaml&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/ELF/compressed-sections.yaml (from r348936, 
lldb/trunk/lit/Modules/compressed-sections.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/compressed-sections.yaml?p2=lldb/trunk/lit/Modules/ELF/compressed-sections.yaml&p1=lldb/trunk/lit/Modules/compressed-sections.yaml&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/ELF/duplicate-section.yaml (from r348936, 
lldb/trunk/lit/Modules/elf-duplicate-section.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/duplicate-section.yaml?p2=lldb/trunk/lit/Modules/ELF/duplicate-section.yaml&p1=lldb/trunk/lit/Modules/elf-duplicate-section.yaml&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/ELF/many-sections.s (from r348936, 
lldb/trunk/lit/Modules/elf-many-sections.s)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/many-sections.s?p2=lldb/trunk/lit/Modules/ELF/many-sections.s&p1=lldb/trunk/lit/Modules/elf-many-sections.s&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/ELF/section-types.yaml (from r348936, 
lldb/trunk/lit/Modules/elf-section-types.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/section-types.yaml?p2=lldb/trunk/lit/Modules/ELF/section-types.yaml&p1=lldb/trunk/lit/Modules/elf-section-types.yaml&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/ELF/short-build-id.yaml (from r348936, 
lldb/trunk/lit/Modules/short-build-id.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/short-build-id.yaml?p2=lldb/trunk/lit/Modules/ELF/short-build-id.yaml&p1=lldb/trunk/lit/Modules/short-build-id.yaml&r1=348936&r2=349027&rev=349027&view=diff
==
(empty)

Copied: lldb/trunk/lit/Modules/MachO/lc_build_version.yaml (from r348936, 
lldb/trunk/lit/Modules/lc_build_version.yaml)
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/lc_build_version.yaml?p2=lldb/trunk/lit/Modules/MachO/lc_build_version.yaml&p1=lldb/trunk/lit/Modules/lc

Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-13 Thread Pavel Labath via lldb-commits

On 13/12/2018 19:32, Leonard Mosescu wrote:

What's the consensus?

Personally I think that, even considering the potential issue that Paval 
pointed out, the "target symbols add ..." is the most conservative 
approach in terms of introducing new behavior. I'm fine with the current 
directory lookup as well (the original change) since it's consistent 
with DWARF lookup.



Yes, but it also regresses existing functionality. Now if I do something 
completely nonsensical like:

(lldb) target create "/bin/ls"
Current executable set to '/bin/ls' (x86_64).
(lldb) target symbols add  -s /bin/ls /tmp/a.txt
error: symbol file '/tmp/a.txt' does not match any existing module

lldb will print a nice error for me. If I remove the safeguards like you 
did in your patch, it turns into this:

(lldb) target create "/bin/ls"
Current executable set to '/bin/ls' (x86_64).
(lldb) target symbols add  -s /bin/ls /tmp/a.txt
symbol file '/tmp/a.txt' has been added to '/bin/ls'

which is a blatant lie, because /bin/ls will continue to use symbols 
from the object file.

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


Re: [Lldb-commits] [PATCH] D55142: Minidump debugging using the native PDB reader

2018-12-14 Thread Pavel Labath via lldb-commits

On 13/12/2018 23:19, Zachary Turner wrote:
The permanent solution would be figuring out what to do about the 
ObjectFile situation (e.g. do we want to make an ObjectFilePDB or do we 
want to live in a world where SymbolFiles need not be backed by 
ObjectFiles?), and then regardless of what we decide there, implementing 
the SymbolVendor that can search a combination of locations including 
(but not limited to) a symbol server.  lldb already has the notion of a 
symbol path.  So using this we could just use that existing logic to 
search the symbol path, and before you run LLDB make sure your minidump 
.pdb files are in that search path.  If we make an ObjectFilePDB, then 
this should be able to fall out naturally of the existing design with no 
additional work, because it will use the normal SymbolVendor search 
logic.  If we allow SymbolFilePDB to live without an ObjectFilePDB, then 
we would have to make changes similar to what you proposed earlier where 
we can still get a SymbolVendor and use it to execute its default search 
algorithm, plus probably some other changes to make sure various other 
things work correctly in the presence of ObjectFile-less SymbolFiles.




+1 for that.


I'm particularly interested in the result of this, as I'm in the middle 
of adding ObjectFileBreakpad, whose raison d´être is to make things 
interoperate more nicely with the rest of lldb.


My take on this is that going the ObjectFile route is going to be faster 
and less intrusive, but it may produce some odd-looking APIs. E.g. maybe 
the ObjectFilePDB will claim it contains no sections (which is the 
traditional way of passing information from ObjectFiles to SymbolFiles), 
but instead provide some private API to access the underlying llvm data 
structures, which will be used by SymbolFilePDB to do it's thing.


OTOH, object-less symbol files has the potential to produce 
nicer-looking APIs overall, but it will require a lot of changes to core 
lldb to make it happen. E.g., besides the fact that searching for 
"symbols" happens on the object file level (which is the whole reason 
we're having this discussion), the object files are also responsible for 
providing unwind information. That would have to change too.

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


[Lldb-commits] [lldb] r349149 - Mark Permissions as a bitmask enum

2018-12-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 14 05:51:20 2018
New Revision: 349149

URL: http://llvm.org/viewvc/llvm-project?rev=349149&view=rev
Log:
Mark Permissions as a bitmask enum

this allows one to use bitwise operators on the variables of this type
without complicated casting.

The gotcha here is that the combinations of these enums were being used
in some constexpr contexts such as case labels (case
ePermissionsWritable | ePermissionsExecutable:), which is not possible
if the user-defined operator| is not constexpr.

So, this commit also marks these operators as constexpr. I am committing
this as a small standalone patch so it can be easily reverted if some
compiler has an issue with this.

Modified:
lldb/trunk/include/lldb/lldb-enumerations.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=349149&r1=349148&r2=349149&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Dec 14 05:51:20 2018
@@ -17,17 +17,17 @@
 // you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply
 // write Enum a = eFoo | eBar.
 #define LLDB_MARK_AS_BITMASK_ENUM(Enum)
\
-  inline Enum operator|(Enum a, Enum b) {  
\
+  constexpr Enum operator|(Enum a, Enum b) {   
\
 return static_cast(  
\
 static_cast::type>(a) | 
\
 static_cast::type>(b)); 
\
   }
\
-  inline Enum operator&(Enum a, Enum b) {  
\
+  constexpr Enum operator&(Enum a, Enum b) {   
\
 return static_cast(  
\
 static_cast::type>(a) & 
\
 static_cast::type>(b)); 
\
   }
\
-  inline Enum operator~(Enum a) {  
\
+  constexpr Enum operator~(Enum a) {   
\
 return static_cast(  
\
 ~static_cast::type>(a));
\
   }
\
@@ -395,6 +395,7 @@ LLDB_MARK_AS_BITMASK_ENUM(SymbolContextI
 FLAGS_ENUM(Permissions){ePermissionsWritable = (1u << 0),
 ePermissionsReadable = (1u << 1),
 ePermissionsExecutable = (1u << 2)};
+LLDB_MARK_AS_BITMASK_ENUM(Permissions)
 
 enum InputReaderAction {
   eInputReaderActivate, // reader is newly pushed onto the reader stack


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


[Lldb-commits] [lldb] r349153 - Fix build with older (<3.0) swigs

2018-12-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 14 06:25:20 2018
New Revision: 349153

URL: http://llvm.org/viewvc/llvm-project?rev=349153&view=rev
Log:
Fix build with older (<3.0) swigs

It turns out it wasn't the compilers, but swig who had issues with my
previous patch -- older versions do not recognise the "constexpr"
keyword.

Fortunately, that can be fixed the same way we fix all other swig
incompatibilities: #ifndef SWIG.

Modified:
lldb/trunk/include/lldb/lldb-enumerations.h

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=349153&r1=349152&r2=349153&view=diff
==
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Dec 14 06:25:20 2018
@@ -12,10 +12,13 @@
 
 #include 
 
+#ifndef SWIG
 // Macro to enable bitmask operations on an enum.  Without this, Enum | Enum
 // gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar).  If
 // you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply
 // write Enum a = eFoo | eBar.
+// Unfortunately, swig<3.0 doesn't recognise the constexpr keyword, so remove
+// this entire block, as it is not necessary for swig processing.
 #define LLDB_MARK_AS_BITMASK_ENUM(Enum)
\
   constexpr Enum operator|(Enum a, Enum b) {   
\
 return static_cast(  
\
@@ -39,6 +42,9 @@
 a = a & b; 
\
 return a;  
\
   }
+#else
+#define LLDB_MARK_AS_BITMASK_ENUM(Enum)
+#endif
 
 #ifndef SWIG
 // With MSVC, the default type of an enum is always signed, even if one of the


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


[Lldb-commits] [lldb] r349154 - Fix minidump unit test failures from r349062

2018-12-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 14 06:41:04 2018
New Revision: 349154

URL: http://llvm.org/viewvc/llvm-project?rev=349154&view=rev
Log:
Fix minidump unit test failures from r349062

This commit added new test inputs, but it did not add them to the cmake
files. This caused the test to fail at runtime.

While in there, I also sorted the list of minidump test inputs.

Modified:
lldb/trunk/unittests/Process/minidump/CMakeLists.txt

Modified: lldb/trunk/unittests/Process/minidump/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/minidump/CMakeLists.txt?rev=349154&r1=349153&r2=349154&view=diff
==
--- lldb/trunk/unittests/Process/minidump/CMakeLists.txt (original)
+++ lldb/trunk/unittests/Process/minidump/CMakeLists.txt Fri Dec 14 06:41:04 
2018
@@ -13,18 +13,21 @@ add_lldb_unittest(LLDBMinidumpTests
   )
 
 set(test_inputs
+   bad_duplicate_streams.dmp
+   bad_overlapping_streams.dmp
+   fizzbuzz_no_heap.dmp
+   fizzbuzz_wow64.dmp
linux-i386.dmp
linux-x86_64.dmp
linux-x86_64_not_crashed.dmp
-   fizzbuzz_no_heap.dmp
-   fizzbuzz_wow64.dmp
-   bad_duplicate_streams.dmp
-   bad_overlapping_streams.dmp
-   thread-list-padded.dmp
-   thread-list-not-padded.dmp
-   module-list-padded.dmp
-   module-list-not-padded.dmp
+   memory-list-not-padded.dmp
memory-list-padded.dmp
-   memory-list-not-padded.dmp)
+   module-list-not-padded.dmp
+   module-list-padded.dmp
+   modules-dup-min-addr.dmp
+   modules-order.dmp
+   thread-list-not-padded.dmp
+   thread-list-padded.dmp
+   )
 
 add_unittest_inputs(LLDBMinidumpTests "${test_inputs}")


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


Re: [Lldb-commits] [lldb] r349175 - [NativePDB] Fix local-variables.cpp test.

2018-12-14 Thread Pavel Labath via lldb-commits

On 14/12/2018 19:43, Zachary Turner via lldb-commits wrote:

Author: zturner
Date: Fri Dec 14 10:43:42 2018
New Revision: 349175

URL: http://llvm.org/viewvc/llvm-project?rev=349175&view=rev
Log:
[NativePDB] Fix local-variables.cpp test.

Since we're actually running an executable on the host now, different
versions of Windows could load different system libraries, so we need
to regex out the number of loaded modules.

Modified:
 lldb/trunk/lit/SymbolFile/NativePDB/local-variables.cpp

Modified: lldb/trunk/lit/SymbolFile/NativePDB/local-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/NativePDB/local-variables.cpp?rev=349175&r1=349174&r2=349175&view=diff
==
--- lldb/trunk/lit/SymbolFile/NativePDB/local-variables.cpp (original)
+++ lldb/trunk/lit/SymbolFile/NativePDB/local-variables.cpp Fri Dec 14 10:43:42 
2018
@@ -151,7 +151,7 @@ int main(int argc, char **argv) {
  // CHECK-NEXT: Process {{.*}} exited with status = 18 (0x0012)
  
  // CHECK:  (lldb) target modules dump ast

-// CHECK-NEXT: Dumping clang ast for 7 modules.
+// CHECK-NEXT: Dumping clang ast for {{.*}} modules.
  // CHECK-NEXT: TranslationUnitDecl
  // CHECK-NEXT: |-FunctionDecl {{.*}} main 'int (int, char **)'
  // CHECK-NEXT: | |-ParmVarDecl {{.*}} argc 'int'


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



It looks like it would be nice to be able to specify the module whose 
clang ast one wishes to dump. This would reduce the amount of output, 
and with it, the chance of FileCheck picking up some false positives.

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


Re: [Lldb-commits] [lldb] r349175 - [NativePDB] Fix local-variables.cpp test.

2018-12-14 Thread Pavel Labath via lldb-commits

On 14/12/2018 19:52, Zachary Turner wrote:
I don't know if there's a good way to do that.  Because debuggers need 
to be able to see across multiple translation units, this is implemented 
internally as constructing one giant AST that contains everything for 
the entire program.  LLDB has no notion of a per-module AST, so it would 
be hard to make this work.




That's not how it's implemented now. The code actually iterates through 
all the modules and dumps each one in turn.


  result.GetOutputStream().Printf("Dumping clang ast for %" PRIu64
  " modules.\n",
  (uint64_t)num_modules);
  for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
if (m_interpreter.WasInterrupted())
  break;
Module *m = target->GetImages().GetModulePointerAtIndex(image_idx);
SymbolFile *sf = m->GetSymbolVendor()->GetSymbolFile();
sf->DumpClangAST(result.GetOutputStream());
  }


In fact, it looks like this command already supports specifying the 
exact module to dump (either by basename or full path).

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


Re: [Lldb-commits] [PATCH] D55430: build.py: Implement "gcc" builder

2018-12-14 Thread Pavel Labath via lldb-commits

On 14/12/2018 20:32, Stella Stamenova via Phabricator wrote:

stella.stamenova added a comment.

I am trying to use the new builder to build the lldb-mi tests, so that they can 
start consistently passing on Windows, so they're now using the gcc builder on 
Linux and failing:


Interesting. Can you run the script in verbose mode so I can see the 
exact commands it executes?


Not being able to find the linker is weird. Can you check whether you 
have /usr/bin/ld on your system? Maybe we need to add something to the 
PATH? Is that clang binary capable of producing executables when you run 
it manually?

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


[Lldb-commits] [lldb] r349267 - Remove /proc/pid/maps parsing code from NativeProcessLinux

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:38:16 2018
New Revision: 349267

URL: http://llvm.org/viewvc/llvm-project?rev=349267&view=rev
Log:
Remove /proc/pid/maps parsing code from NativeProcessLinux

A utility function doing this was added in r349182, so use that instead.

Modified:
lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Modified: lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp?rev=349267&r1=349266&r2=349267&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeProcessLinux.cpp Sat Dec 15 
05:38:16 2018
@@ -45,6 +45,7 @@
 
 #include "NativeThreadLinux.h"
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Plugins/Process/Utility/LinuxProcMaps.h"
 #include "Procfs.h"
 
 #include 
@@ -1232,90 +1233,6 @@ Status NativeProcessLinux::Kill() {
   return error;
 }
 
-static Status
-ParseMemoryRegionInfoFromProcMapsLine(llvm::StringRef &maps_line,
-  MemoryRegionInfo &memory_region_info) {
-  memory_region_info.Clear();
-
-  StringExtractor line_extractor(maps_line);
-
-  // Format: {address_start_hex}-{address_end_hex} perms offset  dev   inode
-  // pathname perms: rwxp   (letter is present if set, '-' if not, final
-  // character is p=private, s=shared).
-
-  // Parse out the starting address
-  lldb::addr_t start_address = line_extractor.GetHexMaxU64(false, 0);
-
-  // Parse out hyphen separating start and end address from range.
-  if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != '-'))
-return Status(
-"malformed /proc/{pid}/maps entry, missing dash between address 
range");
-
-  // Parse out the ending address
-  lldb::addr_t end_address = line_extractor.GetHexMaxU64(false, start_address);
-
-  // Parse out the space after the address.
-  if (!line_extractor.GetBytesLeft() || (line_extractor.GetChar() != ' '))
-return Status(
-"malformed /proc/{pid}/maps entry, missing space after range");
-
-  // Save the range.
-  memory_region_info.GetRange().SetRangeBase(start_address);
-  memory_region_info.GetRange().SetRangeEnd(end_address);
-
-  // Any memory region in /proc/{pid}/maps is by definition mapped into the
-  // process.
-  memory_region_info.SetMapped(MemoryRegionInfo::OptionalBool::eYes);
-
-  // Parse out each permission entry.
-  if (line_extractor.GetBytesLeft() < 4)
-return Status("malformed /proc/{pid}/maps entry, missing some portion of "
-  "permissions");
-
-  // Handle read permission.
-  const char read_perm_char = line_extractor.GetChar();
-  if (read_perm_char == 'r')
-memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (read_perm_char == '-')
-memory_region_info.SetReadable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps read permission char");
-
-  // Handle write permission.
-  const char write_perm_char = line_extractor.GetChar();
-  if (write_perm_char == 'w')
-memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (write_perm_char == '-')
-memory_region_info.SetWritable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps write permission char");
-
-  // Handle execute permission.
-  const char exec_perm_char = line_extractor.GetChar();
-  if (exec_perm_char == 'x')
-memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eYes);
-  else if (exec_perm_char == '-')
-memory_region_info.SetExecutable(MemoryRegionInfo::OptionalBool::eNo);
-  else
-return Status("unexpected /proc/{pid}/maps exec permission char");
-
-  line_extractor.GetChar();  // Read the private bit
-  line_extractor.SkipSpaces();   // Skip the separator
-  line_extractor.GetHexMaxU64(false, 0); // Read the offset
-  line_extractor.GetHexMaxU64(false, 0); // Read the major device number
-  line_extractor.GetChar();  // Read the device id separator
-  line_extractor.GetHexMaxU64(false, 0); // Read the major device number
-  line_extractor.SkipSpaces();   // Skip the separator
-  line_extractor.GetU64(0, 10);  // Read the inode number
-
-  line_extractor.SkipSpaces();
-  const char *name = line_extractor.Peek();
-  if (name)
-memory_region_info.SetName(name);
-
-  return Status();
-}
-
 Status NativeProcessLinux::GetMemoryRegionInfo(lldb::addr_t load_addr,
MemoryRegionInfo &range_info) {
   // FIXME review that the final memory region returned extends to the end of
@@ -1401,23 +1318,23 @@ Status NativeProcessLinux::PopulateMemor
 m_supports_mem_region = LazyBool::eLazyBoolNo;
 return BufferOrError.getError();
   }
-  StringRef Rest = B

[Lldb-commits] [lldb] r349268 - ELF: more section creation cleanup

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:45:38 2018
New Revision: 349268

URL: http://llvm.org/viewvc/llvm-project?rev=349268&view=rev
Log:
ELF: more section creation cleanup

Summary:
This patch attempts to move as much code as possible out of the
CreateSections function to make room for future improvements there. Some
of this may be slightly over-engineered (VMAddressProvider), but I
wanted to keep the logic of this function very simple, because once I
start taking segment headers into acount (as discussed in D55356), the
function is going to grow significantly.

While in there, I also added tests for various bits of functionality.

This should be NFC, except that I changed the order of hac^H^Heuristicks
for determining section type slightly. Previously, name-based deduction
(.symtab -> symtab) would take precedence over type-based (SHT_SYMTAB ->
symtab) one. In fact we would assert if we ran into a .text section with
type SHT_SYMTAB. Though unlikely to matter in practice, this order
seemed wrong to me, so I have inverted it.

Reviewers: clayborg, krytarowski, espindola

Subscribers: emaste, arichardson, lldb-commits

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

Added:
lldb/trunk/lit/Modules/ELF/section-addresses.yaml
lldb/trunk/lit/Modules/ELF/section-permissions.yaml
lldb/trunk/lit/Modules/ELF/section-types-edgecases.yaml
Modified:
lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
lldb/trunk/lit/Modules/ELF/section-types.yaml
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/ELF/compressed-sections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/compressed-sections.yaml?rev=349268&r1=349267&r2=349268&view=diff
==
--- lldb/trunk/lit/Modules/ELF/compressed-sections.yaml (original)
+++ lldb/trunk/lit/Modules/ELF/compressed-sections.yaml Sat Dec 15 05:45:38 2018
@@ -19,15 +19,13 @@ Sections:
 
 # CHECK: Name: .hello_elf
 # CHECK-NEXT: Type: regular
-# CHECK-NEXT: Thread specific: no
-# CHECK-NEXT: VM size: 0
+# CHECK: VM size: 0
 # CHECK-NEXT: File size: 28
 # CHECK-NEXT: Data:
 # CHECK-NEXT: 20304050 60708090
 
 # CHECK: Name: .bogus
 # CHECK-NEXT: Type: regular
-# CHECK-NEXT: Thread specific: no
-# CHECK-NEXT: VM size: 0
+# CHECK: VM size: 0
 # CHECK-NEXT: File size: 8
 # CHECK-NEXT: Data: ()

Added: lldb/trunk/lit/Modules/ELF/section-addresses.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/section-addresses.yaml?rev=349268&view=auto
==
--- lldb/trunk/lit/Modules/ELF/section-addresses.yaml (added)
+++ lldb/trunk/lit/Modules/ELF/section-addresses.yaml Sat Dec 15 05:45:38 2018
@@ -0,0 +1,58 @@
+# RUN: yaml2obj %s > %t
+# RUN: lldb-test object-file %t | FileCheck %s
+
+# CHECK-LABEL: Name: .one
+# CHECK: VM address: 0x0
+
+# CHECK-LABEL: Name: .nonalloc
+# CHECK: VM address: 0x0
+
+# CHECK-LABEL: Name: .two
+# CHECK: VM address: 0x8
+
+# CHECK-LABEL: Name: .three
+# CHECK: VM address: 0xc
+
+# CHECK-LABEL: Name: .four
+# CHECK: VM address: 0xc
+
+# CHECK-LABEL: Name: .five
+# CHECK: VM address: 0x1000
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_REL
+  Machine: EM_X86_64
+  Entry:   0x07A0
+Sections:
+  - Name:.one
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.nonalloc
+Type:SHT_PROGBITS
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.two
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DE
+  - Name:.three
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+  - Name:.four
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x0004
+Content: DEADBEEFBAADF00D
+  - Name:.five
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC ]
+AddressAlign:0x1000
+Content: DEADBEEFBAADF00D
+...

Added: lldb/trunk/lit/Modules/ELF/section-permissions.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/section-permissions.yaml?rev=349268&view=auto
==
--- lldb/trunk/lit/Modules/ELF/section-permissions.yaml (added)
+++ lldb/trunk/lit/Modules/ELF/section-permissions.yaml Sat Dec 15 05:45:38 2018
@@ -0,0 +1,34 @@
+# RUN

[Lldb-commits] [lldb] r349269 - lldb-test: Improve newline handling

2018-12-15 Thread Pavel Labath via lldb-commits
Author: labath
Date: Sat Dec 15 05:49:25 2018
New Revision: 349269

URL: http://llvm.org/viewvc/llvm-project?rev=349269&view=rev
Log:
lldb-test: Improve newline handling

Summary:
Previously lldb-test's LinePrinter would output the indentation spaces
even on completely empty lines. This is not nice, as trailing spaces get
flagged as errors in some tools/editors, and it prevents FileCheck's
CHECK-EMPTY from working.

Equally annoying was the fact that the LinePrinter did not terminate
it's output with a newline (instead it would leave the unterminated hanging
indent from the last NewLine() command), which meant that the shell prompt
following the lldb-test command came out wrong.

This fixes both issues by changing how newlines are handled. NewLine(),
which was ending the previous line ('\n') *and* begging the next line by
printing the indent, is now "demoted" to just printing literal "\n".
Instead, lines are now delimited via a helper Line object, which makes
sure the line is indented and terminated in an RAII fashion. The typical
usage would be:
Printer.line() << "This text will be indented and terminated";
If one needs to do more work than it will fit into a single statement,
one can also assign the result of the line() function to a local
variable. The line will then be terminated when that object goes out of
scope.

Reviewers: zturner

Subscribers: lldb-commits

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

Modified:
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/tools/lldb-test/FormatUtil.cpp
lldb/trunk/tools/lldb-test/FormatUtil.h

Modified: lldb/trunk/lit/Modules/MachO/subsections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/subsections.yaml?rev=349269&r1=349268&r2=349269&view=diff
==
--- lldb/trunk/lit/Modules/MachO/subsections.yaml (original)
+++ lldb/trunk/lit/Modules/MachO/subsections.yaml Sat Dec 15 05:49:25 2018
@@ -11,8 +11,8 @@
 #CHECK-NEXT:  VM size: 4294967296
 #CHECK-NEXT:  File size: 0
 #CHECK-NEXT:  There are no subsections
-#
-#CHECK:   Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:  Index: 1
 #CHECK-NEXT:  Name: __TEXT
 #CHECK-NEXT:  Type: container
 #CHECK-NEXT:  Permissions: r-x
@@ -29,8 +29,8 @@
 #CHECK-NEXT:VM address: 0x10f30
 #CHECK-NEXT:VM size: 22
 #CHECK-NEXT:File size: 22
-#
-#CHECK: Index: 1
+#CHECK-EMPTY:
+#CHECK-NEXT:Index: 1
 #CHECK-NEXT:Name: __unwind_info
 #CHECK-NEXT:Type: compact-unwind
 #CHECK-NEXT:Permissions: r-x
@@ -38,8 +38,8 @@
 #CHECK-NEXT:VM address: 0x10f48
 #CHECK-NEXT:VM size: 76
 #CHECK-NEXT:File size: 76
-#
-#CHECK: Index: 2
+#CHECK-EMPTY:
+#CHECK-NEXT:Index: 2
 #CHECK-NEXT:Name: __eh_frame
 #CHECK-NEXT:Type: eh-frame
 #CHECK-NEXT:Permissions: r-x

Modified: lldb/trunk/tools/lldb-test/FormatUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/FormatUtil.cpp?rev=349269&r1=349268&r2=349269&view=diff
==
--- lldb/trunk/tools/lldb-test/FormatUtil.cpp (original)
+++ lldb/trunk/tools/lldb-test/FormatUtil.cpp Sat Dec 15 05:49:25 2018
@@ -14,6 +14,11 @@
 using namespace lldb_private;
 using namespace llvm;
 
+LinePrinter::Line::~Line() {
+  if (P)
+P->NewLine();
+}
+
 LinePrinter::LinePrinter(int Indent, llvm::raw_ostream &Stream)
 : OS(Stream), IndentSpaces(Indent), CurrentIndent(0) {}
 
@@ -31,39 +36,31 @@ void LinePrinter::Unindent(uint32_t Amou
 
 void LinePrinter::NewLine() {
   OS << "\n";
-  OS.indent(CurrentIndent);
-}
-
-void LinePrinter::print(const Twine &T) { OS << T; }
-
-void LinePrinter::printLine(const Twine &T) {
-  NewLine();
-  OS << T;
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  OS << format_bytes_with_ascii(Data, StartOffset, 32, 4,
+CurrentIndent + IndentSpaces, true);
+  NewLine();
+  line() << ")";
 }
 
 void LinePrinter::formatBinary(StringRef Label, ArrayRef Data,
uint64_t Base, uint32_t StartOffset) {
-  NewLine();
-  OS << Label << " (";
-  if (!Data.empty()) {
-OS << "\n";
-Base += StartOffset;
-OS << format_bytes_with_ascii(Data, Base, 32, 4,
-  CurrentIndent + IndentSpaces, true);
-NewLine();
+  if (Data.empty()) {
+line() << Label << " ()";
+return;
   }
-  OS << ")";
+  line() << Label << " (";
+  Base += StartOffset;
+  OS << format_bytes_with_ascii(Data, Base, 32, 4, CurrentIn

Re: [Lldb-commits] [lldb] r349397 - Remove sleep() synchronisation from teststcase and

2018-12-18 Thread Pavel Labath via lldb-commits
Not that I want to defend the use of sleep, but my expectation  is that 
this will the test even more flaky.


The only thing that test does after attaching is verifying the process 
backtrace to check that it contains the "main" function. If the test 
doesn't sleep, it increases the likelyhood that you will attach before 
it even enters the main function. This may be particularly true on 
linux, where the process needs to invoke a special api (PR_SET_TRACER) 
before we can attach to it, and so the even the attach will fail if it's 
done too early.


One of the patterns for synchronization we have in other tests is to 
have the inferior create a file when it reaches the "safe to attach" 
point. The test then waits for this file to appear 
(lldbutil.wait_for_file_on_target) before proceeding. This still uses 
sleep() under the hood, but only because we don't have/don't want to 
implement a wait_for_file blocking api. In the end it still provides a 
more predictable state of the process we attach to.


On 17/12/2018 22:18, Adrian Prantl via lldb-commits wrote:

Author: adrian
Date: Mon Dec 17 13:18:11 2018
New Revision: 349397

URL: http://llvm.org/viewvc/llvm-project?rev=349397&view=rev
Log:
Remove sleep() synchronisation from teststcase and
make the executable name more unique.

This test is failing sporadically on some bots. By removing the sleep
synchronisation, I'm hoping to get it to fail more reproducibly so I
can investigate what is going on.

Modified:
 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py?rev=349397&r1=349396&r2=349397&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py
 Mon Dec 17 13:18:11 2018
@@ -35,7 +35,7 @@ class HelloWorldTestCase(TestBase):
  def test_with_process_launch_api(self):
  """Create target, breakpoint, launch a process, and then kill it."""
  # Get the full path to our executable to be attached/debugged.
-exe = self.getBuildArtifact(self.testMethodName)
+exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
  d = {'EXE': exe}
  self.build(dictionary=d)
  self.setTearDownCleanup(dictionary=d)
@@ -82,7 +82,7 @@ class HelloWorldTestCase(TestBase):
  @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], 
bugnumber="") # old lldb-server has race condition, 
launching an inferior and then launching debugserver in quick succession sometimes fails
  def test_with_attach_to_process_with_id_api(self):
  """Create target, spawn a process, and attach to it with process 
id."""
-exe = self.getBuildArtifact(self.testMethodName)
+exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
  d = {'EXE': exe}
  self.build(dictionary=d)
  self.setTearDownCleanup(dictionary=d)
@@ -92,9 +92,6 @@ class HelloWorldTestCase(TestBase):
  popen = self.spawnSubprocess(exe, ["abc", "xyz"])
  self.addTearDownHook(self.cleanupSubprocesses)
  
-# Give the subprocess time to start and wait for user input

-time.sleep(0.25)
-
  listener = lldb.SBListener("my.attach.listener")
  error = lldb.SBError()
  process = target.AttachToProcessWithID(listener, popen.pid, error)
@@ -114,7 +111,7 @@ class HelloWorldTestCase(TestBase):
  @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], 
bugnumber="") # old lldb-server has race condition, 
launching an inferior and then launching debugserver in quick succession sometimes fails
  def test_with_attach_to_process_with_name_api(self):
  """Create target, spawn a process, and attach to it with process 
name."""
-exe = self.getBuildArtifact(self.testMethodName)
+exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
  d = {'EXE': exe}
  self.build(dictionary=d)
  self.setTearDownCleanup(dictionary=d)
@@ -124,9 +121,6 @@ class HelloWorldTestCase(TestBase):
  popen = self.spawnSubprocess(exe, ["abc", "xyz"])
  self.addTearDownHook(self.cleanupSubprocesses)
  
-# Give the subprocess time to start and wait for user input

-time.sleep(0.25)
-
  listener = lldb.SBListener("my.attach.listener")
  error = lldb.SBError()
  # Pass 'False' since we don't want to wait for new instance of


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




[Lldb-commits] [lldb] r349461 - build.py: inherit environment in the gcc builder

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 01:07:21 2018
New Revision: 349461

URL: http://llvm.org/viewvc/llvm-project?rev=349461&view=rev
Log:
build.py: inherit environment in the gcc builder

Summary:
This should enable the compiler to find the system linker for the link
step.

Reviewers: stella.stamenova, zturner

Subscribers: lldb-commits

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

Modified:
lldb/trunk/lit/helper/build.py

Modified: lldb/trunk/lit/helper/build.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/helper/build.py?rev=349461&r1=349460&r2=349461&view=diff
==
--- lldb/trunk/lit/helper/build.py (original)
+++ lldb/trunk/lit/helper/build.py Tue Dec 18 01:07:21 2018
@@ -153,6 +153,9 @@ def format_text(lines, indent_0, indent_
 return result
 
 def print_environment(env):
+if env is None:
+print('Inherited')
+return
 for e in env:
 value = env[e]
 lines = value.split(os.pathsep)
@@ -633,7 +636,7 @@ class GccBuilder(Builder):
 args.extend(['-o', obj])
 args.append(source)
 
-return ('compiling', [source], obj, {}, args)
+return ('compiling', [source], obj, None, args)
 
 def _get_link_command(self):
 args = []
@@ -649,7 +652,7 @@ class GccBuilder(Builder):
 args.extend(['-o', self._exe_file_name()])
 args.extend(self._obj_file_names())
 
-return ('linking', self._obj_file_names(), self._exe_file_name(), {}, 
args)
+return ('linking', self._obj_file_names(), self._exe_file_name(), 
None, args)
 
 
 def output_files(self):


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


[Lldb-commits] [lldb] r349478 - Un-XFAIL TestNamespaceLookup for linux

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 04:55:30 2018
New Revision: 349478

URL: http://llvm.org/viewvc/llvm-project?rev=349478&view=rev
Log:
Un-XFAIL TestNamespaceLookup for linux

These tests are now passing on linux, at least with top-of-tree clang,
clang-6 and gcc-7.3. It's possible it may still be failing with some
older compilers, but I don't have those around to test.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py?rev=349478&r1=349477&r2=349478&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/namespace/TestNamespaceLookup.py
 Tue Dec 18 04:55:30 2018
@@ -42,10 +42,7 @@ class NamespaceLookupTestCase(TestBase):
  'stop reason = breakpoint'])
 
 @expectedFailureAll(
-oslist=[
-"windows",
-"linux",
-"freebsd"],
+oslist=["windows", "freebsd"],
 bugnumber="llvm.org/pr25819")
 def test_scope_lookup_with_run_command(self):
 """Test scope lookup of functions in lldb."""
@@ -230,10 +227,7 @@ class NamespaceLookupTestCase(TestBase):
 oslist=["linux"],
 debug_info=["dwo"])  # Skip to avoid crash
 @expectedFailureAll(
-oslist=[
-"windows",
-"linux",
-"freebsd"],
+oslist=["windows", "freebsd"],
 bugnumber="llvm.org/pr25819")
 def test_scope_after_using_directive_lookup_with_run_command(self):
 """Test scope lookup after using directive in lldb."""
@@ -297,10 +291,7 @@ class NamespaceLookupTestCase(TestBase):
 self.expect("expr -- func()", startstr="error")
 
 @expectedFailureAll(
-oslist=[
-"windows",
-"linux",
-"freebsd"],
+oslist=["windows", "freebsd"],
 bugnumber="llvm.org/pr25819")
 def test_scope_lookup_shadowed_by_using_with_run_command(self):
 """Test scope lookup shadowed by using in lldb."""


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


[Lldb-commits] [lldb] r349479 - Un-XFAIL TestExitDuringBreak.py for linux

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 05:12:36 2018
New Revision: 349479

URL: http://llvm.org/viewvc/llvm-project?rev=349479&view=rev
Log:
Un-XFAIL TestExitDuringBreak.py for linux

This test is passing now on linux, and probably has been passing since
r282993.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py?rev=349479&r1=349478&r2=349479&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
 Tue Dec 18 05:12:36 2018
@@ -23,9 +23,6 @@ class ExitDuringBreakpointTestCase(TestB
 # Find the line number for our breakpoint.
 self.breakpoint = line_number('main.cpp', '// Set breakpoint here')
 
-@expectedFailureAll(
-oslist=["linux"],
-bugnumber="llvm.org/pr15824 thread states not properly maintained")
 def test(self):
 """Test thread exit during breakpoint handling."""
 self.build(dictionary=self.getBuildFlags())


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


[Lldb-commits] [lldb] r349482 - Un-XFail TestThreadStates.test_process_interrupt

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 05:32:42 2018
New Revision: 349482

URL: http://llvm.org/viewvc/llvm-project?rev=349482&view=rev
Log:
Un-XFail TestThreadStates.test_process_interrupt

This test is passing now on linux. The same test is claimed to be flaky
on darwin, so it's possible that's true on linux too. If that's the case
we'll have to skip it here too (or fix it).

I mark the test as not-debug-info-dependent as a drive-by.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py?rev=349482&r1=349481&r2=349482&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
 Tue Dec 18 05:32:42 2018
@@ -52,17 +52,6 @@ class ThreadStateTestCase(TestBase):
 self.thread_state_after_expression_test()
 
 # thread states not properly maintained
-@unittest2.expectedFailure("llvm.org/pr16712")
-@expectedFailureAll(
-oslist=["windows"],
-bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
-@skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and 

-def test_process_interrupt(self):
-"""Test process interrupt."""
-self.build(dictionary=self.getBuildFlags(use_cpp11=False))
-self.process_interrupt_test()
-
-# thread states not properly maintained
 @unittest2.expectedFailure("llvm.org/pr15824 and 
")
 @expectedFailureAll(
 oslist=["windows"],
@@ -198,8 +187,14 @@ class ThreadStateTestCase(TestBase):
 # Let the process run to completion
 self.runCmd("process continue")
 
-def process_interrupt_test(self):
+@expectedFailureAll(
+oslist=["windows"],
+bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly")
+@skipIfDarwin # llvm.org/pr15824 thread states not properly maintained and 

+@no_debug_info_test
+def test_process_interrupt(self):
 """Test process interrupt and continue."""
+self.build(dictionary=self.getBuildFlags(use_cpp11=False))
 exe = self.getBuildArtifact("a.out")
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 


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


[Lldb-commits] [lldb] r349485 - Un-XFail TestYMMRegister on linux

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 05:50:38 2018
New Revision: 349485

URL: http://llvm.org/viewvc/llvm-project?rev=349485&view=rev
Log:
Un-XFail TestYMMRegister on linux

This test was disabled in r326756 as a part of "upstreaming debugserver
support for AVX-512 (zmm register set)". This looks like an error
because both register set and remote stubs are different.

In any case, the test passes now.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py?rev=349485&r1=349484&r2=349485&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/register/intel_avx/TestYMMRegister.py
 Tue Dec 18 05:50:38 2018
@@ -21,7 +21,6 @@ class TestYMMRegister(TestBase):
 @skipIfiOSSimulator
 @skipIfTargetAndroid()
 @skipIf(archs=no_match(['i386', 'x86_64']))
-@expectedFailureAll(oslist=["linux"], bugnumber="rdar://30523153")
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr37995")
 def test(self):
 self.build(dictionary={"CFLAGS_EXTRAS": "-march=haswell"})


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


[Lldb-commits] [lldb] r349487 - Skip TestMultithreaded.test_sb_api_listener_resume on linux

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 06:24:55 2018
New Revision: 349487

URL: http://llvm.org/viewvc/llvm-project?rev=349487&view=rev
Log:
Skip TestMultithreaded.test_sb_api_listener_resume on linux

The test still fails occasionally (1/100 runs). Upgrade the xfail to
skip.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py?rev=349487&r1=349486&r2=349487&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
 Tue Dec 18 06:24:55 2018
@@ -68,7 +68,7 @@ class SBBreakpointCallbackCase(TestBase)
 # clang-cl does not support throw or catch (llvm.org/pr24538)
 @skipIfWindows
 @expectedFlakeyFreeBSD
-@expectedFailureAll(oslist=["linux"])
+@skipIf(oslist=["linux"]) # flakey
 def test_sb_api_listener_resume(self):
 """ Test that a process can be resumed from a non-main thread. """
 self.build_and_test(


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


[Lldb-commits] [lldb] r349491 - de-flake TestThreadStates.test_process_interrupt

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 07:15:02 2018
New Revision: 349491

URL: http://llvm.org/viewvc/llvm-project?rev=349491&view=rev
Log:
de-flake TestThreadStates.test_process_interrupt

the "self.assertEqual(thread.GetStopReason(), lldb.eStopReasonSignal)"
was occasionally failing because the stop reason would come out as
"trace" this happened if we issued the interrupt just as the processed
stopped due to single-stepping over the breakpoint (i.e., the it was not
necessary to send any signal).

Fix this by removing the breakpoint before resuming the process. This
ensures the process can run unobstructed.

After this, the test passed 200 consecutive runs successfully for me,
even while the system was under heavy load.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py?rev=349491&r1=349490&r2=349491&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
 Tue Dec 18 07:15:02 2018
@@ -199,7 +199,7 @@ class ThreadStateTestCase(TestBase):
 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
 # This should create a breakpoint in the main thread.
-lldbutil.run_break_set_by_file_and_line(
+bpno = lldbutil.run_break_set_by_file_and_line(
 self, "main.cpp", self.break_1, num_expected_locations=1)
 
 # Run the program.
@@ -213,6 +213,10 @@ class ThreadStateTestCase(TestBase):
 process, lldb.eStopReasonBreakpoint)
 self.assertIsNotNone(thread)
 
+# Remove the breakpoint to avoid the single-step-over-bkpt dance in the
+# "continue" below
+self.assertTrue(target.BreakpointDelete(bpno))
+
 # Continue, the inferior will go into an infinite loop waiting for
 # 'g_test' to change.
 self.dbg.SetAsync(True)


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


[Lldb-commits] [lldb] r349495 - Fix the "dangerous use of tempnam" warning in Host/SocketTest.cpp

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 07:33:50 2018
New Revision: 349495

URL: http://llvm.org/viewvc/llvm-project?rev=349495&view=rev
Log:
Fix the "dangerous use of tempnam" warning in Host/SocketTest.cpp

instead, create a unique temporary directory, and place the socket file
there.

Modified:
lldb/trunk/unittests/Host/SocketTest.cpp

Modified: lldb/trunk/unittests/Host/SocketTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/SocketTest.cpp?rev=349495&r1=349494&r2=349495&view=diff
==
--- lldb/trunk/unittests/Host/SocketTest.cpp (original)
+++ lldb/trunk/unittests/Host/SocketTest.cpp Tue Dec 18 07:33:50 2018
@@ -17,6 +17,8 @@
 #include "lldb/Host/Socket.h"
 #include "lldb/Host/common/TCPSocket.h"
 #include "lldb/Host/common/UDPSocket.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 
 #ifndef LLDB_DISABLE_POSIX
 #include "lldb/Host/posix/DomainSocket.h"
@@ -41,7 +43,6 @@ public:
 
 protected:
   static void AcceptThread(Socket *listen_socket,
-   const char *listen_remote_address,
bool child_processes_inherit, Socket 
**accept_socket,
Status *error) {
 *error = listen_socket->Accept(*accept_socket);
@@ -49,7 +50,7 @@ protected:
 
   template 
   void CreateConnectedSockets(
-  const char *listen_remote_address,
+  llvm::StringRef listen_remote_address,
   const std::function &get_connect_addr,
   std::unique_ptr *a_up, std::unique_ptr *b_up) {
 bool child_processes_inherit = false;
@@ -64,8 +65,8 @@ protected:
 Status accept_error;
 Socket *accept_socket;
 std::thread accept_thread(AcceptThread, listen_socket_up.get(),
-  listen_remote_address, child_processes_inherit,
-  &accept_socket, &accept_error);
+  child_processes_inherit, &accept_socket,
+  &accept_error);
 
 std::string connect_remote_address = get_connect_addr(*listen_socket_up);
 std::unique_ptr connect_socket_up(
@@ -158,15 +159,15 @@ TEST_F(SocketTest, DecodeHostAndPort) {
 
 #ifndef LLDB_DISABLE_POSIX
 TEST_F(SocketTest, DomainListenConnectAccept) {
-  char *file_name_str = tempnam(nullptr, nullptr);
-  EXPECT_NE(nullptr, file_name_str);
-  const std::string file_name(file_name_str);
-  free(file_name_str);
+  llvm::SmallString<64> Path;
+  std::error_code EC = 
llvm::sys::fs::createUniqueDirectory("DomainListenConnectAccept", Path);
+  ASSERT_FALSE(EC);
+  llvm::sys::path::append(Path, "test");
 
   std::unique_ptr socket_a_up;
   std::unique_ptr socket_b_up;
   CreateConnectedSockets(
-  file_name.c_str(), [=](const DomainSocket &) { return file_name; },
+  Path, [=](const DomainSocket &) { return Path.str().str(); },
   &socket_a_up, &socket_b_up);
 }
 #endif


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


Re: [Lldb-commits] [lldb] r349401 - [lit] Detect unexpected passes in lldbtest.

2018-12-18 Thread Pavel Labath via lldb-commits

On 17/12/2018 22:40, Jonas Devlieghere via lldb-commits wrote:

Author: jdevlieghere
Date: Mon Dec 17 13:40:37 2018
New Revision: 349401

URL: http://llvm.org/viewvc/llvm-project?rev=349401&view=rev
Log:
[lit] Detect unexpected passes in lldbtest.

This patch will have lit report unexpected passes when dotest reports at
least one XPASS and no failures.

Modified:
 lldb/trunk/lit/Suite/lldbtest.py

Modified: lldb/trunk/lit/Suite/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Suite/lldbtest.py?rev=349401&r1=349400&r2=349401&view=diff
==
--- lldb/trunk/lit/Suite/lldbtest.py (original)
+++ lldb/trunk/lit/Suite/lldbtest.py Mon Dec 17 13:40:37 2018
@@ -96,6 +96,10 @@ class LLDBTest(TestFormat):
  if exitCode:
  return lit.Test.FAIL, out + err
  
+unexpected_test_line = 'XPASS'

+if unexpected_test_line in out or unexpected_test_line in err:
+return lit.Test.XPASS, ''
+
  passing_test_line = 'RESULT: PASSED'
  if passing_test_line not in out and passing_test_line not in err:
  msg = ('Unable to find %r in dotest output:\n\n%s%s' %


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



It would be nice to have some notice before changes like this are 
implemented. I mean, I know there was some talk of this in the past, but 
that was months ago, so it wasn't really clear if/when is that going to 
happen. It didn't take me too long to clean up the remaining unexpected 
passes on my test configuration (and I found some pretty interesting 
things while doing that, for which I am grateful), but I am not sure 
this will be so simple for everyone.


The other issue I have with this patch is that it creates a rift between 
how lit evaluates test results and how dotest does it (I don't know how 
you guys do this, but I still run dotest manually when I want to zero in 
on a single test failure). Now it can happen that someone runs 
"check-lldb", it reports a failure (unexpected success), and when the 
person runs the single test via dotest, it happily reports that 
everything is alright.


I think it would be better to first teach dotest to treat "unexpected 
successes" as a "bad" result (i.e., to exit with non-zero exit code). 
Then, we can play around with how to convert that result into lit test 
states


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


[Lldb-commits] [lldb] r349498 - ELF: Don't create sections for section header index 0

2018-12-18 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Dec 18 07:56:45 2018
New Revision: 349498

URL: http://llvm.org/viewvc/llvm-project?rev=349498&view=rev
Log:
ELF: Don't create sections for section header index 0

Summary:
The first section header does not define a real section. Instead it is
used for various elf extensions. This patch skips creation of a section
for index 0.

This has one furtunate side-effect, in that it allows us to use the section
header index as the Section ID (where 0 is also invalid). This way, we
can get rid of a lot of spurious +1s in the ObjectFileELF code.

Reviewers: clayborg, krytarowski, joerg, espindola

Subscribers: emaste, lldb-commits, arichardson

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

Modified:
lldb/trunk/lit/Modules/ELF/many-sections.s
lldb/trunk/lit/Modules/MachO/subsections.yaml
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/lit/Modules/ELF/many-sections.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/ELF/many-sections.s?rev=349498&r1=349497&r2=349498&view=diff
==
--- lldb/trunk/lit/Modules/ELF/many-sections.s (original)
+++ lldb/trunk/lit/Modules/ELF/many-sections.s Tue Dec 18 07:56:45 2018
@@ -7,7 +7,7 @@
 ## .., plus a couple of standard ones (.strtab, etc.)
 ## Check the number is correct plus the names of a couple of chosen sections.
 
-# CHECK: Showing 65541 sections
+# CHECK: Showing 65540 sections
 # CHECK: Name: 
 # CHECK: Name: 
 # CHECK: Name: 

Modified: lldb/trunk/lit/Modules/MachO/subsections.yaml
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/MachO/subsections.yaml?rev=349498&r1=349497&r2=349498&view=diff
==
--- lldb/trunk/lit/Modules/MachO/subsections.yaml (original)
+++ lldb/trunk/lit/Modules/MachO/subsections.yaml Tue Dec 18 07:56:45 2018
@@ -3,6 +3,7 @@
 
 #CHECK: Showing 2 sections
 #CHECK-NEXT:  Index: 0
+#CHECK-NEXT:  ID: 0x100
 #CHECK-NEXT:  Name: __PAGEZERO
 #CHECK-NEXT:  Type: container
 #CHECK-NEXT:  Permissions: ---
@@ -13,6 +14,7 @@
 #CHECK-NEXT:  There are no subsections
 #CHECK-EMPTY:
 #CHECK-NEXT:  Index: 1
+#CHECK-NEXT:  ID: 0x200
 #CHECK-NEXT:  Name: __TEXT
 #CHECK-NEXT:  Type: container
 #CHECK-NEXT:  Permissions: r-x
@@ -22,6 +24,7 @@
 #CHECK-NEXT:  File size: 4096
 #CHECK-NEXT:  Showing 3 subsections
 #CHECK-NEXT:Index: 0
+#CHECK-NEXT:ID: 0x1
 #CHECK-NEXT:Name: __text
 #CHECK-NEXT:Type: code
 #CHECK-NEXT:Permissions: r-x
@@ -31,6 +34,7 @@
 #CHECK-NEXT:File size: 22
 #CHECK-EMPTY:
 #CHECK-NEXT:Index: 1
+#CHECK-NEXT:ID: 0x2
 #CHECK-NEXT:Name: __unwind_info
 #CHECK-NEXT:Type: compact-unwind
 #CHECK-NEXT:Permissions: r-x
@@ -40,6 +44,7 @@
 #CHECK-NEXT:File size: 76
 #CHECK-EMPTY:
 #CHECK-NEXT:Index: 2
+#CHECK-NEXT:ID: 0x3
 #CHECK-NEXT:Name: __eh_frame
 #CHECK-NEXT:Type: eh-frame
 #CHECK-NEXT:Permissions: r-x

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=349498&r1=349497&r2=349498&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Dec 18 
07:56:45 2018
@@ -889,11 +889,11 @@ AddressClass ObjectFileELF::GetAddressCl
 }
 
 size_t ObjectFileELF::SectionIndex(const SectionHeaderCollIter &I) {
-  return std::distance(m_section_headers.begin(), I) + 1u;
+  return std::distance(m_section_headers.begin(), I);
 }
 
 size_t ObjectFileELF::SectionIndex(const SectionHeaderCollConstIter &I) const {
-  return std::distance(m_section_headers.begin(), I) + 1u;
+  return std::distance(m_section_headers.begin(), I);
 }
 
 bool ObjectFileELF::ParseHeader() {
@@ -1081,7 +1081,7 @@ size_t ObjectFileELF::ParseDependentModu
 return 0;
   // sh_link: section header index of string table used by entries in the
   // section.
-  Section *dynstr = section_list->FindSectionByID(header->sh_link + 1).get();
+  Section *dynstr = section_list->FindSectionByID(header->sh_link).get();
   if (!dynstr)
 return 0;
 
@@ -1717,10 +1717,10 @@ size_t ObjectFileELF::ParseSectionHeader
 
 const ObjectFileELF::ELFSectionHeaderInfo *
 ObjectFileELF::GetSectionHeaderByIndex(lldb::user_id_t id) {
-  if (!id || !ParseSectionHeaders())
+  if (!ParseSectionHeaders())
 return NULL;
 
-  if (--id < m_section_headers.size())
+  if (id < m_section_headers.size())
 return &m_section_headers[id];
 
   return NULL;
@@ -1853,7 +1853,7 @@ void ObjectFileELF::CreateSections(Secti
 m_sections_ap.reset(new SectionList());
 
 VMAddressPr

[Lldb-commits] [lldb] r350086 - DWARF: Fix a bug in array size computation

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 01:25:34 2018
New Revision: 350086

URL: http://llvm.org/viewvc/llvm-project?rev=350086&view=rev
Log:
DWARF: Fix a bug in array size computation

Summary:
r346165 introduced a bug, where we would fail to parse the size of an
array if that size happened to match an existing die offset.

The logic was:
if (DWARFDIE count = die.GetReferencedDie(DW_AT_count))
  num_elements = compute_vla_size(count);
else
  num_elements = die.GetUsigned(DW_AT_count); // a fixed-size array

The problem with this logic was that GetReferencedDie did not take the
form class of the attribute into account, and would happily return a die
reference for any form, if its value happened to match some die.

As this behavior is inconsistent with how llvm's DWARFFormValue class
operates, I chose to fix the problem by making our version of this class
match the llvm behavior. For this to work, I had to add an explicit form
class check to the .apple_XXX tables parsing code, because they do
(incorrectly?) use data forms as die references.

Reviewers: aprantl, clayborg

Subscribers: JDevlieghere, lldb-commits

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

Added:
lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s
Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp

Added: lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s?rev=350086&view=auto
==
--- lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s (added)
+++ lldb/trunk/lit/SymbolFile/DWARF/array-sizes.s Thu Dec 27 01:25:34 2018
@@ -0,0 +1,147 @@
+# This tests a bug where we would incorrectly parse the size of an array if 
that
+# size happened to match an existing DIE offset. This happened because we
+# misinterpreted that value as a reference to a DIE specifying the VLA size 
even
+# though the form was a data form (as it should be).
+
+# REQUIRES: lld
+
+# RUN: llvm-mc -triple x86_64-pc-linux %s -filetype=obj > %t.o
+# RUN: ld.lld %t.o -o %t
+# RUN: lldb-test symbols %t | FileCheck %s
+
+# CHECK: Variable{0x001e}, name = "X"
+# CHECK-SAME: type = {0033} 0x{{[0-9a-f]*}} (char [56])
+
+
+# Generated from "char X[47];"
+# The array size was modified by hand.
+
+   .text
+   .file   "-"
+   .file   1 "/tmp" ""
+   .type   X,@object   # @X
+   .comm   X,63,16
+   .section.debug_str,"MS",@progbits,1
+.Linfo_string0:
+   .asciz  "clang version 8.0.0 (trunk 349604) (llvm/trunk 349608)" # 
string offset=0
+.Linfo_string1:
+   .asciz  "-" # string offset=55
+.Linfo_string2:
+   .asciz  "/tmp"  # string offset=57
+.Linfo_string3:
+   .asciz  "X" # string offset=62
+.Linfo_string4:
+   .asciz  "char"  # string offset=64
+.Linfo_string5:
+   .asciz  "__ARRAY_SIZE_TYPE__"   # string offset=69
+   .section.debug_abbrev,"",@progbits
+   .byte   1   # Abbreviation Code
+   .byte   17  # DW_TAG_compile_unit
+   .byte   1   # DW_CHILDREN_yes
+   .byte   37  # DW_AT_producer
+   .byte   14  # DW_FORM_strp
+   .byte   19  # DW_AT_language
+   .byte   5   # DW_FORM_data2
+   .byte   3   # DW_AT_name
+   .byte   14  # DW_FORM_strp
+   .byte   16  # DW_AT_stmt_list
+   .byte   23  # DW_FORM_sec_offset
+   .byte   27  # DW_AT_comp_dir
+   .byte   14  # DW_FORM_strp
+   .byte   0   # EOM(1)
+   .byte   0   # EOM(2)
+   .byte   2   # Abbreviation Code
+   .byte   52  # DW_TAG_variable
+   .byte   0   # DW_CHILDREN_no
+   .byte   3   # DW_AT_name
+   .byte   14  # DW_FORM_strp
+   .byte   73  # DW_AT_type
+   .byte   19  # DW_FORM_ref4
+   .byte   63  # DW_AT_external
+   .byte   25  # DW_FORM_flag_present
+   .byte   58  # DW_AT_decl_file
+   .byte   11  # DW_FORM_data1
+   .byte   59  # DW_AT_decl_line
+   .byte   11  # DW_FORM_data1
+   .byte   2   # DW_AT_location
+   .byte   24  # DW_FORM_exprloc
+   .byte   0   # EOM(1)
+   .byte   0   # EOM(2)
+   .byte   3   # Abbreviation Code
+  

[Lldb-commits] [lldb] r350087 - lldb-test ir-memory-map: Use IntervalMap::contains

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 01:32:04 2018
New Revision: 350087

URL: http://llvm.org/viewvc/llvm-project?rev=350087&view=rev
Log:
lldb-test ir-memory-map: Use IntervalMap::contains

Summary:
Simplify the code by using the contains implementation in IntervalMap.

There is a slight change of behavior here: We now treat an allocation of
size 0, as if it was size 1. This guarantees that the returned addresses
will be unique, whereas previously we would allow the allocation
function to return the same zero-sized region multiple times, as long as
it is not null, and not in the middle of an existing interval (but the
situation when we were placing an larger interval over a zero-sized one
was not detected).

I think this behavior makes more sense, as that is pretty much the same
guarantee as offered by malloc (except that is permitted to also return
nullptr).

Reviewers: vsk

Subscribers: lldb-commits

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

Modified:
lldb/trunk/tools/lldb-test/lldb-test.cpp

Modified: lldb/trunk/tools/lldb-test/lldb-test.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-test/lldb-test.cpp?rev=350087&r1=350086&r2=350087&view=diff
==
--- lldb/trunk/tools/lldb-test/lldb-test.cpp (original)
+++ lldb/trunk/tools/lldb-test/lldb-test.cpp Thu Dec 27 01:32:04 2018
@@ -209,7 +209,6 @@ struct IRMemoryMapTestState {
   : Target(Target), Map(Target), Allocations(IntervalMapAllocator) {}
 };
 
-bool areAllocationsOverlapping(const AllocationT &L, const AllocationT &R);
 bool evalMalloc(StringRef Line, IRMemoryMapTestState &State);
 bool evalFree(StringRef Line, IRMemoryMapTestState &State);
 int evaluateMemoryMapCommands(Debugger &Dbg);
@@ -808,13 +807,6 @@ static int dumpObjectFiles(Debugger &Dbg
   return HadErrors;
 }
 
-/// Check if two half-open intervals intersect:
-///   http://world.std.com/~swmcd/steven/tech/interval.html
-bool opts::irmemorymap::areAllocationsOverlapping(const AllocationT &L,
-  const AllocationT &R) {
-  return R.first < L.second && L.first < R.second;
-}
-
 bool opts::irmemorymap::evalMalloc(StringRef Line,
IRMemoryMapTestState &State) {
   // ::=  = malloc  
@@ -861,28 +853,21 @@ bool opts::irmemorymap::evalMalloc(Strin
 exit(1);
   }
 
-  // Check that the allocation does not overlap another allocation. Do so by
-  // testing each allocation which may cover the interval [Addr, EndOfRegion).
-  addr_t EndOfRegion = Addr + Size;
-  auto Probe = State.Allocations.begin();
-  Probe.advanceTo(Addr); //< First interval s.t stop >= Addr.
-  AllocationT NewAllocation = {Addr, EndOfRegion};
-  while (Probe != State.Allocations.end() && Probe.start() < EndOfRegion) {
-AllocationT ProbeAllocation = {Probe.start(), Probe.stop()};
-if (areAllocationsOverlapping(ProbeAllocation, NewAllocation)) {
-  outs() << "Malloc error: overlapping allocation detected"
- << formatv(", previous allocation at [{0:x}, {1:x})\n",
-Probe.start(), Probe.stop());
-  exit(1);
-}
-++Probe;
+  // In case of Size == 0, we still expect the returned address to be unique 
and
+  // non-overlapping.
+  addr_t EndOfRegion = Addr + std::max(Size, 1);
+  if (State.Allocations.overlaps(Addr, EndOfRegion)) {
+auto I = State.Allocations.find(Addr);
+outs() << "Malloc error: overlapping allocation detected"
+   << formatv(", previous allocation at [{0:x}, {1:x})\n", I.start(),
+  I.stop());
+exit(1);
   }
 
   // Insert the new allocation into the interval map. Use unique allocation
   // IDs to inhibit interval coalescing.
   static unsigned AllocationID = 0;
-  if (Size)
-State.Allocations.insert(Addr, EndOfRegion, AllocationID++);
+  State.Allocations.insert(Addr, EndOfRegion, AllocationID++);
 
   // Store the label -> address mapping.
   State.Label2AddrMap[Label] = Addr;


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


[Lldb-commits] [lldb] r350089 - Fix "default argument for lambda parameter" (-Wpedantic) warning

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 01:44:32 2018
New Revision: 350089

URL: http://llvm.org/viewvc/llvm-project?rev=350089&view=rev
Log:
Fix "default argument for lambda parameter" (-Wpedantic) warning

Modified:
lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp

Modified: lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp?rev=350089&r1=350088&r2=350089&view=diff
==
--- lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp (original)
+++ lldb/trunk/source/Plugins/Process/minidump/ProcessMinidump.cpp Thu Dec 27 
01:44:32 2018
@@ -579,7 +579,7 @@ public:
   s.Printf("\n");
 }
 auto DumpTextStream = [&](MinidumpStreamType stream_type,
-llvm::StringRef label = llvm::StringRef()) -> void {
+  llvm::StringRef label) -> void {
   auto bytes = minidump.GetStream(stream_type);
   if (!bytes.empty()) {
 if (label.empty())
@@ -588,7 +588,7 @@ public:
   }
 };
 auto DumpBinaryStream = [&](MinidumpStreamType stream_type,
-llvm::StringRef label = llvm::StringRef()) -> void {
+llvm::StringRef label) -> void {
   auto bytes = minidump.GetStream(stream_type);
   if (!bytes.empty()) {
 if (label.empty())


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


[Lldb-commits] [lldb] r350088 - Delete lldb_utility::Range

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 01:44:27 2018
New Revision: 350088

URL: http://llvm.org/viewvc/llvm-project?rev=350088&view=rev
Log:
Delete lldb_utility::Range

This class is unused, and there is already a lldb_private::Range
(defined in lldb/Core/RangeMap.h), which has similar functionality.

Removed:
lldb/trunk/include/lldb/Utility/Range.h
lldb/trunk/source/Utility/Range.cpp
Modified:
lldb/trunk/include/lldb/Target/MemoryRegionInfo.h
lldb/trunk/source/Utility/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Target/MemoryRegionInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/MemoryRegionInfo.h?rev=350088&r1=350087&r2=350088&view=diff
==
--- lldb/trunk/include/lldb/Target/MemoryRegionInfo.h (original)
+++ lldb/trunk/include/lldb/Target/MemoryRegionInfo.h Thu Dec 27 01:44:27 2018
@@ -14,7 +14,6 @@
 #include "lldb/Core/RangeMap.h"
 #include "llvm/Support/FormatProviders.h"
 #include "lldb/Utility/ConstString.h"
-#include "lldb/Utility/Range.h"
 
 namespace lldb_private {
 class MemoryRegionInfo {

Removed: lldb/trunk/include/lldb/Utility/Range.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Range.h?rev=350087&view=auto
==
--- lldb/trunk/include/lldb/Utility/Range.h (original)
+++ lldb/trunk/include/lldb/Utility/Range.h (removed)
@@ -1,60 +0,0 @@
-//===- Range.h --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#ifndef utility_Range_h_
-#define utility_Range_h_
-
-#include 
-
-namespace lldb_utility {
-
-class Range {
-public:
-  typedef uint64_t ValueType;
-
-  static const ValueType OPEN_END = UINT64_MAX;
-
-  Range(const Range &rng);
-
-  Range(ValueType low = 0, ValueType high = OPEN_END);
-
-  Range &operator=(const Range &rhs);
-
-  ValueType GetLow() { return m_low; }
-
-  ValueType GetHigh() { return m_high; }
-
-  void SetLow(ValueType low) { m_low = low; }
-
-  void SetHigh(ValueType high) { m_high = high; }
-
-  void Flip();
-
-  void Intersection(const Range &other);
-
-  void Union(const Range &other);
-
-  typedef bool (*RangeCallback)(ValueType index);
-
-  void Iterate(RangeCallback callback);
-
-  ValueType GetSize();
-
-  bool IsEmpty();
-
-private:
-  void InitRange();
-
-  ValueType m_low;
-  ValueType m_high;
-};
-
-} // namespace lldb_private
-
-#endif // #ifndef utility_Range_h_

Modified: lldb/trunk/source/Utility/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/CMakeLists.txt?rev=350088&r1=350087&r2=350088&view=diff
==
--- lldb/trunk/source/Utility/CMakeLists.txt (original)
+++ lldb/trunk/source/Utility/CMakeLists.txt Thu Dec 27 01:44:27 2018
@@ -63,7 +63,6 @@ add_lldb_library(lldbUtility
   Log.cpp
   Logging.cpp
   NameMatches.cpp
-  Range.cpp
   RegisterValue.cpp
   RegularExpression.cpp
   Reproducer.cpp

Removed: lldb/trunk/source/Utility/Range.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Range.cpp?rev=350087&view=auto
==
--- lldb/trunk/source/Utility/Range.cpp (original)
+++ lldb/trunk/source/Utility/Range.cpp (removed)
@@ -1,76 +0,0 @@
-//===- Range.cpp -*- 
C++-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "lldb/Utility/Range.h"
-
-#include 
-#include 
-
-using namespace lldb_utility;
-
-Range::Range(const Range &rng) : m_low(rng.m_low), m_high(rng.m_high) {
-  InitRange();
-}
-
-Range::Range(Range::ValueType low, Range::ValueType high)
-: m_low(low), m_high(high) {
-  InitRange();
-}
-
-void Range::InitRange() {
-  if (m_low == OPEN_END) {
-if (m_high == OPEN_END)
-  m_low = 0;
-else {
-  // make an empty range
-  m_low = 1;
-  m_high = 0;
-}
-  }
-}
-
-Range &Range::operator=(const Range &rhs) {
-  if (&rhs != this) {
-this->m_low = rhs.m_low;
-this->m_high = rhs.m_high;
-  }
-  return *this;
-}
-
-void Range::Flip() { std::swap(m_high, m_low); }
-
-void Range::Intersection(const Range &other) {
-  m_low = std::max(m_low, other.m_low);
-  m_high = std::min(m_high, other.m_high);
-}
-
-void Range::Union(const Range &other) {
-  m_low = std::min(m_low, other.m_low);
-  m_high = std::max(m_high, other.m_high);
-}
-
-void Range::Iterate(Rang

[Lldb-commits] [lldb] r350091 - Fix assertion failure in NativeProcessProtocolTest

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 05:45:55 2018
New Revision: 350091

URL: http://llvm.org/viewvc/llvm-project?rev=350091&view=rev
Log:
Fix assertion failure in NativeProcessProtocolTest

The assertion fired (with a debug visual studio STL) because we tried to
dereference the end of a vector (although it was only to take its
address again and form an end iterator). Rewrite this logic to avoid the
questionable code.

Modified:
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp?rev=350091&r1=350090&r2=350091&view=diff
==
--- lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp (original)
+++ lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Thu Dec 27 05:45:55 
2018
@@ -131,7 +131,8 @@ llvm::Expected> Fak
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"Address out of range.");
   Size = std::min(Size, Data.size() - (size_t)Addr);
-  return std::vector(&Data[Addr], &Data[Addr + Size]);
+  auto Begin = std::next(Data.begin(), Addr);
+  return std::vector(Begin, std::next(Begin, Size));
 }
 
 llvm::Expected FakeMemory::Write(addr_t Addr,


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


[Lldb-commits] [lldb] r350094 - Reduce indentation in ObjectFilePECOFF::CreateSections via an early return

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 07:16:44 2018
New Revision: 350094

URL: http://llvm.org/viewvc/llvm-project?rev=350094&view=rev
Log:
Reduce indentation in ObjectFilePECOFF::CreateSections via an early return

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=350094&r1=350093&r2=350094&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Thu Dec 27 
07:16:44 2018
@@ -702,142 +702,142 @@ bool ObjectFilePECOFF::IsStripped() {
 }
 
 void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
-  if (!m_sections_ap.get()) {
-m_sections_ap.reset(new SectionList());
+  if (m_sections_ap)
+return;
+  m_sections_ap.reset(new SectionList());
 
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+const uint32_t nsects = m_sect_headers.size();
 ModuleSP module_sp(GetModule());
-if (module_sp) {
-  std::lock_guard guard(module_sp->GetMutex());
-  const uint32_t nsects = m_sect_headers.size();
-  ModuleSP module_sp(GetModule());
-  for (uint32_t idx = 0; idx < nsects; ++idx) {
-std::string sect_name;
-GetSectionName(sect_name, m_sect_headers[idx]);
-ConstString const_sect_name(sect_name.c_str());
-static ConstString g_code_sect_name(".code");
-static ConstString g_CODE_sect_name("CODE");
-static ConstString g_data_sect_name(".data");
-static ConstString g_DATA_sect_name("DATA");
-static ConstString g_bss_sect_name(".bss");
-static ConstString g_BSS_sect_name("BSS");
-static ConstString g_debug_sect_name(".debug");
-static ConstString g_reloc_sect_name(".reloc");
-static ConstString g_stab_sect_name(".stab");
-static ConstString g_stabstr_sect_name(".stabstr");
-static ConstString g_sect_name_dwarf_debug_abbrev(".debug_abbrev");
-static ConstString g_sect_name_dwarf_debug_aranges(".debug_aranges");
-static ConstString g_sect_name_dwarf_debug_frame(".debug_frame");
-static ConstString g_sect_name_dwarf_debug_info(".debug_info");
-static ConstString g_sect_name_dwarf_debug_line(".debug_line");
-static ConstString g_sect_name_dwarf_debug_loc(".debug_loc");
-static ConstString g_sect_name_dwarf_debug_loclists(".debug_loclists");
-static ConstString g_sect_name_dwarf_debug_macinfo(".debug_macinfo");
-static ConstString g_sect_name_dwarf_debug_names(".debug_names");
-static ConstString g_sect_name_dwarf_debug_pubnames(".debug_pubnames");
-static ConstString g_sect_name_dwarf_debug_pubtypes(".debug_pubtypes");
-static ConstString g_sect_name_dwarf_debug_ranges(".debug_ranges");
-static ConstString g_sect_name_dwarf_debug_str(".debug_str");
-static ConstString g_sect_name_dwarf_debug_types(".debug_types");
-static ConstString g_sect_name_eh_frame(".eh_frame");
-static ConstString g_sect_name_go_symtab(".gosymtab");
-SectionType section_type = eSectionTypeOther;
-if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
-((const_sect_name == g_code_sect_name) ||
- (const_sect_name == g_CODE_sect_name))) {
-  section_type = eSectionTypeCode;
-} else if (m_sect_headers[idx].flags &
-   llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
-   ((const_sect_name == g_data_sect_name) ||
-(const_sect_name == g_DATA_sect_name))) {
-  if (m_sect_headers[idx].size == 0 && m_sect_headers[idx].offset == 0)
-section_type = eSectionTypeZeroFill;
-  else
-section_type = eSectionTypeData;
-} else if (m_sect_headers[idx].flags &
-   llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
-   ((const_sect_name == g_bss_sect_name) ||
-(const_sect_name == g_BSS_sect_name))) {
-  if (m_sect_headers[idx].size == 0)
-section_type = eSectionTypeZeroFill;
-  else
-section_type = eSectionTypeData;
-} else if (const_sect_name == g_debug_sect_name) {
-  section_type = eSectionTypeDebug;
-} else if (const_sect_name == g_stabstr_sect_name) {
-  section_type = eSectionTypeDataCString;
-} else if (const_sect_name == g_reloc_sect_name) {
-  section_type = eSectionTypeOther;
-} else if (const_sect_name == g_sect_name_dwarf_debug_abbrev)
-  section_type = eSectionTypeDWARFDebugAbbrev;
-else if (const_sect_name == g_sect_name

[Lldb-commits] [lldb] r350093 - Fix tests for python 3.7

2018-12-27 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Dec 27 07:16:37 2018
New Revision: 350093

URL: http://llvm.org/viewvc/llvm-project?rev=350093&view=rev
Log:
Fix tests for python 3.7

python 3.7 removes re._pattern_type. Fix the one place where we were
depending on the type of regular expressions to compute the type
dynamically.

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

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=350093&r1=350092&r2=350093&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Thu Dec 27 07:16:37 
2018
@@ -74,13 +74,14 @@ def _check_expected_version(comparison,
 LooseVersion(expected_str))
 
 
+_re_pattern_type = type(re.compile(''))
 def _match_decorator_property(expected, actual):
 if actual is None or expected is None:
 return True
 
 if isinstance(expected, no_match):
 return not _match_decorator_property(expected.item, actual)
-elif isinstance(expected, (re._pattern_type,) + six.string_types):
+elif isinstance(expected, (_re_pattern_type,) + six.string_types):
 return re.search(expected, actual) is not None
 elif hasattr(expected, "__iter__"):
 return any([x is not None and _match_decorator_property(x, actual)


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


[Lldb-commits] [lldb] r350122 - Fix signed-unsigned comparisons in MinidumpParserTest

2018-12-28 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 28 05:34:50 2018
New Revision: 350122

URL: http://llvm.org/viewvc/llvm-project?rev=350122&view=rev
Log:
Fix signed-unsigned comparisons in MinidumpParserTest

Modified:
lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp

Modified: lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp?rev=350122&r1=350121&r2=350122&view=diff
==
--- lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp (original)
+++ lldb/trunk/unittests/Process/minidump/MinidumpParserTest.cpp Fri Dec 28 
05:34:50 2018
@@ -636,8 +636,8 @@ TEST_F(MinidumpParserTest, MinidumpDupli
   // one time, we pick the one with the lowest base_of_image.
   std::vector filtered_modules =
   parser->GetFilteredModuleList();
-  EXPECT_EQ(1, filtered_modules.size());
-  EXPECT_EQ(0x1000, filtered_modules[0]->base_of_image);
+  EXPECT_EQ(1u, filtered_modules.size());
+  EXPECT_EQ(0x1000u, filtered_modules[0]->base_of_image);
 }
 
 TEST_F(MinidumpParserTest, MinidumpModuleOrder) {
@@ -652,12 +652,12 @@ TEST_F(MinidumpParserTest, MinidumpModul
   std::vector filtered_modules =
   parser->GetFilteredModuleList();
   llvm::Optional name;
-  EXPECT_EQ(2, filtered_modules.size());
-  EXPECT_EQ(0x2000, filtered_modules[0]->base_of_image);
+  EXPECT_EQ(2u, filtered_modules.size());
+  EXPECT_EQ(0x2000u, filtered_modules[0]->base_of_image);
   name = parser->GetMinidumpString(filtered_modules[0]->module_name_rva);
   ASSERT_TRUE((bool)name);
   EXPECT_EQ(std::string("/tmp/a"), *name);
-  EXPECT_EQ(0x1000, filtered_modules[1]->base_of_image);
+  EXPECT_EQ(0x1000u, filtered_modules[1]->base_of_image);
   name = parser->GetMinidumpString(filtered_modules[1]->module_name_rva);
   ASSERT_TRUE((bool)name);
   EXPECT_EQ(std::string("/tmp/b"), *name);


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


[Lldb-commits] [lldb] r350121 - Remove unused variable from ClangASTContext

2018-12-28 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Dec 28 05:34:44 2018
New Revision: 350121

URL: http://llvm.org/viewvc/llvm-project?rev=350121&view=rev
Log:
Remove unused variable from ClangASTContext

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

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=350121&r1=350120&r2=350121&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Dec 28 05:34:44 2018
@@ -5533,9 +5533,8 @@ GetDynamicArrayInfo(ClangASTContext &ast
 const ExecutionContext *exe_ctx) {
   if (qual_type->isIncompleteArrayType())
 if (auto *metadata = ast.GetMetadata(qual_type.getAsOpaquePtr()))
-  if (auto *dwarf_parser = ast.GetDWARFParser())
-return sym_file->GetDynamicArrayInfoForUID(metadata->GetUserID(),
-   exe_ctx);
+  return sym_file->GetDynamicArrayInfoForUID(metadata->GetUserID(),
+ exe_ctx);
   return llvm::None;
 }
 


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


Re: [Lldb-commits] [lldb] r350160 - [test] Remove flakiness decorator from TestObjCDynamicSBType

2018-12-31 Thread Pavel Labath via lldb-commits
BTW, the flakiness decorators have no effect when using lit as the test 
runner. They relied on passing a message from the test to the test 
framework, which caused the latter to re-run the test. Of course, lit 
has no idea what to do with these messages.


On 30/12/2018 17:24, Davide Italiano via lldb-commits wrote:

No problem, thanks!

On Sun, Dec 30, 2018 at 5:11 PM Jonas Devlieghere  wrote:




On Sun, Dec 30, 2018 at 05:33 Davide Italiano  wrote:


Nice, thanks!
There is a typo in the commit message, I assume?



Correct, I made a typo in the PR and then mindlessly copied the name of the 
test.




On Sun, Dec 30, 2018 at 7:13 AM Jonas Devlieghere via lldb-commits
 wrote:


Author: jdevlieghere
Date: Sat Dec 29 22:10:03 2018
New Revision: 350160

URL: http://llvm.org/viewvc/llvm-project?rev=350160&view=rev
Log:
[test] Remove flakiness decorator from TestObjCDynamicSBType

The quoted bug report (llvm.org/PR20270) was closed in 2014.

Modified:
 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py?rev=350160&r1=350159&r2=350160&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/expression_command/call-function/TestCallStopAndContinue.py
 Sat Dec 29 22:10:03 2018
@@ -6,7 +6,6 @@ from __future__ import print_function


  import lldb
-from lldbsuite.test.decorators import *
  from lldbsuite.test.lldbtest import *
  from lldbsuite.test import lldbutil

@@ -24,7 +23,6 @@ class ExprCommandCallStopContinueTestCas
  '// Please test these expressions while stopped at this line:')
  self.func_line = line_number('main.cpp', '{5, "five"}')

-@expectedFlakeyDarwin("llvm.org/pr20274")
  def test(self):
  """Test gathering result from interrupted function call."""
  self.build()


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


--
Sent from my iPhone

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



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


[Lldb-commits] [lldb] r350209 - NativeProcessProtocolTest: fix -Winconsistent-missing-override warning

2019-01-02 Thread Pavel Labath via lldb-commits
Author: labath
Date: Wed Jan  2 02:37:38 2019
New Revision: 350209

URL: http://llvm.org/viewvc/llvm-project?rev=350209&view=rev
Log:
NativeProcessProtocolTest: fix -Winconsistent-missing-override warning

The warning comes from the fact that the MOCK_METHOD macros don't use the
override keyword internally. This makes us not use it in the manually overriden
methods either, to be consistent.

Modified:
lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp

Modified: lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp?rev=350209&r1=350208&r2=350209&view=diff
==
--- lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp (original)
+++ lldb/trunk/unittests/Host/NativeProcessProtocolTest.cpp Wed Jan  2 02:37:38 
2019
@@ -24,6 +24,9 @@ public:
   MOCK_METHOD1(DidExec, void(NativeProcessProtocol *Process));
 };
 
+// NB: This class doesn't use the override keyword to avoid
+// -Winconsistent-missing-override warnings from the compiler. The
+// inconsistency comes from the overriding definitions in the MOCK_*** macros.
 class MockProcess : public NativeProcessProtocol {
 public:
   MockProcess(NativeDelegate &Delegate, const ArchSpec &Arch,
@@ -47,9 +50,9 @@ public:
   MOCK_METHOD2(GetFileLoadAddress,
Status(const llvm::StringRef &FileName, addr_t &Addr));
 
-  const ArchSpec &GetArchitecture() const override { return Arch; }
+  const ArchSpec &GetArchitecture() const /*override*/ { return Arch; }
   Status SetBreakpoint(lldb::addr_t Addr, uint32_t Size,
-   bool Hardware) override {
+   bool Hardware) /*override*/ {
 if (Hardware)
   return SetHardwareBreakpoint(Addr, Size);
 else
@@ -59,9 +62,9 @@ public:
   // Redirect base class Read/Write Memory methods to functions whose 
signatures
   // are more mock-friendly.
   Status ReadMemory(addr_t Addr, void *Buf, size_t Size,
-size_t &BytesRead) override;
+size_t &BytesRead) /*override*/;
   Status WriteMemory(addr_t Addr, const void *Buf, size_t Size,
- size_t &BytesWritten) override;
+ size_t &BytesWritten) /*override*/;
 
   MOCK_METHOD2(ReadMemory,
llvm::Expected>(addr_t Addr, size_t Size));


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


Re: [Lldb-commits] [PATCH] D56173: Introduce SymbolFileBreakpad and use it to fill symtab

2019-01-02 Thread Pavel Labath via lldb-commits

On 02/01/2019 18:32, Zachary Turner wrote:
Just to be sure, this new test will fail without your Symtab changes 
right?  I'm not in a state where I can look at code right now, and you 
say anything that symbolicates an address *can* use the symtab, but I 
don't know if you really meant *must* use the symtab.




Yes, the test will fail without these changes. The reason I said "can" 
is because symtab is one of the sources of symbolication (the other is 
debug info for instance). However, in this case there is no other source 
of symbol information, so this information "must" come from the symtab

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


Re: [Lldb-commits] [PATCH] D56233: [lldb-server] Add initial support for building lldb-server on Windows

2019-01-03 Thread Pavel Labath via lldb-commits

On 03/01/2019 02:08, Zachary Turner via lldb-commits wrote:
Very excited to see this.  I'm technically on vacation so I might not be 
able to review it immediately, but I'm looking forward to getting to it 
soon.




I am also very excited. Unlike PDBs, I think I actually know a thing or 
two about lldb-server :), so I've added myself as a reviewer to these 
patches too.

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


[Lldb-commits] [lldb] r350291 - Simplify ObjectFile::GetArchitecture

2019-01-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jan  3 02:37:19 2019
New Revision: 350291

URL: http://llvm.org/viewvc/llvm-project?rev=350291&view=rev
Log:
Simplify ObjectFile::GetArchitecture

Summary:
instead of returning the architecture through by-ref argument and a
boolean value indicating success, we can just return the ArchSpec
directly. Since the ArchSpec already has an invalid state, it can be
used to denote the failure without the additional bool.

Reviewers: clayborg, zturner, espindola

Subscribers: emaste, arichardson, JDevlieghere, lldb-commits

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

Modified:
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Expression/IRExecutionUnit.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/include/lldb/Symbol/UnwindTable.h
lldb/trunk/include/lldb/Utility/ArchSpec.h
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Expression/IRExecutionUnit.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
lldb/trunk/source/Plugins/ObjectFile/JIT/ObjectFileJIT.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/CompactUnwindInfo.cpp
lldb/trunk/source/Symbol/DWARFCallFrameInfo.cpp
lldb/trunk/source/Symbol/FuncUnwinders.cpp
lldb/trunk/source/Symbol/Type.cpp
lldb/trunk/source/Symbol/UnwindTable.cpp
lldb/trunk/unittests/Utility/ArchSpecTest.cpp

Modified: lldb/trunk/include/lldb/Core/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=350291&r1=350290&r2=350291&view=diff
==
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Jan  3 02:37:19 2019
@@ -168,10 +168,11 @@ public:
 // Once we get the object file, update our module with the object file's
 // architecture since it might differ in vendor/os if some parts were
 // unknown.
-if (!module_sp->m_objfile_sp->GetArchitecture(module_sp->m_arch))
-  return nullptr;
-
-return module_sp;
+if (ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture()) {
+  module_sp->m_arch = arch;
+  return module_sp;
+}
+return nullptr;
   }
 
   //--

Modified: lldb/trunk/include/lldb/Expression/IRExecutionUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRExecutionUnit.h?rev=350291&r1=350290&r2=350291&view=diff
==
--- lldb/trunk/include/lldb/Expression/IRExecutionUnit.h (original)
+++ lldb/trunk/include/lldb/Expression/IRExecutionUnit.h Thu Jan  3 02:37:19 
2019
@@ -108,7 +108,7 @@ public:
   void PopulateSectionList(lldb_private::ObjectFile *obj_file,
lldb_private::SectionList §ion_list) override;
 
-  bool GetArchitecture(lldb_private::ArchSpec &arch) override;
+  ArchSpec GetArchitecture() override;
 
   lldb::ModuleSP GetJITModule();
 

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=350291&r1=350290&r2=350291&view=diff
==
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Thu Jan  3 02:37:19 2019
@@ -40,7 +40,7 @@ public:
   virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file,
lldb_private::SectionList §ion_list) = 
0;
 
-  virtual bool GetArchitecture(lldb_private::ArchSpec &arch) = 0;
+  virtual ArchSpec GetArchitecture() = 0;
 };
 
 //--
@@ -305,19 +305,13 @@ public:
   virtual const FileSpec &GetFileSpec() const { return m_file; }
 
   //--
-  /// Get the name of the cpu, vendor and OS for this object file.
-  ///
-  /// This value is a string that represents the target triple where the cpu
-  /// type, the vendor and the OS are encoded into a string.
-  ///
-  /// @param[out] target_triple
-  /// The string value of the target triple.
+  /// Get the ArchSpec for this object file.
   ///
   /// @return
-  /// 

[Lldb-commits] [lldb] r350294 - Fix some -Wreorder warnings introduced in r350274

2019-01-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jan  3 03:31:50 2019
New Revision: 350294

URL: http://llvm.org/viewvc/llvm-project?rev=350294&view=rev
Log:
Fix some -Wreorder warnings introduced in r350274

Modified:
lldb/trunk/include/lldb/Symbol/LineTable.h

Modified: lldb/trunk/include/lldb/Symbol/LineTable.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=350294&r1=350293&r2=350294&view=diff
==
--- lldb/trunk/include/lldb/Symbol/LineTable.h (original)
+++ lldb/trunk/include/lldb/Symbol/LineTable.h Thu Jan  3 03:31:50 2019
@@ -238,21 +238,22 @@ public:
 protected:
   struct Entry {
 Entry()
-: file_addr(LLDB_INVALID_ADDRESS), line(0), column(0), file_idx(0),
+: file_addr(LLDB_INVALID_ADDRESS), line(0),
   is_start_of_statement(false), is_start_of_basic_block(false),
   is_prologue_end(false), is_epilogue_begin(false),
-  is_terminal_entry(false) {}
+  is_terminal_entry(false), column(0), file_idx(0) {}
 
 Entry(lldb::addr_t _file_addr, uint32_t _line, uint16_t _column,
   uint16_t _file_idx, bool _is_start_of_statement,
   bool _is_start_of_basic_block, bool _is_prologue_end,
   bool _is_epilogue_begin, bool _is_terminal_entry)
-: file_addr(_file_addr), line(_line), column(_column),
-  file_idx(_file_idx), is_start_of_statement(_is_start_of_statement),
+: file_addr(_file_addr), line(_line),
+  is_start_of_statement(_is_start_of_statement),
   is_start_of_basic_block(_is_start_of_basic_block),
   is_prologue_end(_is_prologue_end),
   is_epilogue_begin(_is_epilogue_begin),
-  is_terminal_entry(_is_terminal_entry) {}
+  is_terminal_entry(_is_terminal_entry), column(_column),
+  file_idx(_file_idx) {}
 
 int bsearch_compare(const void *key, const void *arrmem);
 


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


[Lldb-commits] [lldb] r350298 - PECOFF: Remove tabs introduced accidentally in r350094

2019-01-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jan  3 04:07:38 2019
New Revision: 350298

URL: http://llvm.org/viewvc/llvm-project?rev=350298&view=rev
Log:
PECOFF: Remove tabs introduced accidentally in r350094

Modified:
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp

Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=350298&r1=350297&r2=350298&view=diff
==
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Thu Jan  3 
04:07:38 2019
@@ -743,96 +743,96 @@ void ObjectFilePECOFF::CreateSections(Se
   static ConstString g_sect_name_go_symtab(".gosymtab");
   SectionType section_type = eSectionTypeOther;
   if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_CNT_CODE &&
- ((const_sect_name == g_code_sect_name) ||
-  (const_sect_name == g_CODE_sect_name))) {
-   section_type = eSectionTypeCode;
+  ((const_sect_name == g_code_sect_name) ||
+   (const_sect_name == g_CODE_sect_name))) {
+section_type = eSectionTypeCode;
   } else if (m_sect_headers[idx].flags &
-llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
-((const_sect_name == g_data_sect_name) ||
- (const_sect_name == g_DATA_sect_name))) {
-   if (m_sect_headers[idx].size == 0 && m_sect_headers[idx].offset == 0)
- section_type = eSectionTypeZeroFill;
-   else
- section_type = eSectionTypeData;
+ llvm::COFF::IMAGE_SCN_CNT_INITIALIZED_DATA &&
+ ((const_sect_name == g_data_sect_name) ||
+  (const_sect_name == g_DATA_sect_name))) {
+if (m_sect_headers[idx].size == 0 && m_sect_headers[idx].offset == 0)
+  section_type = eSectionTypeZeroFill;
+else
+  section_type = eSectionTypeData;
   } else if (m_sect_headers[idx].flags &
-llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
-((const_sect_name == g_bss_sect_name) ||
- (const_sect_name == g_BSS_sect_name))) {
-   if (m_sect_headers[idx].size == 0)
- section_type = eSectionTypeZeroFill;
-   else
- section_type = eSectionTypeData;
+ llvm::COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA &&
+ ((const_sect_name == g_bss_sect_name) ||
+  (const_sect_name == g_BSS_sect_name))) {
+if (m_sect_headers[idx].size == 0)
+  section_type = eSectionTypeZeroFill;
+else
+  section_type = eSectionTypeData;
   } else if (const_sect_name == g_debug_sect_name) {
-   section_type = eSectionTypeDebug;
+section_type = eSectionTypeDebug;
   } else if (const_sect_name == g_stabstr_sect_name) {
-   section_type = eSectionTypeDataCString;
+section_type = eSectionTypeDataCString;
   } else if (const_sect_name == g_reloc_sect_name) {
-   section_type = eSectionTypeOther;
+section_type = eSectionTypeOther;
   } else if (const_sect_name == g_sect_name_dwarf_debug_abbrev)
-   section_type = eSectionTypeDWARFDebugAbbrev;
+section_type = eSectionTypeDWARFDebugAbbrev;
   else if (const_sect_name == g_sect_name_dwarf_debug_aranges)
-   section_type = eSectionTypeDWARFDebugAranges;
+section_type = eSectionTypeDWARFDebugAranges;
   else if (const_sect_name == g_sect_name_dwarf_debug_frame)
-   section_type = eSectionTypeDWARFDebugFrame;
+section_type = eSectionTypeDWARFDebugFrame;
   else if (const_sect_name == g_sect_name_dwarf_debug_info)
-   section_type = eSectionTypeDWARFDebugInfo;
+section_type = eSectionTypeDWARFDebugInfo;
   else if (const_sect_name == g_sect_name_dwarf_debug_line)
-   section_type = eSectionTypeDWARFDebugLine;
+section_type = eSectionTypeDWARFDebugLine;
   else if (const_sect_name == g_sect_name_dwarf_debug_loc)
-   section_type = eSectionTypeDWARFDebugLoc;
+section_type = eSectionTypeDWARFDebugLoc;
   else if (const_sect_name == g_sect_name_dwarf_debug_loclists)
-   section_type = eSectionTypeDWARFDebugLocLists;
+section_type = eSectionTypeDWARFDebugLocLists;
   else if (const_sect_name == g_sect_name_dwarf_debug_macinfo)
-   section_type = eSectionTypeDWARFDebugMacInfo;
+section_type = eSectionTypeDWARFDebugMacInfo;
   else if (const_sect_name == g_sect_name_dwarf_debug_names)
-   section_type = eSectionTypeDWARFDebugNames;
+section_type = eSectionTypeDWARFDebugNames;
   else if (const_sect_name == g_sect_name_dwarf_debug_pubnames)
-   section_type = eSectionTypeDWARFDebugPubNames;
+section_type = eSectionTypeDWARFDebugPubNames;
   else if (const_sect

[Lldb-commits] [lldb] r350380 - RangeMap.h: merge RangeDataArray and RangeDataVector

2019-01-03 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu Jan  3 23:14:17 2019
New Revision: 350380

URL: http://llvm.org/viewvc/llvm-project?rev=350380&view=rev
Log:
RangeMap.h: merge RangeDataArray and RangeDataVector

Summary:
The main difference between the classes was supposed to be the fact that
one is backed by llvm::SmallVector, and the other by std::vector.
However, over the years, they have accumulated various other differences
too.

This essentially removes the std::vector version, as that is pretty much
identical to llvm::SmallVector, and combines their interfaces. It
does not attempt to do a more significant refactoring, even though there
is still a lot of duplication in this file, as it is hard to tell which
quirk of some API is depended on by somebody (and, a previous, more
ambitious attempt at this in D16769 has failed).

I also add some tests, including one which demonstrates one of the
quirks/bugs of the API I have noticed in the process.

Reviewers: clayborg, teemperor, tberghammer

Subscribers: mgorny, JDevlieghere, lldb-commits

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

Added:
lldb/trunk/unittests/Core/RangeMapTest.cpp
Modified:
lldb/trunk/include/lldb/Core/RangeMap.h
lldb/trunk/source/Plugins/Process/elf-core/ProcessElfCore.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
lldb/trunk/unittests/Core/CMakeLists.txt

Modified: lldb/trunk/include/lldb/Core/RangeMap.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=350380&r1=350379&r2=350380&view=diff
==
--- lldb/trunk/include/lldb/Core/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Core/RangeMap.h Thu Jan  3 23:14:17 2019
@@ -633,201 +633,12 @@ struct RangeData : public Range {
   }
 };
 
-template  class RangeDataArray 
{
+template 
+class RangeDataVector {
 public:
   typedef RangeData Entry;
   typedef llvm::SmallVector Collection;
 
-  RangeDataArray() = default;
-
-  ~RangeDataArray() = default;
-
-  void Append(const Entry &entry) { m_entries.push_back(entry); }
-
-  void Sort() {
-if (m_entries.size() > 1)
-  std::stable_sort(m_entries.begin(), m_entries.end());
-  }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
-  bool IsSorted() const {
-typename Collection::const_iterator pos, end, prev;
-// First we determine if we can combine any of the Entry objects so we
-// don't end up allocating and making a new collection for no reason
-for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != 
end;
- prev = pos++) {
-  if (prev != end && *pos < *prev)
-return false;
-}
-return true;
-  }
-#endif
-
-  void CombineConsecutiveEntriesWithEqualData() {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
-assert(IsSorted());
-#endif
-typename Collection::iterator pos;
-typename Collection::iterator end;
-typename Collection::iterator prev;
-bool can_combine = false;
-// First we determine if we can combine any of the Entry objects so we
-// don't end up allocating and making a new collection for no reason
-for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != 
end;
- prev = pos++) {
-  if (prev != end && prev->data == pos->data) {
-can_combine = true;
-break;
-  }
-}
-
-// We we can combine at least one entry, then we make a new collection and
-// populate it accordingly, and then swap it into place.
-if (can_combine) {
-  Collection minimal_ranges;
-  for (pos = m_entries.begin(), end = m_entries.end(), prev = end;
-   pos != end; prev = pos++) {
-if (prev != end && prev->data == pos->data)
-  minimal_ranges.back().SetRangeEnd(pos->GetRangeEnd());
-else
-  minimal_ranges.push_back(*pos);
-  }
-  // Use the swap technique in case our new vector is much smaller. We must
-  // swap when using the STL because std::vector objects never release or
-  // reduce the memory once it has been allocated/reserved.
-  m_entries.swap(minimal_ranges);
-}
-  }
-
-  void Clear() { m_entries.clear(); }
-
-  bool IsEmpty() const { return m_entries.empty(); }
-
-  size_t GetSize() const { return m_entries.size(); }
-
-  const Entry *GetEntryAtIndex(size_t i) const {
-return ((i < m_entries.size()) ? &m_entries[i] : nullptr);
-  }
-
-  // Clients must ensure that "i" is a valid index prior to calling this
-  // function
-  const Entry &GetEntryRef(size_t i) const { return m_entries[i]; }
-
-  static bool BaseLessThan(const Entry &lhs, const Entry &rhs) {
-return lhs.GetRangeBase() < rhs.GetRangeBase();
-  }
-
-  uint32_t FindEntryIndexThatContains(B addr) const {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
-assert(IsSorted());
-#endif
-if (!m_entries.empty()) {
-  Entry entry(addr, 1);
-  typename Collection::const_iterator begin = m_entries.begin();
-  typename Collection::const_iterator end = m_entries.end

[Lldb-commits] [lldb] r350384 - Symtab: Remove one copy of symbol size computation code

2019-01-04 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri Jan  4 02:11:25 2019
New Revision: 350384

URL: http://llvm.org/viewvc/llvm-project?rev=350384&view=rev
Log:
Symtab: Remove one copy of symbol size computation code

Summary:
The implementation in CalculateSymbolSizes has been made redundant in
D19004, as this patch added another copy of size computation code into
InitAddressIndexes (which is called by CalculateSymbolSizes).

Reviewers: clayborg, jasonmolenda, tberghammer

Subscribers: lldb-commits

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

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

Modified: lldb/trunk/source/Symbol/Symtab.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=350384&r1=350383&r2=350384&view=diff
==
--- lldb/trunk/source/Symbol/Symtab.cpp (original)
+++ lldb/trunk/source/Symbol/Symtab.cpp Fri Jan  4 02:11:25 2019
@@ -976,32 +976,8 @@ void Symtab::InitAddressIndexes() {
 
 void Symtab::CalculateSymbolSizes() {
   std::lock_guard guard(m_mutex);
-
-  if (!m_symbols.empty()) {
-if (!m_file_addr_to_index_computed)
-  InitAddressIndexes();
-
-const size_t num_entries = m_file_addr_to_index.GetSize();
-
-for (size_t i = 0; i < num_entries; ++i) {
-  // The entries in the m_file_addr_to_index have calculated the sizes
-  // already so we will use this size if we need to.
-  const FileRangeToIndexMap::Entry &entry =
-  m_file_addr_to_index.GetEntryRef(i);
-
-  Symbol &symbol = m_symbols[entry.data];
-
-  // If the symbol size is already valid, no need to do anything
-  if (symbol.GetByteSizeIsValid())
-continue;
-
-  const addr_t range_size = entry.GetByteSize();
-  if (range_size > 0) {
-symbol.SetByteSize(range_size);
-symbol.SetSizeIsSynthesized(true);
-  }
-}
-  }
+  // Size computation happens inside InitAddressIndexes.
+  InitAddressIndexes();
 }
 
 Symbol *Symtab::FindSymbolAtFileAddress(addr_t file_addr) {


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


Re: [Lldb-commits] [PATCH] D56315: Add a verbose mode to "image dump line-table" and use it to write a .debug_line test

2019-01-07 Thread Pavel Labath via lldb-commits

On 04/01/2019 17:53, Zachary Turner wrote:
It seems like this test could be made to work with non dwarf debug info 
by compiling a real source file. WDYT?


Well.. I could write a test by compiling a real source, but it wouldn't 
be *this* test. The idea here was to validate the parsing of the debug 
info into lldb internal data structures (including all the 
is_start_of_statement, is_end_of_prologue bits, etc.), and for that I 
need to be able to specify the input with great precision.


Without that, the only thing I could assert is that there is "some" line 
entry for a given line number, which isn't going to be much useful 
because that is already be extensively tested when setting line 
breakpoints.


So, the main use I see for this is testing the workings of a specific 
parser. Then, if that parser works correctly, anything which consumes 
the data from it (e.g., the breakpoint machinery) should work fine too.

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


Re: [Lldb-commits] [PATCH] D56293: Use the minidump exception record if present

2019-01-07 Thread Pavel Labath via lldb-commits

On 04/01/2019 17:48, Zachary Turner wrote:
For those kinds of cases, we could use obj2yaml and check in yaml right? 
Fwiw I tried to round-trip an exe through obj->yaml->obj recently and 
the resulting exe was incorrect but it was close, so I think there’s 
only some small fixes needed.




I agree yaml2obj should be used whenever possible, but here I'm talking 
specifically about things that cannot be repesented in yaml. For 
example, you can't get yaml2obj to produce a binary that's truncated in 
the middle of the section list. Or one whose section contents points 
back to the section list... And yet it makes sense to test that lldb 
doesn't crash or do other weird stuff when opening these files. It also 
probably doesn't make sense to write a special tool for generating 
these, as there aren't going to be many of these cases, and each of them 
will be special in some way.

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


[Lldb-commits] [lldb] r350510 - ProcessLaunchInfo: remove Debugger reference

2019-01-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Jan  7 02:59:57 2019
New Revision: 350510

URL: http://llvm.org/viewvc/llvm-project?rev=350510&view=rev
Log:
ProcessLaunchInfo: remove Debugger reference

Summary:
The Debuffer object was being used in "GetListenerForProcess" to provide
a default listener object if one was not specified in the launch_info
object.

Since all the callers of this function immediately passed the result to
Target::CreateProcess, it was easy to move this logic there instead.

This brings us one step closer towards being able to move the LaunchInfo
classes to the Host layer (which is there the launching code that
consumes them lives).

Reviewers: zturner, jingham, teemperor

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
lldb/trunk/include/lldb/Target/Target.h
lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Target/ProcessLaunchInfo.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h?rev=350510&r1=350509&r2=350510&view=diff
==
--- lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h (original)
+++ lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h Mon Jan  7 02:59:57 2019
@@ -131,8 +131,6 @@ public:
 m_listener_sp = listener_sp;
   }
 
-  lldb::ListenerSP GetListenerForProcess(Debugger &debugger);
-
   lldb::ListenerSP GetHijackListener() const { return m_hijack_listener_sp; }
 
   void SetHijackListener(const lldb::ListenerSP &listener_sp) {

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=350510&r1=350509&r2=350510&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Mon Jan  7 02:59:57 2019
@@ -533,7 +533,9 @@ public:
   //--
   void Dump(Stream *s, lldb::DescriptionLevel description_level);
 
-  const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener,
+  // If listener_sp is null, the listener of the owning Debugger object will be
+  // used.
+  const lldb::ProcessSP &CreateProcess(lldb::ListenerSP listener_sp,
llvm::StringRef plugin_name,
const FileSpec *crash_file);
 

Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=350510&r1=350509&r2=350510&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Mon Jan  7 
02:59:57 2019
@@ -318,8 +318,8 @@ PlatformLinux::DebugProcess(ProcessLaunc
 
   // Now create the gdb-remote process.
   LLDB_LOG(log, "having target create process with gdb-remote plugin");
-  process_sp = target->CreateProcess(
-  launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
+  process_sp =
+  target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
 
   if (!process_sp) {
 error.SetErrorString("CreateProcess() failed for gdb-remote process");

Modified: lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp?rev=350510&r1=350509&r2=350510&view=diff
==
--- lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp Mon Jan  7 
02:59:57 2019
@@ -287,8 +287,8 @@ PlatformNetBSD::DebugProcess(ProcessLaun
 
   // Now create the gdb-remote process.
   LLDB_LOG(log, "having target create process with gdb-remote plugin");
-  process_sp = target->CreateProcess(
-  launch_info.GetListenerForProcess(debugger), "gdb-remote", nullptr);
+  process_sp =
+  target->CreateProcess(launch_info.GetListener(), "gdb-remote", nullptr);
 
   if (!process_sp) {
 error.SetErrorString("CreateProcess() failed for gdb-remote process");

Modified: lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Windows/PlatformWindows.cpp?rev=350510&r1=350509&r2=350510&view=diff
=

[Lldb-commits] [lldb] r350511 - ObjectFileBreakpad: Implement sections

2019-01-07 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon Jan  7 03:14:08 2019
New Revision: 350511

URL: http://llvm.org/viewvc/llvm-project?rev=350511&view=rev
Log:
ObjectFileBreakpad: Implement sections

Summary:
This patch allows ObjectFileBreakpad to parse the contents of Breakpad
files into sections. This sounds slightly odd at first, but in essence
its not too different from how other object files handle things. For
example in elf files, the symtab section consists of a number of
"records", where each record represents a single symbol. The same is
true for breakpad's PUBLIC section, except in this case, the records will be
textual instead of binary.

To keep sections contiguous, I create a new section every time record
type changes. Normally, the breakpad processor will group all records of
the same type in one block, but the format allows them to be intermixed,
so in general, the "object file" may contain multiple sections with the
same record type.

Reviewers: clayborg, zturner, lemo, markmentovai, amccarth

Subscribers: lldb-commits

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

Added:
lldb/trunk/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms
lldb/trunk/lit/Modules/Breakpad/Inputs/sections.syms
lldb/trunk/lit/Modules/Breakpad/discontiguous-sections.test
lldb/trunk/lit/Modules/Breakpad/sections-trailing-func.test
lldb/trunk/lit/Modules/Breakpad/sections.test
Modified:
lldb/trunk/include/lldb/Utility/DataExtractor.h
lldb/trunk/source/Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.cpp

Modified: lldb/trunk/include/lldb/Utility/DataExtractor.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/DataExtractor.h?rev=350511&r1=350510&r2=350511&view=diff
==
--- lldb/trunk/include/lldb/Utility/DataExtractor.h (original)
+++ lldb/trunk/include/lldb/Utility/DataExtractor.h Mon Jan  7 03:14:08 2019
@@ -14,6 +14,7 @@
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-types.h"
+#include "llvm/ADT/ArrayRef.h"
 
 #include 
 #include 
@@ -1094,6 +1095,10 @@ public:
 
   void Checksum(llvm::SmallVectorImpl &dest, uint64_t max_data = 0);
 
+  llvm::ArrayRef GetData() const {
+return {GetDataStart(), GetByteSize()};
+  }
+
 protected:
   //--
   // Member variables

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms?rev=350511&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/discontiguous-sections.syms Mon Jan  
7 03:14:08 2019
@@ -0,0 +1,5 @@
+MODULE Linux x86_64 24B5D199F0F766FF5DC30 linux.out
+INFO CODE_ID B52499D1F0F766FF5DC3
+FILE 0 /tmp/a.c
+PUBLIC 1010 0 _start
+FILE 1 /tmp/b.c

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms?rev=350511&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/sections-trailing-func.syms Mon Jan  
7 03:14:08 2019
@@ -0,0 +1,8 @@
+MODULE Linux x86_64 24B5D199F0F766FF5DC30 linux.out
+INFO CODE_ID B52499D1F0F766FF5DC3
+FILE 0 /tmp/a.c
+FUNC 1010 10 0 _start
+1010 4 4 0
+1014 5 5 0
+1019 5 6 0
+101e 2 7 0

Added: lldb/trunk/lit/Modules/Breakpad/Inputs/sections.syms
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/Inputs/sections.syms?rev=350511&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/Inputs/sections.syms (added)
+++ lldb/trunk/lit/Modules/Breakpad/Inputs/sections.syms Mon Jan  7 03:14:08 
2019
@@ -0,0 +1,12 @@
+MODULE Linux x86_64 24B5D199F0F766FF5DC30 linux.out
+INFO CODE_ID B52499D1F0F766FF5DC3
+FILE 0 /tmp/a.c
+FUNC 1010 10 0 _start
+1010 4 4 0
+1014 5 5 0
+1019 5 6 0
+101e 2 7 0
+PUBLIC 1010 0 _start
+STACK CFI INIT 1010 10 .cfa: $rsp 8 + .ra: .cfa -8 + ^
+STACK CFI 1011 $rbp: .cfa -16 + ^ .cfa: $rsp 16 +
+STACK CFI 1014 .cfa: $rbp 16 +

Added: lldb/trunk/lit/Modules/Breakpad/discontiguous-sections.test
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Modules/Breakpad/discontiguous-sections.test?rev=350511&view=auto
==
--- lldb/trunk/lit/Modules/Breakpad/discontiguous-sections.test (added)
+++ lldb/trunk/lit/Modules/Breakpad/discontiguous-sections.test Mon Jan

Re: [Lldb-commits] [PATCH] D56418: Change lldb-test to use ParseAllDebugSymbols instead of ParseDeclsForContext

2019-01-08 Thread Pavel Labath via lldb-commits

On 08/01/2019 11:45, Zachary Turner wrote:
The same plugin is being used in both cases, the patch only touches the 
nonnative PDB reader. The followup changes to the plugin itself are 
necessary because the results were not identical (another reason i want 
to de-support ParseDeclsForContext at global acope - having 2 
implementations of the same thing means they will differ slightly).


In this case it happened that the ParseAllDebugSymbolsPath reconstructed 
both the lldb type hierarchy and the clang ast hierarchy, but the 
ParseAllDebugSymbols path missed a few things in the clang ast hierarchy )


The changes to the test that you see are because the two paths — even 
though they’re still in the same plugin — result in things being 
constructed in a different order


Ok, that makes sense. Thanks.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r350617 - ProcessLaunchInfo: Remove Target reference

2019-01-08 Thread Pavel Labath via lldb-commits
Author: labath
Date: Tue Jan  8 03:55:19 2019
New Revision: 350617

URL: http://llvm.org/viewvc/llvm-project?rev=350617&view=rev
Log:
ProcessLaunchInfo: Remove Target reference

Summary:
The target was being used in FinalizeFileActions to provide default
values for stdin/out/err. Also, most of the logic of this function was
very specific to how the lldb's Target class wants to launch processes,
so I, move it to Target::FinalizeFileActions, inverting the dependency.
The only piece of logic that was useful elsewhere (lldb-server) was the
part which sets up a pty and relevant file actions. I've kept this part
as ProcessLaunchInfo::SetUpPtyRedirection.

This makes ProcessLaunchInfo independent of any high-level lldb constructs.

Reviewers: zturner, jingham, teemperor

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
lldb/trunk/include/lldb/Target/Target.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/trunk/source/Target/ProcessLaunchInfo.cpp
lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h?rev=350617&r1=350616&r2=350617&view=diff
==
--- lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h (original)
+++ lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h Tue Jan  8 03:55:19 2019
@@ -52,7 +52,10 @@ public:
 
   bool AppendSuppressFileAction(int fd, bool read, bool write);
 
-  void FinalizeFileActions(Target *target, bool default_to_use_pty);
+  // Redirect stdin/stdout/stderr to a pty, if no action for the respective 
file
+  // descriptor is specified. (So if stdin and stdout already have file 
actions,
+  // but stderr doesn't, then only stderr will be redirected to a pty.)
+  llvm::Error SetUpPtyRedirection();
 
   size_t GetNumFileActions() const { return m_file_actions.size(); }
 

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=350617&r1=350616&r2=350617&view=diff
==
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Tue Jan  8 03:55:19 2019
@@ -1354,6 +1354,8 @@ private:
 
   void AddBreakpoint(lldb::BreakpointSP breakpoint_sp, bool internal);
 
+  void FinalizeFileActions(ProcessLaunchInfo &info);
+
   DISALLOW_COPY_AND_ASSIGN(Target);
 };
 

Modified: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp?rev=350617&r1=350616&r2=350617&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
 (original)
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
 Tue Jan  8 03:55:19 2019
@@ -218,8 +218,10 @@ Status GDBRemoteCommunicationServerLLGS:
   m_process_launch_info.SetLaunchInSeparateProcessGroup(true);
   m_process_launch_info.GetFlags().Set(eLaunchFlagDebug);
 
-  const bool default_to_use_pty = true;
-  m_process_launch_info.FinalizeFileActions(nullptr, default_to_use_pty);
+  if (should_forward_stdio) {
+if (llvm::Error Err = m_process_launch_info.SetUpPtyRedirection())
+  return Status(std::move(Err));
+  }
 
   {
 std::lock_guard guard(m_debugged_process_mutex);

Modified: lldb/trunk/source/Target/ProcessLaunchInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ProcessLaunchInfo.cpp?rev=350617&r1=350616&r2=350617&view=diff
==
--- lldb/trunk/source/Target/ProcessLaunchInfo.cpp (original)
+++ lldb/trunk/source/Target/ProcessLaunchInfo.cpp Tue Jan  8 03:55:19 2019
@@ -14,7 +14,6 @@
 #include "lldb/Host/HostInfo.h"
 #include "lldb/Target/FileAction.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
-#include "lldb/Target/Target.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/StreamString.h"
 
@@ -206,123 +205,38 @@ void ProcessLaunchInfo::SetDetachOnError
 m_flags.Clear(lldb::eLaunchFlagDetachOnError);
 }
 
-void ProcessLaunchInfo::FinalizeFileActions(Target *target,
-bool default_to_use_pty) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
-
-  // If nothing for stdin or stdout or stderr was specified, then check the
-  // process for any default settings that were set with "settings set"
-  if (GetFileActionForFD(STDIN_FILENO) == nullptr ||
-  GetFileActionForFD(STDOUT_FILENO) == nullptr ||
-  GetFileActionForFD(STDERR_FILENO) 

[Lldb-commits] [lldb] r331966 - CPlusPlusLanguage: Add unit tests for the FindAlternateFunctionManglings method

2018-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 10 01:59:17 2018
New Revision: 331966

URL: http://llvm.org/viewvc/llvm-project?rev=331966&view=rev
Log:
CPlusPlusLanguage: Add unit tests for the FindAlternateFunctionManglings method

I was considering modifying this function, so I wrote some tests to make
sure I don't regress its behavior. I am not sure if I will actually
proceed with the modifications, but the tests seem useful nonetheless.

Modified:
lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Modified: lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp?rev=331966&r1=331965&r2=331966&view=diff
==
--- lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp (original)
+++ lldb/trunk/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp Thu May 
10 01:59:17 2018
@@ -6,9 +6,9 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-#include "gtest/gtest.h"
-
 #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
 
 using namespace lldb_private;
 
@@ -163,3 +163,24 @@ TEST(CPlusPlusLanguage, ExtractContextAn
   EXPECT_FALSE(CPlusPlusLanguage::ExtractContextAndIdentifier(
   "f>", context, basename));
 }
+
+static std::set FindAlternate(llvm::StringRef Name) {
+  std::set Results;
+  uint32_t Count = CPlusPlusLanguage::FindAlternateFunctionManglings(
+  ConstString(Name), Results);
+  EXPECT_EQ(Count, Results.size());
+  std::set Strings;
+  for (ConstString Str : Results)
+Strings.insert(Str.GetStringRef());
+  return Strings;
+}
+
+TEST(CPlusPlusLanguage, FindAlternateFunctionManglings) {
+  using namespace testing;
+
+  EXPECT_THAT(FindAlternate("_ZN1A1fEv"),
+  UnorderedElementsAre("_ZNK1A1fEv", "_ZLN1A1fEv"));
+  EXPECT_THAT(FindAlternate("_ZN1A1fEa"), Contains("_ZN1A1fEc"));
+  EXPECT_THAT(FindAlternate("_ZN1A1fEx"), Contains("_ZN1A1fEl"));
+  EXPECT_THAT(FindAlternate("_ZN1A1fEy"), Contains("_ZN1A1fEm"));
+}


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


[Lldb-commits] [lldb] r331970 - Convert all RunShellCommand functions to use the Timeout class

2018-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 10 03:46:03 2018
New Revision: 331970

URL: http://llvm.org/viewvc/llvm-project?rev=331970&view=rev
Log:
Convert all RunShellCommand functions to use the Timeout class

this completes the Timeout migration started in r331880 with the
Predicate class.

Modified:
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/include/lldb/Target/Platform.h
lldb/trunk/source/API/SBPlatform.cpp
lldb/trunk/source/Commands/CommandObjectPlatform.cpp
lldb/trunk/source/Host/common/Host.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.h
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h

lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/trunk/source/Target/Platform.cpp

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=331970&r1=331969&r2=331970&view=diff
==
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Thu May 10 03:46:03 2018
@@ -14,6 +14,7 @@
 #include "lldb/Host/HostThread.h"
 #include "lldb/Utility/Environment.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-private.h"
 #include 
@@ -219,8 +220,7 @@ public:
// process to exit
   std::string
   *command_output, // Pass NULL if you don't want the command output
-  uint32_t timeout_sec,
-  bool run_in_default_shell = true);
+  const Timeout &timeout, bool run_in_default_shell = true);
 
   static Status RunShellCommand(
   const Args &args,
@@ -231,8 +231,7 @@ public:
// process to exit
   std::string
   *command_output, // Pass NULL if you don't want the command output
-  uint32_t timeout_sec,
-  bool run_in_default_shell = true);
+  const Timeout &timeout, bool run_in_default_shell = true);
 
   static bool OpenFileInExternalEditor(const FileSpec &file_spec,
uint32_t line_no);

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=331970&r1=331969&r2=331970&view=diff
==
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Thu May 10 03:46:03 2018
@@ -27,6 +27,7 @@
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/ConstString.h"
 #include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Timeout.h"
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
@@ -676,8 +677,7 @@ public:
// the process to exit
   std::string
   *command_output, // Pass nullptr if you don't want the command output
-  uint32_t timeout_sec); // Timeout in seconds to wait for shell program to
- // finish
+  const Timeout &timeout);
 
   virtual void SetLocalCacheDirectory(const char *local);
 

Modified: lldb/trunk/source/API/SBPlatform.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBPlatform.cpp?rev=331970&r1=331969&r2=331970&view=diff
==
--- lldb/trunk/source/API/SBPlatform.cpp (original)
+++ lldb/trunk/source/API/SBPlatform.cpp Thu May 10 03:46:03 2018
@@ -53,8 +53,7 @@ struct PlatformConnectOptions {
 //--
 struct PlatformShellCommand {
   PlatformShellCommand(const char *shell_command = NULL)
-  : m_command(), m_working_dir(), m_status(0), m_signo(0),
-m_timeout_sec(UINT32_MAX) {
+  : m_command(), m_working_dir(), m_status(0), m_signo(0) {
 if (shell_command && shell_command[0])
   m_command = shell_command;
   }
@@ -66,7 +65,7 @@ struct PlatformShellCommand {
   std::string m_output;
   int m_status;
   int m_signo;
-  uint32_t m_timeout_sec;
+  Timeout> m_timeout = llvm::None;
 };
 //--
 // SBPlatformConnectOptions
@@ -182,11 +181,16 @@ void SBPlatformShellCommand::SetWorkingD
 }
 
 uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
-  return m_opaque_ptr->m_timeout_sec;
+  if (m_opaque_ptr->m_timeout)
+return m_opaque_ptr->m_timeout->count();
+  return UINT32

[Lldb-commits] [lldb] r331974 - Fix windows&mac builds broken by r331970 (RunShellCommand/Timeout) refactor

2018-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 10 04:27:43 2018
New Revision: 331974

URL: http://llvm.org/viewvc/llvm-project?rev=331974&view=rev
Log:
Fix windows&mac builds broken by r331970 (RunShellCommand/Timeout) refactor

Modified:
lldb/trunk/source/Host/macosx/Symbols.cpp
lldb/trunk/source/Host/windows/Host.cpp

Modified: lldb/trunk/source/Host/macosx/Symbols.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=331974&r1=331973&r2=331974&view=diff
==
--- lldb/trunk/source/Host/macosx/Symbols.cpp (original)
+++ lldb/trunk/source/Host/macosx/Symbols.cpp Thu May 10 04:27:43 2018
@@ -571,8 +571,9 @@ bool Symbols::DownloadObjectAndSymbolFil
 &exit_status,// Exit status
 &signo,  // Signal int *
 &command_output, // Command output
-30, // Large timeout to allow for long dsym download times
-false); // Don't run in a shell (we don't need shell expansion)
+std::chrono::seconds(
+30), // Large timeout to allow for long dsym download times
+false);  // Don't run in a shell (we don't need shell expansion)
 if (error.Success() && exit_status == 0 && !command_output.empty()) {
   CFCData data(CFDataCreateWithBytesNoCopy(
   NULL, (const UInt8 *)command_output.data(), 
command_output.size(),

Modified: lldb/trunk/source/Host/windows/Host.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/windows/Host.cpp?rev=331974&r1=331973&r2=331974&view=diff
==
--- lldb/trunk/source/Host/windows/Host.cpp (original)
+++ lldb/trunk/source/Host/windows/Host.cpp Thu May 10 04:27:43 2018
@@ -207,7 +207,7 @@ Status Host::ShellExpandArguments(Proces
 std::string output;
 std::string command = expand_command.GetString();
 RunShellCommand(command.c_str(), launch_info.GetWorkingDirectory(), 
&status,
-nullptr, &output, 10);
+nullptr, &output, std::chrono::seconds(10));
 
 if (status != 0) {
   error.SetErrorStringWithFormat("lldb-argdumper exited with error %d",


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


[Lldb-commits] [lldb] r331977 - Fix one more RunShellcommand occurence in mac code

2018-05-10 Thread Pavel Labath via lldb-commits
Author: labath
Date: Thu May 10 05:02:24 2018
New Revision: 331977

URL: http://llvm.org/viewvc/llvm-project?rev=331977&view=rev
Log:
Fix one more RunShellcommand occurence in mac code

Modified:
lldb/trunk/source/Host/macosx/Host.mm

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=331977&r1=331976&r2=331977&view=diff
==
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Thu May 10 05:02:24 2018
@@ -1554,7 +1554,8 @@ Status Host::ShellExpandArguments(Proces
 launch_info.SetWorkingDirectory(working_dir);
   }
 }
-RunShellCommand(expand_command, cwd, &status, nullptr, &output, 10);
+RunShellCommand(expand_command, cwd, &status, nullptr, &output,
+std::chrono::seconds(10));
 
 if (status != 0) {
   error.SetErrorStringWithFormat("lldb-argdumper exited with error %d",


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


Re: [Lldb-commits] [RFC] Type lookup for template types is broken...

2018-05-10 Thread Pavel Labath via lldb-commits
On Thu, 10 May 2018 at 16:19,  wrote:

> > Anyway, the issue is that the PS4 targets don't emit DW_AT_linkage_name
> > attributes in the debug info, but we are still emitting an index entry
> > with
> > the mangled names. This caused the verifier to complain.
> >
> > Two interesting questions follow from this:
> > 1. (mainly for Paul, I guess) Should we fix the debug_names generator to
> > not emit the linkage name index entry for PS4 targets?

> I think there's a flag controlling this which is not the triple, but yes
> if the DIEs don't have linkage names then I think the index also
shouldn't.
Agreed. I expect it to be at least the debugger tuning flag, maybe even a
specific setting. Anyway, I'll track that down and send a patch.



> >
> > 2. (for everyone) Is this verifier check actually valid? This depending
on
> > the interpretation of the last (non-normative) paragraph of Section
> > 6.1.1.1
> > (*). One way of reading it is that a producer is allowed to insert
> > additional entries into the name index. Another would be that we can
also
> > insert additional names for existing entries. This is interesting here
> > because this is exactly what the the template stripping proposal would
do
> > (add extra names to existing entries). If we don't remove that check, it
> > will cause the verifier to complain again.
> >
> > regards
> > pavel
> >
> > (*) The intent of the above rules is to provide the consumer with some
> > assurance that looking up an unqualified name in the index will yield
all
> > relevant debugging information entries that provide a defining
declaration
> > at global scope for that name. A producer may choose to implement
> > additional rules for what names are placed in the index, and may
> > communicate those rules to a cooperating consumer via an augmentation
> > string, described below.

> I read it as, if we emit additional entries, we should emit an
augmentation
> string that says so.  If the augmentation is superseded by a spec change
in
> DWARF 6, I'm sure everybody can accommodate that too.
> --paulr

Satisfying the "augmentation" part is easy, as the spec does not say
anything about how the string should look like. The interesting part for me
is what does the "additional entry" mean. Is it adding an additional name
to an .debug_info entry (possibly one that is not contained in any of the
standard attributes) like template proposal we were floating around? Or, is
it adding a previously unindexed .debug_info entry to the index (e.g. the
enumerator issue we were talking about in the dwarf_discuss thread)? (or
both..)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r332088 - Remove custom path manipulation functions from FileSpec

2018-05-11 Thread Pavel Labath via lldb-commits
Author: labath
Date: Fri May 11 04:55:34 2018
New Revision: 332088

URL: http://llvm.org/viewvc/llvm-project?rev=332088&view=rev
Log:
Remove custom path manipulation functions from FileSpec

Summary:
now that llvm supports host-agnostic path manipulation functions (and
most of their kinks have been ironed out), we can remove our copies of
the path parsing functions in favour of the llvm ones.

This should be NFC except for the slight difference in handling of the
"//" path, which is now normalized to "/" (this only applies to the
literal "//" path; "//net" and friends still get to keep the two
slashes).

Reviewers: zturner, clayborg

Subscribers: lldb-commits

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

Modified:
lldb/trunk/source/Utility/FileSpec.cpp
lldb/trunk/unittests/Utility/FileSpecTest.cpp

Modified: lldb/trunk/source/Utility/FileSpec.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/FileSpec.cpp?rev=332088&r1=332087&r2=332088&view=diff
==
--- lldb/trunk/source/Utility/FileSpec.cpp (original)
+++ lldb/trunk/source/Utility/FileSpec.cpp Fri May 11 04:55:34 2018
@@ -82,67 +82,6 @@ void Denormalize(llvm::SmallVectorImpl 0 && IsPathSeparator(str.back(), syntax))
-return str.size() - 1;
-
-  size_t pos = str.find_last_of(GetPathSeparators(syntax), str.size() - 1);
-
-  if (!PathSyntaxIsPosix(syntax) && pos == llvm::StringRef::npos)
-pos = str.find_last_of(':', str.size() - 2);
-
-  if (pos == llvm::StringRef::npos ||
-  (pos == 1 && IsPathSeparator(str[0], syntax)))
-return 0;
-
-  return pos + 1;
-}
-
-size_t RootDirStart(llvm::StringRef str, FileSpec::PathSyntax syntax) {
-  // case "c:/"
-  if (!PathSyntaxIsPosix(syntax) &&
-  (str.size() > 2 && str[1] == ':' && IsPathSeparator(str[2], syntax)))
-return 2;
-
-  // case "//"
-  if (str.size() == 2 && IsPathSeparator(str[0], syntax) && str[0] == str[1])
-return llvm::StringRef::npos;
-
-  // case "//net"
-  if (str.size() > 3 && IsPathSeparator(str[0], syntax) && str[0] == str[1] &&
-  !IsPathSeparator(str[2], syntax))
-return str.find_first_of(GetPathSeparators(syntax), 2);
-
-  // case "/"
-  if (str.size() > 0 && IsPathSeparator(str[0], syntax))
-return 0;
-
-  return llvm::StringRef::npos;
-}
-
-size_t ParentPathEnd(llvm::StringRef path, FileSpec::PathSyntax syntax) {
-  size_t end_pos = FilenamePos(path, syntax);
-
-  bool filename_was_sep =
-  path.size() > 0 && IsPathSeparator(path[end_pos], syntax);
-
-  // Skip separators except for root dir.
-  size_t root_dir_pos = RootDirStart(path.substr(0, end_pos), syntax);
-
-  while (end_pos > 0 && (end_pos - 1) != root_dir_pos &&
- IsPathSeparator(path[end_pos - 1], syntax))
---end_pos;
-
-  if (end_pos == 1 && root_dir_pos == 0 && filename_was_sep)
-return llvm::StringRef::npos;
-
-  return end_pos;
-}
-
 } // end anonymous namespace
 
 void FileSpec::Resolve(llvm::SmallVectorImpl &path) {
@@ -312,10 +251,6 @@ const FileSpec &FileSpec::operator=(cons
 //--
 void FileSpec::SetFile(llvm::StringRef pathname, bool resolve,
PathSyntax syntax) {
-  // CLEANUP: Use StringRef for string handling.  This function is kind of a
-  // mess and the unclear semantics of RootDirStart and ParentPathEnd make it
-  // very difficult to understand this function.  There's no reason this
-  // function should be particularly complicated or difficult to understand.
   m_filename.Clear();
   m_directory.Clear();
   m_is_resolved = false;
@@ -339,26 +274,11 @@ void FileSpec::SetFile(llvm::StringRef p
   if (m_syntax == FileSpec::ePathSyntaxWindows)
 std::replace(resolved.begin(), resolved.end(), '\\', '/');
 
-  llvm::StringRef resolve_path_ref(resolved.c_str());
-  size_t dir_end = ParentPathEnd(resolve_path_ref, m_syntax);
-  if (dir_end == 0) {
-m_filename.SetString(resolve_path_ref);
-return;
-  }
-
-  m_directory.SetString(resolve_path_ref.substr(0, dir_end));
-
-  size_t filename_begin = dir_end;
-  size_t root_dir_start = RootDirStart(resolve_path_ref, m_syntax);
-  while (filename_begin != llvm::StringRef::npos &&
- filename_begin < resolve_path_ref.size() &&
- filename_begin != root_dir_start &&
- IsPathSeparator(resolve_path_ref[filename_begin], m_syntax))
-++filename_begin;
-  m_filename.SetString((filename_begin == llvm::StringRef::npos ||
-filename_begin >= resolve_path_ref.size())
-   ? "."
-   : resolve_path_ref.substr(filename_begin));
+  auto style = LLVMPathSyntax(syntax);
+  m_filename.SetString(llvm::sys::path::filename(resolved, style));
+  llvm::StringRef dir = llvm::sys::path::parent_path(resolved, style);
+  if (!dir.empty())
+m_directory.SetString(dir);
 }
 
 void FileSpec::SetFile(llvm::StringRef path, bool resolve,

Modified:

Re: [Lldb-commits] [lldb] r332162 - [LLDB] Support GNU-style compressed debug sections (.zdebug)

2018-05-14 Thread Pavel Labath via lldb-commits
I would suggest testing this the way we have started testing all other
ObjectFile changes -- yaml2obj + lldb-test (see tests in lit/Modules). A
full-scale integration test is interesting, but I would consider it
optional, as this patch touches no files outside the object layer.
On Sat, 12 May 2018 at 01:57, Davide Italiano via lldb-commits <
lldb-commits@lists.llvm.org> wrote:

> On Fri, May 11, 2018 at 5:29 PM, Davide Italiano via lldb-commits
>  wrote:
> > Author: davide
> > Date: Fri May 11 17:29:25 2018
> > New Revision: 332162
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=332162&view=rev
> > Log:
> > [LLDB] Support GNU-style compressed debug sections (.zdebug)
> >
> > Patch by Erik Welander!
> >

> Erik, I'm going to revert this because it broke the ubuntu 14.04 bot.
> Please take a look and I'll recommit it for you once it's fixed.

> Log:

http://lab.llvm.org:8011/builders/lldb-x86_64-ubuntu-14.04-cmake/builds/23184

> Culprit:
> ```
> Build Command Output:
> objcopy: option '--compress-debug-sections' doesn't allow an argument
> ```
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D46810: Fix DWARFUnit::GetUnitDIEPtrOnly stale pointer

2018-05-14 Thread Pavel Labath via lldb-commits
On Mon, 14 May 2018 at 15:24, Jan Kratochvil via Phabricator <
revi...@reviews.llvm.org> wrote:

> jankratochvil added a comment.

> In https://reviews.llvm.org/D46810#1097829, @labath wrote:

> > I am not sure it's that simple. I've found at least one case
(`SymbolFileDWARF::ParseImportedModuleswhere we call GetFirstChild() on the
value returned by `GetUnitDIEOnly`


> OK, that is clearly a bug there, thanks for finding it. I see some new
assertion check would be good (I may try even a compile time check by some
new class wrapper). `SymbolFileDWARF::ParseImportedModules` should just
call `DIE()`.

>DWARFDIE GetUnitDIEOnly() -> DWARFDebugInfoEntry *GetUnitDIEPtrOnly()
-> ExtractDIEsIfNeeded(true ) -> CU DIE only
>DWARFDIEDIE() -> DWARFDebugInfoEntry *   DIEPtr()
-> ExtractDIEsIfNeeded(false) -> all DIEs



> > I was thinking of making this safer by changing the `GetUnitDIEOnly` so
that the caller has to explicitly request (either with an argument, or by
splitting it into two functions) whether it wants a CU die, which can be
used to access other DIEs, or just a bare attribute-only DIE. In second
case, we would return &m_first_die, in the first case &m_die_array[0]
(after making sure it's properly initialized).

> But there is already such function, it is called `DIE()`, we need no new
parameter.

Ah, I see. Thanks for pointing that out (I'm fairly new to this part of the
code as well :)).

> Maybe we should rename those functions, their current names are cryptic,
what about changing the second line to:

>DWARFDIE GetUnitDIEOnly() -> DWARFDebugInfoEntry *GetUnitDIEPtrOnly()
-> ExtractDIEsIfNeeded(true ) -> CU DIE only
>DWARFDIE GetUnitAllDIEs() -> DWARFDebugInfoEntry *GetUnitAllDIEsPtr()
-> ExtractDIEsIfNeeded(false) -> all DIEs

I'm not opposed to that, though I'm not sure if it makes things
substantially better. I'm not sure if this is a thing that can be
succinctly expressed in a name (DIEWhichCanBeUsedToAccessOtherDIEs). Maybe
just a comment explaining their difference would be enough.




> > Then `m_first_die` can have `has_children` property set to false to
enforce that noone accesses children that way.

> I would prefer an assert (or even a compilation error by some wrapper
class) in such case but I agree this may be enough.

Since it seems this is how things worked already, I don't think we need to
go out of our way here. If you can get an assert there then great.
Otherwise, I think the has_children should be enough.
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] r332247 - FileSpec: Remove PathSyntax enum and use llvm version instead

2018-05-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon May 14 07:52:47 2018
New Revision: 332247

URL: http://llvm.org/viewvc/llvm-project?rev=332247&view=rev
Log:
FileSpec: Remove PathSyntax enum and use llvm version instead

Summary:
The llvm version of the enum has the same enumerators, with stlightly
different names, so this is mostly just a search&replace exercise. One
concrete benefit of this is that we can remove the function for
converting between the two enums.

To avoid typing llvm::sys::path::Style::windows everywhere I import the
enum into the FileSpec class, so it can be referenced as
FileSpec::Style::windows.

Reviewers: zturner, clayborg

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Utility/FileSpec.h
lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/trunk/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/trunk/source/Utility/FileSpec.cpp
lldb/trunk/unittests/Process/gdb-remote/GDBRemoteCommunicationClientTest.cpp
lldb/trunk/unittests/Target/ModuleCacheTest.cpp
lldb/trunk/unittests/Utility/FileSpecTest.cpp

Modified: lldb/trunk/include/lldb/Utility/FileSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/FileSpec.h?rev=332247&r1=332246&r2=332247&view=diff
==
--- lldb/trunk/include/lldb/Utility/FileSpec.h (original)
+++ lldb/trunk/include/lldb/Utility/FileSpec.h Mon May 14 07:52:47 2018
@@ -22,6 +22,7 @@
 #include "llvm/ADT/StringRef.h" // for StringRef
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Path.h"
 
 #include  // for size_t
 #include  // for uint32_t, uint64_t
@@ -60,11 +61,7 @@ namespace lldb_private {
 //--
 class FileSpec {
 public:
-  enum PathSyntax : unsigned char {
-ePathSyntaxPosix,
-ePathSyntaxWindows,
-ePathSyntaxHostNative
-  };
+  using Style = llvm::sys::path::Style;
 
   FileSpec();
 
@@ -86,7 +83,7 @@ public:
   /// @see FileSpec::SetFile (const char *path, bool resolve)
   //--
   explicit FileSpec(llvm::StringRef path, bool resolve_path,
-PathSyntax syntax = ePathSyntaxHostNative);
+Style style = Style::native);
 
   explicit FileSpec(llvm::StringRef path, bool resolve_path,
 const llvm::Triple &Triple);
@@ -261,7 +258,7 @@ public:
   /// \b true if the file path is case sensitive (POSIX), false
   ///  if case insensitive (Windows).
   //--
-  bool IsCaseSensitive() const { return m_syntax != ePathSyntaxWindows; }
+  bool IsCaseSensitive() const { return m_style != Style::windows; }
 
   //--
   /// Dump this object to a Stream.
@@ -316,7 +313,7 @@ public:
 
   uint64_t GetByteSize() const;
 
-  PathSyntax GetPathSyntax() const;
+  Style GetPathStyle() const;
 
   //--
   /// Directory string get accessor.
@@ -494,7 +491,7 @@ public:
   /// the static FileSpec::Resolve.
   //--
   void SetFile(llvm::StringRef path, bool resolve_path,
-   PathSyntax syntax = ePathSyntaxHostNative);
+   Style style = Style::native);
 
   void SetFile(llvm::StringRef path, bool resolve_path,
const llvm::Triple &Triple);
@@ -567,8 +564,7 @@ protected:
   ConstString m_directory;///< The uniqued directory path
   ConstString m_filename; ///< The uniqued filename path
   mutable bool m_is_resolved = false; ///< True if this path has been resolved.
-  PathSyntax
-  m_syntax; ///< The syntax that this path uses (e.g. Windows / Posix)
+  Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
 };
 
 //--

Modified: lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp?rev=332247&r1=332246&r2=332247&view=diff
==
--- lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/Android/PlatformAndroid.cpp Mon May 14 
07:52:47 2018
@@ -193,8 +193,7 @@ Status PlatformAndroid::GetFile(const Fi
   if (IsHost() || !m_remote_platform_sp)
 return PlatformLinux::GetFile(source, destination);
 
-  FileSpec source_spec(source.GetPath(false), false,
-   FileSpec::ePathSyntaxPosix);
+  FileSpec source_spec(source.GetPath(false), false, FileSpec::Style::posix);
   if (source_spec.

[Lldb-commits] [lldb] r332250 - Remove Process references from the Host module

2018-05-14 Thread Pavel Labath via lldb-commits
Author: labath
Date: Mon May 14 08:13:13 2018
New Revision: 332250

URL: http://llvm.org/viewvc/llvm-project?rev=332250&view=rev
Log:
Remove Process references from the Host module

The Process class was only being referenced because of the last-ditch
effort in the process launchers to set a process death callback in case
one isn't set already.

Although launching a process for debugging is the most important kind of
"launch" we are doing, it is by far not the only one, so assuming this
particular callback is the one to be used is not a good idea (besides
breaking layering). Instead of assuming a particular exit callback, I
change the launcher code to require the callback to be set by the user (and fix
up the two call sites which did not set the callback already).

Reviewers: jingham, davide

Subscribers: lldb-commits

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

Modified:
lldb/trunk/include/lldb/Host/Host.h
lldb/trunk/include/lldb/Host/MonitoringProcessLauncher.h
lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
lldb/trunk/source/Host/common/NativeProcessProtocol.cpp
lldb/trunk/source/Host/macosx/Host.mm
lldb/trunk/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
lldb/trunk/source/Target/ProcessLaunchInfo.cpp
lldb/trunk/unittests/tools/lldb-server/tests/TestClient.cpp

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=332250&r1=332249&r2=332250&view=diff
==
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Mon May 14 08:13:13 2018
@@ -199,6 +199,9 @@ public:
 
   static const lldb::UnixSignalsSP &GetUnixSignals();
 
+  /// Launch the process specified in launch_info. The monitoring callback in
+  /// launch_info must be set, and it will be called when the process
+  /// terminates.
   static Status LaunchProcess(ProcessLaunchInfo &launch_info);
 
   //--

Modified: lldb/trunk/include/lldb/Host/MonitoringProcessLauncher.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/MonitoringProcessLauncher.h?rev=332250&r1=332249&r2=332250&view=diff
==
--- lldb/trunk/include/lldb/Host/MonitoringProcessLauncher.h (original)
+++ lldb/trunk/include/lldb/Host/MonitoringProcessLauncher.h Mon May 14 
08:13:13 2018
@@ -24,6 +24,9 @@ public:
   explicit MonitoringProcessLauncher(
   std::unique_ptr delegate_launcher);
 
+  /// Launch the process specified in launch_info. The monitoring callback in
+  /// launch_info must be set, and it will be called when the process
+  /// terminates.
   HostProcess LaunchProcess(const ProcessLaunchInfo &launch_info,
 Status &error) override;
 

Modified: lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h?rev=332250&r1=332249&r2=332250&view=diff
==
--- lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h (original)
+++ lldb/trunk/include/lldb/Target/ProcessLaunchInfo.h Mon May 14 08:13:13 2018
@@ -107,6 +107,12 @@ public:
 return m_monitor_callback;
   }
 
+  /// A Monitor callback which does not take any action on process events. Use
+  /// this if you don't need to take any particular action when the process
+  /// terminates, but you still need to reap it.
+  static bool NoOpMonitorCallback(lldb::pid_t pid, bool exited, int signal,
+  int status);
+
   bool GetMonitorSignals() const { return m_monitor_signals; }
 
   // If the LaunchInfo has a monitor callback, then arrange to monitor the

Modified: lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp?rev=332250&r1=332249&r2=332250&view=diff
==
--- lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp (original)
+++ lldb/trunk/source/Host/common/MonitoringProcessLauncher.cpp Mon May 14 
08:13:13 2018
@@ -9,7 +9,6 @@
 
 #include "lldb/Host/MonitoringProcessLauncher.h"
 #include "lldb/Host/HostProcess.h"
-#include "lldb/Target/Process.h"
 #include "lldb/Target/ProcessLaunchInfo.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Status.h"
@@ -58,18 +57,9 @@ MonitoringProcessLauncher::LaunchProcess
   if (process.GetProcessId() != LLDB_INVALID_PROCESS_ID) {
 Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));
 
-Host::MonitorChildProcessCallback callback =
-launch_info.GetMonitorProcessCallback();
-
-bool monitor_signals = f

  1   2   3   4   5   6   7   8   9   10   >