[Lldb-commits] [PATCH] D89236: [lldb] Fix bitfield "frame var" for pointers (pr47743)

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

@shafik, @teemperor, any thoughts on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89236

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


[Lldb-commits] [PATCH] D90102: [lldb] [Process/FreeBSDRemote] Enable watchpoint support

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny planned changes to this revision.
mgorny added a comment.

This patch breaks multithreaded register tests, so I need to look into 
threading more.


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

https://reviews.llvm.org/D90102

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


[Lldb-commits] [PATCH] D90034: [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.
Herald added a subscriber: JDevlieghere.



Comment at: 
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp:994-995
 !(m_xstate.xs_rfbm & XCR0_YMM_Hi128)) {
-  error.SetErrorStringWithFormat("register \"%s\" not supported by 
CPU/kernel",
- reg_info->name);
+  error.SetErrorStringWithFormat(
+  "register \"%s\" not supported by CPU/kernel", reg_info->name);
 } else {

mgorny wrote:
> labath wrote:
> > Is this code actually reachable? Ideally, I'd expect this to be checked 
> > immediately after program startup, so that we can avoid even reporting the 
> > existence of [xy]mm registers..
> Yes, it is. I've just run it inside qemu with an emulated non-AVX CPU, and 
> the code definitely gets run. The user-visible result is apparently that the 
> registers are reported as unavailable.
> 
> I suppose we could use sysctl (or cpuid) to check for supported instruction 
> sets in constructor but I don't really know how to make LLDB consider them 
> non-existing.
> 
> In any case, I think that's material for a separate patch.
I think you can make them non-existent by returning a smaller number via 
`GetUserRegisterCount`. Linux code has something like that, though I'm not sure 
that it is entirely correct.

Yeah, this is for a separate patch, though it has some implications for the 
caching code. The current linux code works by assuming that each "register set" 
is either entirely present or entirely absent (a reasonable assumption I'd 
say). That might make things tricky of one wants to have a single register set 
for reading/caching all of xstate data.

I'm wondering if register sets (as presented to the user) and register sets for 
the purposes of caching (maybe these should have a different name) shouldn't be 
distinct concepts...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90034

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


[Lldb-commits] [PATCH] D90114: [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I am somewhat surprised that this is sufficient. IIRC (from the time when I was 
fixing the same bug on linux) linux will set this bit on ANY modification of 
these registers, regardless of the value. OTOH, guaranteeing that the process 
does not touch these registers at all would be pretty tricky, so I guess this 
is better than nothing.


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

https://reviews.llvm.org/D90114

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


[Lldb-commits] [PATCH] D90105: [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.

Linux has this factored into a separate function (UpdateXSTATEforWrite), but 
this isn't too bad either. Could be another candidate for factoring...


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

https://reviews.llvm.org/D90105

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


[Lldb-commits] [PATCH] D90119: [lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

We arm bots, at least. Other arches will have to fix any build issues post 
commit ("if you like it, then you shoulda put a bot on it")


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

https://reviews.llvm.org/D90119

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


[Lldb-commits] [PATCH] D89236: [lldb] Fix bitfield "frame var" for pointers (pr47743)

2020-10-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89236

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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt:6
+lldbCore
+lldbHost
+lldbSymbol

I don't see this using any Host functionality.



Comment at: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:855
   m_sections_up = std::make_unique();
-
   ModuleSP module_sp(GetModule());

this too



Comment at: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp:145
 return nullptr;
-
   return objfile_up.release();

labath wrote:
> revert spurious changes.
do revert this before committing.



Comment at: lldb/test/Shell/ObjectFile/PDB/object.test:1
+# RUN: llvm-pdbutil yaml2pdb %p/Inputs/pdb.yaml -pdb=%t.pdb
+# RUN: lldb-test object-file %t.pdb | FileCheck %s

Consider "inlining" the yaml input into this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [PATCH] D90034: [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: 
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp:994-995
 !(m_xstate.xs_rfbm & XCR0_YMM_Hi128)) {
-  error.SetErrorStringWithFormat("register \"%s\" not supported by 
CPU/kernel",
- reg_info->name);
+  error.SetErrorStringWithFormat(
+  "register \"%s\" not supported by CPU/kernel", reg_info->name);
 } else {

labath wrote:
> mgorny wrote:
> > labath wrote:
> > > Is this code actually reachable? Ideally, I'd expect this to be checked 
> > > immediately after program startup, so that we can avoid even reporting 
> > > the existence of [xy]mm registers..
> > Yes, it is. I've just run it inside qemu with an emulated non-AVX CPU, and 
> > the code definitely gets run. The user-visible result is apparently that 
> > the registers are reported as unavailable.
> > 
> > I suppose we could use sysctl (or cpuid) to check for supported instruction 
> > sets in constructor but I don't really know how to make LLDB consider them 
> > non-existing.
> > 
> > In any case, I think that's material for a separate patch.
> I think you can make them non-existent by returning a smaller number via 
> `GetUserRegisterCount`. Linux code has something like that, though I'm not 
> sure that it is entirely correct.
> 
> Yeah, this is for a separate patch, though it has some implications for the 
> caching code. The current linux code works by assuming that each "register 
> set" is either entirely present or entirely absent (a reasonable assumption 
> I'd say). That might make things tricky of one wants to have a single 
> register set for reading/caching all of xstate data.
> 
> I'm wondering if register sets (as presented to the user) and register sets 
> for the purposes of caching (maybe these should have a different name) 
> shouldn't be distinct concepts...
I've been thinking about having two levels of 'register sets' but I've came to 
the conclusion that the benefit is not worth the added complexity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90034

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


[Lldb-commits] [PATCH] D90114: [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Well, NetBSD passes whatever value is in the XSAVE Area, and (according to the 
Intel manual) XSAVE indicates whether the values match the defaults.


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

https://reviews.llvm.org/D90114

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


[Lldb-commits] [lldb] 37d4d3b - [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-10-26T11:54:00+01:00
New Revision: 37d4d3bb4daf409102237132ae8e1db250da83be

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

LOG: [lldb] [test/Register] Use initial state for write tests

Reset registers to their 'initial' state instead of a semi-random
pattern in write tests.  While the latter might have been helpful
while debugging failures (i.e. to distinguish unmodified registers
from mistakenly written zeroes), the former makes it possible to test
whether xstate_bv field is written correctly when using XSAVE.

With this change, the four relevant tests start failing on NetBSD
without D90105.

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

Added: 


Modified: 
lldb/test/Shell/Register/Inputs/x86-64-write.cpp
lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp

Removed: 




diff  --git a/lldb/test/Shell/Register/Inputs/x86-64-write.cpp 
b/lldb/test/Shell/Register/Inputs/x86-64-write.cpp
index 056f2ebe2138..143805c5c0f9 100644
--- a/lldb/test/Shell/Register/Inputs/x86-64-write.cpp
+++ b/lldb/test/Shell/Register/Inputs/x86-64-write.cpp
@@ -9,7 +9,7 @@ union alignas(16) xmm_t {
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t r64[8];

diff  --git a/lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp 
b/lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
index 631d6f3a513a..c6b84d9232bd 100644
--- a/lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
+++ b/lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
@@ -9,7 +9,7 @@ union alignas(16) xmm_t {
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t mm[8];

diff  --git a/lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp 
b/lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
index 3375853291ed..0798e52467aa 100644
--- a/lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
+++ b/lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
@@ -9,8 +9,7 @@ union alignas(32) ymm_t {
 
 int main() {
   constexpr ymm_t ymm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0 }
   };
 
   ymm_t ymm[16];

diff  --git a/lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp 
b/lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
index 4830fb2a7424..c7b3e3f1bcb2 100644
--- a/lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
+++ b/lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
@@ -9,10 +9,7 @@ union alignas(64) zmm_t {
 
 int main() {
   constexpr zmm_t zmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
   zmm_t zmm[32];



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


[Lldb-commits] [PATCH] D90105: [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa8902376651a: [lldb] [Process/NetBSD] Set xs_xstate_bv 
correctly when setting regs (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90105

Files:
  lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp


Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -754,6 +754,8 @@
 return error;
   }
 
+  uint64_t new_xstate_bv = XCR0_X87;  // the most common case
+
   switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
   case llvm::Triple::x86_64:
 break;
@@ -918,9 +920,11 @@
 break;
   case lldb_mxcsr_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_mxcsrmask_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr_mask = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_st0_x86_64:
   case lldb_st1_x86_64:
@@ -966,6 +970,7 @@
 } else {
   ::memcpy(&m_xstate.xs_fxsave.fx_xmm[reg - lldb_xmm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
+  new_xstate_bv = XCR0_SSE;
 }
 break;
   case lldb_ymm0_x86_64:
@@ -994,6 +999,7 @@
   ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
   YMMToXState(ymm, m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
   m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+  new_xstate_bv = XCR0_SSE | XCR0_YMM_Hi128;
 }
 break;
   case lldb_dr0_x86_64:
@@ -1010,6 +1016,9 @@
 llvm_unreachable("Reading unknown/unsupported register");
   }
 
+  if (set == XStateRegSet)
+m_xstate.xs_xstate_bv |= new_xstate_bv;
+
   return WriteRegisterSet(set);
 }
 


Index: lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -754,6 +754,8 @@
 return error;
   }
 
+  uint64_t new_xstate_bv = XCR0_X87;  // the most common case
+
   switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
   case llvm::Triple::x86_64:
 break;
@@ -918,9 +920,11 @@
 break;
   case lldb_mxcsr_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_mxcsrmask_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr_mask = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_st0_x86_64:
   case lldb_st1_x86_64:
@@ -966,6 +970,7 @@
 } else {
   ::memcpy(&m_xstate.xs_fxsave.fx_xmm[reg - lldb_xmm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
+  new_xstate_bv = XCR0_SSE;
 }
 break;
   case lldb_ymm0_x86_64:
@@ -994,6 +999,7 @@
   ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
   YMMToXState(ymm, m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
   m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+  new_xstate_bv = XCR0_SSE | XCR0_YMM_Hi128;
 }
 break;
   case lldb_dr0_x86_64:
@@ -1010,6 +1016,9 @@
 llvm_unreachable("Reading unknown/unsupported register");
   }
 
+  if (set == XStateRegSet)
+m_xstate.xs_xstate_bv |= new_xstate_bv;
+
   return WriteRegisterSet(set);
 }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90119: [lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf5ca27569eac: [lldb] [Process/Linux] Reuse 
NativeRegisterContextWatchpoint_x86 (authored by mgorny).
Herald added a subscriber: jrtc27.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90119

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h

Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
@@ -12,6 +12,7 @@
 #define lldb_NativeRegisterContextLinux_x86_64_h
 
 #include "Plugins/Process/Linux/NativeRegisterContextLinux.h"
+#include "Plugins/Process/Utility/NativeRegisterContextWatchpoint_x86.h"
 #include "Plugins/Process/Utility/RegisterContext_x86.h"
 #include "Plugins/Process/Utility/lldb-x86-register-enums.h"
 #include 
@@ -21,7 +22,9 @@
 
 class NativeProcessLinux;
 
-class NativeRegisterContextLinux_x86_64 : public NativeRegisterContextLinux {
+class NativeRegisterContextLinux_x86_64
+: public NativeRegisterContextLinux,
+  public NativeRegisterContextWatchpoint_x86 {
 public:
   NativeRegisterContextLinux_x86_64(const ArchSpec &target_arch,
 NativeThreadProtocol &native_thread);
@@ -42,28 +45,6 @@
 
   Status WriteAllRegisterValues(const lldb::DataBufferSP &data_sp) override;
 
-  Status IsWatchpointHit(uint32_t wp_index, bool &is_hit) override;
-
-  Status GetWatchpointHitIndex(uint32_t &wp_index,
-   lldb::addr_t trap_addr) override;
-
-  Status IsWatchpointVacant(uint32_t wp_index, bool &is_vacant) override;
-
-  bool ClearHardwareWatchpoint(uint32_t wp_index) override;
-
-  Status ClearAllHardwareWatchpoints() override;
-
-  Status SetHardwareWatchpointWithIndex(lldb::addr_t addr, size_t size,
-uint32_t watch_flags,
-uint32_t wp_index);
-
-  uint32_t SetHardwareWatchpoint(lldb::addr_t addr, size_t size,
- uint32_t watch_flags) override;
-
-  lldb::addr_t GetWatchpointAddress(uint32_t wp_index) override;
-
-  uint32_t NumSupportedHardwareWatchpoints() override;
-
   llvm::Optional GetSyscallData() override;
 
   llvm::Optional GetMmapData() override;
@@ -109,6 +90,7 @@
 uint32_t first_mpxc;
 uint32_t last_mpxc;
 uint32_t first_dr;
+uint32_t last_dr;
 uint32_t gpr_flags;
   };
 
@@ -132,6 +114,8 @@
 
   bool IsFPR(uint32_t reg_index) const;
 
+  bool IsDR(uint32_t reg_index) const;
+
   bool CopyXSTATEtoYMM(uint32_t reg_index, lldb::ByteOrder byte_order);
 
   bool CopyYMMtoXSTATE(uint32_t reg, lldb::ByteOrder byte_order);
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
@@ -293,8 +293,8 @@
 
 NativeRegisterContextLinux_x86_64::NativeRegisterContextLinux_x86_64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
-: NativeRegisterContextLinux(native_thread,
- CreateRegisterInfoInterface(target_arch)),
+: NativeRegisterContextRegisterInfo(
+  native_thread, CreateRegisterInfoInterface(target_arch)),
   m_xstate_type(XStateType::Invalid), m_ymm_set(), m_mpx_set(),
   m_reg_info(), m_gpr_x86_64() {
   // Set up data about ranges of valid registers.
@@ -321,6 +321,7 @@
 m_reg_info.first_mpxc = lldb_bndcfgu_i386;
 m_reg_info.last_mpxc = lldb_bndstatus_i386;
 m_reg_info.first_dr = lldb_dr0_i386;
+m_reg_info.last_dr = lldb_dr7_i386;
 m_reg_info.gpr_flags = lldb_eflags_i386;
 break;
   case llvm::Triple::x86_64:
@@ -345,6 +346,7 @@
 m_reg_info.first_mpxc = lldb_bndcfgu_x86_64;
 m_reg_info.last_mpxc = lldb_bndstatus_x86_64;
 m_reg_info.first_dr = lldb_dr0_x86_64;
+m_reg_info.last_dr = lldb_dr7_x86_64;
 m_reg_info.gpr_flags = lldb_rflags_x86_64;
 break;
   default:
@@ -578,7 +580,7 @@
 
   UpdateXSTATEforWrite(r

[Lldb-commits] [PATCH] D90114: [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG37d4d3bb4daf: [lldb] [test/Register] Use initial state for 
write tests (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90114

Files:
  lldb/test/Shell/Register/Inputs/x86-64-write.cpp
  lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
  lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
  lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp


Index: lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
@@ -9,10 +9,7 @@
 
 int main() {
   constexpr zmm_t zmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
   zmm_t zmm[32];
Index: lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
@@ -9,8 +9,7 @@
 
 int main() {
   constexpr ymm_t ymm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0 }
   };
 
   ymm_t ymm[16];
Index: lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
@@ -9,7 +9,7 @@
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t mm[8];
Index: lldb/test/Shell/Register/Inputs/x86-64-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-64-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-64-write.cpp
@@ -9,7 +9,7 @@
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t r64[8];


Index: lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-zmm-write.cpp
@@ -9,10 +9,7 @@
 
 int main() {
   constexpr zmm_t zmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0, 0, 0, 0, 0 }
   };
 
   zmm_t zmm[32];
Index: lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-ymm-write.cpp
@@ -9,8 +9,7 @@
 
 int main() {
   constexpr ymm_t ymm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F,
-   0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0, 0, 0 }
   };
 
   ymm_t ymm[16];
Index: lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-mm-xmm-write.cpp
@@ -9,7 +9,7 @@
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t mm[8];
Index: lldb/test/Shell/Register/Inputs/x86-64-write.cpp
===
--- lldb/test/Shell/Register/Inputs/x86-64-write.cpp
+++ lldb/test/Shell/Register/Inputs/x86-64-write.cpp
@@ -9,7 +9,7 @@
 
 int main() {
   constexpr xmm_t xmm_fill = {
-.as_uint64 = { 0x0F0F0F0F0F0F0F0F, 0x0F0F0F0F0F0F0F0F }
+.as_uint64 = { 0, 0 }
   };
 
   uint64_t r64[8];
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90128: [lldb] [Process/FreeBSDRemote] Fix #include for i386 compat

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7acf2e2e1e8f: [lldb] [Process/FreeBSDRemote] Fix #include 
for i386 compat (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90128

Files:
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp


Index: 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -11,7 +11,7 @@
 #include "NativeRegisterContextFreeBSD_x86_64.h"
 
 // clang-format off
-#include 
+#include 
 #include 
 #include 
 // clang-format on


Index: lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
===
--- lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -11,7 +11,7 @@
 #include "NativeRegisterContextFreeBSD_x86_64.h"
 
 // clang-format off
-#include 
+#include 
 #include 
 #include 
 // clang-format on
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 7acf2e2 - [lldb] [Process/FreeBSDRemote] Fix #include for i386 compat

2020-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-10-26T11:53:26+01:00
New Revision: 7acf2e2e1e8f7e2eac2dd5bbf7d752ba7ad4e79c

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

LOG: [lldb] [Process/FreeBSDRemote] Fix #include for i386 compat

Include  rather than , as the latter is not
present on i386.

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

Added: 


Modified: 

lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
index 3460f53a2934..ac83aeda997c 100644
--- 
a/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
+++ 
b/lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
@@ -11,7 +11,7 @@
 #include "NativeRegisterContextFreeBSD_x86_64.h"
 
 // clang-format off
-#include 
+#include 
 #include 
 #include 
 // clang-format on



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


[Lldb-commits] [lldb] f5ca275 - [lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86

2020-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-10-26T11:55:22+01:00
New Revision: f5ca27569eacc398f0e4fc63a9b55cafac398c04

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

LOG: [lldb] [Process/Linux] Reuse NativeRegisterContextWatchpoint_x86

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

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
index 1b9e067639cc..90a6d8dcba04 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -19,11 +19,6 @@
 using namespace lldb_private;
 using namespace lldb_private::process_linux;
 
-NativeRegisterContextLinux::NativeRegisterContextLinux(
-NativeThreadProtocol &native_thread,
-RegisterInfoInterface *reg_info_interface_p)
-: NativeRegisterContextRegisterInfo(native_thread, reg_info_interface_p) {}
-
 lldb::ByteOrder NativeRegisterContextLinux::GetByteOrder() const {
   return m_thread.GetProcess().GetByteOrder();
 }

diff  --git a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
index 7f321c0b5926..fa067b78d176 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -15,11 +15,9 @@
 namespace lldb_private {
 namespace process_linux {
 
-class NativeRegisterContextLinux : public NativeRegisterContextRegisterInfo {
+class NativeRegisterContextLinux
+: public virtual NativeRegisterContextRegisterInfo {
 public:
-  NativeRegisterContextLinux(NativeThreadProtocol &native_thread,
- RegisterInfoInterface *reg_info_interface_p);
-
   // This function is implemented in the NativeRegisterContextLinux_* 
subclasses
   // to create a new instance of the host specific NativeRegisterContextLinux.
   // The implementations can't collide as only one NativeRegisterContextLinux_*

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
index 04714ec3c374..e15e0f8a5651 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
@@ -56,8 +56,8 @@ 
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
 
 NativeRegisterContextLinux_arm::NativeRegisterContextLinux_arm(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
-: NativeRegisterContextLinux(native_thread,
- new RegisterInfoPOSIX_arm(target_arch)) {
+: NativeRegisterContextRegisterInfo(
+  native_thread, new RegisterInfoPOSIX_arm(target_arch)) {
   assert(target_arch.GetMachine() == llvm::Triple::arm);
 
   ::memset(&m_fpr, 0, sizeof(m_fpr));

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
index 0aef36c7e231..810bc8479742 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
@@ -56,8 +56,8 @@ 
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
 
 NativeRegisterContextLinux_arm64::NativeRegisterContextLinux_arm64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
-: NativeRegisterContextLinux(native_thread,
- new RegisterInfoPOSIX_arm64(target_arch)) {
+: NativeRegisterContextRegisterInfo(
+  native_thread, new RegisterInfoPOSIX_arm64(target_arch)) {
   ::memset(&m_fpr, 0, sizeof(m_fpr));
   ::memset(&m_gpr_arm64, 0, sizeof(m_gpr_arm64));
   ::memset(&m_hwp_regs, 0, sizeof(m_hwp_regs));

diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_mips64.cpp
index b0a4ad94ce0

[Lldb-commits] [lldb] a890237 - [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

2020-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2020-10-26T11:54:40+01:00
New Revision: a8902376651a7adbacd0c1934d9f70bdb9fad7f0

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

LOG: [lldb] [Process/NetBSD] Set xs_xstate_bv correctly when setting regs

Ensure that xs_xstate_bv is set correctly before calling
WriteRegisterSet().  The bit can be clear if the relevant registers
were at their initial state when they were read, and it needs to be set
in order to apply changes from the XState structure.

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

Added: 


Modified: 
lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp 
b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
index fb8d64ffe997..2e2eacdfccef 100644
--- a/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
+++ b/lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
@@ -754,6 +754,8 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
 return error;
   }
 
+  uint64_t new_xstate_bv = XCR0_X87;  // the most common case
+
   switch (GetRegisterInfoInterface().GetTargetArchitecture().GetMachine()) {
   case llvm::Triple::x86_64:
 break;
@@ -918,9 +920,11 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
 break;
   case lldb_mxcsr_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_mxcsrmask_x86_64:
 m_xstate.xs_fxsave.fx_mxcsr_mask = reg_value.GetAsUInt32();
+new_xstate_bv = XCR0_SSE;
 break;
   case lldb_st0_x86_64:
   case lldb_st1_x86_64:
@@ -966,6 +970,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
 } else {
   ::memcpy(&m_xstate.xs_fxsave.fx_xmm[reg - lldb_xmm0_x86_64],
reg_value.GetBytes(), reg_value.GetByteSize());
+  new_xstate_bv = XCR0_SSE;
 }
 break;
   case lldb_ymm0_x86_64:
@@ -994,6 +999,7 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
   ::memcpy(ymm.bytes, reg_value.GetBytes(), reg_value.GetByteSize());
   YMMToXState(ymm, m_xstate.xs_fxsave.fx_xmm[reg_index].xmm_bytes,
   m_xstate.xs_ymm_hi128.xs_ymm[reg_index].ymm_bytes);
+  new_xstate_bv = XCR0_SSE | XCR0_YMM_Hi128;
 }
 break;
   case lldb_dr0_x86_64:
@@ -1010,6 +1016,9 @@ Status NativeRegisterContextNetBSD_x86_64::WriteRegister(
 llvm_unreachable("Reading unknown/unsupported register");
   }
 
+  if (set == XStateRegSet)
+m_xstate.xs_xstate_bv |= new_xstate_bv;
+
   return WriteRegisterSet(set);
 }
 



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


[Lldb-commits] [lldb] e4cc6e9 - [lldb] Modernize PseudoTerminal::Fork

2020-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-10-26T12:01:20+01:00
New Revision: e4cc6e9bcdff5fe979ab72025cb803d723cd9c31

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

LOG: [lldb] Modernize PseudoTerminal::Fork

Added: 


Modified: 
lldb/include/lldb/Host/PseudoTerminal.h
lldb/source/Host/common/PseudoTerminal.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/PseudoTerminal.h 
b/lldb/include/lldb/Host/PseudoTerminal.h
index f7f8e636730e..350f926dcac1 100644
--- a/lldb/include/lldb/Host/PseudoTerminal.h
+++ b/lldb/include/lldb/Host/PseudoTerminal.h
@@ -62,15 +62,11 @@ class PseudoTerminal {
   /// @li PseudoTerminal::ReleasePrimaryFileDescriptor() @li
   /// PseudoTerminal::ReleaseSaveFileDescriptor()
   ///
-  /// \param[out] error_str
-  /// An pointer to an error that can describe any errors that
-  /// occur. This can be NULL if no error status is desired.
-  ///
   /// \return
   /// \b Parent process: a child process ID that is greater
-  /// than zero, or -1 if the fork fails.
+  /// than zero, or an error if the fork fails.
   /// \b Child process: zero.
-  lldb::pid_t Fork(char *error_str, size_t error_len);
+  llvm::Expected Fork();
 
   /// The primary file descriptor accessor.
   ///

diff  --git a/lldb/source/Host/common/PseudoTerminal.cpp 
b/lldb/source/Host/common/PseudoTerminal.cpp
index dc0298cee849..c5f101caffe3 100644
--- a/lldb/source/Host/common/PseudoTerminal.cpp
+++ b/lldb/source/Host/common/PseudoTerminal.cpp
@@ -28,12 +28,6 @@ int posix_openpt(int flags);
 
 using namespace lldb_private;
 
-// Write string describing error number
-static void ErrnoToStr(char *error_str, size_t error_len) {
-  std::string strerror = llvm::sys::StrError();
-  ::snprintf(error_str, error_len, "%s", strerror.c_str());
-}
-
 // PseudoTerminal constructor
 PseudoTerminal::PseudoTerminal()
 : m_primary_fd(invalid_fd), m_secondary_fd(invalid_fd) {}
@@ -123,79 +117,47 @@ std::string PseudoTerminal::GetSecondaryName() const {
 #endif
 }
 
-// Fork a child process and have its stdio routed to a pseudo terminal.
-//
-// In the parent process when a valid pid is returned, the primary file
-// descriptor can be used as a read/write access to stdio of the child process.
-//
-// In the child process the stdin/stdout/stderr will already be routed to the
-// secondary pseudo terminal and the primary file descriptor will be closed as
-// it is no longer needed by the child process.
-//
-// This class will close the file descriptors for the primary/secondary when 
the
-// destructor is called, so be sure to call ReleasePrimaryFileDescriptor() or
-// ReleaseSecondaryFileDescriptor() if any file descriptors are going to be 
used
-// past the lifespan of this object.
-//
-// RETURNS:
-//  in the parent process: the pid of the child, or -1 if fork fails
-//  in the child process: zero
-lldb::pid_t PseudoTerminal::Fork(char *error_str, size_t error_len) {
-  if (error_str)
-error_str[0] = '\0';
-  pid_t pid = LLDB_INVALID_PROCESS_ID;
+llvm::Expected PseudoTerminal::Fork() {
 #if LLDB_ENABLE_POSIX
-  if (llvm::Error Err = OpenFirstAvailablePrimary(O_RDWR | O_CLOEXEC)) {
-snprintf(error_str, error_len, "%s", toString(std::move(Err)).c_str());
-return LLDB_INVALID_PROCESS_ID;
-  }
+  if (llvm::Error Err = OpenFirstAvailablePrimary(O_RDWR | O_CLOEXEC))
+return std::move(Err);
 
-  pid = ::fork();
+  pid_t pid = ::fork();
   if (pid < 0) {
-// Fork failed
-if (error_str)
-  ErrnoToStr(error_str, error_len);
-  } else if (pid == 0) {
-// Child Process
-::setsid();
-
-if (llvm::Error Err = OpenSecondary(O_RDWR)) {
-  snprintf(error_str, error_len, "%s", toString(std::move(Err)).c_str());
-  return LLDB_INVALID_PROCESS_ID;
-}
+return llvm::errorCodeToError(
+std::error_code(errno, std::generic_category()));
+  }
+  if (pid > 0) {
+// Parent process.
+return pid;
+  }
 
-// Primary FD should have O_CLOEXEC set, but let's close it just in
-// case...
-ClosePrimaryFileDescriptor();
+  // Child Process
+  ::setsid();
 
-#if defined(TIOCSCTTY)
-// Acquire the controlling terminal
-if (::ioctl(m_secondary_fd, TIOCSCTTY, (char *)0) < 0) {
-  if (error_str)
-ErrnoToStr(error_str, error_len);
-}
-#endif
-// Duplicate all stdio file descriptors to the secondary pseudo terminal
-if (::dup2(m_secondary_fd, STDIN_FILENO) != STDIN_FILENO) {
-  if (error_str && !error_str[0])
-ErrnoToStr(error_str, error_len);
-}
+  if (llvm::Error Err = OpenSecondary(O_RDWR))
+return std::move(Err);
 
-if (::dup2(m_secondary_fd, STDOUT_FILENO) != STDOUT_FILENO) {
-  if (error_str && !error_str[0])
-

[Lldb-commits] [PATCH] D89236: [lldb] Fix bitfield "frame var" for pointers (pr47743)

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97ca9ca180f0: [lldb] Fix bitfield "frame var" for 
pointers (pr47743) (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89236

Files:
  lldb/source/Core/ValueObjectChild.cpp
  lldb/test/API/lang/c/bitfields/TestBitfields.py
  lldb/test/API/lang/c/bitfields/main.c

Index: lldb/test/API/lang/c/bitfields/main.c
===
--- lldb/test/API/lang/c/bitfields/main.c
+++ lldb/test/API/lang/c/bitfields/main.c
@@ -90,6 +90,7 @@
 
 struct LargePackedBits large_packed =
   (struct LargePackedBits){ 0xc, 0xd };
+struct LargePackedBits *large_packed_ptr = &large_packed;
 
 return 0;    Set break point at this line.
 
Index: lldb/test/API/lang/c/bitfields/TestBitfields.py
===
--- lldb/test/API/lang/c/bitfields/TestBitfields.py
+++ lldb/test/API/lang/c/bitfields/TestBitfields.py
@@ -147,6 +147,12 @@
 self.expect("v/x large_packed", VARIABLES_DISPLAYED_CORRECTLY,
 substrs=["a = 0x000c", "b = 0x000deee"])
 
+# Check reading a bitfield through a pointer in various ways (PR47743)
+self.expect("v/x large_packed_ptr->b",
+substrs=["large_packed_ptr->b = 0x000d"])
+self.expect("v/x large_packed_ptr[0].b",
+substrs=["large_packed_ptr[0].b = 0x000d"])
+
 # BitFields exhibit crashes in record layout on Windows
 # (http://llvm.org/pr21800)
 @skipIfWindows
Index: lldb/source/Core/ValueObjectChild.cpp
===
--- lldb/source/Core/ValueObjectChild.cpp
+++ lldb/source/Core/ValueObjectChild.cpp
@@ -111,8 +111,7 @@
   CompilerType parent_type(parent->GetCompilerType());
   // Copy the parent scalar value and the scalar value type
   m_value.GetScalar() = parent->GetValue().GetScalar();
-  Value::ValueType value_type = parent->GetValue().GetValueType();
-  m_value.SetValueType(value_type);
+  m_value.SetValueType(parent->GetValue().GetValueType());
 
   Flags parent_type_flags(parent_type.GetTypeInfo());
   const bool is_instance_ptr_base =
@@ -120,93 +119,80 @@
(parent_type_flags.AnySet(lldb::eTypeInstanceIsPointer)));
 
   if (parent->GetCompilerType().ShouldTreatScalarValueAsAddress()) {
-lldb::addr_t addr = parent->GetPointerValue();
-m_value.GetScalar() = addr;
-
+m_value.GetScalar() = parent->GetPointerValue();
+
+switch (parent->GetAddressTypeOfChildren()) {
+case eAddressTypeFile: {
+  lldb::ProcessSP process_sp(GetProcessSP());
+  if (process_sp && process_sp->IsAlive())
+m_value.SetValueType(Value::eValueTypeLoadAddress);
+  else
+m_value.SetValueType(Value::eValueTypeFileAddress);
+} break;
+case eAddressTypeLoad:
+  m_value.SetValueType(is_instance_ptr_base
+   ? Value::eValueTypeScalar
+   : Value::eValueTypeLoadAddress);
+  break;
+case eAddressTypeHost:
+  m_value.SetValueType(Value::eValueTypeHostAddress);
+  break;
+case eAddressTypeInvalid:
+  // TODO: does this make sense?
+  m_value.SetValueType(Value::eValueTypeScalar);
+  break;
+}
+  }
+  switch (m_value.GetValueType()) {
+  case Value::eValueTypeLoadAddress:
+  case Value::eValueTypeFileAddress:
+  case Value::eValueTypeHostAddress: {
+lldb::addr_t addr = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 if (addr == LLDB_INVALID_ADDRESS) {
   m_error.SetErrorString("parent address is invalid.");
 } else if (addr == 0) {
   m_error.SetErrorString("parent is NULL");
 } else {
-  m_value.GetScalar() += m_byte_offset;
-  AddressType addr_type = parent->GetAddressTypeOfChildren();
-
-  switch (addr_type) {
-  case eAddressTypeFile: {
-lldb::ProcessSP process_sp(GetProcessSP());
-if (process_sp && process_sp->IsAlive())
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-else
-  m_value.SetValueType(Value::eValueTypeFileAddress);
-  } break;
-  case eAddressTypeLoad:
-m_value.SetValueType(is_instance_ptr_base
- ? Value::eValueTypeScalar
- : Value::eValueTypeLoadAddress);
-break;
-  case eAddressTypeHost:
-m_value.SetValueType(Value::eValueTypeHostAddress);
-bre

[Lldb-commits] [lldb] 97ca9ca - [lldb] Fix bitfield "frame var" for pointers (pr47743)

2020-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-10-26T12:01:20+01:00
New Revision: 97ca9ca180f0810adcc1637d1a6dd32a04f63cfe

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

LOG: [lldb] Fix bitfield "frame var" for pointers (pr47743)

Displaying large packed bitfields did not work if one was accessing them
through a pointer, and he used the "->" notation ("[0]." notation is
fine). The reason for that is that implicit dereference in -> is plumbed
all the way down to ValueObjectChild::UpdateValue, where the process of
fetching the child value was forked for this flag. The bitfield
"sliding" code was implemented only for the branch which did not require
dereferencing.

This patch restructures the function to avoid this mistake. Processing
now happens in two stages.
- first the parent is dereferenced (if needed)
- then the child value is computed (this step includes sliding and is
  common for both branches)

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

Added: 


Modified: 
lldb/source/Core/ValueObjectChild.cpp
lldb/test/API/lang/c/bitfields/TestBitfields.py
lldb/test/API/lang/c/bitfields/main.c

Removed: 




diff  --git a/lldb/source/Core/ValueObjectChild.cpp 
b/lldb/source/Core/ValueObjectChild.cpp
index 63661a482313..97974d7b98fb 100644
--- a/lldb/source/Core/ValueObjectChild.cpp
+++ b/lldb/source/Core/ValueObjectChild.cpp
@@ -111,8 +111,7 @@ bool ValueObjectChild::UpdateValue() {
   CompilerType parent_type(parent->GetCompilerType());
   // Copy the parent scalar value and the scalar value type
   m_value.GetScalar() = parent->GetValue().GetScalar();
-  Value::ValueType value_type = parent->GetValue().GetValueType();
-  m_value.SetValueType(value_type);
+  m_value.SetValueType(parent->GetValue().GetValueType());
 
   Flags parent_type_flags(parent_type.GetTypeInfo());
   const bool is_instance_ptr_base =
@@ -120,93 +119,80 @@ bool ValueObjectChild::UpdateValue() {
(parent_type_flags.AnySet(lldb::eTypeInstanceIsPointer)));
 
   if (parent->GetCompilerType().ShouldTreatScalarValueAsAddress()) {
-lldb::addr_t addr = parent->GetPointerValue();
-m_value.GetScalar() = addr;
-
+m_value.GetScalar() = parent->GetPointerValue();
+
+switch (parent->GetAddressTypeOfChildren()) {
+case eAddressTypeFile: {
+  lldb::ProcessSP process_sp(GetProcessSP());
+  if (process_sp && process_sp->IsAlive())
+m_value.SetValueType(Value::eValueTypeLoadAddress);
+  else
+m_value.SetValueType(Value::eValueTypeFileAddress);
+} break;
+case eAddressTypeLoad:
+  m_value.SetValueType(is_instance_ptr_base
+   ? Value::eValueTypeScalar
+   : Value::eValueTypeLoadAddress);
+  break;
+case eAddressTypeHost:
+  m_value.SetValueType(Value::eValueTypeHostAddress);
+  break;
+case eAddressTypeInvalid:
+  // TODO: does this make sense?
+  m_value.SetValueType(Value::eValueTypeScalar);
+  break;
+}
+  }
+  switch (m_value.GetValueType()) {
+  case Value::eValueTypeLoadAddress:
+  case Value::eValueTypeFileAddress:
+  case Value::eValueTypeHostAddress: {
+lldb::addr_t addr = 
m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
 if (addr == LLDB_INVALID_ADDRESS) {
   m_error.SetErrorString("parent address is invalid.");
 } else if (addr == 0) {
   m_error.SetErrorString("parent is NULL");
 } else {
-  m_value.GetScalar() += m_byte_offset;
-  AddressType addr_type = parent->GetAddressTypeOfChildren();
-
-  switch (addr_type) {
-  case eAddressTypeFile: {
-lldb::ProcessSP process_sp(GetProcessSP());
-if (process_sp && process_sp->IsAlive())
-  m_value.SetValueType(Value::eValueTypeLoadAddress);
-else
-  m_value.SetValueType(Value::eValueTypeFileAddress);
-  } break;
-  case eAddressTypeLoad:
-m_value.SetValueType(is_instance_ptr_base
- ? Value::eValueTypeScalar
- : Value::eValueTypeLoadAddress);
-break;
-  case eAddressTypeHost:
-m_value.SetValueType(Value::eValueTypeHostAddress);
-break;
-  case eAddressTypeInvalid:
-// TODO: does this make sense?
-m_value.SetValueType(Value::eValueTypeScalar);
-break;
-  }
-}
-  } else {
-switch (value_type) {
-case Value::eValueTypeLoadAddress:
-case Value::eValueTypeFileAddress:
-case Value::eValueTy

[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Andy Yankovsky via Phabricator via lldb-commits
werat created this revision.
werat added a reviewer: JDevlieghere.
werat added a project: LLDB.
Herald added a subscriber: lldb-commits.
werat requested review of this revision.

`SBError::SetErrorToGenericError` should call `Status::SetErrorToGenericError`, 
not `Status::SetErrorToErrno`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90151

Files:
  lldb/source/API/SBError.cpp


Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {


Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

Could you add a test for this? This should be enough:

  diff --git a/lldb/test/API/python_api/sberror/TestSBError.py 
b/lldb/test/API/python_api/sberror/TestSBError.py
  new file mode 100644
  index ..91d5a334bff2
  --- /dev/null
  +++ b/lldb/test/API/python_api/sberror/TestSBError.py
  @@ -0,0 +1,11 @@
  +from lldbsuite.test.lldbtest import *
  +
  +class TestSBError(TestBase):
  +
  +mydir = TestBase.compute_mydir(__file__)
  +NO_DEBUG_INFO_TESTCASE = True
  +
  +def test_generic_error(self):
  +  error = lldb.SBError()
  +  error.SetErrorToGenericError()
  +  self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)

Otherwise this LGTM, thanks for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90151

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


[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Andy Yankovsky via Phabricator via lldb-commits
werat updated this revision to Diff 300652.
werat added a comment.

Add a test case.


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

https://reviews.llvm.org/D90151

Files:
  lldb/source/API/SBError.cpp
  lldb/test/API/python_api/sberror/TestSBError.py


Index: lldb/test/API/python_api/sberror/TestSBError.py
===
--- /dev/null
+++ lldb/test/API/python_api/sberror/TestSBError.py
@@ -0,0 +1,13 @@
+"""Test the SBError APIs."""
+
+from lldbsuite.test.lldbtest import *
+
+class TestSBError(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_generic_error(self):
+error = lldb.SBError()
+error.SetErrorToGenericError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)
Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {


Index: lldb/test/API/python_api/sberror/TestSBError.py
===
--- /dev/null
+++ lldb/test/API/python_api/sberror/TestSBError.py
@@ -0,0 +1,13 @@
+"""Test the SBError APIs."""
+
+from lldbsuite.test.lldbtest import *
+
+class TestSBError(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_generic_error(self):
+error = lldb.SBError()
+error.SetErrorToGenericError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)
Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

Thanks! I assume you don't have commit access, so I'll land this for you.


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

https://reviews.llvm.org/D90151

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


[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Andy Yankovsky via Phabricator via lldb-commits
werat added a comment.

Thanks! Yeah, I don't have commit access, thanks for landing it for me.


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

https://reviews.llvm.org/D90151

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


[Lldb-commits] [lldb] d0ee1d8 - [lldb][NFC] Make GetShellSafeArgument simpler and faster

2020-10-26 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-10-26T15:29:13+01:00
New Revision: d0ee1d8efe804b3184b1073cd367a307867f1372

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

LOG: [lldb][NFC] Make GetShellSafeArgument simpler and faster

Escaping by inserting characters in the middle of a std::string isn't cheap.
It's much more verbose than just prepending a backslash in a loop.

Added: 


Modified: 
lldb/source/Utility/Args.cpp

Removed: 




diff  --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp
index 152e73db08ea..ed61e1c16303 100644
--- a/lldb/source/Utility/Args.cpp
+++ b/lldb/source/Utility/Args.cpp
@@ -383,7 +383,7 @@ std::string Args::GetShellSafeArgument(const FileSpec 
&shell,
llvm::StringRef unsafe_arg) {
   struct ShellDescriptor {
 ConstString m_basename;
-const char *m_escapables;
+llvm::StringRef m_escapables;
   };
 
   static ShellDescriptor g_Shells[] = {{ConstString("bash"), " '\"<>()&"},
@@ -391,7 +391,7 @@ std::string Args::GetShellSafeArgument(const FileSpec 
&shell,
{ConstString("sh"), " '\"<>()&"}};
 
   // safe minimal set
-  const char *escapables = " '\"";
+  llvm::StringRef escapables = " '\"";
 
   if (auto basename = shell.GetFilename()) {
 for (const auto &Shell : g_Shells) {
@@ -402,16 +402,13 @@ std::string Args::GetShellSafeArgument(const FileSpec 
&shell,
 }
   }
 
-  std::string safe_arg(unsafe_arg);
-  size_t prev_pos = 0;
-  while (prev_pos < safe_arg.size()) {
-// Escape spaces and quotes
-size_t pos = safe_arg.find_first_of(escapables, prev_pos);
-if (pos != std::string::npos) {
-  safe_arg.insert(pos, 1, '\\');
-  prev_pos = pos + 2;
-} else
-  break;
+  std::string safe_arg;
+  safe_arg.reserve(unsafe_arg.size());
+  // Add a \ before every character that needs to be escaped.
+  for (char c : unsafe_arg) {
+if (escapables.contains(c))
+  safe_arg.push_back('\\');
+safe_arg.push_back(c);
   }
   return safe_arg;
 }



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


[Lldb-commits] [PATCH] D90114: [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.
Herald added a subscriber: JDevlieghere.

In D90114#2353155 , @mgorny wrote:

> Well, NetBSD passes whatever value is in the XSAVE Area, and (according to 
> the Intel manual) XSAVE indicates whether the values match the defaults.

It seems I was wrong. Disabling the relevant linux code makes your new tests 
pass. Thanks for figuring how how to test these.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90114

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


[Lldb-commits] [PATCH] D90151: Fix SBError::SetErrorToGenericError

2020-10-26 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG206e8d890503: Fix SBError::SetErrorToGenericError (authored 
by werat, committed by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90151

Files:
  lldb/source/API/SBError.cpp
  lldb/test/API/python_api/sberror/TestSBError.py


Index: lldb/test/API/python_api/sberror/TestSBError.py
===
--- /dev/null
+++ lldb/test/API/python_api/sberror/TestSBError.py
@@ -0,0 +1,13 @@
+"""Test the SBError APIs."""
+
+from lldbsuite.test.lldbtest import *
+
+class TestSBError(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_generic_error(self):
+error = lldb.SBError()
+error.SetErrorToGenericError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)
Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {


Index: lldb/test/API/python_api/sberror/TestSBError.py
===
--- /dev/null
+++ lldb/test/API/python_api/sberror/TestSBError.py
@@ -0,0 +1,13 @@
+"""Test the SBError APIs."""
+
+from lldbsuite.test.lldbtest import *
+
+class TestSBError(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_generic_error(self):
+error = lldb.SBError()
+error.SetErrorToGenericError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)
Index: lldb/source/API/SBError.cpp
===
--- lldb/source/API/SBError.cpp
+++ lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 206e8d8 - Fix SBError::SetErrorToGenericError

2020-10-26 Thread Raphael Isemann via lldb-commits

Author: Andy Yankovsky
Date: 2020-10-26T15:44:38+01:00
New Revision: 206e8d8905035f6e9049b97c9cd8af0eaa5aa118

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

LOG: Fix SBError::SetErrorToGenericError

`SBError::SetErrorToGenericError` should call `Status::SetErrorToGenericError`,
not `Status::SetErrorToErrno`.

Reviewed By: teemperor

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

Added: 
lldb/test/API/python_api/sberror/TestSBError.py

Modified: 
lldb/source/API/SBError.cpp

Removed: 




diff  --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp
index 67c7663d3583..f979572778e0 100644
--- a/lldb/source/API/SBError.cpp
+++ b/lldb/source/API/SBError.cpp
@@ -118,7 +118,7 @@ void SBError::SetErrorToGenericError() {
   LLDB_RECORD_METHOD_NO_ARGS(void, SBError, SetErrorToGenericError);
 
   CreateIfNeeded();
-  m_opaque_up->SetErrorToErrno();
+  m_opaque_up->SetErrorToGenericError();
 }
 
 void SBError::SetErrorString(const char *err_str) {

diff  --git a/lldb/test/API/python_api/sberror/TestSBError.py 
b/lldb/test/API/python_api/sberror/TestSBError.py
new file mode 100644
index ..aa798ba48730
--- /dev/null
+++ b/lldb/test/API/python_api/sberror/TestSBError.py
@@ -0,0 +1,13 @@
+"""Test the SBError APIs."""
+
+from lldbsuite.test.lldbtest import *
+
+class TestSBError(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+NO_DEBUG_INFO_TESTCASE = True
+
+def test_generic_error(self):
+error = lldb.SBError()
+error.SetErrorToGenericError()
+self.assertEqual(error.GetType(), lldb.eErrorTypeGeneric)



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


[Lldb-commits] [PATCH] D90114: [lldb] [test/Register] Use initial state for write tests

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I've discovered this by accident when I was figuring why fp-write tests started 
failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90114

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


[Lldb-commits] [PATCH] D90034: [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm not sure I agree with that. Given the ever-growing number of registers 
(which are likely going to all end up in the "xstate" block), I think it is 
important to be able to add some structure to the list of registers. Also, 
having the ability to group registers which can come or go together will 
probably make it easier to implement the "disappearance" of unsupported 
registers. Given how xstate works, I think the individual register sets are a 
better match (more or less) for the individual "features" of that state rather 
than for the block as a whole.

I don't think it should be that hard to come up with a solution that allows 
caching at xstate level, but still keeps finer-grained groups. One way, which 
does not require the explicit concept of a "second order group", is to allow 
the cache reading/writing function to mark multiple sets as read/written. In 
this world it wouldn't be the generic code which manages the state of each set, 
but the individual writing function instead. This way the reading/writing 
function could mark any number of registers sets as read/written. The generic 
code could just assert that the set that it cares about has been processed 
correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90034

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


[Lldb-commits] [PATCH] D78972: Treat hasWeakODRLinkage symbols as external in REPL computations

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Right -- I can understand that. I'm not sure whether this is a real issue -- 
I'd expect that these compiler-internal symbols would normally have private 
(not "internal") linkage (and hence be caught by line 330) -- but I'm not 
insisting on exposing all of the internal linkage symbols either.

However, I think the phrase "meant to be exported" brings us back to the 
beginning, full circle. Objects with "weak" linkage are also "meant" to be 
exported (== externally visible in a normal compilation), just like their 
weak_odr counterparts. I think that the real bug here is that we've started 
special-casing individual linkage types, and that it's only a matter of time 
before we find ourselves needing to add another linkage type to this list. Llvm 
has a bunch of functions to check for the properties of linkage types, and it 
seems to me like we should be able to pick one of them. So, if we want to just 
expose the functions that would be visible during a normal compilation, the 
function to use is `hasLocalLinkage()` (negation of it, that is)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78972

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


[Lldb-commits] [PATCH] D89283: [trace][intel-pt] Implement the basic decoding functionality

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I'm not sure if I'll have time to go through this again, but it seems ok. One 
question inline, though.

In D89283#2348815 , @wallace wrote:

> The diff is the now ready for review. There are a few updates, including some 
> design decisions after some chats with Greg.
>
> - Now the dump command includes disassembly information and symbol context 
> information whenever relevant, e.g.

I should've said something earlier, but I think the decision to the actual 
disassembling in a separate patch was a good one. This patch was big enough as 
it was.

> - I tried to use yaml to represent the binary fails, but it doesn't work. The 
> yaml representation doesn't have all the required information and the decoder 
> complaints about missing memory. At this point it's better to just include 
> the binary and have strong tests.

That makes me sad, but I am not going to hold this patch over that. I would 
encourage you to find and implement the missing bits in yaml2obj though...




Comment at: lldb/packages/Python/lldbsuite/test/lldbtest.py:2111
 # Fail fast if 'cmd' is not meaningful.
-if not cmd or len(cmd) == 0:
+if not allowEmptyCmd and (not cmd or len(cmd) == 0):
 raise Exception("Bad 'cmd' parameter encountered")

I think that we could just drop the len(cmd)==0 check. It's pretty unlikely 
that anyone will do that by accident (and have all of his checks will still 
pass)...



Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:53-56
+size_t DecodedThread::SetPosition(size_t new_position) {
+  m_position = std::min(new_position, GetLastPosition());
+  return m_position;
+}

I don't see this used anywhere. And if it's not used, how is the dump command 
implemented?

(I'm guessing this is used to implement per-thread "last dumped instruction" 
positions. I'm not sure if that feature is worth it (the `list` command doesn't 
have that), but if that's the case maybe the name should also be more specific, 
as that position is unlikely to be useful for anything else.)



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:109
+  else {
+consumeError(decoded_thread.takeError());
+return 0;

wallace wrote:
> labath wrote:
> > wallace wrote:
> > > labath wrote:
> > > > I'm having doubts about this "I have an thread but was not able to 
> > > > decode _anything_ about it" state is worth it. Having many different 
> > > > ways to report errors just increases the chance of something going 
> > > > wrong, and in `TraverseInstructions` you're already treating this state 
> > > > as a pseudo-instruction.
> > > > 
> > > > Maybe that representation should be used all the way down? Or (and this 
> > > > may be even better) we avoid creating such Threads in the first place 
> > > > (print an error/warning when the target is created).
> > > > Maybe that representation should be used all the way down? 
> > > 
> > > I'll follow that path. This will create consistency through the code
> > > 
> > > 
> > > > Or (and this may be even better) we avoid creating such Threads in the 
> > > > first place (print an error/warning when the target is created).
> > >  
> > > I wish I could do that, but decoding is very expensive and should be done 
> > > lazily. According to Intel and my tests, if a thread was traced during T 
> > > seconds, then decoding takes around 10T, which is a big amount of time if 
> > > you were tracing 10 threads for 5 seconds, which would take 500 seconds 
> > > to decode. At least for know we are not doing parallel decoding. I 
> > > imagine at some point we'll have to work on that.
> > If you can pull that off -- great. However, I have doubts (and judging by 
> > the other comments, you're starting to have some too) regarding how long 
> > will you be able to postpone the decoding. For example, lldb very much 
> > likes to know the PC value of each thread (can you really blame it?) -- so 
> > much that we've added a special field to the gdb-remote stop-reply packet 
> > which lists the pc values of all threads.
> > 
> > That leads me to believe that you'll need to decode at least the last block 
> > of each thread's trace very early on
> Yes, I ended up understanding more of LLDB and it seems that it'll be as you 
> describe. I'll try to limit the initial decoding to at most the PC of each 
> thread, which would indeed be very beneficial, because we could catch early 
> some critical errors. I'll do that early decoding in another diff.
Sounds good.

I am slightly worried about the emphasis on sequential instruction numbers in 
this design. It seems like it'd be hard to avoid decoding the entire trace if 
one needs to assign a sequential id to each instruction. But let's see how it 
goes...


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

https://reviews.llvm.org/D89283

_

[Lldb-commits] [PATCH] D89334: [lldb] Support Python imports relative the to the current file being sourced

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D89334#2344765 , @JDevlieghere 
wrote:

> For paths relative to the CWD we add both already:
>
> 1. We add "." to the sys path once: 
> https://github.com/llvm/llvm-project/blob/5d796645d6c8cadeb003715c33e231a8ba05b6de/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp#L3234
> 2. We "resolve" (make absolute) the relative path 
> (https://github.com/llvm/llvm-project/blob/5d796645d6c8cadeb003715c33e231a8ba05b6de/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp#L2747)
>  and if it exists add its dir to the sys path 
> (https://github.com/llvm/llvm-project/blob/5d796645d6c8cadeb003715c33e231a8ba05b6de/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp#L2785).
>
> For source-relative imports all this was a hypothetical solution to the 
> relative import from Python issue you described.

I'm afraid we've completely desynchronized by this point. Let's try to reset. 
The algorithm I'm proposing is:

  if (is_relative_to_command_file(path))  {// how to implement that?
ExtendPathIfNotExists(dirname(command_file));
import(path);
  } else {
// Same as before
path = make_absolute(path, cwd);
ExtendPathIfNotExists(dirname(path));
import(basename(path));
  }

The algorithm that I think this patch implements is:

  if (is_relative_to_command_file(path)) // implemented by checking cwd for 
this file ?
path = make_absolute(path, dirname(command_file);
  else
path = make_absolute(path, cwd);
  ExtendPathIfNotExists(dirname(path));
  import(basename(path));

Is that an accurate depiction?

Both algorithms add at most one path entry for each import command. (I'm 
ignoring the '.' entry which gets added unconditionally.) For cwd-relative 
imports they behave the same way. The difference is in the command-relative 
imports. The first algorithm adds at most one path for each command file which 
executes import commands. The second one can add more -- if the imported 
scripts are in different directories, then all of those directories will be 
added to the path.

>> Actually, this guessing of what they user meant to say is one of the things 
>> I don't like about this approach. I think it would be better if there was 
>> some way (command option or something) to specify where the module should be 
>> imported from. The docstring for that option could also explain the rule for 
>> how the module is being imported.
>
> How are we guessing more than before? We're doing the exact same thing as for 
> relative paths, i.e. we resolve them and add the dir's path to the system 
> path (= 2 from above).

But how do we know if the user meant to do a CWD-relative import or a 
command-relative one? That's an extra level of guessing (uncertainty). What if 
the file is present at both locations. I think it would be better if there was 
some way to explicitly say that you're importing a module using this 
command-relative scheme.  And that this might give us an excuse to implement a 
more pythonic module import scheme (?)


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

https://reviews.llvm.org/D89334

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


[Lldb-commits] [PATCH] D90034: [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I wonder if 'register sets' shouldn't become shared LLVM concept rather than 
per-plugin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90034

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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 300720.
zequanwu marked 4 inline comments as done.
zequanwu added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

Files:
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/test/Shell/ObjectFile/PDB/object.test
  lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp

Index: lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
@@ -0,0 +1,32 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// Test that lldb load PDB file by command `target symbols add`
+
+// RUN: mkdir -p %t/executable
+// RUN: rm -f %t/executable/foo.exe %t/executable/bar.pdb
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t/executable/foo.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t/executable/foo.obj \
+// RUN: -out:%t/executable/foo.exe -pdb:%t/executable/foo.pdb
+// Rename the PDB file so that the name is different from the name inside the executable (foo.exe).
+// RUN: mv %t/executable/foo.pdb %t/executable/bar.pdb
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t/executable/foo.exe \
+// RUN: -o "target symbols add %t/executable/bar.pdb" \
+// RUN: -o "b main" \
+// RUN: -o "image dump symfile" -o "quit" | FileCheck %s
+
+int main(int argc, char** argv) {
+  return 0;
+}
+
+// CHECK: (lldb) target symbols add {{.*}}bar.pdb
+// CHECK: symbol file '{{.*}}/bar.pdb' has been added to '{{.*}}/foo.exe'
+// CHECK: (lldb) b main
+// CHECK: Breakpoint 1: where = foo.exe`main + 23 at load-pdb.cpp:19, address = 0x000140001017
+// CHECK: (lldb) image dump symfile
+// CHECK: Types:
+// CHECK: {{.*}}: Type{0x00010024} , size = 0, compiler_type = {{.*}} int (int, char **)
+// CHECK: Compile units:
+// CHECK: {{.*}}: CompileUnit{0x}, language = "c++", file = '{{.*}}/load-pdb.cpp'
+// CHECK: {{.*}}:   Function{0x0841}, demangled = main, type = {{.*}}
+// CHECK: {{.*}}:   Block{0x0841}
Index: lldb/test/Shell/ObjectFile/PDB/object.test
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PDB/object.test
@@ -0,0 +1,280 @@
+# RUN: llvm-pdbutil yaml2pdb %s -pdb=%t.pdb
+# RUN: lldb-test object-file %t.pdb | FileCheck %s
+
+# CHECK: Plugin name: pdb
+# CHECK: Architecture: x86_64-pc-windows-msvc
+# CHECK: UUID: 3F58AF61-A829-6C7A-4C4C-44205044422E-0001
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: debug info
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x
+# CHECK: There are no sections
+
+---
+MSF:
+  SuperBlock:
+BlockSize:   4096
+FreeBlockMap:2
+NumBlocks:   18
+NumDirectoryBytes: 116
+Unknown1:0
+BlockMapAddr:3
+  NumDirectoryBlocks: 1
+  DirectoryBlocks: [ 17 ]
+  NumStreams:  15
+  FileSize:73728
+StreamSizes: [ 0, 93, 100, 550, 136, 0, 544, 576, 40, 20, 120, 368, 
+   336, 49, 24 ]
+StreamMap:
+  - Stream:  [  ]
+  - Stream:  [ 16 ]
+  - Stream:  [ 7 ]
+  - Stream:  [ 12 ]
+  - Stream:  [ 14 ]
+  - Stream:  [  ]
+  - Stream:  [ 4 ]
+  - Stream:  [ 5 ]
+  - Stream:  [ 6 ]
+  - Stream:  [ 8 ]
+  - Stream:  [ 9 ]
+  - Stream:  [ 10 ]
+  - Stream:  [ 11 ]
+  - Stream:  [ 13 ]
+  - Stream:  [ 15 ]
+StringTable:
+  - '/tmp/a.cpp'
+PdbStream:
+  Age: 1
+  Guid:'{61AF583F-29A8-7A6C-4C4C-44205044422E}'
+  Signature:   1062776673
+  Features:[ VC140 ]
+  Version: VC70
+DbiStream:
+  VerHeader:   V70
+  Age: 1
+  BuildNumber: 36363
+  PdbDllVersion:   0
+  PdbDllRbld:  0
+  Flags:   0
+  MachineType: Amd64
+  Modules:
+- Module:  '/tmp/pdb.obj'
+  ObjFile: '/tmp/pdb.obj'
+  SourceFiles:
+- '/tmp/a.cpp'
+  Subsections:
+- !Lines
+  CodeSize:28
+  Flags:   [  ]
+  RelocOffset: 0
+  RelocSegment:1
+  Blocks:
+- FileName:'/tmp/a.cpp'
+  Lines:
+- Offset:  0
+  LineStart:   1
+  IsStatement: false
+  En

[Lldb-commits] [lldb] 242e1e9 - [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2020-10-26T10:28:48-07:00
New Revision: 242e1e9910441ad00118e580e4cbd5743c77ea5e

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

LOG: [lldb][PDB] Add ObjectFile PDB plugin

To allow loading PDB file with `target symbols add` command.

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

Added: 
lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
lldb/test/Shell/ObjectFile/PDB/object.test
lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp

Modified: 
lldb/source/Plugins/ObjectFile/CMakeLists.txt
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
index 77ca511bd7cf1..3b2cc6177d313 100644
--- a/lldb/source/Plugins/ObjectFile/CMakeLists.txt
+++ b/lldb/source/Plugins/ObjectFile/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_subdirectory(Breakpad)
 add_subdirectory(ELF)
 add_subdirectory(Mach-O)
+add_subdirectory(PDB)
 add_subdirectory(PECOFF)
 add_subdirectory(JIT)
 add_subdirectory(wasm)

diff  --git a/lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt 
b/lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt
new file mode 100644
index 0..d5ade2b93ad86
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_lldb_library(lldbPluginObjectFilePDB PLUGIN
+  ObjectFilePDB.cpp
+
+  LINK_LIBS
+lldbCore
+lldbSymbol
+lldbUtility
+  LINK_COMPONENTS
+Support
+  )

diff  --git a/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp 
b/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
new file mode 100644
index 0..f467f926128a1
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
@@ -0,0 +1,229 @@
+//===-- ObjectFilePDB.cpp 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ObjectFilePDB.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/Section.h"
+#include "lldb/Utility/StreamString.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
+#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
+#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
+#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
+#include "llvm/DebugInfo/PDB/PDB.h"
+#include "llvm/Support/BinaryByteStream.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace llvm::pdb;
+using namespace llvm::codeview;
+
+LLDB_PLUGIN_DEFINE(ObjectFilePDB)
+
+struct CVInfoPdb70 {
+  // 16-byte GUID
+  struct _Guid {
+llvm::support::ulittle32_t Data1;
+llvm::support::ulittle16_t Data2;
+llvm::support::ulittle16_t Data3;
+uint8_t Data4[8];
+  } Guid;
+
+  llvm::support::ulittle32_t Age;
+};
+
+static UUID GetPDBUUID(InfoStream &IS) {
+  // This part is similar with what has done in ObjectFilePECOFF.
+  using llvm::support::endian::read16be;
+  using llvm::support::endian::read32;
+  using llvm::support::endian::read32be;
+
+  GUID guid = IS.getGuid();
+  const uint8_t *guid_p = guid.Guid;
+  struct CVInfoPdb70 info;
+  info.Guid.Data1 = read32be(guid_p);
+  guid_p += 4;
+  info.Guid.Data2 = read16be(guid_p);
+  guid_p += 2;
+  info.Guid.Data3 = read16be(guid_p);
+  guid_p += 2;
+  memcpy(info.Guid.Data4, guid_p, 8);
+
+  // Return 20-byte UUID if the Age is not zero
+  uint32_t age = IS.getAge();
+  if (age) {
+info.Age = read32(&age, llvm::support::big);
+return UUID::fromOptionalData(&info, sizeof(info));
+  }
+  // Otherwise return 16-byte GUID
+  return UUID::fromOptionalData(&info.Guid, sizeof(info.Guid));
+}
+
+char ObjectFilePDB::ID;
+
+void ObjectFilePDB::Initialize() {
+  PluginManager::RegisterPlugin(GetPluginNameStatic(),
+GetPluginDescriptionStatic(), CreateInstance,
+CreateMemoryInstance, GetModuleSpecifications);
+}
+
+void ObjectFilePDB::Terminate() {
+  PluginManager::UnregisterPlugin(CreateInstance);
+}
+
+ConstString ObjectFilePDB::GetPluginNameStatic(

[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG242e1e991044: [lldb][PDB] Add ObjectFile PDB plugin 
(authored by zequanwu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

Files:
  lldb/source/Plugins/ObjectFile/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/PDB/CMakeLists.txt
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbIndex.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/test/Shell/ObjectFile/PDB/object.test
  lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp

Index: lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
@@ -0,0 +1,32 @@
+// clang-format off
+// REQUIRES: lld, x86
+
+// Test that lldb load PDB file by command `target symbols add`
+
+// RUN: mkdir -p %t/executable
+// RUN: rm -f %t/executable/foo.exe %t/executable/bar.pdb
+// RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t/executable/foo.obj -- %s
+// RUN: lld-link -debug:full -nodefaultlib -entry:main %t/executable/foo.obj \
+// RUN: -out:%t/executable/foo.exe -pdb:%t/executable/foo.pdb
+// Rename the PDB file so that the name is different from the name inside the executable (foo.exe).
+// RUN: mv %t/executable/foo.pdb %t/executable/bar.pdb
+// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t/executable/foo.exe \
+// RUN: -o "target symbols add %t/executable/bar.pdb" \
+// RUN: -o "b main" \
+// RUN: -o "image dump symfile" -o "quit" | FileCheck %s
+
+int main(int argc, char** argv) {
+  return 0;
+}
+
+// CHECK: (lldb) target symbols add {{.*}}bar.pdb
+// CHECK: symbol file '{{.*}}/bar.pdb' has been added to '{{.*}}/foo.exe'
+// CHECK: (lldb) b main
+// CHECK: Breakpoint 1: where = foo.exe`main + 23 at load-pdb.cpp:19, address = 0x000140001017
+// CHECK: (lldb) image dump symfile
+// CHECK: Types:
+// CHECK: {{.*}}: Type{0x00010024} , size = 0, compiler_type = {{.*}} int (int, char **)
+// CHECK: Compile units:
+// CHECK: {{.*}}: CompileUnit{0x}, language = "c++", file = '{{.*}}/load-pdb.cpp'
+// CHECK: {{.*}}:   Function{0x0841}, demangled = main, type = {{.*}}
+// CHECK: {{.*}}:   Block{0x0841}
Index: lldb/test/Shell/ObjectFile/PDB/object.test
===
--- /dev/null
+++ lldb/test/Shell/ObjectFile/PDB/object.test
@@ -0,0 +1,280 @@
+# RUN: llvm-pdbutil yaml2pdb %s -pdb=%t.pdb
+# RUN: lldb-test object-file %t.pdb | FileCheck %s
+
+# CHECK: Plugin name: pdb
+# CHECK: Architecture: x86_64-pc-windows-msvc
+# CHECK: UUID: 3F58AF61-A829-6C7A-4C4C-44205044422E-0001
+# CHECK: Executable: false
+# CHECK: Stripped: false
+# CHECK: Type: debug info
+# CHECK: Strata: user
+# CHECK: Base VM address: 0x
+# CHECK: There are no sections
+
+---
+MSF:
+  SuperBlock:
+BlockSize:   4096
+FreeBlockMap:2
+NumBlocks:   18
+NumDirectoryBytes: 116
+Unknown1:0
+BlockMapAddr:3
+  NumDirectoryBlocks: 1
+  DirectoryBlocks: [ 17 ]
+  NumStreams:  15
+  FileSize:73728
+StreamSizes: [ 0, 93, 100, 550, 136, 0, 544, 576, 40, 20, 120, 368, 
+   336, 49, 24 ]
+StreamMap:
+  - Stream:  [  ]
+  - Stream:  [ 16 ]
+  - Stream:  [ 7 ]
+  - Stream:  [ 12 ]
+  - Stream:  [ 14 ]
+  - Stream:  [  ]
+  - Stream:  [ 4 ]
+  - Stream:  [ 5 ]
+  - Stream:  [ 6 ]
+  - Stream:  [ 8 ]
+  - Stream:  [ 9 ]
+  - Stream:  [ 10 ]
+  - Stream:  [ 11 ]
+  - Stream:  [ 13 ]
+  - Stream:  [ 15 ]
+StringTable:
+  - '/tmp/a.cpp'
+PdbStream:
+  Age: 1
+  Guid:'{61AF583F-29A8-7A6C-4C4C-44205044422E}'
+  Signature:   1062776673
+  Features:[ VC140 ]
+  Version: VC70
+DbiStream:
+  VerHeader:   V70
+  Age: 1
+  BuildNumber: 36363
+  PdbDllVersion:   0
+  PdbDllRbld:  0
+  Flags:   0
+  MachineType: Amd64
+  Modules:
+- Module:  '/tmp/pdb.obj'
+  ObjFile: '/tmp/pdb.obj'
+  SourceFiles:
+- '/tmp/a.cpp'
+  Subsections:
+- !Lines
+  CodeSize:28
+  Flags:   [  ]
+  RelocOffset: 0
+  RelocSegment:1
+  Blocks:
+- FileName:'/tmp/a.cpp'
+  Lines:
+- Offset:  0
+  

[Lldb-commits] [PATCH] D90034: [lldb] [Process/NetBSD] Use XStateRegSet for all FPU registers

2020-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D90034#2353873 , @mgorny wrote:

> I wonder if 'register sets' shouldn't become shared LLVM concept rather than 
> per-plugin.

I'm totally down with that. In fact there's been some movement on that front 
recently, with the introduction of `RegisterInfoAndSetInterface` class 
(currently only used for arm).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90034

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


[Lldb-commits] [PATCH] D90102: [lldb] [Process/FreeBSDRemote] Enable watchpoint support

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 300741.
mgorny edited the summary of this revision.
mgorny added a comment.

Ok, should be fixed now.


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

https://reviews.llvm.org/D90102

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointDelayBreakpointOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelaySignalBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelaySignalWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalNWatchNBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneDelaySignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py

Index: lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
===
--- lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
+++ lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
@@ -11,7 +11,6 @@
 
 mydir = ConcurrentEventsBase.compute_mydir(__file__)
 
-@skipIfFreeBSD  # timing out on buildbot
 # Atomic sequences are not supported yet for MIPS in LLDB.
 @skipIf(triple='^mips')
 @add_test_categories(["watchpoint"])
Index: lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
===
--- lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
+++ lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
@@ -11,7 +11,6 @@
 
 mydir = ConcurrentEventsBase.compute_mydir(__file__)
 
-@skipIfFreeBSD  # timing out on buildbot
 # Atomic sequ

[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

It has regressed buildbots:

  SymbolFile/NativePDB/load-pdb.cpp
  lldb-x86_64-fedora: http://lab.llvm.org:8014/#/builders/14/builds/1006
  lldb-x86_64-debian: http://lab.llvm.org:8011/#/builders/68/builds/782


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D89812#2354320 , @jankratochvil 
wrote:

> It has regressed buildbots:
>
>   SymbolFile/NativePDB/load-pdb.cpp
>   lldb-x86_64-fedora: http://lab.llvm.org:8014/#/builders/14/builds/1006
>   lldb-x86_64-debian: http://lab.llvm.org:8011/#/builders/68/builds/782

Just put a fix here: 
https://reviews.llvm.org/rG4b83747ab1577b7899116b0ddb75f05de2471694
This should fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [lldb] 4b83747 - [lldb][NativePDB] fix test load-pdb.cpp

2020-10-26 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2020-10-26T11:38:12-07:00
New Revision: 4b83747ab1577b7899116b0ddb75f05de2471694

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

LOG: [lldb][NativePDB] fix test load-pdb.cpp

Added: 


Modified: 
lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp 
b/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
index b4b9d0f8d22e..c0584df59355 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
@@ -28,5 +28,5 @@ int main(int argc, char** argv) {
 // CHECK: {{.*}}: Type{0x00010024} , size = 0, compiler_type = {{.*}} int 
(int, char **)
 // CHECK: Compile units:
 // CHECK: {{.*}}: CompileUnit{0x}, language = "c++", file = 
'{{.*}}/load-pdb.cpp'
-// CHECK: {{.*}}:   Function{0x0841}, demangled = main, type = {{.*}}
-// CHECK: {{.*}}:   Block{0x0841}
+// CHECK: {{.*}}:   Function{{{.*}}}, demangled = main, type = {{.*}}
+// CHECK: {{.*}}:   Block{{{.*}}}



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


[Lldb-commits] [PATCH] D90081: Test lldb backtraces with machine function splitter

2020-10-26 Thread Sriraman Tallam via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9aa7a721ce3d: Test to check backtraces with machine function 
splitting. (authored by tmsriram).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90081

Files:
  lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
  lldb/test/Shell/Unwind/split-machine-functions.test

Index: lldb/test/Shell/Unwind/split-machine-functions.test
===
--- /dev/null
+++ lldb/test/Shell/Unwind/split-machine-functions.test
@@ -0,0 +1,46 @@
+# Test to check if machine function splitter still produces the right backtraces
+# with lldb when a function is split into a hot and cold part and the cold part
+# is executed.  The cold part has the same function symbol name but with a
+# ".cold" suffix and this test checks that the back trace is clear.
+
+# UNSUPPORTED: system-darwin, system-windows
+# REQUIRES: target-x86_64
+# REQUIRES: lld
+
+# RUN: split-file %s %t.split
+#
+# RUN: %clang_host %p/Inputs/split-machine-functions.ll -o %t
+# RUN: %lldb %t -s %t.split/commands -o exit | FileCheck  %s --check-prefix=DEFAULT
+#
+# RUN: %clang_host %p/Inputs/split-machine-functions.ll -fsplit-machine-functions -o %t
+# RUN: %lldb %t -s %t.split/commands -o exit | FileCheck  %s --check-prefix=SPLIT
+#
+# Test a permutation where foo.cold is very far from foo.  The default ordering does not
+# ensure that there will be a gap between foo and foo.cold.  Using a symbol ordering
+# file guarantees this
+# RUN: %clang_host %p/Inputs/split-machine-functions.ll -fsplit-machine-functions -o %t -fuse-ld=lld -Wl,--symbol-ordering-file,%t.split/sym_order_1.txt -Wl,--warn-symbol-ordering -Wl,--fatal-warnings
+# RUN: %lldb %t -s %t.split/commands -o exit | FileCheck  %s --check-prefix=SPLIT
+
+#--- commands
+breakpoint set -n bar
+# DEFAULT: Breakpoint 1: where = {{.*}}`bar
+# SPLIT: Breakpoint 1: where = {{.*}}`bar
+
+process launch
+# DEFAULT: stop reason = breakpoint 1.1
+# SPLIT: stop reason = breakpoint 1.1
+
+thread backtrace
+# DEFAULT: frame #0: {{.*}}`bar
+# DEFAULT: frame #1: {{.*}}`foo() +
+# DEFAULT: frame #2: {{.*}}`main +
+# SPLIT: frame #0: {{.*}}`bar
+# SPLIT: frame #1: {{.*}}`foo() (.cold) +
+# SPLIT: frame #2: {{.*}}`main +
+
+#--- sym_order_1.txt
+_Z3foov
+main
+_Z3barv
+_Z3bazv
+_Z3foov.cold
Index: lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
===
--- /dev/null
+++ lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
@@ -0,0 +1,99 @@
+;; IR + Profile to split machine functions with -fsplit-machine-functions
+;; Source used to generate this file
+;; int k;
+
+;; int baz() {
+;;   return 0;
+;; }
+;;
+;; int bar() {
+;;   return 0;
+;; }
+;;
+;; int foo() {
+;;   if (k)
+;; baz();
+;;   else
+;; bar();
+;;   return 0;
+;; }
+;;
+;; int main() {
+;;   foo();
+;;   return 0;
+;; }
+
+;; Commands:
+;; clang -fprofile-generate -O0 source.cc
+;; ./a.out && llvm-profdata merge -o default.profdata *.profraw
+;; clang -fprofile-use -O0 source.cc -emit-llvm -S
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@k = dso_local global i32 0, align 4
+
+define dso_local i32 @_Z3bazv() !prof !31 {
+  ret i32 0
+}
+
+define dso_local i32 @_Z3barv() !prof !32 {
+  ret i32 0
+}
+
+define dso_local i32 @_Z3foov() !prof !32 {
+  %1 = load i32, i32* @k, align 4
+  %2 = icmp ne i32 %1, 0
+  br i1 %2, label %3, label %5, !prof !33
+
+3:; preds = %0
+  %4 = call i32 @_Z3bazv()
+  br label %7
+
+5:; preds = %0
+  %6 = call i32 @_Z3barv()
+  br label %7
+
+7:; preds = %5, %3
+  ret i32 0
+}
+
+define dso_local i32 @main() !prof !32 {
+  %1 = call i32 @_Z3foov()
+  ret i32 0
+}
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"ProfileSummary", !2}
+!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}
+!3 = !{!"ProfileFormat", !"InstrProf"}
+!4 = !{!"TotalCount", i64 3}
+!5 = !{!"MaxCount", i64 1}
+!6 = !{!"MaxInternalCount", i64 1}
+!7 = !{!"MaxFunctionCount", i64 1}
+!8 = !{!"NumCounts", i64 5}
+!9 = !{!"NumFunctions", i64 4}
+!10 = !{!"IsPartialProfile", i64 0}
+!11 = !{!"PartialProfileRatio", double 0.00e+00}
+!12 = !{!"DetailedSummary", !13}
+!13 = !{!14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29}
+!14 = !{i32 1, i64 0, i32 0}
+!15 = !{i32 10, i64 0, i32 0}
+!16 = !{i32 20, i64 0, i32 0}
+!17 = !{i32 30, i64 0, i32 0}
+!18 = !{i32 40, i64 1, i32 3}
+!19 = !{i32 50, i64 1, i32 3}
+!20 = !{i32 60, i64 1, i32 3}
+!21 = !{i32 70, i64 1, i32 3}
+!22 = !{i32 80, i64 1, i32 3}
+!23 = !{i32 90, i64 1, i32 3}
+!24 = !{i32 95, i64 1, i32 3}
+!25 = !{i32

[Lldb-commits] [lldb] 9aa7a72 - Test to check backtraces with machine function splitting.

2020-10-26 Thread Sriraman Tallam via lldb-commits

Author: Sriraman Tallam
Date: 2020-10-26T14:08:42-07:00
New Revision: 9aa7a721ce3dc84d0ad2d987af72cf14ff76d8a7

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

LOG: Test to check backtraces with machine function splitting.

clang supports option -fsplit-machine-functions and this test checks if the
backtraces are sane when functions are split.

With -fsplit-machine-functions, a function with profiles can get split into 2
parts, the original function containing hot code and a cold part as determined
by the profile info and the cold cutoff threshold.. The cold part gets the
".cold" suffix to disambiguate its symbol from the hot part and can be placed
arbitrarily in the address space.

This test checks if the back-trace looks correct when the cold part is executed.

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

Added: 
lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
lldb/test/Shell/Unwind/split-machine-functions.test

Modified: 


Removed: 




diff  --git a/lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll 
b/lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
new file mode 100644
index ..415e1fdafe11
--- /dev/null
+++ b/lldb/test/Shell/Unwind/Inputs/split-machine-functions.ll
@@ -0,0 +1,99 @@
+;; IR + Profile to split machine functions with -fsplit-machine-functions
+;; Source used to generate this file
+;; int k;
+
+;; int baz() {
+;;   return 0;
+;; }
+;;
+;; int bar() {
+;;   return 0;
+;; }
+;;
+;; int foo() {
+;;   if (k)
+;; baz();
+;;   else
+;; bar();
+;;   return 0;
+;; }
+;;
+;; int main() {
+;;   foo();
+;;   return 0;
+;; }
+
+;; Commands:
+;; clang -fprofile-generate -O0 source.cc
+;; ./a.out && llvm-profdata merge -o default.profdata *.profraw
+;; clang -fprofile-use -O0 source.cc -emit-llvm -S
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@k = dso_local global i32 0, align 4
+
+define dso_local i32 @_Z3bazv() !prof !31 {
+  ret i32 0
+}
+
+define dso_local i32 @_Z3barv() !prof !32 {
+  ret i32 0
+}
+
+define dso_local i32 @_Z3foov() !prof !32 {
+  %1 = load i32, i32* @k, align 4
+  %2 = icmp ne i32 %1, 0
+  br i1 %2, label %3, label %5, !prof !33
+
+3:; preds = %0
+  %4 = call i32 @_Z3bazv()
+  br label %7
+
+5:; preds = %0
+  %6 = call i32 @_Z3barv()
+  br label %7
+
+7:; preds = %5, %3
+  ret i32 0
+}
+
+define dso_local i32 @main() !prof !32 {
+  %1 = call i32 @_Z3foov()
+  ret i32 0
+}
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 1, !"ProfileSummary", !2}
+!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}
+!3 = !{!"ProfileFormat", !"InstrProf"}
+!4 = !{!"TotalCount", i64 3}
+!5 = !{!"MaxCount", i64 1}
+!6 = !{!"MaxInternalCount", i64 1}
+!7 = !{!"MaxFunctionCount", i64 1}
+!8 = !{!"NumCounts", i64 5}
+!9 = !{!"NumFunctions", i64 4}
+!10 = !{!"IsPartialProfile", i64 0}
+!11 = !{!"PartialProfileRatio", double 0.00e+00}
+!12 = !{!"DetailedSummary", !13}
+!13 = !{!14, !15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, 
!28, !29}
+!14 = !{i32 1, i64 0, i32 0}
+!15 = !{i32 10, i64 0, i32 0}
+!16 = !{i32 20, i64 0, i32 0}
+!17 = !{i32 30, i64 0, i32 0}
+!18 = !{i32 40, i64 1, i32 3}
+!19 = !{i32 50, i64 1, i32 3}
+!20 = !{i32 60, i64 1, i32 3}
+!21 = !{i32 70, i64 1, i32 3}
+!22 = !{i32 80, i64 1, i32 3}
+!23 = !{i32 90, i64 1, i32 3}
+!24 = !{i32 95, i64 1, i32 3}
+!25 = !{i32 99, i64 1, i32 3}
+!26 = !{i32 999000, i64 1, i32 3}
+!27 = !{i32 00, i64 1, i32 3}
+!28 = !{i32 90, i64 1, i32 3}
+!29 = !{i32 99, i64 1, i32 3}
+!31 = !{!"function_entry_count", i64 0}
+!32 = !{!"function_entry_count", i64 1}
+!33 = !{!"branch_weights", i32 1, i32 0}

diff  --git a/lldb/test/Shell/Unwind/split-machine-functions.test 
b/lldb/test/Shell/Unwind/split-machine-functions.test
new file mode 100644
index ..bc631b12fa54
--- /dev/null
+++ b/lldb/test/Shell/Unwind/split-machine-functions.test
@@ -0,0 +1,46 @@
+# Test to check if machine function splitter still produces the right 
backtraces
+# with lldb when a function is split into a hot and cold part and the cold part
+# is executed.  The cold part has the same function symbol name but with a
+# ".cold" suffix and this test checks that the back trace is clear.
+
+# UNSUPPORTED: system-darwin, system-windows
+# REQUIRES: target-x86_64
+# REQUIRES: lld
+
+# RUN: split-file %s %t.split
+#
+# RUN: %clang_host %p/Inputs/split-machine-functions.ll -o %t
+# RUN: %lldb %t -s %t.split/commands -o exit | FileCheck  %s 
--check-prefix=DEFAULT
+#
+# RUN: %clang_host %p/Inputs/split-machine-functions.ll 
-fsplit-machine

[Lldb-commits] [PATCH] D87172: Check if debug line sequences are starting after the first code segment

2020-10-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Just remove the braces as suggested in inline comments. Pavel?




Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:503-505
+  if (section_list) {
+InitializeFirstCodeAddress(*section_list);
+  }

remove braces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87172

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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

load-pdb is still failing on the Windows bot. Can you please commit a fix soon 
or revert the change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D89812#2354862 , @stella.stamenova 
wrote:

> load-pdb is still failing on the Windows bot. Can you please commit a fix 
> soon or revert the change?

Okay, I'm looking at it now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [PATCH] D89334: [lldb] Support Python imports relative the to the current file being sourced

2020-10-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 300803.
JDevlieghere added a comment.
Herald added a subscriber: dang.

Briefly discussed this with Pavel on IRC. The latest revision implements what I 
think you suggested:

- Make the new logic conditional on a new flag (`-c`).
- Add the "command search dir" to the path, not `dirname(path)`.
- Change the test to import a relative module as `baz.hello` instead of 
`baz/hello`.


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

https://reviews.llvm.org/D89334

Files:
  lldb/include/lldb/Interpreter/CommandInterpreter.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/source/Commands/CommandObjectCommands.cpp
  lldb/source/Commands/Options.td
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.in
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.py
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.in
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.py
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.in
  lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.py
  lldb/test/Shell/ScriptInterpreter/Python/command_relative_import.test

Index: lldb/test/Shell/ScriptInterpreter/Python/command_relative_import.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/command_relative_import.test
@@ -0,0 +1,27 @@
+# REQUIRES: python
+
+# RUN: rm -rf %t && mkdir -p %t/foo/bar/baz
+# RUN: cp %S/Inputs/magritte.py %t/foo
+# RUN: cp %S/Inputs/magritte.in %t/foo
+# RUN: cp %S/Inputs/zip.py %t/foo
+# RUN: cp %S/Inputs/zip.in %t/foo
+# RUN: cp %S/Inputs/hello.py %t/foo/bar/baz
+# RUN: cp %S/Inputs/hello.in %t/foo/bar
+# RUN: echo 'command source %t/foo/bar/hello.in' >> %t/foo/zip.in
+
+# RUN: %lldb --script-language python \
+# RUN:-o 'command source %t/foo/magritte.in' \
+# RUN:-o 'command source %t/foo/zip.in' \
+# RUN:-o 'command source %t/foo/magritte.in' \
+# RUN;-o 'zip' \
+# RUN:-o 'hello'
+# RUN -o 'magritte' 2>&1 | FileCheck %s
+
+# The first time importing 'magritte' fails because we didn't pass -c.
+# CHECK: ModuleNotFoundError: No module named 'magritte'
+# CHECK-NOT: Ceci n'est pas une pipe
+# CHECK: 95126
+# CHECK: Hello, World!
+# The second time importing 'magritte' works, even without passing -c because
+# we added '%t/foo' to the Python path when importing 'zip'.
+# CHECK: Ceci n'est pas une pipe
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.py
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.py
@@ -0,0 +1,7 @@
+import lldb
+
+def zip(debugger, command, result, internal_dict):
+print("95126")
+
+def __lldb_init_module(debugger, internal_dict):
+debugger.HandleCommand('command script add -f zip.zip zip')
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/zip.in
@@ -0,0 +1 @@
+command script import -c zip
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.py
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.py
@@ -0,0 +1,7 @@
+import lldb
+
+def magritte(debugger, command, result, internal_dict):
+print("Ceci n'est pas une pipe")
+
+def __lldb_init_module(debugger, internal_dict):
+debugger.HandleCommand('command script add -f magritte.magritte magritte')
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/magritte.in
@@ -0,0 +1 @@
+command script import magritte
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.py
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.py
@@ -0,0 +1,7 @@
+import lldb
+
+def hello(debugger, command, result, internal_dict):
+print("Hello, World!")
+
+def __lldb_init_module(debugger, internal_dict):
+debugger.HandleCommand('command script add -f baz.hello.hello hello')
Index: lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.in
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Inputs/hello.in
@@ -0,0 +1 @@
+command script import -c baz.hello
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPyth

[Lldb-commits] [lldb] 7611c5b - [nfc] [lldb] Refactor DWARFUnit::GetDIE

2020-10-26 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-10-26T23:18:19+01:00
New Revision: 7611c5bb42a96c13d0e53ade546633bf9ed56f0c

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

LOG: [nfc] [lldb] Refactor DWARFUnit::GetDIE

Reduce indentation of the code by early returns for failed code paths.

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 5da23e7c89f1..12e8b25130a9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -525,21 +525,23 @@ static bool CompareDIEOffset(const DWARFDebugInfoEntry 
&die,
 // DIE from this compile unit. Otherwise we grab the DIE from the DWARF file.
 DWARFDIE
 DWARFUnit::GetDIE(dw_offset_t die_offset) {
-  if (die_offset != DW_INVALID_OFFSET) {
-if (ContainsDIEOffset(die_offset)) {
-  ExtractDIEsIfNeeded();
-  DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();
-  DWARFDebugInfoEntry::const_iterator pos =
-  lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
-  if (pos != end) {
-if (die_offset == (*pos).GetOffset())
-  return DWARFDIE(this, &(*pos));
-  }
-} else
-  GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-  "GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
-  die_offset, GetOffset());
+  if (die_offset == DW_INVALID_OFFSET)
+return DWARFDIE(); // Not found
+
+  if (!ContainsDIEOffset(die_offset)) {
+GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+"GetDIE for DIE 0x%" PRIx32 " is outside of its CU 0x%" PRIx32,
+die_offset, GetOffset());
+return DWARFDIE(); // Not found
   }
+
+  ExtractDIEsIfNeeded();
+  DWARFDebugInfoEntry::const_iterator end = m_die_array.cend();
+  DWARFDebugInfoEntry::const_iterator pos =
+  lower_bound(m_die_array.cbegin(), end, die_offset, CompareDIEOffset);
+
+  if (pos != end && die_offset == (*pos).GetOffset())
+return DWARFDIE(this, &(*pos));
   return DWARFDIE(); // Not found
 }
 



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


[Lldb-commits] [PATCH] D90102: [lldb] [Process/FreeBSDRemote] Enable watchpoint support

2020-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 300806.
mgorny added a comment.

Included a fix to respect `LLDB_REMOTE_PLUGIN` in API tests, and reenabled more 
tests. FWICS these tests also pass with the old plugin.


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

https://reviews.llvm.org/D90102

Files:
  lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD.h
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.cpp
  
lldb/source/Plugins/Process/FreeBSDRemote/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/FreeBSDRemote/NativeThreadFreeBSD.cpp
  
lldb/test/API/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandPython.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointDelayBreakpointOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelaySignalBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelaySignalWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalDelayBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalDelayWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalNWatchNBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentSignalWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneDelaySignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneWatchpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointThreads.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneSignal.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchBreak.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
  
lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
  lldb/test/API/lit.cfg.py

Index: lldb/test/API/lit.cfg.py
===
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -257,3 +257,8 @@
 
 # testFormat: The test format to use to interpret tests.
 config.test_format = lldbtest.LLDBTest(dotest_cmd)
+
+# Propagate FREEBSD_REMOTE_PLUGIN
+if 'FREEBSD_REMOTE_PLUGIN' in os.environ:
+  config.environment['FREEBSD_REMOTE_PLUGIN'] = os.environ[
+  'FREEBSD_REMOTE_PLUGIN']
Index: lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
===
--- lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
+++ lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
@@ -11,7 +11,6 @@
 
 mydir = ConcurrentEventsBase.compute_mydir(__file__)
 
-@skipIfFreeBSD  # timing out on buildbot
 # Atomic sequences are not supporte

[Lldb-commits] [lldb] 779deb9 - [lldb][NativePDB] fix test load-pdb.cpp

2020-10-26 Thread Zequan Wu via lldb-commits

Author: Zequan Wu
Date: 2020-10-26T17:12:51-07:00
New Revision: 779deb9750a4853485ac7beca86f518b067ad6d6

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

LOG: [lldb][NativePDB] fix test load-pdb.cpp

Added: 


Modified: 
lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp 
b/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
index c0584df59355..2ffcece075b0 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/load-pdb.cpp
@@ -20,13 +20,13 @@ int main(int argc, char** argv) {
 }
 
 // CHECK: (lldb) target symbols add {{.*}}bar.pdb
-// CHECK: symbol file '{{.*}}/bar.pdb' has been added to '{{.*}}/foo.exe'
+// CHECK: symbol file '{{.*}}bar.pdb' has been added to '{{.*}}foo.exe'
 // CHECK: (lldb) b main
 // CHECK: Breakpoint 1: where = foo.exe`main + 23 at load-pdb.cpp:19, address 
= 0x000140001017
 // CHECK: (lldb) image dump symfile
 // CHECK: Types:
 // CHECK: {{.*}}: Type{0x00010024} , size = 0, compiler_type = {{.*}} int 
(int, char **)
 // CHECK: Compile units:
-// CHECK: {{.*}}: CompileUnit{0x}, language = "c++", file = 
'{{.*}}/load-pdb.cpp'
+// CHECK: {{.*}}: CompileUnit{0x}, language = "c++", file = 
'{{.*}}load-pdb.cpp'
 // CHECK: {{.*}}:   Function{{{.*}}}, demangled = main, type = {{.*}}
 // CHECK: {{.*}}:   Block{{{.*}}}



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


[Lldb-commits] [PATCH] D89812: [lldb][PDB] Add ObjectFile PDB plugin

2020-10-26 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu added a comment.

In D89812#2354862 , @stella.stamenova 
wrote:

> load-pdb is still failing on the Windows bot. Can you please commit a fix 
> soon or revert the change?

It's slash vs back slash thing. Put a fix at 
https://reviews.llvm.org/rG779deb9750a4853485ac7beca86f518b067ad6d6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89812

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


[Lldb-commits] [PATCH] D89283: [trace][intel-pt] Implement the basic decoding functionality

2020-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace marked 7 inline comments as done.
wallace added a comment.

> That makes me sad, but I am not going to hold this patch over that. I would 
> encourage you to find and implement the missing bits in yaml2obj though...

I'll do that later as a way to learn yaml2obj.




Comment at: lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp:53-56
+size_t DecodedThread::SetPosition(size_t new_position) {
+  m_position = std::min(new_position, GetLastPosition());
+  return m_position;
+}

labath wrote:
> I don't see this used anywhere. And if it's not used, how is the dump command 
> implemented?
> 
> (I'm guessing this is used to implement per-thread "last dumped instruction" 
> positions. I'm not sure if that feature is worth it (the `list` command 
> doesn't have that), but if that's the case maybe the name should also be more 
> specific, as that position is unlikely to be useful for anything else.)
I'm not using it in this patch, but I added it along with the 
GetCurrentPosition. I plan to use it for the reverse debugging case, in which a 
reverse-next would move this value to a different position, that would get 
picked by any subsequent dump or reverse command. I'll improve the 
documentation and the function name



Comment at: lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp:109
+  else {
+consumeError(decoded_thread.takeError());
+return 0;

labath wrote:
> wallace wrote:
> > labath wrote:
> > > wallace wrote:
> > > > labath wrote:
> > > > > I'm having doubts about this "I have an thread but was not able to 
> > > > > decode _anything_ about it" state is worth it. Having many different 
> > > > > ways to report errors just increases the chance of something going 
> > > > > wrong, and in `TraverseInstructions` you're already treating this 
> > > > > state as a pseudo-instruction.
> > > > > 
> > > > > Maybe that representation should be used all the way down? Or (and 
> > > > > this may be even better) we avoid creating such Threads in the first 
> > > > > place (print an error/warning when the target is created).
> > > > > Maybe that representation should be used all the way down? 
> > > > 
> > > > I'll follow that path. This will create consistency through the code
> > > > 
> > > > 
> > > > > Or (and this may be even better) we avoid creating such Threads in 
> > > > > the first place (print an error/warning when the target is created).
> > > >  
> > > > I wish I could do that, but decoding is very expensive and should be 
> > > > done lazily. According to Intel and my tests, if a thread was traced 
> > > > during T seconds, then decoding takes around 10T, which is a big amount 
> > > > of time if you were tracing 10 threads for 5 seconds, which would take 
> > > > 500 seconds to decode. At least for know we are not doing parallel 
> > > > decoding. I imagine at some point we'll have to work on that.
> > > If you can pull that off -- great. However, I have doubts (and judging by 
> > > the other comments, you're starting to have some too) regarding how long 
> > > will you be able to postpone the decoding. For example, lldb very much 
> > > likes to know the PC value of each thread (can you really blame it?) -- 
> > > so much that we've added a special field to the gdb-remote stop-reply 
> > > packet which lists the pc values of all threads.
> > > 
> > > That leads me to believe that you'll need to decode at least the last 
> > > block of each thread's trace very early on
> > Yes, I ended up understanding more of LLDB and it seems that it'll be as 
> > you describe. I'll try to limit the initial decoding to at most the PC of 
> > each thread, which would indeed be very beneficial, because we could catch 
> > early some critical errors. I'll do that early decoding in another diff.
> Sounds good.
> 
> I am slightly worried about the emphasis on sequential instruction numbers in 
> this design. It seems like it'd be hard to avoid decoding the entire trace if 
> one needs to assign a sequential id to each instruction. But let's see how it 
> goes...
I think that the actual problem is we can avoid decoding the entire trace in 
the first place. This will be unavoidable if we want to show backtraces, as the 
frames are scattered throughout the trace and there's no way to know where they 
are unless you decode it all. I don't know of any other efficient tracing 
mechanism that doesn't have this problem. When I implement the backtrace 
reconstruction we can have a much better picture of what's possible and what 
not.


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

https://reviews.llvm.org/D89283

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


[Lldb-commits] [PATCH] D89283: [trace][intel-pt] Implement the basic decoding functionality

2020-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace updated this revision to Diff 300864.
wallace marked 2 inline comments as done.
wallace added a comment.

Address issues.


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

https://reviews.llvm.org/D89283

Files:
  lldb/include/lldb/Core/Disassembler.h
  lldb/include/lldb/Symbol/SymbolContext.h
  lldb/include/lldb/Target/Trace.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Commands/Options.td
  lldb/source/Core/Disassembler.cpp
  lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
  lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
  lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.cpp
  lldb/source/Plugins/Trace/intel-pt/IntelPTDecoder.h
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
  lldb/source/Symbol/SymbolContext.cpp
  lldb/source/Target/ProcessTrace.cpp
  lldb/source/Target/Trace.cpp
  lldb/source/Target/TraceSessionFileParser.cpp
  lldb/test/API/commands/trace/TestTraceDumpInstructions.py
  lldb/test/API/commands/trace/intelpt-trace-multi-file/a.out
  lldb/test/API/commands/trace/intelpt-trace-multi-file/bar.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-file/bar.h
  lldb/test/API/commands/trace/intelpt-trace-multi-file/foo.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-file/foo.h
  lldb/test/API/commands/trace/intelpt-trace-multi-file/libbar.so
  lldb/test/API/commands/trace/intelpt-trace-multi-file/libfoo.so
  lldb/test/API/commands/trace/intelpt-trace-multi-file/main.cpp
  lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json
  lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file.trace
  lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json
  lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json

Index: lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace_wrong_cpu.json
@@ -0,0 +1,31 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 2123123,
+  "model": 12123123,
+  "stepping": 1231231
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 3842849,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "6AA9A4E2-6F28-2F33-377D-59FECE874C71-5B41261A"
+}
+  ]
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace/trace_bad_image.json
@@ -0,0 +1,31 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 1234,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 3842849,
+  "traceFile": "3842849.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x00F0",
+  "uuid": "6AA9A4E2-6F28-2F33-377D-59FECE874C71-5B41261A"
+}
+  ]
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json
===
--- /dev/null
+++ lldb/test/API/commands/trace/intelpt-trace-multi-file/multi-file-no-ld.json
@@ -0,0 +1,43 @@
+{
+  "trace": {
+"type": "intel-pt",
+"pt_cpu": {
+  "vendor": "intel",
+  "family": 6,
+  "model": 79,
+  "stepping": 1
+}
+  },
+  "processes": [
+{
+  "pid": 815455,
+  "triple": "x86_64-*-linux",
+  "threads": [
+{
+  "tid": 815455,
+  "traceFile": "multi-file.trace"
+}
+  ],
+  "modules": [
+{
+  "file": "a.out",
+  "systemPath": "a.out",
+  "loadAddress": "0x0040",
+  "uuid": "D2414468-7112-B7C5-408D-FF07E30D5B17-A5BFD2C4"
+},
+{
+  "file": "libfoo.so",
+  "systemPath": "libfoo.so",
+  "loadAddress": "0x77bd9000",
+  "uuid": "B30FFEDA-8BB2-3D08-4580-C5937ED11E2B-21BE778C"
+},
+{
+  "file": "libbar.so",
+  "systemPath": "libbar.so",
+  "loadAddress": "0x779d7000",
+  "uuid": "6633B038-EA73-D1A6-FF9A-7D0C0EDF733D-95FEA2CC"
+}
+  ]
+}
+  ]
+}
Index: lldb/test/API/commands/trace/intelpt-trace-multi-file/main.cpp