[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon added inline comments.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:391-394
+  uint32_t GetMaxX() const { return getmaxx(m_window); }
+  uint32_t GetMaxY() const { return getmaxy(m_window); }
+  uint32_t GetWidth() const { return GetMaxX(); }
+  uint32_t GetHeight() const { return GetMaxY(); }

clayborg wrote:
> the underlying curses functions return "int". Were there places where people 
> were comparing them to unsigned?
A function HorizontalLine() at line 2582 requires non-negative input. Good 
point about the underlying function possibly returning a negative still.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:2582
 surface.MoveCursor(0, 1);
 surface.HorizontalLine(surface.GetWidth());
   }

Here we have HorizontalLine() function that requires non-negative input


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

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


[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon added a comment.

Responded to comments




Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:391-394
+  uint32_t GetMaxX() const { return getmaxx(m_window); }
+  uint32_t GetMaxY() const { return getmaxy(m_window); }
+  uint32_t GetWidth() const { return GetMaxX(); }
+  uint32_t GetHeight() const { return GetMaxY(); }

fixathon wrote:
> clayborg wrote:
> > the underlying curses functions return "int". Were there places where 
> > people were comparing them to unsigned?
> A function HorizontalLine() at line 2582 requires non-negative input. Good 
> point about the underlying function possibly returning a negative still.
I took another look, and I am not sure what the complaint is. Both the 
HorizontalLine() and its underlying call to ::whline take input typed as 
"signed int". Perhaps ::whline is unable to handle negative input?

  void HorizontalLine(int n, chtype h_char = ACS_HLINE) {
::whline(m_window, h_char, n);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

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


[Lldb-commits] [PATCH] D131658: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon created this revision.
fixathon added reviewers: clayborg, JDevlieghere, DavidSpickett, jasonmolenda.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
fixathon requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Functionally broken code for reading and writing registers, likely due to 
typos, 
and could cause out-of-bounds memory access.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131658

Files:
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   uint64_t value = reg_value.GetAsUInt64();
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
 m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
   } else
@@ -92,7 +92,7 @@
 value = m_gpr[reg_num - dwarf_r0];
   else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
 uint32_t idx = reg_num - dwarf_d0;
 if (idx < 16)


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   uint64_t value = reg_value.GetAsUInt64();
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
 m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
   } else
@@ -92,7 +92,7 @@
 value = m_gpr[reg_num - dwarf_r0];
   else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
 uint32_t idx = reg_num - dwarf_d0;
 if (idx < 16)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Please include more context 
(https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface)
 in future patches.

Thanks for the tests regardless!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131658: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM and I'll add a test later that would break without this fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131658

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


[Lldb-commits] [PATCH] D131658: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon added a comment.

Thank you. Yes, this does need a unit test




Comment at: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp:54
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;

Here index 'i' represents an offset starting at dwarf_d0, and index 'idx' is 
normalized to start at 0. 
"i" will always be greater than 16 causing the 'else' statement to always 
execute regardless of the intent.



Comment at: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp:95
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {

Also clearly a typo as can be seen from the if condition, and the corresponding 
store code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131658

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


[Lldb-commits] [lldb] ab6a082 - [LLDB] Fix out-of-bounds memory access in EmulationStateArm

2022-08-11 Thread Slava Gurevich via lldb-commits

Author: Slava Gurevich
Date: 2022-08-11T01:34:18-07:00
New Revision: ab6a0823afc7e4cc660f0fd3bd07f791fe9e103f

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

LOG: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

Functionally broken code for reading and writing registers, likely due to typos,
and could cause out-of-bounds memory access.

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

Added: 


Modified: 
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp 
b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
index da679a3e85471..4bfff9277f08b 100644
--- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@ bool 
EmulationStateARM::LoadPseudoRegistersFromFrame(StackFrame &frame) {
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   uint64_t value = reg_value.GetAsUInt64();
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
 m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
   } else
@@ -92,7 +92,7 @@ uint64_t EmulationStateARM::ReadPseudoRegisterValue(uint32_t 
reg_num,
 value = m_gpr[reg_num - dwarf_r0];
   else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
 uint32_t idx = reg_num - dwarf_d0;
 if (idx < 16)



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


[Lldb-commits] [PATCH] D131658: [LLDB] Fix out-of-bounds memory access in EmulationStateArm

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab6a0823afc7: [LLDB] Fix out-of-bounds memory access in 
EmulationStateArm (authored by fixathon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131658

Files:
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   uint64_t value = reg_value.GetAsUInt64();
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
 m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
   } else
@@ -92,7 +92,7 @@
 value = m_gpr[reg_num - dwarf_r0];
   else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
 uint32_t idx = reg_num - dwarf_d0;
 if (idx < 16)


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -51,7 +51,7 @@
 if (reg_ctx->ReadRegister(reg_info, reg_value)) {
   uint64_t value = reg_value.GetAsUInt64();
   uint32_t idx = i - dwarf_d0;
-  if (i < 16) {
+  if (idx < 16) {
 m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
 m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
   } else
@@ -92,7 +92,7 @@
 value = m_gpr[reg_num - dwarf_r0];
   else if ((dwarf_s0 <= reg_num) && (reg_num <= dwarf_s31)) {
 uint32_t idx = reg_num - dwarf_s0;
-value = m_vfp_regs.d_regs[idx];
+value = m_vfp_regs.s_regs[idx];
   } else if ((dwarf_d0 <= reg_num) && (reg_num <= dwarf_d31)) {
 uint32_t idx = reg_num - dwarf_d0;
 if (idx < 16)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131543: [LLDB][NFC] Fix the style issue in TCPSocket

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

"LLDB’s code style differs from LLVM’s coding style. Unfortunately there is no 
document describing the differences. Please be consistent with the existing 
code."

Well I don't remember seeing any Yoda conditions elsewhere so LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131543

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


[Lldb-commits] [PATCH] D131663: [LLDB][ARM] Extend testing for vpush emulation

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

https://reviews.llvm.org/D131658 found a bug in
ReadPseudoRegisterValue which would mean we read out
of bounds if the s register number was high enough.

This adds a memory check to vpush-1-thumb, which
should have been doing that anyway. Then copies that
test and uses the last 4 s registers instead.

Without the mentioned fix we see random values in
the final memory, with the fix it passes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131663

Files:
  lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
  lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat

Index: lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
===
--- lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
+++ lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
@@ -43,19 +43,33 @@
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }
 }
 after_state={
+memory={
+address=0x2fdffe40
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+]
+}
 registers={
 r0=0x
 r1=0x0001
@@ -96,14 +110,14 @@
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }
Index: lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
===
--- lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
+++ lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
@@ -1,7 +1,7 @@
 InstructionEmulationState={
-assembly_string="vpush	{d11, d12, d13, d14}"
+assembly_string="vpush	{s28, s29, s30, s31}"
 triple=thumb-apple-ios
-opcode=0xed2dbb08
+opcode=0xed2dea04
 before_state={
 registers={
 r0=0x
@@ -49,13 +49,23 @@
 s25=0x
 s26=0x
 s27=0x
-s28=0x
-s29=0x
-s30=0x
-s31=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
 }
 }
 after_state={
+memory={
+address=0x2fdffe50
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+]
+}
 registers={
 r0=0x
 r1=0x0001
@@ -70,7 +80,7 @@
 r10=0x000a
 r11=0x000b
 r12=0x000c
-r13=0x2fdffe40
+r13=0x2fdffe50
 r14=0x2f80
 r15=0x2ffc
 cpsr=0x6030
@@ -102,10 +112,10 @@
 s25=0x
 s26=0x
 s27=0x
-s28=0x
-s29=0x
-s30=0x
-s31=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
 }
 }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131664: [LLDB][ARM] Remove unused LoadPseudoRegistersFromFrame function

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

https://reviews.llvm.org/D131658 identified a bug in this and
turns out it's not used anywhere.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131664

Files:
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
  lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
@@ -32,8 +32,6 @@
 
   void ClearPseudoMemory();
 
-  bool LoadPseudoRegistersFromFrame(lldb_private::StackFrame &frame);
-
   bool LoadStateFromDictionary(lldb_private::OptionValueDictionary *test_data);
 
   bool CompareState(EmulationStateARM &other_state,
Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -26,43 +26,6 @@
 
 EmulationStateARM::~EmulationStateARM() = default;
 
-bool EmulationStateARM::LoadPseudoRegistersFromFrame(StackFrame &frame) {
-  RegisterContext *reg_ctx = frame.GetRegisterContext().get();
-  bool success = true;
-  uint32_t reg_num;
-
-  for (int i = dwarf_r0; i < dwarf_r0 + 17; ++i) {
-reg_num =
-reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindDWARF, i);
-const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
-RegisterValue reg_value;
-if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-  m_gpr[i - dwarf_r0] = reg_value.GetAsUInt32();
-} else
-  success = false;
-  }
-
-  for (int i = dwarf_d0; i < dwarf_d0 + 32; ++i) {
-reg_num =
-reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindDWARF, i);
-RegisterValue reg_value;
-const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
-
-if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-  uint64_t value = reg_value.GetAsUInt64();
-  uint32_t idx = i - dwarf_d0;
-  if (idx < 16) {
-m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
-m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
-  } else
-m_vfp_regs.d_regs[idx - 16] = value;
-} else
-  success = false;
-  }
-
-  return success;
-}
-
 bool EmulationStateARM::StorePseudoRegisterValue(uint32_t reg_num,
  uint64_t value) {
   if (reg_num <= dwarf_cpsr)


Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.h
@@ -32,8 +32,6 @@
 
   void ClearPseudoMemory();
 
-  bool LoadPseudoRegistersFromFrame(lldb_private::StackFrame &frame);
-
   bool LoadStateFromDictionary(lldb_private::OptionValueDictionary *test_data);
 
   bool CompareState(EmulationStateARM &other_state,
Index: lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
===
--- lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
+++ lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
@@ -26,43 +26,6 @@
 
 EmulationStateARM::~EmulationStateARM() = default;
 
-bool EmulationStateARM::LoadPseudoRegistersFromFrame(StackFrame &frame) {
-  RegisterContext *reg_ctx = frame.GetRegisterContext().get();
-  bool success = true;
-  uint32_t reg_num;
-
-  for (int i = dwarf_r0; i < dwarf_r0 + 17; ++i) {
-reg_num =
-reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindDWARF, i);
-const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
-RegisterValue reg_value;
-if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-  m_gpr[i - dwarf_r0] = reg_value.GetAsUInt32();
-} else
-  success = false;
-  }
-
-  for (int i = dwarf_d0; i < dwarf_d0 + 32; ++i) {
-reg_num =
-reg_ctx->ConvertRegisterKindToRegisterNumber(eRegisterKindDWARF, i);
-RegisterValue reg_value;
-const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num);
-
-if (reg_ctx->ReadRegister(reg_info, reg_value)) {
-  uint64_t value = reg_value.GetAsUInt64();
-  uint32_t idx = i - dwarf_d0;
-  if (idx < 16) {
-m_vfp_regs.s_regs[idx * 2] = (uint32_t)value;
-m_vfp_regs.s_regs[idx * 2 + 1] = (uint32_t)(value >> 32);
-  } else
-m_vfp_regs.d_regs[idx - 16] = value;
-} else
-  success = false;
-  }
-
-  return success;
-}
-
 bool EmulationStateARM::StorePseudoRegisterValue(uint32_t reg_num,
  

[Lldb-commits] [PATCH] D131664: [LLDB][ARM] Remove unused LoadPseudoRegistersFromFrame function

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added reviewers: fixathon, JDevlieghere.
DavidSpickett added a subscriber: JDevlieghere.
DavidSpickett added a comment.

@JDevlieghere Unless this is still used in your downstream?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131664

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


[Lldb-commits] [PATCH] D131663: [LLDB][ARM] Extend testing for vpush emulation

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon accepted this revision.
fixathon added a comment.
This revision is now accepted and ready to land.

Thank you for adding this test!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131663

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


[Lldb-commits] [lldb] 14913fa - [LLDB][ARM] Extend testing for vpush emulation

2022-08-11 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2022-08-11T10:02:37Z
New Revision: 14913fa5d0508c3e29ae69552ef0710c82913a75

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

LOG: [LLDB][ARM] Extend testing for vpush emulation

https://reviews.llvm.org/D131658 found a bug in
ReadPseudoRegisterValue which would mean we read out
of bounds if the s register number was high enough.

This adds a memory check to vpush-1-thumb, which
should have been doing that anyway. Then copies that
test and uses the last 4 s registers instead.

Without the mentioned fix we see random values in
the final memory, with the fix it passes.

Reviewed By: fixathon

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

Added: 
lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat

Modified: 
lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat

Removed: 




diff  --git 
a/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat 
b/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
new file mode 100644
index 0..188c8be42c3f3
--- /dev/null
+++ 
b/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
@@ -0,0 +1,121 @@
+InstructionEmulationState={
+assembly_string="vpush {s28, s29, s30, s31}"
+triple=thumb-apple-ios
+opcode=0xed2dea04
+before_state={
+registers={
+r0=0x
+r1=0x0001
+r2=0x0002
+r3=0x0003
+r4=0x0004
+r5=0x0005
+r6=0x0006
+r7=0x2fdffe60
+r8=0x0008
+r9=0x0009
+r10=0x000a
+r11=0x000b
+r12=0x000c
+r13=0x2fdffe60
+r14=0x2f80
+r15=0x2ff8
+cpsr=0x6030
+s0=0x
+s1=0x
+s2=0x
+s3=0x
+s4=0x
+s5=0x
+s6=0x
+s7=0x
+s8=0x
+s9=0x
+s10=0x
+s11=0x
+s12=0x
+s13=0x
+s14=0x
+s15=0x
+s16=0x
+s17=0x
+s18=0x
+s19=0x
+s20=0x
+s21=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
+}
+}
+after_state={
+memory={
+address=0x2fdffe50
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+]
+}
+registers={
+r0=0x
+r1=0x0001
+r2=0x0002
+r3=0x0003
+r4=0x0004
+r5=0x0005
+r6=0x0006
+r7=0x2fdffe60
+r8=0x0008
+r9=0x0009
+r10=0x000a
+r11=0x000b
+r12=0x000c
+r13=0x2fdffe50
+r14=0x2f80
+r15=0x2ffc
+cpsr=0x6030
+s0=0x
+s1=0x
+s2=0x
+s3=0x
+s4=0x
+s5=0x
+s6=0x
+s7=0x
+s8=0x
+s9=0x
+s10=0x
+s11=0x
+s12=0x
+s13=0x
+s14=0x
+s15=0x
+s16=0x
+s17=0x
+s18=0x
+s19=0x
+s20=0x
+s21=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
+}
+}
+}

diff  --git a/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat 
b/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
index ac4ef56be6655..46f734d67d76d 100644
--- a/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
+++ b/lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
@@ -43,19 +43,33 @@ s18=0x
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }
 }
 after_state={
+memory={
+address=0x2fdffe40
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+]
+}
 registers={
 r0=0x
 r1=0x0001
@@ -96,14 +110,14 @@ s18=0x
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }



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


[Lldb-commits] [PATCH] D131663: [LLDB][ARM] Extend testing for vpush emulation

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14913fa5d050: [LLDB][ARM] Extend testing for vpush emulation 
(authored by DavidSpickett).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131663

Files:
  lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
  lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat

Index: lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
===
--- lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
+++ lldb/test/API/arm/emulation/new-test-files/test-vpush-1-thumb.dat
@@ -43,19 +43,33 @@
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }
 }
 after_state={
+memory={
+address=0x2fdffe40
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+0x
+]
+}
 registers={
 r0=0x
 r1=0x0001
@@ -96,14 +110,14 @@
 s19=0x
 s20=0x
 s21=0x
-s22=0x
-s23=0x
-s24=0x
-s25=0x
-s26=0x
-s27=0x
-s28=0x
-s29=0x
+s22=0x
+s23=0x
+s24=0x
+s25=0x
+s26=0x
+s27=0x
+s28=0x
+s29=0x
 s30=0x
 s31=0x
 }
Index: lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
===
--- lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
+++ lldb/test/API/arm/emulation/new-test-files/test-vpush-1-high-sregs-thumb.dat
@@ -1,7 +1,7 @@
 InstructionEmulationState={
-assembly_string="vpush	{d11, d12, d13, d14}"
+assembly_string="vpush	{s28, s29, s30, s31}"
 triple=thumb-apple-ios
-opcode=0xed2dbb08
+opcode=0xed2dea04
 before_state={
 registers={
 r0=0x
@@ -49,13 +49,23 @@
 s25=0x
 s26=0x
 s27=0x
-s28=0x
-s29=0x
-s30=0x
-s31=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
 }
 }
 after_state={
+memory={
+address=0x2fdffe50
+data_encoding=uint32_t
+data=[
+0x
+0x
+0x
+0x
+]
+}
 registers={
 r0=0x
 r1=0x0001
@@ -70,7 +80,7 @@
 r10=0x000a
 r11=0x000b
 r12=0x000c
-r13=0x2fdffe40
+r13=0x2fdffe50
 r14=0x2f80
 r15=0x2ffc
 cpsr=0x6030
@@ -102,10 +112,10 @@
 s25=0x
 s26=0x
 s27=0x
-s28=0x
-s29=0x
-s30=0x
-s31=0x
+s28=0x
+s29=0x
+s30=0x
+s31=0x
 }
 }
 }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-11 Thread Dávid Bolvanský via Phabricator via lldb-commits
xbolva00 added inline comments.



Comment at: llvm/docs/ReleaseNotes.rst:57
+
+* GCC >= 7.1
+* Clang >= 5.0

Do we have bots which uses last supported compiler versions? GCC 7.1, Clang 5.0 
and MSVC 16.7.

It is bad to promise something and then breakages here and there, for example: 
https://github.com/llvm/llvm-project/issues/57057 so probably no such bots.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[Lldb-commits] [PATCH] D130689: [LLVM] Update C++ standard to 17

2022-08-11 Thread Tobias Hieta via Phabricator via lldb-commits
thieta added inline comments.



Comment at: llvm/docs/ReleaseNotes.rst:57
+
+* GCC >= 7.1
+* Clang >= 5.0

xbolva00 wrote:
> Do we have bots which uses last supported compiler versions? GCC 7.1, Clang 
> 5.0 and MSVC 16.7.
> 
> It is bad to promise something and then breakages here and there, for 
> example: https://github.com/llvm/llvm-project/issues/57057 so probably no 
> such bots.
I am not sure. I think it would be good if you posted that to discourse so that 
bot owners can reply to that. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130689

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


[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add riscv register definition and read/write

2022-08-11 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.

This breaks building on windows: http://45.33.8.238/win/64255/step_4.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130342

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


[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add riscv register definition and read/write

2022-08-11 Thread Emmmer S via Phabricator via lldb-commits
Emmmer added a comment.

In D130342#3715622 , @thakis wrote:

> This breaks building on windows: http://45.33.8.238/win/64255/step_4.txt
>
> Please take a look and revert for now if it takes a while to fix.

Yes. This is probably because we don't have a CI configured to enable riscv 
target.
It should be a simple fix and it is coming, don't worry :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130342

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


[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add riscv register definition and read/write

2022-08-11 Thread Emmmer S via Phabricator via lldb-commits
Emmmer added a comment.

In D130342#3715622 , @thakis wrote:

> This breaks building on windows: http://45.33.8.238/win/64255/step_4.txt
>
> Please take a look and revert for now if it takes a while to fix.

Should be fixed after D131667 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130342

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


[Lldb-commits] [lldb] be98d93 - [LLDB] Disable FP test for arm 32 bit

2022-08-11 Thread via lldb-commits

Author: Pavel Kosov
Date: 2021-09-14T18:57:03+03:00
New Revision: be98d938794fb531db6f04e55775e4096e4c7ab1

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

LOG: [LLDB] Disable FP test for arm 32 bit

Test was introduced in https://reviews.llvm.org/D126359

~~~

OS Laboratory. Huawei RRI. Saint-Petersburg

Added: 


Modified: 
lldb/test/API/lang/c/fpeval/TestFPEval.py

Removed: 




diff  --git a/lldb/test/API/lang/c/fpeval/TestFPEval.py 
b/lldb/test/API/lang/c/fpeval/TestFPEval.py
index 694d1ed7aa99d..6a3dc955ebf66 100644
--- a/lldb/test/API/lang/c/fpeval/TestFPEval.py
+++ b/lldb/test/API/lang/c/fpeval/TestFPEval.py
@@ -19,6 +19,7 @@ def setUp(self):
 # Find the line number to break inside main().
 self.line = line_number('main.c', '// Set break point at this line.')
 
+@skipIf(archs=no_match(['amd64', 'x86_64', 'arm64'])) # lldb jitter 
incorrectly evals function with FP args on 32 bit arm
 def test(self):
 """Test floating point expressions while jitter is disabled."""
 self.build()



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


[Lldb-commits] [PATCH] D130342: [LLDB][RISCV] Add riscv register definition and read/write

2022-08-11 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

The error appears to be:

  ../../lldb/source/Plugins/Process/Utility/RegisterInfos_riscv64.h(67,5): 
error: constant expression evaluates to -1 which cannot be narrowed to type 
'uint32_t' (aka 'unsigned int') [-Wc++11-narrowing]
  DEFINE_GPR64(pc, LLDB_REGNUM_GENERIC_PC),

So I'm not sure that pitch will fix everything but let's see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130342

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


[Lldb-commits] [lldb] 55e511f - [LLDB][RISCV] Fix risc-v target build

2022-08-11 Thread via lldb-commits

Author: Emmmer
Date: 2022-08-11T21:42:44+08:00
New Revision: 55e511f9f61992ff57741148a92cd2f6b6a21337

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

LOG: [LLDB][RISCV] Fix risc-v target build

Fixed an inconsistency between D130985 and D130342

This should be a follow-up of D130985

Reviewed By: DavidSpickett

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

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
lldb/source/Utility/RISCV_DWARF_Registers.h

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp 
b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
index 135254962af05..342fc1aa1a416 100644
--- a/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
@@ -10,6 +10,7 @@
 
 #include "NativeRegisterContextLinux_riscv64.h"
 
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -48,6 +49,11 @@ 
NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
   }
 }
 
+llvm::Expected
+NativeRegisterContextLinux::DetermineArchitecture(lldb::tid_t tid) {
+  return HostInfo::GetArchitecture();
+}
+
 NativeRegisterContextLinux_riscv64::NativeRegisterContextLinux_riscv64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
 std::unique_ptr register_info_up)

diff  --git a/lldb/source/Utility/RISCV_DWARF_Registers.h 
b/lldb/source/Utility/RISCV_DWARF_Registers.h
index d543bf0a6b5b1..88a0b7300ff29 100644
--- a/lldb/source/Utility/RISCV_DWARF_Registers.h
+++ b/lldb/source/Utility/RISCV_DWARF_Registers.h
@@ -124,7 +124,7 @@ enum {
   dwarf_gpr_fp = dwarf_gpr_x8,
 
   // mock pc regnum
-  dwarf_gpr_pc = UINT32_MAX,
+  dwarf_gpr_pc = 11451,
 };
 
 } // namespace riscv_dwarf



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


[Lldb-commits] [PATCH] D131667: [LLDB][RISCV] Fix risc-v target build

2022-08-11 Thread Emmmer S via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG55e511f9f619: [LLDB][RISCV] Fix risc-v target build 
(authored by Emmmer).
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131667

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
  lldb/source/Utility/RISCV_DWARF_Registers.h


Index: lldb/source/Utility/RISCV_DWARF_Registers.h
===
--- lldb/source/Utility/RISCV_DWARF_Registers.h
+++ lldb/source/Utility/RISCV_DWARF_Registers.h
@@ -124,7 +124,7 @@
   dwarf_gpr_fp = dwarf_gpr_x8,
 
   // mock pc regnum
-  dwarf_gpr_pc = UINT32_MAX,
+  dwarf_gpr_pc = 11451,
 };
 
 } // namespace riscv_dwarf
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
@@ -10,6 +10,7 @@
 
 #include "NativeRegisterContextLinux_riscv64.h"
 
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -48,6 +49,11 @@
   }
 }
 
+llvm::Expected
+NativeRegisterContextLinux::DetermineArchitecture(lldb::tid_t tid) {
+  return HostInfo::GetArchitecture();
+}
+
 NativeRegisterContextLinux_riscv64::NativeRegisterContextLinux_riscv64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
 std::unique_ptr register_info_up)


Index: lldb/source/Utility/RISCV_DWARF_Registers.h
===
--- lldb/source/Utility/RISCV_DWARF_Registers.h
+++ lldb/source/Utility/RISCV_DWARF_Registers.h
@@ -124,7 +124,7 @@
   dwarf_gpr_fp = dwarf_gpr_x8,
 
   // mock pc regnum
-  dwarf_gpr_pc = UINT32_MAX,
+  dwarf_gpr_pc = 11451,
 };
 
 } // namespace riscv_dwarf
Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_riscv64.cpp
@@ -10,6 +10,7 @@
 
 #include "NativeRegisterContextLinux_riscv64.h"
 
+#include "lldb/Host/HostInfo.h"
 #include "lldb/Utility/DataBufferHeap.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegisterValue.h"
@@ -48,6 +49,11 @@
   }
 }
 
+llvm::Expected
+NativeRegisterContextLinux::DetermineArchitecture(lldb::tid_t tid) {
+  return HostInfo::GetArchitecture();
+}
+
 NativeRegisterContextLinux_riscv64::NativeRegisterContextLinux_riscv64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread,
 std::unique_ptr register_info_up)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131667: [LLDB][RISCV] Fix risc-v target build

2022-08-11 Thread Nico Weber via Phabricator via lldb-commits
thakis added a comment.
Herald added a subscriber: JDevlieghere.

This helped, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131667

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


[Lldb-commits] [lldb] af4cdfe - [lldb][unittests] Add more test cases to CPlusPlusNameParser unit-tests

2022-08-11 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2022-08-11T15:05:48+01:00
New Revision: af4cdfe136056426eaf63a113067791dad3820c3

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

LOG: [lldb][unittests] Add more test cases to CPlusPlusNameParser unit-tests

Add test cases for the possible function qualifiers that the
`CPlusPlusNameParser` supports.

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

Added: 


Modified: 
lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Removed: 




diff  --git a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp 
b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
index bf887fb0777c5..8ec4b5492fa5c 100644
--- a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -108,7 +108,10 @@ TEST(CPlusPlusLanguage, MethodNameParsing) {
"llvm", "isUInt<10u>", "(unsigned long)", "", "llvm::isUInt<10u>"},
   {"f, sizeof(B)()", "",
"f, sizeof(B)", "()", "",
-   "f, sizeof(B)"}};
+   "f, sizeof(B)"},
+  {"llvm::Optional::operator*() const volatile &&",
+   "llvm::Optional", "operator*", "()", "const volatile 
&&",
+   "llvm::Optional::operator*"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));



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


[Lldb-commits] [PATCH] D131332: [lldb][unittests] Add more test cases to CPlusPlusNameParser unit-tests

2022-08-11 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf4cdfe13605: [lldb][unittests] Add more test cases to 
CPlusPlusNameParser unit-tests (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131332

Files:
  lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp


Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -108,7 +108,10 @@
"llvm", "isUInt<10u>", "(unsigned long)", "", "llvm::isUInt<10u>"},
   {"f, sizeof(B)()", "",
"f, sizeof(B)", "()", "",
-   "f, sizeof(B)"}};
+   "f, sizeof(B)"},
+  {"llvm::Optional::operator*() const volatile &&",
+   "llvm::Optional", "operator*", "()", "const volatile 
&&",
+   "llvm::Optional::operator*"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));


Index: lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
===
--- lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -108,7 +108,10 @@
"llvm", "isUInt<10u>", "(unsigned long)", "", "llvm::isUInt<10u>"},
   {"f, sizeof(B)()", "",
"f, sizeof(B)", "()", "",
-   "f, sizeof(B)"}};
+   "f, sizeof(B)"},
+  {"llvm::Optional::operator*() const volatile &&",
+   "llvm::Optional", "operator*", "()", "const volatile &&",
+   "llvm::Optional::operator*"}};
 
   for (const auto &test : test_cases) {
 CPlusPlusLanguage::MethodName method(ConstString(test.input));
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] c6c5944 - [lldb] Allow DataFileCache to be constructed with a different policy

2022-08-11 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2022-08-11T09:28:30-07:00
New Revision: c6c5944d05e81b5c7f48abea22a98389b1204a33

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

LOG: [lldb] Allow DataFileCache to be constructed with a different policy

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

Added: 


Modified: 
lldb/include/lldb/Core/DataFileCache.h
lldb/source/Core/DataFileCache.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/DataFileCache.h 
b/lldb/include/lldb/Core/DataFileCache.h
index 2dc69f6ce6b09..300c4842d9d22 100644
--- a/lldb/include/lldb/Core/DataFileCache.h
+++ b/lldb/include/lldb/Core/DataFileCache.h
@@ -14,6 +14,7 @@
 #include "lldb/Utility/UUID.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/CachePruning.h"
 #include "llvm/Support/Caching.h"
 #include 
 
@@ -40,11 +41,18 @@ namespace lldb_private {
 
 class DataFileCache {
 public:
-  /// Create a data file cache in the directory path that is specified.
+  /// Create a data file cache in the directory path that is specified, using
+  /// the specified policy.
   ///
   /// Data will be cached in files created in this directory when clients call
   /// DataFileCache::SetCacheData.
-  DataFileCache(llvm::StringRef path);
+  DataFileCache(llvm::StringRef path,
+llvm::CachePruningPolicy policy =
+DataFileCache::GetLLDBIndexCachePolicy());
+
+  /// Gets the default LLDB index cache policy, which is controlled by the
+  /// "LLDBIndexCache" family of settings.
+  static llvm::CachePruningPolicy GetLLDBIndexCachePolicy();
 
   /// Get cached data from the cache directory for the specified key.
   ///

diff  --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index b38adfda169aa..07c6839f01494 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -19,26 +19,34 @@
 
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(llvm::StringRef path) {
-  m_cache_dir.SetPath(path);
 
-  // Prune the cache based off of the LLDB settings each time we create a cache
-  // object.
-  ModuleListProperties &properties =
-  ModuleList::GetGlobalModuleListProperties();
-  llvm::CachePruningPolicy policy;
-  // Only scan once an hour. If we have lots of debug sessions we don't want
-  // to scan this directory too often. A timestamp file is written to the
-  // directory to ensure 
diff erent processes don't scan the directory too often.
-  // This setting doesn't mean that a thread will continually scan the cache
-  // directory within this process.
-  policy.Interval = std::chrono::hours(1);
-  // Get the user settings for pruning.
-  policy.MaxSizeBytes = properties.GetLLDBIndexCacheMaxByteSize();
-  policy.MaxSizePercentageOfAvailableSpace =
-  properties.GetLLDBIndexCacheMaxPercent();
-  policy.Expiration =
-  std::chrono::hours(properties.GetLLDBIndexCacheExpirationDays() * 24);
+llvm::CachePruningPolicy DataFileCache::GetLLDBIndexCachePolicy() {
+  static llvm::CachePruningPolicy policy;
+  static llvm::once_flag once_flag;
+
+  llvm::call_once(once_flag, []() {
+// Prune the cache based off of the LLDB settings each time we create a
+// cache object.
+ModuleListProperties &properties =
+ModuleList::GetGlobalModuleListProperties();
+// Only scan once an hour. If we have lots of debug sessions we don't want
+// to scan this directory too often. A timestamp file is written to the
+// directory to ensure 
diff erent processes don't scan the directory too
+// often. This setting doesn't mean that a thread will continually scan the
+// cache directory within this process.
+policy.Interval = std::chrono::hours(1);
+// Get the user settings for pruning.
+policy.MaxSizeBytes = properties.GetLLDBIndexCacheMaxByteSize();
+policy.MaxSizePercentageOfAvailableSpace =
+properties.GetLLDBIndexCacheMaxPercent();
+policy.Expiration =
+std::chrono::hours(properties.GetLLDBIndexCacheExpirationDays() * 24);
+  });
+  return policy;
+}
+
+DataFileCache::DataFileCache(llvm::StringRef path, llvm::CachePruningPolicy 
policy) {
+  m_cache_dir.SetPath(path);
   pruneCache(path, policy);
 
   // This lambda will get called when the data is gotten from the cache and
@@ -311,3 +319,4 @@ llvm::StringRef StringTableReader::Get(uint32_t offset) 
const {
 return llvm::StringRef();
   return llvm::StringRef(m_data.data() + offset);
 }
+



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


[Lldb-commits] [PATCH] D131531: [lldb] Allow DataFileCache to be constructed with a different policy

2022-08-11 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6c5944d05e8: [lldb] Allow DataFileCache to be constructed 
with a different policy (authored by augusto2112).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131531

Files:
  lldb/include/lldb/Core/DataFileCache.h
  lldb/source/Core/DataFileCache.cpp


Index: lldb/source/Core/DataFileCache.cpp
===
--- lldb/source/Core/DataFileCache.cpp
+++ lldb/source/Core/DataFileCache.cpp
@@ -19,26 +19,34 @@
 
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(llvm::StringRef path) {
-  m_cache_dir.SetPath(path);
 
-  // Prune the cache based off of the LLDB settings each time we create a cache
-  // object.
-  ModuleListProperties &properties =
-  ModuleList::GetGlobalModuleListProperties();
-  llvm::CachePruningPolicy policy;
-  // Only scan once an hour. If we have lots of debug sessions we don't want
-  // to scan this directory too often. A timestamp file is written to the
-  // directory to ensure different processes don't scan the directory too 
often.
-  // This setting doesn't mean that a thread will continually scan the cache
-  // directory within this process.
-  policy.Interval = std::chrono::hours(1);
-  // Get the user settings for pruning.
-  policy.MaxSizeBytes = properties.GetLLDBIndexCacheMaxByteSize();
-  policy.MaxSizePercentageOfAvailableSpace =
-  properties.GetLLDBIndexCacheMaxPercent();
-  policy.Expiration =
-  std::chrono::hours(properties.GetLLDBIndexCacheExpirationDays() * 24);
+llvm::CachePruningPolicy DataFileCache::GetLLDBIndexCachePolicy() {
+  static llvm::CachePruningPolicy policy;
+  static llvm::once_flag once_flag;
+
+  llvm::call_once(once_flag, []() {
+// Prune the cache based off of the LLDB settings each time we create a
+// cache object.
+ModuleListProperties &properties =
+ModuleList::GetGlobalModuleListProperties();
+// Only scan once an hour. If we have lots of debug sessions we don't want
+// to scan this directory too often. A timestamp file is written to the
+// directory to ensure different processes don't scan the directory too
+// often. This setting doesn't mean that a thread will continually scan the
+// cache directory within this process.
+policy.Interval = std::chrono::hours(1);
+// Get the user settings for pruning.
+policy.MaxSizeBytes = properties.GetLLDBIndexCacheMaxByteSize();
+policy.MaxSizePercentageOfAvailableSpace =
+properties.GetLLDBIndexCacheMaxPercent();
+policy.Expiration =
+std::chrono::hours(properties.GetLLDBIndexCacheExpirationDays() * 24);
+  });
+  return policy;
+}
+
+DataFileCache::DataFileCache(llvm::StringRef path, llvm::CachePruningPolicy 
policy) {
+  m_cache_dir.SetPath(path);
   pruneCache(path, policy);
 
   // This lambda will get called when the data is gotten from the cache and
@@ -311,3 +319,4 @@
 return llvm::StringRef();
   return llvm::StringRef(m_data.data() + offset);
 }
+
Index: lldb/include/lldb/Core/DataFileCache.h
===
--- lldb/include/lldb/Core/DataFileCache.h
+++ lldb/include/lldb/Core/DataFileCache.h
@@ -14,6 +14,7 @@
 #include "lldb/Utility/UUID.h"
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/CachePruning.h"
 #include "llvm/Support/Caching.h"
 #include 
 
@@ -40,11 +41,18 @@
 
 class DataFileCache {
 public:
-  /// Create a data file cache in the directory path that is specified.
+  /// Create a data file cache in the directory path that is specified, using
+  /// the specified policy.
   ///
   /// Data will be cached in files created in this directory when clients call
   /// DataFileCache::SetCacheData.
-  DataFileCache(llvm::StringRef path);
+  DataFileCache(llvm::StringRef path,
+llvm::CachePruningPolicy policy =
+DataFileCache::GetLLDBIndexCachePolicy());
+
+  /// Gets the default LLDB index cache policy, which is controlled by the
+  /// "LLDBIndexCache" family of settings.
+  static llvm::CachePruningPolicy GetLLDBIndexCachePolicy();
 
   /// Get cached data from the cache directory for the specified key.
   ///


Index: lldb/source/Core/DataFileCache.cpp
===
--- lldb/source/Core/DataFileCache.cpp
+++ lldb/source/Core/DataFileCache.cpp
@@ -19,26 +19,34 @@
 
 using namespace lldb_private;
 
-DataFileCache::DataFileCache(llvm::StringRef path) {
-  m_cache_dir.SetPath(path);
 
-  // Prune the cache based off of the LLDB settings each time we create a cache
-  // object.
-  ModuleListProperties &properties =
-  ModuleList::GetGlobalModuleListProperties();
-  llvm::CachePruningPolicy policy;
-  // Only scan once an hour. If we have lots of debug sessions we don't want
- 

[Lldb-commits] [PATCH] D131693: [lldb][Breakpoint] Prevent crash when resolving regex breakpoint on functions with asm declaration

2022-08-11 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Michael137 added a reviewer: jingham.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Currently, a function whose mangled name got
changed using an `asm()` statement on its
declaration will cause lldb to crash when
resolving restricted regex breakpoints.

The crash occurs because we previously assumed
that all functions in the SymbolContext will
cleanly demangle into a function name that we
can compare against the restrictions list.
However, with the `asm()` attribute applied
the mangled name may not conform to the
supported mangling schemes and we return
a nullptr.

The fix is to use the fallback parameter to
`ConstString::AsCString()`.

**Testing**

- Added API test


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131693

Files:
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
  
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(void) asm("NonStandardMangling");
+
+int func_with_asm(void) { return 10; }
+
+int main() {
+  func_with_asm();
+  return 0;
+}
Index: 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
@@ -0,0 +1,50 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestSourceRegexBreakpointsWithAsm(TestBase):
+
+def test_restrictions(self):
+self.build()
+self.source_regex_restrictions()
+
+def source_regex_restrictions(self):
+""" Test restricting source expressions to to functions with 
non-standard mangling."""
+# Create a target by the debugger.
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+asm_tag = "NonStandardMangling"
+
+# Sanity check that we can set breakpoint on non-standard mangled name
+main_break = target.BreakpointCreateByName(asm_tag)
+
+expected_num_locations = 1
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
+
+# Check regex on asm tag restricted to function names
+func_names = lldb.SBStringList()
+func_names.AppendString('main')
+func_names.AppendString('func')
+func_names.AppendString('""')
+func_names.AppendString('NonStandardMangling')
+
+main_break = target.BreakpointCreateBySourceRegex(
+asm_tag, lldb.SBFileSpecList(), lldb.SBFileSpecList(), func_names)
+
+expected_num_locations = 0
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -122,8 +122,9 @@
 sc_ctx
 .GetFunctionName(
 Mangled::NamePreference::ePreferDemangledWithoutArguments)
-.AsCString());
-if (!m_function_names.count(name)) {
+.AsCString(""));
+
+if (name.empty() || !m_function_names.count(name)) {
   sc_to_remove.push_back(i);
 }
   }


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(

[Lldb-commits] [lldb] c4fb631 - [NFC][lldb][trace] Fix formatting of tracing files

2022-08-11 Thread Walter Erquinigo via lldb-commits

Author: Walter Erquinigo
Date: 2022-08-11T11:00:26-07:00
New Revision: c4fb631ceeeff2a292cc9cf5232b491afe09744d

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

LOG: [NFC][lldb][trace] Fix formatting of tracing files

Pavel Labath taught me that clang-format sorts headers automatically
using llvm's rules, and it's better not to have spaces between

So in this diff I'm removing those spaces and formatting them as well.

I used `clang-format -i` to format these files.

Added: 


Modified: 
lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
lldb/source/Plugins/Process/Linux/IntelPTCollector.h
lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.h
lldb/source/Plugins/Process/Linux/IntelPTProcessTrace.h
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.h
lldb/source/Plugins/Process/Linux/Perf.cpp
lldb/source/Plugins/Process/Linux/Perf.h
lldb/source/Plugins/Process/Linux/Procfs.h
lldb/source/Plugins/Trace/intel-pt/CommandObjectTraceStartIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/DecodedThread.cpp
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp
lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h
lldb/source/Plugins/Trace/intel-pt/PerfContextSwitchDecoder.h
lldb/source/Plugins/Trace/intel-pt/TaskTimer.cpp
lldb/source/Plugins/Trace/intel-pt/TaskTimer.h
lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.cpp
lldb/source/Plugins/Trace/intel-pt/ThreadDecoder.h
lldb/source/Plugins/Trace/intel-pt/TraceCursorIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleLoader.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTBundleSaver.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTJSONStructs.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTOptions.td

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
index f89936445b2ba..5f4be5b00fdb6 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTCollector.cpp
@@ -1,4 +1,4 @@
-//===-- IntelPTCollector.cpp 
===//
+//===-- IntelPTCollector.cpp 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,18 +7,14 @@
 
//===--===//
 
 #include "IntelPTCollector.h"
-
 #include "Perf.h"
-#include "Procfs.h"
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Procfs.h"
 #include "lldb/Host/linux/Support.h"
 #include "lldb/Utility/StreamString.h"
-
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MathExtras.h"
-
 #include 
 #include 
 #include 

diff  --git a/lldb/source/Plugins/Process/Linux/IntelPTCollector.h 
b/lldb/source/Plugins/Process/Linux/IntelPTCollector.h
index b77c434b3a3ac..4598616650b85 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTCollector.h
+++ b/lldb/source/Plugins/Process/Linux/IntelPTCollector.h
@@ -9,17 +9,14 @@
 #ifndef liblldb_IntelPTCollector_H_
 #define liblldb_IntelPTCollector_H_
 
-#include "Perf.h"
-
 #include "IntelPTMultiCoreTrace.h"
 #include "IntelPTPerThreadProcessTrace.h"
 #include "IntelPTSingleBufferTrace.h"
-
+#include "Perf.h"
 #include "lldb/Host/common/NativeProcessProtocol.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/TraceIntelPTGDBRemotePackets.h"
 #include "lldb/lldb-types.h"
-
 #include 
 #include 
 #include 

diff  --git a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp 
b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
index a4794e7c8ca34..d8ee3e5600c9e 100644
--- a/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
+++ b/lldb/source/Plugins/Process/Linux/IntelPTMultiCoreTrace.cpp
@@ -7,10 +7,8 @@
 
//===--===//
 
 #include "IntelPTMultiCoreTrace.h"
-
-#include "Procfs.h"
-
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "Procfs.h"
 
 using namespace l

[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:391-394
+  uint32_t GetMaxX() const { return getmaxx(m_window); }
+  uint32_t GetMaxY() const { return getmaxy(m_window); }
+  uint32_t GetWidth() const { return GetMaxX(); }
+  uint32_t GetHeight() const { return GetMaxY(); }

fixathon wrote:
> fixathon wrote:
> > clayborg wrote:
> > > the underlying curses functions return "int". Were there places where 
> > > people were comparing them to unsigned?
> > A function HorizontalLine() at line 2582 requires non-negative input. Good 
> > point about the underlying function possibly returning a negative still.
> I took another look, and I am not sure what the complaint is. Both the 
> HorizontalLine() and its underlying call to ::whline take input typed as 
> "signed int". Perhaps ::whline is unable to handle negative input?
> 
>   void HorizontalLine(int n, chtype h_char = ACS_HLINE) {
> ::whline(m_window, h_char, n);
>   }
Not sure either. I don't want to change these as they should return "int" like 
the original API.



Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:2582
 surface.MoveCursor(0, 1);
 surface.HorizontalLine(surface.GetWidth());
   }

fixathon wrote:
> Here we have HorizontalLine() function that requires non-negative input
But surface.HorizontalLine(...) function takes an "int", and now we are passing 
it a uint32_t. If this function requires a >= 0 value, it should do the check 
internally


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

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


[Lldb-commits] [PATCH] D131554: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon marked 2 inline comments as done.
fixathon added inline comments.



Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:540
+for (uint32_t i = 0;
+ count > 0 && count <= sizeof(gpr.r) && i < count - 1; ++i) {
   gpr.r[i] = data.GetU32(&offset);

fixathon wrote:
> jasonmolenda wrote:
> > jasonmolenda wrote:
> > > clayborg wrote:
> > > > 
> > > The `count` field for a Darwin register context is the number of 4-byte 
> > > entries in the object - it's a trick the kernel API often use so they can 
> > > add fields later and the kernel knows what version of the object the 
> > > userland process is requesting when it asks for "flavor, size" in a 
> > > `get_thread_state` call.  This Aarch32 register context is `struct GPR 
> > > {uint32_t r[16]; uint32_t cpsr};` or count 17, but `sizeof(gpr.r)` is 
> > > going to be 64.  We only want to loop for 16 entries.
> > FWIW the Aarch64 version of this function hardcodes the number of elements 
> > (where each general purpose register is 8-bytes, so count==2, and then 
> > there's one cpsr 4-byte register),
> > ```
> > // x0-x29 + fp + lr + sp + pc (== 33 64-bit registers) plus cpsr (1
> > // 32-bit register)
> > if (count >= (33 * 2) + 1) {
> >   for (uint32_t i = 0; i < 29; ++i)
> > gpr.x[i] = data.GetU64(&offset);
> >   gpr.fp = data.GetU64(&offset);
> >   gpr.lr = data.GetU64(&offset);
> >   gpr.sp = data.GetU64(&offset);
> >   gpr.pc = data.GetU64(&offset);
> >   gpr.cpsr = data.GetU32(&offset);
> > ```
> Good catch. I'll: count <= sizeof(gpr.r)/sizeof(gpr.r[0]) 
"count > 0 && count <= sizeof(gpr.r)/sizeof(uint32_t) && i < count - 1; ++i)" 
was causing a compiler warning, which is the reason I moved **count** out of 
the for loop condition


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131554

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


[Lldb-commits] [PATCH] D131705: Don't create sections for SHN_ABS symbols in ELF files.

2022-08-11 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: labath, JDevlieghere, jingham, yinghuitan.
Herald added a subscriber: emaste.
Herald added a project: All.
clayborg requested review of this revision.
Herald added subscribers: lldb-commits, MaskRay.
Herald added a project: LLDB.

Symbols that have the section index of SHN_ABS were previously creating extra 
top level sections that contained the value of the symbol as if the symbol's 
value was an address. As far as I can tell, these symbol's values are not 
addresses, even if they do have a size. To make matters worse, adding these 
extra sections can stop address lookups from succeeding if the symbol's value + 
size overlaps with an existing section as these sections get mapped into memory 
when the image is loaded by the dynamic loader. This can cause stack frames to 
appear empty as the address lookup fails completely.

This patch:

- doesn't create a section for any SHN_ABS symbols
- makes symbols that are absolute have values that are not addresses
- add accessors to SBSymbol to get the value and size of a symbol as raw 
integers. Prevoiusly there was no way to access a symbol's value from a 
SBSymbol because the only accessors were:

  SBAddress SBSymbol::GetStartAddress(); SBAddress SBSymbol::GetEndAddress();

  and these accessors would return an invalid SBAddress if the symbol's value 
wasn't an address
- Adds a test to ensure no ".absolute." sections are created
- Adds a test to test the new SBSymbol APIs


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131705

Files:
  lldb/bindings/interface/SBSymbol.i
  lldb/include/lldb/API/SBSymbol.h
  lldb/include/lldb/Symbol/Symbol.h
  lldb/source/API/SBSymbol.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
  lldb/source/Symbol/Symbol.cpp
  lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py
  lldb/test/API/python_api/absolute_symbol/absolute.yaml
  lldb/test/Shell/SymbolFile/absolute-symbol.test

Index: lldb/test/Shell/SymbolFile/absolute-symbol.test
===
--- lldb/test/Shell/SymbolFile/absolute-symbol.test
+++ lldb/test/Shell/SymbolFile/absolute-symbol.test
@@ -1,8 +1,7 @@
 # RUN: yaml2obj %s -o %t.o
 # RUN: %lldb -b -o 'target modules lookup -s absolute_symbol' %t.o | FileCheck %s
 # CHECK: 1 symbols match 'absolute_symbol'
-# CHECK:   Address: 0x12345678 (0x12345678)
-# CHECK:   Summary: 0x12345678
+# CHECK:   Value: 0x12345678
 # Created from:
 #   .globl absolute_symbol
 #   absolute_symbol = 0x12345678
@@ -92,4 +91,3 @@
 - ltmp0
 - ''
 ...
-
Index: lldb/test/API/python_api/absolute_symbol/absolute.yaml
===
--- /dev/null
+++ lldb/test/API/python_api/absolute_symbol/absolute.yaml
@@ -0,0 +1,36 @@
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  OSABI:   ELFOSABI_FREEBSD
+  Type:ET_EXEC
+  Machine: EM_X86_64
+  Entry:   0x8037C000
+Sections:
+  - Name:.text
+Type:SHT_PROGBITS
+Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
+Address: 0x1000
+AddressAlign:0x4
+Content: "c3c3c3c3"
+ProgramHeaders:
+  - Type: PT_LOAD
+Flags: [ PF_X, PF_R ]
+VAddr: 0x1000
+PAddr: 0x1000
+Align: 0x4
+FirstSec: .text
+LastSec:  .text
+Symbols:
+  - Name:main
+Type:STT_FUNC
+Section: .text
+Binding: STB_GLOBAL
+Value:   0x1000
+Size:0x4
+  - Name:absolute
+Index:   SHN_ABS
+Binding: STB_GLOBAL
+Value:   0x8000
+Size:0x9
+
Index: lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py
===
--- /dev/null
+++ lldb/test/API/python_api/absolute_symbol/TestAbsoluteSymbol.py
@@ -0,0 +1,80 @@
+"""
+Test absolute symbols in ELF files to make sure they don't create sections and
+to verify that symbol values and size can still be accessed via SBSymbol APIs.
+"""
+
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import os
+
+class TestAbsoluteSymbol(TestBase):
+
+@no_debug_info_test
+def test_absolute_symbol(self):
+'''
+Load an ELF file that contains two symbols:
+- "absolute" which is a symbol with the section SHN_ABS
+- "main" which is a code symbol in .text
+
+Index   st_namest_value   st_sizest_info st_other st_shndx Name
+=== -- -- -- ---   ===
+[0] 0x 0x0

[Lldb-commits] [PATCH] D131543: [LLDB][NFC] Fix the style issue in TCPSocket

2022-08-11 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

if we are going to fix the coding conventions we should do it for all of the 
locations if possible. All of them should be super simple.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131543

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


[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-08-11 Thread Alexander Kornienko via Phabricator via lldb-commits
alexfh added a comment.

One more problem related to this patch: it changes the behavior of 
__PRETTY_FUNCTION__: https://gcc.godbolt.org/z/Mvnj9j74E. There may be 
dependencies upon the specific format of expansions of this macro: tests, log 
processing tools, libraries like ctti, and probably other things. It would be 
better to retain the format of function names expanded from this macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-08-11 Thread Matheus Izvekov via Phabricator via lldb-commits
mizvekov marked an inline comment as done.
mizvekov added a comment.

In D112374#3716944 , @alexfh wrote:

> One more problem related to this patch: it changes the behavior of 
> __PRETTY_FUNCTION__: https://gcc.godbolt.org/z/Mvnj9j74E. There may be 
> dependencies upon the specific format of expansions of this macro: tests, log 
> processing tools, libraries like ctti, and probably other things. It would be 
> better to retain the format of function names expanded from this macro.

Well it looks to me that is a bug fix.

We even match GCC now: https://gcc.godbolt.org/z/WT93WdE7e

Ie we are printing the function type as-written correctly now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[Lldb-commits] [PATCH] D131630: [trace][intel pt] Fix per-psb packet decoding

2022-08-11 Thread Jakob Johnson via Phabricator via lldb-commits
jj10306 requested changes to this revision.
jj10306 added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:164-166
+  /// \param[in] decoder
+  /// A decoder configured to start and end within the boundaries of the
+  /// given \p psb_block.

should this be trace_intel_pt?




Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.cpp:476-478
+  if (event.has_tsc) {
+tsc = event.tsc;
+break;

so is this inner loop what's actually doing the work of getting to the next 
PSB? is the assumption that if an event has a tsc then it's a PSB?
Can you explain what the two different while loops are doing?



Comment at: lldb/source/Plugins/Trace/intel-pt/LibiptDecoder.h:109
+llvm::Expected>
 SplitTraceInContinuousExecutions(TraceIntelPT &trace_intel_pt,
+ llvm::ArrayRef buffer,

should we rename now that we are using PSBBlock everywhere?



Comment at: 
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTMultiCpuDecoder.cpp:95
-static Expected>
+static Expected>
 GetIntelPTSubtracesForCpu(TraceIntelPT &trace, cpu_id_t cpu_id) {
-  std::vector intel_pt_subtraces;

rename?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131630

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


[Lldb-commits] [PATCH] D131693: [lldb][Breakpoint] Prevent crash when resolving regex breakpoint on functions with asm declaration

2022-08-11 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 451946.
Michael137 added a comment.

- Tweak test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131693

Files:
  lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
  
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
  lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(void) asm("NonStandardMangling");
+
+int func_with_asm(void) { return 10; }
+
+int main() {
+  func_with_asm();
+  return 0;
+}
Index: 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
===
--- /dev/null
+++ 
lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
@@ -0,0 +1,50 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestSourceRegexBreakpointsWithAsm(TestBase):
+
+def test_restrictions(self):
+self.build()
+self.source_regex_restrictions()
+
+def source_regex_restrictions(self):
+""" Test restricting source expressions to to functions with 
non-standard mangling."""
+# Create a target by the debugger.
+exe = self.getBuildArtifact("a.out")
+target = self.dbg.CreateTarget(exe)
+self.assertTrue(target, VALID_TARGET)
+
+asm_tag = "NonStandardMangling"
+
+# Sanity check that we can set breakpoint on non-standard mangled name
+main_break = target.BreakpointCreateByName(asm_tag)
+
+expected_num_locations = 1
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
+
+# Check regex on asm tag restricted to function names
+func_names = lldb.SBStringList()
+func_names.AppendString('main')
+func_names.AppendString('func')
+func_names.AppendString('')
+func_names.AppendString('NonStandardMangling')
+
+main_break = target.BreakpointCreateBySourceRegex(
+asm_tag, lldb.SBFileSpecList(), lldb.SBFileSpecList(), func_names)
+
+expected_num_locations = 0
+num_locations = main_break.GetNumLocations()
+self.assertEqual(
+num_locations, expected_num_locations,
+"We should have gotten %d matches, got %d." %
+(expected_num_locations, num_locations))
Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
===
--- lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
+++ lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp
@@ -122,8 +122,9 @@
 sc_ctx
 .GetFunctionName(
 Mangled::NamePreference::ePreferDemangledWithoutArguments)
-.AsCString());
-if (!m_function_names.count(name)) {
+.AsCString(""));
+
+if (name.empty() || !m_function_names.count(name)) {
   sc_to_remove.push_back(i);
 }
   }


Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/main.cpp
@@ -0,0 +1,8 @@
+int func_with_asm(void) asm("NonStandardMangling");
+
+int func_with_asm(void) { return 10; }
+
+int main() {
+  func_with_asm();
+  return 0;
+}
Index: lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
===
--- /dev/null
+++ lldb/test/API/functionalities/breakpoint/source_regexp_with_asm/TestSourceRegexBreakpointsWithAsm.py
@@ -0,0 +1,50 @@
+"""
+Test lldb breakpoint setting by source regular expression.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+clas

[Lldb-commits] [lldb] 181c037 - [lldb] Simplify TestExec's source code

2022-08-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-08-11T12:36:54-07:00
New Revision: 181c0373d2832afbb62ca50c6c59d9759d17edf7

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

LOG: [lldb] Simplify TestExec's source code

Simplify the test's source code, remove unnecessary headers, and convert
it from C++ to C.

Added: 


Modified: 
lldb/test/API/functionalities/exec/Makefile
lldb/test/API/functionalities/exec/main.cpp

Removed: 




diff  --git a/lldb/test/API/functionalities/exec/Makefile 
b/lldb/test/API/functionalities/exec/Makefile
index afc520010ee29..8b9148ea8a355 100644
--- a/lldb/test/API/functionalities/exec/Makefile
+++ b/lldb/test/API/functionalities/exec/Makefile
@@ -1,4 +1,4 @@
-CXX_SOURCES := main.cpp
+C_SOURCES := main.c
 
 all: secondprog
 

diff  --git a/lldb/test/API/functionalities/exec/main.cpp 
b/lldb/test/API/functionalities/exec/main.cpp
index 51c67d5f232dc..cd4d5f1068fa2 100644
--- a/lldb/test/API/functionalities/exec/main.cpp
+++ b/lldb/test/API/functionalities/exec/main.cpp
@@ -1,19 +1,10 @@
-#define _POSIX_C_SOURCE 200809L
-
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 #include 
 
 int main(int argc, char const **argv) {
-  char *buf = strdup(argv[0]); // Set breakpoint 1 here
-  std::string directory_name(::dirname(buf));
-
-  std::string other_program = directory_name + "/secondprog";
-  argv[0] = other_program.c_str();
-  execv(argv[0], const_cast(argv));
+  // Set breakpoint 1 here
+  execl("secondprog", "secondprog", NULL);
   perror("execve");
   abort();
 }



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


[Lldb-commits] [PATCH] D131543: [LLDB][NFC] Fix the style issue in TCPSocket

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon updated this revision to Diff 451952.
fixathon added a comment.

Fix the style in the entire file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131543

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


Index: lldb/source/Host/common/TCPSocket.cpp
===
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -167,14 +167,14 @@
 
 address.SetPort(host_port->port);
 
-if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-  &address.sockaddr(),
-  address.GetLength())) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+&address.sockaddr(),
+address.GetLength()) == -1) {
   Close();
   continue;
 }
 
-if (-1 == SetOptionNoDelay()) {
+if (SetOptionNoDelay() == -1) {
   Close();
   continue;
 }
@@ -210,8 +210,8 @@
 int option_value = 1;
 set_socket_option_arg_type option_value_p =
 reinterpret_cast(&option_value);
-if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
-   sizeof(option_value))) {
+if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value)) == -1) {
   CLOSE_SOCKET(fd);
   continue;
 }
@@ -224,10 +224,10 @@
 
 int err =
 ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
-if (-1 != err)
+if (err != -1)
   err = ::listen(fd, backlog);
 
-if (-1 == err) {
+if (err == -1) {
   error = GetLastSocketError();
   CLOSE_SOCKET(fd);
   continue;
@@ -294,7 +294,7 @@
 
 lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
 if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
-  if (kInvalidSocketValue != sock) {
+  if (sock != kInvalidSocketValue) {
 CLOSE_SOCKET(sock);
 sock = kInvalidSocketValue;
   }


Index: lldb/source/Host/common/TCPSocket.cpp
===
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -167,14 +167,14 @@
 
 address.SetPort(host_port->port);
 
-if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-  &address.sockaddr(),
-  address.GetLength())) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+&address.sockaddr(),
+address.GetLength()) == -1) {
   Close();
   continue;
 }
 
-if (-1 == SetOptionNoDelay()) {
+if (SetOptionNoDelay() == -1) {
   Close();
   continue;
 }
@@ -210,8 +210,8 @@
 int option_value = 1;
 set_socket_option_arg_type option_value_p =
 reinterpret_cast(&option_value);
-if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
-   sizeof(option_value))) {
+if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value)) == -1) {
   CLOSE_SOCKET(fd);
   continue;
 }
@@ -224,10 +224,10 @@
 
 int err =
 ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
-if (-1 != err)
+if (err != -1)
   err = ::listen(fd, backlog);
 
-if (-1 == err) {
+if (err == -1) {
   error = GetLastSocketError();
   CLOSE_SOCKET(fd);
   continue;
@@ -294,7 +294,7 @@
 
 lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
 if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
-  if (kInvalidSocketValue != sock) {
+  if (sock != kInvalidSocketValue) {
 CLOSE_SOCKET(sock);
 sock = kInvalidSocketValue;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] a8bc9b6 - [lldb] Simplify TestExec's source code (2/2)

2022-08-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-08-11T12:44:38-07:00
New Revision: a8bc9b627ea143b84253fc911902cf2c8e429630

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

LOG: [lldb] Simplify TestExec's source code (2/2)

I accidentally forgot to stage part of the changes in the previous
commit.

Added: 
lldb/test/API/functionalities/exec/main.c

Modified: 
lldb/test/API/functionalities/exec/TestExec.py

Removed: 
lldb/test/API/functionalities/exec/main.cpp



diff  --git a/lldb/test/API/functionalities/exec/TestExec.py 
b/lldb/test/API/functionalities/exec/TestExec.py
index 1eb8c5d61683..3da9c2f6fbc3 100644
--- a/lldb/test/API/functionalities/exec/TestExec.py
+++ b/lldb/test/API/functionalities/exec/TestExec.py
@@ -44,7 +44,7 @@ def do_test(self, skip_exec):
 
 # Create any breakpoints we need
 breakpoint1 = target.BreakpointCreateBySourceRegex(
-'Set breakpoint 1 here', lldb.SBFileSpec("main.cpp", False))
+'Set breakpoint 1 here', lldb.SBFileSpec("main.c", False))
 self.assertTrue(breakpoint1, VALID_BREAKPOINT)
 breakpoint2 = target.BreakpointCreateBySourceRegex(
 'Set breakpoint 2 here', lldb.SBFileSpec("secondprog.cpp", False))
@@ -132,7 +132,7 @@ def test_correct_thread_plan_state_before_exec(self):
 target = self.dbg.CreateTarget(exe)
 
 (target, process, thread, breakpoint1) = 
lldbutil.run_to_source_breakpoint(
-self, 'Set breakpoint 1 here', lldb.SBFileSpec('main.cpp', False))
+self, 'Set breakpoint 1 here', lldb.SBFileSpec('main.c', False))
 
 # The stop reason of the thread should be breakpoint.
 self.assertState(process.GetState(), lldb.eStateStopped,
@@ -145,7 +145,7 @@ def test_correct_thread_plan_state_before_exec(self):
 # thread plan, which should be cleared when a new thread list appears.
 #
 # Continuing after this instruction step will trigger a call to
-# ThreadPlan::ShouldReportRun, which sets the ThreadPlan's Thread 
cache to 
+# ThreadPlan::ShouldReportRun, which sets the ThreadPlan's Thread 
cache to
 # the old Thread* value. In Process::UpdateThreadList we are clearing 
this
 # cache in preparation for the new ThreadList.
 #

diff  --git a/lldb/test/API/functionalities/exec/main.cpp 
b/lldb/test/API/functionalities/exec/main.c
similarity index 100%
rename from lldb/test/API/functionalities/exec/main.cpp
rename to lldb/test/API/functionalities/exec/main.c



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


[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon updated this revision to Diff 451957.
fixathon added a comment.

Address review comments about the signed/unsigned issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@
 
 FileAction action;
 if (m_standard_input_field->IsSpecified()) {
-  action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-  false);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), 
true,
+  false))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_output_field->IsSpecified()) {
-  action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_error_field->IsSpecified()) {
-  action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
   }
 
@@ -6821,7 +6821,7 @@
 bool set_selected_line_to_pc = false;
 
 if (update_location) {
-  const bool process_alive = process ? process->IsAlive() : false;
+  const bool process_alive = process->IsAlive();
   bool thread_changed = false;
   if (process_alive) {
 thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 15,
   line_y);
-window.PrintfTruncated(1, "<<< Thread %u: %s ",
-   thread->GetIndexID(), stop_description);
+if (thread)
+  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+ thread->GetIndexID(),
+ stop_description);
   }
 } else {
   window.Printf("%*s", window_width - window.GetCursorX() - 1, "");


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@
 
 FileAction action;
 if (m_standard_input_field->IsSpecified()) {
-  action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-  false);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
+  false))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_output_field->IsSpecified()) {
-  action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_error_field->IsSpecified()) {
-  action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
   }
 
@@ -6821,7 +6821,7 @@
 bool set_selected_line_to_pc = false;
 
 if (update_location) {
-  const bool process_alive = process ? process->IsAlive() : false;
+  const bool process_alive = process->IsAlive();
   bool thread_changed = false;
   if (process_alive) {
 thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 15,
   line_y);
-window.PrintfTruncated(1, "<<< Thread %u: %s ",
-   thread->GetIndexID(), stop_description);
+if (thread)
+  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+ thread->GetIndexID(),
+ stop_descr

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: JDevlieghere, kastiglione.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch parses CrashLog exception data from the raw
text format and adapts it to the new JSON format.

This is necessary for feature parity between the 2 formats.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = None
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_.*) 
\s*\((.*)\)')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[\d]+),\s*(0x[\d]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -670,6 +674,41 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+(exc_type, exc_signal) = exception_type_match.groups()
+self.crashlog.exception = {}
+self.crashlog.exception['type'] = exc_type
+self.crashlog.exception['signal'] = exc_signal
+return
+elif line.startswith('Exception Subtype:'): # iOS
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if self.crashlog.exception['type']:
+self.crashlog.exception['subtype']: 
self.crashlog.thread_exception_subtype
+return
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+(code, subcode) = exception_codes_match.groups()
+self.crashlog.exception['rawcodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+return
+else:
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['message'] = 
exception_extra_match.group(0)
+return
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +732,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
 self.crashlog.parent_process_id = parent_process_match.group(2)
-elif line.startswith('Exception Type:'):
-self.crashlog.thread_exception = line[15:].strip()
-return
-elif line.startswith('Exception Codes:'):
-self.crashlog.thread_exception_data = line[16:].strip()
-return
-elif line.startswith('Exception Subtype:'): # iOS
-self.crashlog.thread_exception_data = line[18:].strip()
+elif line.startswith('Exception'):
+self.parse_exception(line)
 return
 elif line.startswith('Crashed Thread:'):
 self.crashlog.crashed_thread_idx = 
int(line[15:].strip().split()[0])


Index:

[Lldb-commits] [PATCH] D131305: [lldb] Tidy some regex in crashlog.py (NFC)

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 451983.
kastiglione added a comment.

Fix one crashlog test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131305

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
@@ -52,7 +52,6 @@
 # CHECK: MyFramework Plus.dylib
 # CHECK: ({{.*}}
 # CHECK: 1.11 - MyFramework 1.11
-# CHECK: <{{.*}}
 # CHECK: 01234
 # CHECK: /tmp/MyFramework Plus.dylib
 
@@ -62,7 +61,6 @@
 # CHECK: MyFramework-dev.dylib
 # CHECK: ({{.*}}
 # CHECK: 1.0.0svn - 1.0.0svn
-# CHECK: <{{.*}}
 # CHECK: 01234
 # CHECK: /MyFramework-dev.dylib
 
@@ -73,7 +71,6 @@
 # CHECK: ({{.*}}
 # CHECK: 400.9.4
 # CHECK: None
-# CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
 
 "0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
@@ -82,7 +79,6 @@
 # CHECK: dyld
 # CHECK: {{.*}}
 # CHECK: arm64e
-# CHECK: <{{.*}}
 # CHECK: cfa789d10da63f9a8996daf84ed9d04f
 # CHECK: /usr/lib/dyld
 ]
@@ -101,9 +97,6 @@
 "2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
 # CHECK: 2
 # CHECK: MyApp Pro
-# CHECK: a
-# CHECK: arm64
-# CHECK: a
 # CHECK: 0x00019b0db3a8
 # CHECK: foo + 72
 "3   He 0x1	0x00019b0db3a8 foo + 72"
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -603,26 +603,26 @@
 
 
 class TextCrashLogParser(CrashLogParser):
-parent_process_regex = re.compile('^Parent Process:\s*(.*)\[(\d+)\]')
-thread_state_regex = re.compile('^Thread ([0-9]+) crashed with')
-thread_instrs_regex = re.compile('^Thread ([0-9]+) instruction stream')
-thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
-app_backtrace_regex = re.compile('^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
-frame_regex = re.compile(r'^([0-9]+)' r'\s+'# id
- r'(.+?)' r'\s+'# img_name
- r'(' +version+ r')?'   # img_version
- r'(0x[0-9a-fA-F]{7,})' # addr (7 chars or more)
- r' +(.*)'  # offs
+parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
+thread_state_regex = re.compile(r'^Thread \d+ crashed with')
+thread_instrs_regex = re.compile(r'^Thread \d+ instruction stream')
+thread_regex = re.compile(r'^Thread (\d+).*:')
+app_backtrace_regex = re.compile(r'^Application Specific Backtrace (\d+).*:')
+version = r'\(.+\)|(?:arm|x86_)[0-9a-z]+'
+frame_regex = re.compile(r'^(\d+)\s+'  # id
+ r'(.+?)\s+'   # img_name
+ r'(?:' +version+ r'\s+)?' # img_version
+ r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
-  r'\s+' '-' r'\s+'  #   -
-  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
-  r'[+]?(.+?)'r'\s+' # img_name
-  r'(' +version+ ')?'# img_version
-  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)'   # img_path
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
+  r'\s+-\s+'   #   -
+  r'(0x[0-9a-fA-F]+)\s+'   # img_hi
+  r'[+]?(.+?)\s+'  # img_name
+  r'(?:(' +version+ r')\s+)?'  # img_version
+  r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)' # img_path
  )
 
 def __init__(self, debugger, path, verbose):
@@ -768,8 +768,8 @@
 return
 frame_match = self.frame_regex.search(line)
 if frame_match:
-(frame_id, frame_img_name, _, frame_img_version, _,
-frame_addr, frame_ofs) = frame_match.groups()
+(frame_id, frame_img_name, frame_addr,
+frame_ofs) =

[Lldb-commits] [lldb] a5881e8 - [lldb] Silence a GCC warning about missing returns after a fully covered switch. NFC.

2022-08-11 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2022-08-12T00:35:32+03:00
New Revision: a5881e8a810bac74af2efcdcf12c741d52a1970a

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

LOG: [lldb] Silence a GCC warning about missing returns after a fully covered 
switch. NFC.

Added: 


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

Removed: 




diff  --git a/lldb/tools/lldb-test/lldb-test.cpp 
b/lldb/tools/lldb-test/lldb-test.cpp
index c6f9463dbb6de..466e082534e58 100644
--- a/lldb/tools/lldb-test/lldb-test.cpp
+++ b/lldb/tools/lldb-test/lldb-test.cpp
@@ -879,6 +879,7 @@ static Mangled::NamePreference 
opts::symtab::getNamePreference() {
   case ManglingPreference::MangledWithoutArguments:
 return Mangled::ePreferDemangledWithoutArguments;
   }
+  llvm_unreachable("Fully covered switch above!");
 }
 
 int opts::symtab::handleSymtabCommand(Debugger &Dbg) {



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


[Lldb-commits] [PATCH] D131605: [lldb][tests] Test queue-specific breakpoints

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/test/API/macosx/queues/TestQueues.py:133
+"The breakpoint for queue %s has not been hit" % 
(queue_breakpoint.GetQueueName()))
+self.assertEqual(queue1_thread.GetStopReason(), 3,
+ "Queue %s is not stopped at breakpoint %d" %

Could you replace that with the enum variable ?



Comment at: lldb/test/API/macosx/queues/TestQueues.py:388
+# to be the name of the main thread
+queue_breakpoint = lldbutil.run_to_name_breakpoint(self, "stopper", 
only_one_thread=False)[3]
+queue_breakpoint.SetQueueName(main_thread.GetQueue().GetName())

Do you really need a `main_thread` variable since 
`lldbutil.run_to_name_breakpoint` would return a tuple with `(target, process, 
thread, bkpt)` ? Is the thread returned here different from the `main_thread` 
you created above ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131605

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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 451998.
mib added a comment.

Change regex to support **actual** hex addresses


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

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = None
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_.*) 
\s*\((.*)\)')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -670,6 +674,41 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+(exc_type, exc_signal) = exception_type_match.groups()
+self.crashlog.exception = {}
+self.crashlog.exception['type'] = exc_type
+self.crashlog.exception['signal'] = exc_signal
+return
+elif line.startswith('Exception Subtype:'): # iOS
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if self.crashlog.exception['type']:
+self.crashlog.exception['subtype']: 
self.crashlog.thread_exception_subtype
+return
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+(code, subcode) = exception_codes_match.groups()
+self.crashlog.exception['rawcodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+return
+else:
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)
+return
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +732,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
 self.crashlog.parent_process_id = parent_process_match.group(2)
-elif line.startswith('Exception Type:'):
-self.crashlog.thread_exception = line[15:].strip()
-return
-elif line.startswith('Exception Codes:'):
-self.crashlog.thread_exception_data = line[16:].strip()
-return
-elif line.startswith('Exception Subtype:'): # iOS
-self.crashlog.thread_exception_data = line[18:].strip()
+elif line.startswith('Exception'):
+self.parse_exception(line)
 return
 elif line.startswith('Crashed Thread:'):
 self.crashlog.crashed_thread_idx = 
int(line[15:].strip().split()[0])


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific b

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/crashlog.py:628
  )
+exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_.*) 
\s*\((.*)\)')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')

consider using `EXC_[A-Z_]+` or `EXC_.*?` to not over match.

` \s*` (a space followed by `\s*`) could be replaced with `\s+`


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/crashlog.py:708-709
+if exception_extra_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)

is this meaning to check that the key `'type'` exists, and that it is false-y? 
Or, should it be checking whether the key `'type'` is in the dictionary (`if 
key is not in dict`)

also, this check could be hoisted out, and avoid performing the regex search if 
the result isn't going to be used. As it is now, the regex search happens, and 
the result is ignored if this condition is met.


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:628
  )
+exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_.*) 
\s*\((.*)\)')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')

kastiglione wrote:
> consider using `EXC_[A-Z_]+` or `EXC_.*?` to not over match.
> 
> ` \s*` (a space followed by `\s*`) could be replaced with `\s+`
Yeah, that's better! Also, I suspect the second group to be optional, so I need 
to change this regex anyway


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [lldb] 28d0c0c - [lldb] Tidy some regex in crashlog.py (NFC)

2022-08-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-08-11T15:24:57-07:00
New Revision: 28d0c0c2c8e88d2b6599ee34c84eb58eed43a626

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

LOG: [lldb] Tidy some regex in crashlog.py (NFC)

A spiritual follow up to D131032. I noticed some regex could be simplified.

This does some of the following:
1. Removes unused capture groups
2. Uses non-capturing `(?:...)` groups where grouping is needed but capturing 
isn't
3. Removes trailing `.*`
4. Uses `\d` over `[0-9]`
5. Uses raw strings
6. Uses `{N,}` to indicate N-or-more

Also improves the call site of a `re.findall`.

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

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index 33f4c4f3b3680..ad0d70a669a85 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -603,26 +603,26 @@ class CrashLogParseMode:
 
 
 class TextCrashLogParser(CrashLogParser):
-parent_process_regex = re.compile('^Parent Process:\s*(.*)\[(\d+)\]')
-thread_state_regex = re.compile('^Thread ([0-9]+) crashed with')
-thread_instrs_regex = re.compile('^Thread ([0-9]+) instruction stream')
-thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
-app_backtrace_regex = re.compile('^Application Specific Backtrace 
([0-9]+)([^:]*):(.*)')
-version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
-frame_regex = re.compile(r'^([0-9]+)' r'\s+'# id
- r'(.+?)' r'\s+'# img_name
- r'(' +version+ r')?'   # img_version
- r'(0x[0-9a-fA-F]{7,})' # addr (7 
chars or more)
- r' +(.*)'  # offs
+parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
+thread_state_regex = re.compile(r'^Thread \d+ crashed with')
+thread_instrs_regex = re.compile(r'^Thread \d+ instruction stream')
+thread_regex = re.compile(r'^Thread (\d+).*:')
+app_backtrace_regex = re.compile(r'^Application Specific Backtrace 
(\d+).*:')
+version = r'\(.+\)|(?:arm|x86_)[0-9a-z]+'
+frame_regex = re.compile(r'^(\d+)\s+'  # id
+ r'(.+?)\s+'   # img_name
+ r'(?:' +version+ r'\s+)?' # img_version
+ r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
-  r'\s+' '-' r'\s+'  #   -
-  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
-  r'[+]?(.+?)'r'\s+' # img_name
-  r'(' +version+ ')?'# img_version
-  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)'   # img_path
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
+  r'\s+-\s+'   #   -
+  r'(0x[0-9a-fA-F]+)\s+'   # img_hi
+  r'[+]?(.+?)\s+'  # img_name
+  r'(?:(' +version+ r')\s+)?'  # img_version
+  r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)' # img_path
  )
 
 def __init__(self, debugger, path, verbose):
@@ -768,8 +768,8 @@ def parse_thread(self, line):
 return
 frame_match = self.frame_regex.search(line)
 if frame_match:
-(frame_id, frame_img_name, _, frame_img_version, _,
-frame_addr, frame_ofs) = frame_match.groups()
+(frame_id, frame_img_name, frame_addr,
+frame_ofs) = frame_match.groups()
 ident = frame_img_name
 self.thread.add_ident(ident)
 if ident not in self.crashlog.idents:
@@ -782,8 +782,8 @@ def parse_thread(self, line):
 def parse_images(self, line):
 image_match = self.image_regex_uuid.search(line)
 if image_match:
-(img_lo, img_hi, img_name, _, img_version, _,
-_, img_uuid, img_path) = image_match.groups()
+(img_

[Lldb-commits] [PATCH] D131305: [lldb] Tidy some regex in crashlog.py (NFC)

2022-08-11 Thread Dave Lee 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 rG28d0c0c2c8e8: [lldb] Tidy some regex in crashlog.py (NFC) 
(authored by kastiglione).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131305

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/parser_text.test
@@ -52,7 +52,6 @@
 # CHECK: MyFramework Plus.dylib
 # CHECK: ({{.*}}
 # CHECK: 1.11 - MyFramework 1.11
-# CHECK: <{{.*}}
 # CHECK: 01234
 # CHECK: /tmp/MyFramework Plus.dylib
 
@@ -62,7 +61,6 @@
 # CHECK: MyFramework-dev.dylib
 # CHECK: ({{.*}}
 # CHECK: 1.0.0svn - 1.0.0svn
-# CHECK: <{{.*}}
 # CHECK: 01234
 # CHECK: /MyFramework-dev.dylib
 
@@ -73,7 +71,6 @@
 # CHECK: ({{.*}}
 # CHECK: 400.9.4
 # CHECK: None
-# CHECK: None
 # CHECK: /usr/lib/libc++.1.dylib
 
 "0x1047b8000 - 0x10481 dyld arm64e   /usr/lib/dyld"
@@ -82,7 +79,6 @@
 # CHECK: dyld
 # CHECK: {{.*}}
 # CHECK: arm64e
-# CHECK: <{{.*}}
 # CHECK: cfa789d10da63f9a8996daf84ed9d04f
 # CHECK: /usr/lib/dyld
 ]
@@ -101,9 +97,6 @@
 "2   MyApp Pro arm64	0x00019b0db3a8 foo + 72",
 # CHECK: 2
 # CHECK: MyApp Pro
-# CHECK: a
-# CHECK: arm64
-# CHECK: a
 # CHECK: 0x00019b0db3a8
 # CHECK: foo + 72
 "3   He 0x1	0x00019b0db3a8 foo + 72"
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -603,26 +603,26 @@
 
 
 class TextCrashLogParser(CrashLogParser):
-parent_process_regex = re.compile('^Parent Process:\s*(.*)\[(\d+)\]')
-thread_state_regex = re.compile('^Thread ([0-9]+) crashed with')
-thread_instrs_regex = re.compile('^Thread ([0-9]+) instruction stream')
-thread_regex = re.compile('^Thread ([0-9]+)([^:]*):(.*)')
-app_backtrace_regex = re.compile('^Application Specific Backtrace ([0-9]+)([^:]*):(.*)')
-version = r'(\(.+\)|(arm|x86_)[0-9a-z]+)\s+'
-frame_regex = re.compile(r'^([0-9]+)' r'\s+'# id
- r'(.+?)' r'\s+'# img_name
- r'(' +version+ r')?'   # img_version
- r'(0x[0-9a-fA-F]{7,})' # addr (7 chars or more)
- r' +(.*)'  # offs
+parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
+thread_state_regex = re.compile(r'^Thread \d+ crashed with')
+thread_instrs_regex = re.compile(r'^Thread \d+ instruction stream')
+thread_regex = re.compile(r'^Thread (\d+).*:')
+app_backtrace_regex = re.compile(r'^Application Specific Backtrace (\d+).*:')
+version = r'\(.+\)|(?:arm|x86_)[0-9a-z]+'
+frame_regex = re.compile(r'^(\d+)\s+'  # id
+ r'(.+?)\s+'   # img_name
+ r'(?:' +version+ r'\s+)?' # img_version
+ r'(0x[0-9a-fA-F]{7,})'# addr (7 chars or more)
+ r' +(.*)' # offs
 )
-null_frame_regex = re.compile(r'^([0-9]+)\s+\?\?\?\s+(0{7}0+) +(.*)')
-image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'# img_lo
-  r'\s+' '-' r'\s+'  #   -
-  r'(0x[0-9a-fA-F]+)' r'\s+' # img_hi
-  r'[+]?(.+?)'r'\s+' # img_name
-  r'(' +version+ ')?'# img_version
-  r'(<([-0-9a-fA-F]+)>\s+)?' # img_uuid
-  r'(/.*)'   # img_path
+null_frame_regex = re.compile(r'^\d+\s+\?\?\?\s+0{7,} +')
+image_regex_uuid = re.compile(r'(0x[0-9a-fA-F]+)'  # img_lo
+  r'\s+-\s+'   #   -
+  r'(0x[0-9a-fA-F]+)\s+'   # img_hi
+  r'[+]?(.+?)\s+'  # img_name
+  r'(?:(' +version+ r')\s+)?'  # img_version
+  r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
+  r'(/.*)' # img_path
  )
 
 def __init__(self, debugger, path, verbose):
@@ -768,8 +768,8 @@
 return
 frame_match = self.frame_regex.search(line)
 if frame_match:
-(frame_id, frame_img_name, _, frame_img_version, _,
-   

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added inline comments.



Comment at: lldb/examples/python/crashlog.py:708-709
+if exception_extra_match:
+if not self.crashlog.exception['type']:
+return
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)

kastiglione wrote:
> is this meaning to check that the key `'type'` exists, and that it is 
> false-y? Or, should it be checking whether the key `'type'` is in the 
> dictionary (`if key is not in dict`)
> 
> also, this check could be hoisted out, and avoid performing the regex search 
> if the result isn't going to be used. As it is now, the regex search happens, 
> and the result is ignored if this condition is met.
+1 


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [PATCH] D131304: [lldb] Remove uses of six module (NFC)

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione updated this revision to Diff 452007.
kastiglione added a comment.

Restore LLDB_USE_SYSTEM_SIX


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131304

Files:
  lldb/bindings/interface/SBData.i
  lldb/bindings/python/python.swig
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/examples/summaries/synth.py
  lldb/packages/Python/lldbsuite/support/encoded_file.py
  lldb/packages/Python/lldbsuite/support/seven.py
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  lldb/packages/Python/lldbsuite/test/lldbplatform.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/API/api/listeners/TestListener.py
  lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
  lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
  lldb/test/API/commands/process/launch/TestProcessLaunch.py
  lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
  lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
  lldb/test/API/python_api/frame/TestFrames.py
  lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
  lldb/test/API/test_utils/base/TestBaseTest.py
  lldb/third_party/Python/module/progress/progress.py
  lldb/third_party/Python/module/unittest2/unittest2/case.py
  lldb/third_party/Python/module/unittest2/unittest2/main.py
  lldb/third_party/Python/module/unittest2/unittest2/result.py
  lldb/third_party/Python/module/unittest2/unittest2/suite.py
  lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
  
lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py

Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
@@ -1,5 +1,4 @@
 import unittest2
-import six
 
 from unittest2.test.support import LoggingResult
 
@@ -125,7 +124,7 @@
 def test_id(self):
 test = unittest2.FunctionTestCase(lambda: None)
 
-self.assertIsInstance(test.id(), six.string_types)
+self.assertIsInstance(test.id(), str)
 
 # "Returns a one-line description of the test, or None if no description
 # has been provided. The default implementation of this method returns
Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
@@ -1,7 +1,6 @@
 import difflib
 import pprint
 import re
-import six
 
 from copy import deepcopy
 
@@ -543,7 +542,7 @@
 def runTest(self):
 pass
 
-self.assertIsInstance(Foo().id(), six.string_types)
+self.assertIsInstance(Foo().id(), str)
 
 # "If result is omitted or None, a temporary result object is created
 # and used, but is not made available to the caller. As TestCase owns the
Index: lldb/third_party/Python/module/unittest2/unittest2/suite.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/suite.py
+++ lldb/third_party/Python/module/unittest2/unittest2/suite.py
@@ -3,7 +3,6 @@
 import sys
 import unittest
 from unittest2 import case, util
-import six
 
 __unittest = True
 
@@ -50,7 +49,7 @@
 self._tests.append(test)
 
 def addTests(self, tests):
-if isinstance(tests, six.string_types):
+if isinstance(tests, str):
 raise TypeError("tests must be an iterable of tests, not a string")
 for test in tests:
 self.addTest(test)
Index: lldb/third_party/Python/module/unittest2/unittest2/result.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/result.py
+++ lldb/third_party/Python/module/unittest2/unittest2/result.py
@@ -2,12 +2,11 @@
 
 import use_lldb_suite
 
+import io
 import sys
 import traceback
 import unittest
 
-from six import StringIO as SixStringIO
-
 from unittest2 import u

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 452016.
mib added a comment.

Address @kastiglione comments


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

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = None
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(\s+\((.*)\))?')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -670,6 +674,37 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+exc_type, _, exc_signal = exception_type_match.groups()
+self.crashlog.exception = { 'type': exc_type }
+if exc_signal:
+self.crashlog.exception['signal'] = exc_signal
+elif line.startswith('Exception Subtype:'):
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if self.crashlog.exception['type']:
+self.crashlog.exception['subtype']: 
self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+if not (self.crashlog.exception and 
hasattr(self.crashlog.exception, 'type')):
+return
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+code, subcode = exception_codes_match.groups()
+self.crashlog.exception['rawCodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+else:
+if not (self.crashlog.exception and 
hasattr(self.crashlog.exception, 'type')):
+return
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +728,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
 self.crashlog.parent_process_id = parent_process_match.group(2)
-elif line.startswith('Exception Type:'):
-self.crashlog.thread_exception = line[15:].strip()
-return
-elif line.startswith('Exception Codes:'):
-self.crashlog.thread_exception_data = line[16:].strip()
-return
-elif line.startswith('Exception Subtype:'): # iOS
-self.crashlog.thread_exception_data = line[18:].strip()
+elif line.startswith('Exception'):
+self.parse_exception(line)
 return
 elif line.startswith('Crashed Thread:'):
 self.crashlog.crashed_thread_idx = 
int(line[15:].strip().split()[0])


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  

[Lldb-commits] [PATCH] D113155: [lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)

2022-08-11 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:561
+  default:
+LLVM_FALLTHROUGH;
+  case ArchSpec::eCore_arm_arm64: {

fixathon wrote:
> JDevlieghere wrote:
> > fixathon wrote:
> > > This will default to the ArchSpec::eCore_arm_arm64 case if no matching 
> > > ArchSpec is specified. Double-checking if this by intent.
> > I'm sure it was intentional when I wrote it, but I can't figure out for 
> > which core this would actually make sense. If the test suite passes with 
> > returning an empty array here, that works for me. 
> When this is fixed, one test is failing, and I think that might be a problem 
> with the test itself: test_ios in 
> test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py  running on 
> MacOS. 
> 
>   File 
> "lvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
>  line 48, in test_ios
> self.platform_test(host="ios",
>   File 
> "llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
>  line 44, in platform_test
> self.assertEqual(platform.GetName(), expected_platform)
> AssertionError: 'host' != 'remote-ios'
> - host+ remote-ios
Looks like it might be a problem with the test indeed. The "def 
qHostInfo(self):" from line 21 is returning a CPU type for the host of 
"cputype:16777223". This is 0x0107 which is "x86_64" as the 'qHostInfo' 
packet uses a decimal encoding. Later when asked about the process with "def 
qProcessInfo(self):" it returns "cputype:10c" which is hex encoded with no 
"0x" prefix and it means "arm64".

Not sure if this test is trying to test a remote ios debugging scenario from a 
desktop machine debugging to a ios device, but if this is the case, both 
qHostInfo and qProcessInfo should be agreeing on the architecture and using the 
same thing, which would be "arm64"? These are packets that are usually going to 
the "debugserver", which is run on a phone. So my guess would be to try and set 
qHostInfo to have "cputype:16777228" (which is decimal for 0x010c) and see 
if that works.

Jonas, does this make sense?





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113155

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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added inline comments.



Comment at: lldb/examples/python/crashlog.py:343
 self.errors = list()
+self.exception = None
 self.crashed_thread_idx = -1

should this be initialized to `{}`?



Comment at: lldb/examples/python/crashlog.py:684
+if exception_type_match:
+exc_type, _, exc_signal = exception_type_match.groups()
+self.crashlog.exception = { 'type': exc_type }

if you would like to avoid the ignored group (`_`) then you can use 
non-capturing grouping `(?:...)` in the regex:

before:
```
r'^Exception Type:\s+(EXC_[A-Z_]+)(\s+\((.*)\))?'
```

after:
```
r'^Exception Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?'
```


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [lldb] ce075df - [lldb] Fix output for unconditionally decorated tests

2022-08-11 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2022-08-11T16:20:15-07:00
New Revision: ce075dfa190454f6f85920ad4ffe6928980868af

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

LOG: [lldb] Fix output for unconditionally decorated tests

A missing call to `format` resulted in curly braces getting printed in
the reason a test was modified by a decorator. For example it would
print "{} unconditionally" instead of "skipping unconditionally" for
tests that were marked as such.

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 6d6591c3a9f20..477f4a7209820 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -248,7 +248,7 @@ def fn(self):
 reason_str = "{} due to the following parameter(s): {}".format(
 mode_str, reason_str)
 else:
-reason_str = "{} unconditionally"
+reason_str = "{} unconditionally".format(mode_str)
 if bugnumber is not None and not six.callable(bugnumber):
 reason_str = reason_str + " [" + str(bugnumber) + "]"
 return reason_str



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


[Lldb-commits] [PATCH] D130796: [LLDB][NativePDB] Switch to use DWARFLocationList.

2022-08-11 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu updated this revision to Diff 452031.
zequanwu added a comment.

- Add missing test case for simple type because subfield_register_simple_type.s 
is deleted, forgot to add it before.
- Address rnk's comment by only accepting subfield locations that are on 
register, because we don't have the size information if the subfield is in 
memory. Previous algorithm was not correct, removed in the update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130796

Files:
  lldb/include/lldb/Utility/RangeMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/CodeViewRegisterMapping.h
  lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.h
  lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/test/Shell/SymbolFile/NativePDB/Inputs/local-variables-registers.lldbinit
  lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
  lldb/test/Shell/SymbolFile/NativePDB/local-variables-registers.s
  lldb/test/Shell/SymbolFile/NativePDB/subfield_register_simple_type.s

Index: lldb/test/Shell/SymbolFile/NativePDB/subfield_register_simple_type.s
===
--- lldb/test/Shell/SymbolFile/NativePDB/subfield_register_simple_type.s
+++ /dev/null
@@ -1,433 +0,0 @@
-# clang-format off
-# REQUIRES: lld, x86
-
-# RUN: %clang_cl --target=i386-windows-msvc -c /Fo%t.obj -- %s
-# RUN: lld-link /debug:full /nodefaultlib /entry:main %t.obj /out:%t.exe /base:0x40
-# RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
-# RUN: %p/Inputs/subfield_register_simple_type.lldbinit 2>&1 | FileCheck %s
-
-# This file is compiled from following source file:
-# clang-cl --target=i386-windows-msvc /Z7 /O1 -c /Fa a.cpp
-# __int64 __attribute__((optnone)) bar(__int64 x) { return x; };
-# __int64 foo(__int64 x) {
-#   return bar(x);
-# }
-#
-# int main(int argc, char** argv) {
-#   foo(argc);
-#   return 0;
-# }
-
-# FIXME: The following variable location have wrong register numbers due to
-# https://github.com/llvm/llvm-project/issues/53575. Fix them after resolving
-# the issue.
-
-# CHECK:  (lldb) image lookup -a 0x40102f -v
-# CHECK:  LineEntry: [0x00401026-0x00401039): C:\src\a.cpp:3
-# CHECK-NEXT: Variable: id = {{.*}}, name = "x", type = "int64_t", valid ranges = [0x0040102f-0x00401036), location = DW_OP_reg0 EAX, DW_OP_piece 0x4, DW_OP_reg2 EDX, DW_OP_piece 0x4, decl =
-
-	.text
-	.def	@feat.00;
-	.scl	3;
-	.type	0;
-	.endef
-	.globl	@feat.00
-.set @feat.00, 1
-	.intel_syntax noprefix
-	.file	"a.cpp"
-	.def	"?bar@@YA_J_J@Z";
-	.scl	2;
-	.type	32;
-	.endef
-	.section	.text,"xr",one_only,"?bar@@YA_J_J@Z"
-	.globl	"?bar@@YA_J_J@Z"# -- Begin function ?bar@@YA_J_J@Z
-	.p2align	4, 0x90
-"?bar@@YA_J_J@Z":   # @"?bar@@YA_J_J@Z"
-Lfunc_begin0:
-	.cv_func_id 0
-	.cv_file	1 "C:\\src\\a.cpp" "CB99424BC3DD1AB059A2DBC6841147F2" 1
-	.cv_loc	0 1 1 0 # a.cpp:1:0
-	.cv_fpo_proc	"?bar@@YA_J_J@Z" 8
-# %bb.0:# %entry
-	push	ebp
-	.cv_fpo_pushreg	ebp
-	mov	ebp, esp
-	.cv_fpo_setframe	ebp
-	and	esp, -8
-	.cv_fpo_stackalign	8
-	sub	esp, 8
-	.cv_fpo_stackalloc	8
-	.cv_fpo_endprologue
-	mov	eax, dword ptr [ebp + 8]
-	mov	ecx, dword ptr [ebp + 12]
-	mov	dword ptr [esp], eax
-	mov	dword ptr [esp + 4], ecx
-Ltmp0:
-	mov	eax, dword ptr [esp]
-	mov	edx, dword ptr [esp + 4]
-	mov	esp, ebp
-	pop	ebp
-	ret
-Ltmp1:
-	.cv_fpo_endproc
-Lfunc_end0:
-# -- End function
-	.def	"?foo@@YA_J_J@Z";
-	.scl	2;
-	.type	32;
-	.endef
-	.section	.text,"xr",one_only,"?foo@@YA_J_J@Z"
-	.globl	"?foo@@YA_J_J@Z"# -- Begin function ?foo@@YA_J_J@Z
-"?foo@@YA_J_J@Z":   # @"?foo@@YA_J_J@Z"
-Lfunc_begin1:
-	.cv_func_id 1
-	.cv_fpo_proc	"?foo@@YA_J_J@Z" 8
-# %bb.0:# %entry
-	#DEBUG_VALUE: foo:x <- [DW_OP_plus_uconst 4] [$esp+0]
-	.cv_loc	1 1 3 0 # a.cpp:3:0
-	jmp	"?bar@@YA_J_J@Z"# TAILCALL
-Ltmp2:
-	.cv_fpo_endproc
-Lfunc_end1:
-# -- End function
-	.def	_main;
-	.scl	2;
-	.type	32;
-	.endef
-	.section	.text,"xr",one_only,_main
-	.globl	_main   # -- Begin function main
-_main:  # @main
-Lfunc_begin2:
-	.cv_func_id 2
-	.cv_loc	2 1 6 0 # a.cpp:6:0
-	.cv_fpo_proc	_main 8
-# %bb.0:# %entry
-	#DEBUG_VALUE: main:argv <- [DW_OP_plus_uconst 8] [$esp+0]
-	#DEBUG_VALUE: main:argc <- [DW_OP_plus_uconst 4] [$esp+0]
-	.cv_inline_site_id 3 within 2 inlined_at 1 7 0
-	.cv_loc	3 1 3 0   

[Lldb-commits] [PATCH] D130796: [LLDB][NativePDB] Switch to use DWARFLocationList.

2022-08-11 Thread Zequan Wu via Phabricator via lldb-commits
zequanwu marked an inline comment as done.
zequanwu added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/NativePDB/PdbUtil.cpp:843-846
+std::map offset_to_size;
+// Get the size of each fields if it's udt.
+if (!FindMembersSize::GetMemberSizesForUdt(result.type, index.tpi(), 0,
+   offset_to_size))

zequanwu wrote:
> rnk wrote:
> > I'm a bit worried about performance. This code runs for every `S_LOCAL` 
> > record. So, every time we encounter a `std::string` local variable, we walk 
> > over the entire string class hierarchy field list to compute this map, 
> > which we may or may not need later.
> > 
> > This code is pretty thorough, but can we reduce the scope of this patch by 
> > ignoring subfield records stored in memory, since they lack size 
> > information? I think that would make it easier to review and test. Just 
> > focus on variables in registers, and subfields in registers, since those 
> > are easiest to test and understand.
> `std::__1::basic_string,std::__1::allocator
>  >` (aka `std::string`) has a very shallow class hierarchy, only 1 parent 
> ,`std::__1::__basic_string_common<1>`, which is the top in class hierarchy.
> I agree that it's doing duplicate work by revisiting the parent class 
> multiple times, but keeping the extra info could consume more memory, doesn't 
> seems worth it. I think it shouldn't be much a performance problem most time.
> 
> > but can we reduce the scope of this patch by ignoring subfield records 
> > stored in memory, since they lack size information?
> Yes, we could, but it's more tedious. 
> `llvm/include/llvm/DebugInfo/CodeView/CodeViewRegisters.def` has all the 
> register names, then we need to map each register name to its the 
> corresponding byte size.
I updated to only accept subfield locations that are on register. I didn't 
realize it's that complicated until I tried to add a test case for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130796

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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 452032.
mib marked 2 inline comments as done.
mib added a comment.

- Make `CrashLog.exception` a dictionary at initialization
- Update exception_type regex to use a non-capture group


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

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = dict()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -670,6 +674,37 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+exc_type, exc_signal = exception_type_match.groups()
+self.crashlog.exception['type'] = exc_type
+if exc_signal:
+self.crashlog.exception['signal'] = exc_signal
+elif line.startswith('Exception Subtype:'):
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if self.crashlog.exception['type']:
+self.crashlog.exception['subtype']: 
self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+if 'type' not in self.crashlog.exception:
+return
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+code, subcode = exception_codes_match.groups()
+self.crashlog.exception['rawCodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+else:
+if 'type' not in self.crashlog.exception:
+return
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +728,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
 self.crashlog.parent_process_id = parent_process_match.group(2)
-elif line.startswith('Exception Type:'):
-self.crashlog.thread_exception = line[15:].strip()
-return
-elif line.startswith('Exception Codes:'):
-self.crashlog.thread_exception_data = line[16:].strip()
-return
-elif line.startswith('Exception Subtype:'): # iOS
-self.crashlog.thread_exception_data = line[18:].strip()
+elif line.startswith('Exception'):
+self.parse_exception(line)
 return
 elif line.startswith('Crashed Thread:'):
 self.crashlog.crashed_thread_idx = 
int(line[15:].strip().split()[0])


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specif

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.
This revision is now accepted and ready to land.

one typo to fix, but otherwise looks good




Comment at: lldb/examples/python/crashlog.py:690-691
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if self.crashlog.exception['type']:
+self.crashlog.exception['subtype']: 
self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):

should this also be `if 'type' in self.crashlog.exception`?

typo, should be ` = ` instead of `: `


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

https://reviews.llvm.org/D131719

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


[Lldb-commits] [PATCH] D113155: [lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked an inline comment as done.
JDevlieghere added inline comments.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:561
+  default:
+LLVM_FALLTHROUGH;
+  case ArchSpec::eCore_arm_arm64: {

clayborg wrote:
> fixathon wrote:
> > JDevlieghere wrote:
> > > fixathon wrote:
> > > > This will default to the ArchSpec::eCore_arm_arm64 case if no matching 
> > > > ArchSpec is specified. Double-checking if this by intent.
> > > I'm sure it was intentional when I wrote it, but I can't figure out for 
> > > which core this would actually make sense. If the test suite passes with 
> > > returning an empty array here, that works for me. 
> > When this is fixed, one test is failing, and I think that might be a 
> > problem with the test itself: test_ios in 
> > test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py  running 
> > on MacOS. 
> > 
> >   File 
> > "lvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
> >  line 48, in test_ios
> > self.platform_test(host="ios",
> >   File 
> > "llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
> >  line 44, in platform_test
> > self.assertEqual(platform.GetName(), expected_platform)
> > AssertionError: 'host' != 'remote-ios'
> > - host+ remote-ios
> Looks like it might be a problem with the test indeed. The "def 
> qHostInfo(self):" from line 21 is returning a CPU type for the host of 
> "cputype:16777223". This is 0x0107 which is "x86_64" as the 'qHostInfo' 
> packet uses a decimal encoding. Later when asked about the process with "def 
> qProcessInfo(self):" it returns "cputype:10c" which is hex encoded with 
> no "0x" prefix and it means "arm64".
> 
> Not sure if this test is trying to test a remote ios debugging scenario from 
> a desktop machine debugging to a ios device, but if this is the case, both 
> qHostInfo and qProcessInfo should be agreeing on the architecture and using 
> the same thing, which would be "arm64"? These are packets that are usually 
> going to the "debugserver", which is run on a phone. So my guess would be to 
> try and set qHostInfo to have "cputype:16777228" (which is decimal for 
> 0x010c) and see if that works.
> 
> Jonas, does this make sense?
> 
> 
> 
No, this is intentional and pretty much the point of this test. There's more 
details in https://reviews.llvm.org/D121444 but the TL;DR is that this is 
testing running iPhone and iPad Apps on Apple Silicon Macs. That also explains 
the default then, which I was pretty sure I added for a reason :-) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113155

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


[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: davide, jasonmolenda.
Herald added subscribers: pengfei, kristof.beyls.
Herald added a project: All.
JDevlieghere requested review of this revision.

Starting with Xcode 14, ld64 is using authenticated fixups for x86_64 as well 
as arm64 (where that has always been the case). This results in 4 test failures 
when switching to an Xcode 14 toolchain:

  Failed Tests (4):
lldb-api :: commands/target/basic/TestTargetCommand.py
lldb-api :: functionalities/return-value/TestReturnValue.py
lldb-api :: lang/c/global_variables/TestGlobalVariables.py
lldb-api :: lang/cpp/char8_t/TestCxxChar8_t.py

This tests marks them as XFAIL based on the ld64 version.


https://reviews.llvm.org/D131741

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py

Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -14,6 +14,7 @@
 
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
 @expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@expectedFailureDarwin(archs=['x86_64'], ld64_version=['>=', '800'])
 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -20,6 +20,7 @@
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
 @expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@expectedFailureDarwin(archs=['x86_64'], ld64_version=['>=', '800'])
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -43,6 +43,7 @@
 self.do_target_command()
 
 @expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@expectedFailureDarwin(archs=['x86_64'], ld64_version=['>=', '800'])
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -108,6 +108,14 @@
 return True
 
 
+def getLd64Version():
+output = subprocess.check_output(['xcrun', 'ld', '-v'], stderr=subprocess.STDOUT).decode("utf-8")
+m = re.search('PROJECT:ld64-([\d.]+)', output)
+if m:
+return m.group(1)
+return None
+
+
 def expectedFailure(func):
 return unittest2.expectedFailure(func)
 
@@ -167,7 +175,6 @@
 else:
 return skipTestIfFn_impl
 
-
 def _decorateTest(mode,
   bugnumber=None, oslist=None, hostoslist=None,
   compiler=None, compiler_version=None,
@@ -175,6 +182,7 @@
   debug_info=None,
   swig_version=None, py_version=None,
   macos_version=None,
+  ld64_version=None,
   remote=None, dwarf_version=None,
   setting=None):
 def fn(self):
@@ -211,6 +219,11 @@
 macos_version[0],
 macos_version[1],
 platform.mac_ver()[0])))
+skip_for_ld64_version = (ld64_version is None) or (
+(_check_expected_version(
+ld64_version[0],
+ld64_version[1],
+getLd64Version(
 skip_for_dwarf_version = (dwarf_version is None) or (
 _check_expected_version(dwarf_version[0], dwarf_version[1],
 self.getDwarfVersion()))
@@ -229,6 +242,7 @@
   (swig_version, skip_for_swig_version, "swig version"),
   (py_version, skip_for_py_version, "python version"),
   (macos_version, skip_for_macos_version, "macOS version"),
+  (ld64_version, skip_for_ld64_version, "ld64 version"),
   (remote, skip_for_remote, "platform locality (remote/local)"),
   (dwarf_version, skip_for_dwarf_version, "dwarf version"),
  

[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

With this patch applied the test suite should be clean on an Intel mac running 
macOS Ventura beta + Xcode 14 beta.


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

https://reviews.llvm.org/D131741

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


[Lldb-commits] [PATCH] D131086: [lldb/crashlog] Improve exception reporting for interactive mode

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 452040.
mib marked an inline comment as done.
mib added a comment.

Reflect changes from D131719 


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

https://reviews.llvm.org/D131086

Files:
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
  lldb/source/Plugins/Process/Utility/StopInfoMachException.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -10,11 +10,11 @@
 
 process status
 # CHECK: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 thread backtrace
-# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
@@ -10,11 +10,11 @@
 
 # CHECK: (lldb) process status
 # CHECK-NEXT: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 # CHECK: (lldb) thread backtrace
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK-NEXT: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 # CHECK: (lldb) bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:  * f

[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 452042.
mib marked an inline comment as done.
mib added a comment.

Fixing typo


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

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = dict()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -670,6 +674,37 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+exc_type, exc_signal = exception_type_match.groups()
+self.crashlog.exception['type'] = exc_type
+if exc_signal:
+self.crashlog.exception['signal'] = exc_signal
+elif line.startswith('Exception Subtype:'):
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if 'type' in self.crashlog.exception:
+self.crashlog.exception['subtype'] = 
self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+if 'type' not in self.crashlog.exception:
+return
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+code, subcode = exception_codes_match.groups()
+self.crashlog.exception['rawCodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+else:
+if 'type' not in self.crashlog.exception:
+return
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+self.crashlog.exception['message'] = 
exception_extra_match.group(1)
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +728,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(1)
 self.crashlog.parent_process_id = parent_process_match.group(2)
-elif line.startswith('Exception Type:'):
-self.crashlog.thread_exception = line[15:].strip()
-return
-elif line.startswith('Exception Codes:'):
-self.crashlog.thread_exception_data = line[16:].strip()
-return
-elif line.startswith('Exception Subtype:'): # iOS
-self.crashlog.thread_exception_data = line[18:].strip()
+elif line.startswith('Exception'):
+self.parse_exception(line)
 return
 elif line.startswith('Crashed Thread:'):
 self.crashlog.crashed_thread_idx = 
int(line[15:].strip().split()[0])


Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing all stack

[Lldb-commits] [PATCH] D131086: [lldb/crashlog] Improve exception reporting for interactive mode

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM assuming this compiles on non-apple hosts




Comment at: 
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:525-542
+  case EXC_BAD_ACCESS:
+return "EXC_BAD_ACCESS";
+  case EXC_BAD_INSTRUCTION:
+return "EXC_BAD_INSTRUCTION";
+  case EXC_ARITHMETIC:
+return "EXC_ARITHMETIC";
+  case EXC_EMULATION:

mib wrote:
> JDevlieghere wrote:
> > Just double checking: I assume these are always defined, even when 
> > `mach/exception.h` is not included?
> no, I'm getting the following error if I don't include `mach/exception.h `
> 
> ```
> llvm.org/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp:525:8: 
> error: use of undeclared identifier 'EXC_BAD_ACCESS'
>   case EXC_BAD_ACCESS:
>^
> ```
So doesn't that mean this won't compile on a non-apple platform? Is this whole 
block __APPLE__ only? 


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

https://reviews.llvm.org/D131086

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


[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda added a comment.

I don't know if I support bothering with checking ld's version, I think these 
tests should be skipped on Darwin.

Before macOS 12, if you built these tests arm64e, the address for something 
like `my_global_str` in lldb/test/API/commands/target/basic/globals.c would be 
the file address and an extra high bit set, a flag to dyld at runtime.  As of 
macOS 12 and newer, on arm64 and arm64e, chained fixups are being used and now 
my_global_str as a file offset (not a file address) and a high bit to indicate 
the linker needs to fix it.

On Intel, if you use Xcode 13's ld64 and have a deployment target of macOS 13 
(macOS Ventura, the one in beta right now), you'll also get chained fixups.  
Old linker, newer deployment target, and the tests can fail.  Using the Xcode 
13 ld64 on a macOS 13 system would probably get you chained fixups by default.

We already skip these tests for arm64 & arm64e because of the chained fixups 
and arm64e fixups before that -- and now we're going to skip them on x86_64 if 
the deployment target is new enough (that's the right way to do it, not the 
linker version) -- I say we skip them on Darwin outright.  Pre-execution, we 
can't reliably view global variables, unless we talk with the ld64/dyld folks 
and see if we can reliably get the file offset out of these fields and work out 
the file address ourselves.


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

https://reviews.llvm.org/D131741

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


[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 452045.
JDevlieghere added a comment.

Check the darwin OS version as a proxy for the deployment target


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

https://reviews.llvm.org/D131741

Files:
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,10 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,10 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,9 @@
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +53,9 @@
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,10 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,10 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+# Chained Fixups
+@expectedFailureDarwin(archs=["arm64", "arm64e"])
+@expectedFailureDarwin(archs=['x86_64'], macos_version=[">=", "13.0"])
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,9 @@
 self.buildAll()
 

[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D131741#3717974 , @jasonmolenda 
wrote:

> We already skip these tests for arm64 & arm64e because of the chained fixups 
> and arm64e fixups before that -- and now we're going to skip them on x86_64 
> if the deployment target is new enough (that's the right way to do it, not 
> the linker version) -- I say we skip them on Darwin outright.  Pre-execution, 
> we can't reliably view global variables, unless we talk with the ld64/dyld 
> folks and see if we can reliably get the file offset out of these fields and 
> work out the file address ourselves.

They're XFAILed rather than skipped on Apple Silicon. We can't XFAIL them 
outright on Intel because the bots are running an older OS/Xcode, but you're 
totally right that we could skip them. I'd still like to get this working 
(although I'm not that motivated) once the linker folks finish upstreaming 
support for chained fixups in llvm. That + the fact that skipped tests bit rot 
much faster made me stick with XFAIL. WDYT?


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

https://reviews.llvm.org/D131741

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


[Lldb-commits] [lldb] 256ba77 - [LLDB][NFC] Fix the style issue in TCPSocket

2022-08-11 Thread Slava Gurevich via lldb-commits

Author: Slava Gurevich
Date: 2022-08-11T18:02:01-07:00
New Revision: 256ba7738ea8a07372a82cadd29e9c08fdf9145c

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

LOG: [LLDB][NFC] Fix the style issue in TCPSocket

Style fixes for the entire file

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

Added: 


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

Removed: 




diff  --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index f424b42db7b64..91465d2fe4976 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -167,14 +167,14 @@ Status TCPSocket::Connect(llvm::StringRef name) {
 
 address.SetPort(host_port->port);
 
-if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-  &address.sockaddr(),
-  address.GetLength())) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+&address.sockaddr(),
+address.GetLength()) == -1) {
   Close();
   continue;
 }
 
-if (-1 == SetOptionNoDelay()) {
+if (SetOptionNoDelay() == -1) {
   Close();
   continue;
 }
@@ -210,8 +210,8 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 int option_value = 1;
 set_socket_option_arg_type option_value_p =
 reinterpret_cast(&option_value);
-if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
-   sizeof(option_value))) {
+if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value)) == -1) {
   CLOSE_SOCKET(fd);
   continue;
 }
@@ -224,10 +224,10 @@ Status TCPSocket::Listen(llvm::StringRef name, int 
backlog) {
 
 int err =
 ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
-if (-1 != err)
+if (err != -1)
   err = ::listen(fd, backlog);
 
-if (-1 == err) {
+if (err == -1) {
   error = GetLastSocketError();
   CLOSE_SOCKET(fd);
   continue;
@@ -294,7 +294,7 @@ Status TCPSocket::Accept(Socket *&conn_socket) {
 
 lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
 if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
-  if (kInvalidSocketValue != sock) {
+  if (sock != kInvalidSocketValue) {
 CLOSE_SOCKET(sock);
 sock = kInvalidSocketValue;
   }



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


[Lldb-commits] [PATCH] D131543: [LLDB][NFC] Fix the style issue in TCPSocket

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG256ba7738ea8: [LLDB][NFC] Fix the style issue in TCPSocket 
(authored by fixathon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131543

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


Index: lldb/source/Host/common/TCPSocket.cpp
===
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -167,14 +167,14 @@
 
 address.SetPort(host_port->port);
 
-if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-  &address.sockaddr(),
-  address.GetLength())) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+&address.sockaddr(),
+address.GetLength()) == -1) {
   Close();
   continue;
 }
 
-if (-1 == SetOptionNoDelay()) {
+if (SetOptionNoDelay() == -1) {
   Close();
   continue;
 }
@@ -210,8 +210,8 @@
 int option_value = 1;
 set_socket_option_arg_type option_value_p =
 reinterpret_cast(&option_value);
-if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
-   sizeof(option_value))) {
+if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value)) == -1) {
   CLOSE_SOCKET(fd);
   continue;
 }
@@ -224,10 +224,10 @@
 
 int err =
 ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
-if (-1 != err)
+if (err != -1)
   err = ::listen(fd, backlog);
 
-if (-1 == err) {
+if (err == -1) {
   error = GetLastSocketError();
   CLOSE_SOCKET(fd);
   continue;
@@ -294,7 +294,7 @@
 
 lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
 if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
-  if (kInvalidSocketValue != sock) {
+  if (sock != kInvalidSocketValue) {
 CLOSE_SOCKET(sock);
 sock = kInvalidSocketValue;
   }


Index: lldb/source/Host/common/TCPSocket.cpp
===
--- lldb/source/Host/common/TCPSocket.cpp
+++ lldb/source/Host/common/TCPSocket.cpp
@@ -167,14 +167,14 @@
 
 address.SetPort(host_port->port);
 
-if (-1 == llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-  &address.sockaddr(),
-  address.GetLength())) {
+if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
+&address.sockaddr(),
+address.GetLength()) == -1) {
   Close();
   continue;
 }
 
-if (-1 == SetOptionNoDelay()) {
+if (SetOptionNoDelay() == -1) {
   Close();
   continue;
 }
@@ -210,8 +210,8 @@
 int option_value = 1;
 set_socket_option_arg_type option_value_p =
 reinterpret_cast(&option_value);
-if (-1 == ::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
-   sizeof(option_value))) {
+if (::setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, option_value_p,
+ sizeof(option_value)) == -1) {
   CLOSE_SOCKET(fd);
   continue;
 }
@@ -224,10 +224,10 @@
 
 int err =
 ::bind(fd, &listen_address.sockaddr(), listen_address.GetLength());
-if (-1 != err)
+if (err != -1)
   err = ::listen(fd, backlog);
 
-if (-1 == err) {
+if (err == -1) {
   error = GetLastSocketError();
   CLOSE_SOCKET(fd);
   continue;
@@ -294,7 +294,7 @@
 
 lldb_private::SocketAddress &AddrIn = m_listen_sockets[listen_sock];
 if (!AddrIn.IsAnyAddr() && AcceptAddr != AddrIn) {
-  if (kInvalidSocketValue != sock) {
+  if (sock != kInvalidSocketValue) {
 CLOSE_SOCKET(sock);
 sock = kInvalidSocketValue;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D113155: [lldb] Remove nested switches from ARMGetSupportedArchitectureAtIndex (NFC)

2022-08-11 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp:561
+  default:
+LLVM_FALLTHROUGH;
+  case ArchSpec::eCore_arm_arm64: {

JDevlieghere wrote:
> clayborg wrote:
> > fixathon wrote:
> > > JDevlieghere wrote:
> > > > fixathon wrote:
> > > > > This will default to the ArchSpec::eCore_arm_arm64 case if no 
> > > > > matching ArchSpec is specified. Double-checking if this by intent.
> > > > I'm sure it was intentional when I wrote it, but I can't figure out for 
> > > > which core this would actually make sense. If the test suite passes 
> > > > with returning an empty array here, that works for me. 
> > > When this is fixed, one test is failing, and I think that might be a 
> > > problem with the test itself: test_ios in 
> > > test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py  running 
> > > on MacOS. 
> > > 
> > >   File 
> > > "lvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
> > >  line 48, in test_ios
> > > self.platform_test(host="ios",
> > >   File 
> > > "llvm-project/lldb/test/API/functionalities/gdb_remote_client/TestPlatformMacOSX.py",
> > >  line 44, in platform_test
> > > self.assertEqual(platform.GetName(), expected_platform)
> > > AssertionError: 'host' != 'remote-ios'
> > > - host+ remote-ios
> > Looks like it might be a problem with the test indeed. The "def 
> > qHostInfo(self):" from line 21 is returning a CPU type for the host of 
> > "cputype:16777223". This is 0x0107 which is "x86_64" as the 'qHostInfo' 
> > packet uses a decimal encoding. Later when asked about the process with 
> > "def qProcessInfo(self):" it returns "cputype:10c" which is hex encoded 
> > with no "0x" prefix and it means "arm64".
> > 
> > Not sure if this test is trying to test a remote ios debugging scenario 
> > from a desktop machine debugging to a ios device, but if this is the case, 
> > both qHostInfo and qProcessInfo should be agreeing on the architecture and 
> > using the same thing, which would be "arm64"? These are packets that are 
> > usually going to the "debugserver", which is run on a phone. So my guess 
> > would be to try and set qHostInfo to have "cputype:16777228" (which is 
> > decimal for 0x010c) and see if that works.
> > 
> > Jonas, does this make sense?
> > 
> > 
> > 
> No, this is intentional and pretty much the point of this test. There's more 
> details in https://reviews.llvm.org/D121444 but the TL;DR is that this is 
> testing running iPhone and iPad Apps on Apple Silicon Macs. That also 
> explains the default then, which I was pretty sure I added for a reason :-) 
Gotcha, looks like Slava need to debug this and  see why we are getting a 
invalid core type passed to the GetCompatibleArchs() function in the first 
place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113155

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


[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon marked 3 inline comments as done.
fixathon added a comment.

Addressed the comments. Will deal with the signed/unsigned issue in a separate 
diff if still needed.




Comment at: lldb/source/Core/IOHandlerCursesGUI.cpp:2582
 surface.MoveCursor(0, 1);
 surface.HorizontalLine(surface.GetWidth());
   }

clayborg wrote:
> fixathon wrote:
> > Here we have HorizontalLine() function that requires non-negative input
> But surface.HorizontalLine(...) function takes an "int", and now we are 
> passing it a uint32_t. If this function requires a >= 0 value, it should do 
> the check internally
I agree. I've reverted the function signatures back to signed int and will 
revisit the signed/unsigned issue in another diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

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


[Lldb-commits] [PATCH] D131743: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon created this revision.
fixathon added a reviewer: clayborg.
Herald added a project: All.
fixathon requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Add the fixes suggested post-push in D131554 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131743

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


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4114,16 +4114,15 @@
 switch (n_type) {
 case N_INDR: {
   const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-  if (reexport_name_cstr && reexport_name_cstr[0]) {
+  if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
 type = eSymbolTypeReExported;
 ConstString reexport_name(reexport_name_cstr +
   ((reexport_name_cstr[0] == '_') ? 1 : 
0));
 sym[sym_idx].SetReExportedSymbolName(reexport_name);
 set_value = false;
 reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-indirect_symbol_names.insert(ConstString(
-symbol_name +
-((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+indirect_symbol_names.insert(
+ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
   } else
 type = eSymbolTypeUndefined;
 } break;
@@ -6898,10 +6897,9 @@
 }
 uint32_t imgcount = m_data.GetU32(&offset);
 uint64_t entries_fileoff = m_data.GetU64(&offset);
-/* leaving the following dead code as comments for spec documentation
-offset += 4; // uint32_t entries_size;
-offset += 4; // uint32_t unused;
-*/
+// 'entries_size' is not used, nor is the 'unused' entry.
+//  offset += 4; // uint32_t entries_size;
+//  offset += 4; // uint32_t unused;
 
 offset = entries_fileoff;
 for (uint32_t i = 0; i < imgcount; i++) {


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4114,16 +4114,15 @@
 switch (n_type) {
 case N_INDR: {
   const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-  if (reexport_name_cstr && reexport_name_cstr[0]) {
+  if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
 type = eSymbolTypeReExported;
 ConstString reexport_name(reexport_name_cstr +
   ((reexport_name_cstr[0] == '_') ? 1 : 0));
 sym[sym_idx].SetReExportedSymbolName(reexport_name);
 set_value = false;
 reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-indirect_symbol_names.insert(ConstString(
-symbol_name +
-((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+indirect_symbol_names.insert(
+ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
   } else
 type = eSymbolTypeUndefined;
 } break;
@@ -6898,10 +6897,9 @@
 }
 uint32_t imgcount = m_data.GetU32(&offset);
 uint64_t entries_fileoff = m_data.GetU64(&offset);
-/* leaving the following dead code as comments for spec documentation
-offset += 4; // uint32_t entries_size;
-offset += 4; // uint32_t unused;
-*/
+// 'entries_size' is not used, nor is the 'unused' entry.
+//  offset += 4; // uint32_t entries_size;
+//  offset += 4; // uint32_t unused;
 
 offset = entries_fileoff;
 for (uint32_t i = 0; i < imgcount; i++) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D131554: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon marked 3 inline comments as done.
fixathon added a comment.

Replied to comments, and adding the suggested modifications in 
https://reviews.llvm.org/D131743 because this diff has already been pushed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131554

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


[Lldb-commits] [PATCH] D131743: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
fixathon added a comment.
Herald added a subscriber: JDevlieghere.

Implemented most fixes suggested in https://reviews.llvm.org/D131554 post-push.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131743

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


[Lldb-commits] [lldb] 56f9cfe - [lldb] Remove uses of six module (NFC)

2022-08-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-08-11T19:06:15-07:00
New Revision: 56f9cfe30c4488aade888905bb6280ecb952a613

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

LOG: [lldb] Remove uses of six module (NFC)

With lldb (& llvm) requiring Python 3.6+, use of the `six` module can be 
removed.

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

Added: 


Modified: 
lldb/bindings/interface/SBData.i
lldb/bindings/python/python.swig
lldb/examples/python/scripted_process/scripted_process.py
lldb/examples/summaries/synth.py
lldb/packages/Python/lldbsuite/support/encoded_file.py
lldb/packages/Python/lldbsuite/support/seven.py
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/lldbpexpect.py
lldb/packages/Python/lldbsuite/test/lldbplatform.py
lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/test/API/api/listeners/TestListener.py
lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
lldb/test/API/commands/process/launch/TestProcessLaunch.py
lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
lldb/test/API/python_api/frame/TestFrames.py
lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
lldb/test/API/test_utils/base/TestBaseTest.py
lldb/third_party/Python/module/progress/progress.py
lldb/third_party/Python/module/unittest2/unittest2/case.py
lldb/third_party/Python/module/unittest2/unittest2/main.py
lldb/third_party/Python/module/unittest2/unittest2/result.py
lldb/third_party/Python/module/unittest2/unittest2/suite.py
lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py

lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py

Removed: 




diff  --git a/lldb/bindings/interface/SBData.i 
b/lldb/bindings/interface/SBData.i
index 1f2f9fbf05e2d..8e1d2fcf9d3ec 100644
--- a/lldb/bindings/interface/SBData.i
+++ b/lldb/bindings/interface/SBData.i
@@ -157,7 +157,7 @@ public:
 for x in range(*key.indices(self.__len__())):
 list.append(self.__getitem__(x))
 return list
-if not (isinstance(key,six.integer_types)):
+if not (isinstance(key, int)):
 raise TypeError('must be int')
 key = key * self.item_size # SBData uses byte-based indexes, 
but we want to use itemsize-based indexes here
 error = SBError()

diff  --git a/lldb/bindings/python/python.swig 
b/lldb/bindings/python/python.swig
index cb80e1be61a82..b1f6c4b9301da 100644
--- a/lldb/bindings/python/python.swig
+++ b/lldb/bindings/python/python.swig
@@ -84,8 +84,6 @@ void name ## _set(type *t, int index, type val) {
 import uuid
 import re
 import os
-
-import six
 %}
 
 // Include the version of swig that was used to generate this interface.

diff  --git a/lldb/examples/python/scripted_process/scripted_process.py 
b/lldb/examples/python/scripted_process/scripted_process.py
index b9388ae25e466..48966f8385cb0 100644
--- a/lldb/examples/python/scripted_process/scripted_process.py
+++ b/lldb/examples/python/scripted_process/scripted_process.py
@@ -1,10 +1,8 @@
 from abc import ABCMeta, abstractmethod
-import six
 
 import lldb
 
-@six.add_metaclass(ABCMeta)
-class ScriptedProcess:
+class ScriptedProcess(metaclass=ABCMeta):
 
 """
 The base class for a scripted process.
@@ -193,8 +191,7 @@ def get_scripted_thread_plugin(self):
 """
 return None
 
-@six.add_metaclass(ABCMeta)
-class ScriptedThread:
+class ScriptedThread(metaclass=ABCMeta):
 
 """
 The base class for a scripted thread.

diff  --git a/lldb/examples/summaries/synth.py 
b/lldb/examples/summaries/synth.py
index 02dcc4f701467..97e84ea9b09d3 100644
--- a/lldb/examples/summaries/synth.py
+++ b/lldb/examples/summaries/synth.py
@@ -33,8 +33,7 @@ def has_children(self):
 def gen_child(self, name, value):
 data = None
 type = None
-im

[Lldb-commits] [PATCH] D131304: [lldb] Remove uses of six module (NFC)

2022-08-11 Thread Dave Lee 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 rG56f9cfe30c44: [lldb] Remove uses of six module (NFC) 
(authored by kastiglione).

Changed prior to commit:
  https://reviews.llvm.org/D131304?vs=452007&id=452052#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131304

Files:
  lldb/bindings/interface/SBData.i
  lldb/bindings/python/python.swig
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/examples/summaries/synth.py
  lldb/packages/Python/lldbsuite/support/encoded_file.py
  lldb/packages/Python/lldbsuite/support/seven.py
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbpexpect.py
  lldb/packages/Python/lldbsuite/test/lldbplatform.py
  lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/lldbgdbserverutils.py
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/test/API/api/listeners/TestListener.py
  lldb/test/API/commands/command/script/import/thepackage/TPunitA.py
  lldb/test/API/commands/command/script/import/thepackage/TPunitB.py
  lldb/test/API/commands/process/launch/TestProcessLaunch.py
  lldb/test/API/functionalities/gdb_remote_client/TestGdbClientModuleLoad.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py
  lldb/test/API/functionalities/postmortem/minidump/TestMiniDump.py
  lldb/test/API/functionalities/postmortem/wow64_minidump/TestWow64MiniDump.py
  lldb/test/API/python_api/frame/TestFrames.py
  lldb/test/API/terminal/TestSTTYBeforeAndAfter.py
  lldb/test/API/test_utils/base/TestBaseTest.py
  lldb/third_party/Python/module/progress/progress.py
  lldb/third_party/Python/module/unittest2/unittest2/case.py
  lldb/third_party/Python/module/unittest2/unittest2/main.py
  lldb/third_party/Python/module/unittest2/unittest2/result.py
  lldb/third_party/Python/module/unittest2/unittest2/suite.py
  lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
  
lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py

Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_functiontestcase.py
@@ -1,5 +1,4 @@
 import unittest2
-import six
 
 from unittest2.test.support import LoggingResult
 
@@ -125,7 +124,7 @@
 def test_id(self):
 test = unittest2.FunctionTestCase(lambda: None)
 
-self.assertIsInstance(test.id(), six.string_types)
+self.assertIsInstance(test.id(), str)
 
 # "Returns a one-line description of the test, or None if no description
 # has been provided. The default implementation of this method returns
Index: lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
+++ lldb/third_party/Python/module/unittest2/unittest2/test/test_case.py
@@ -1,7 +1,6 @@
 import difflib
 import pprint
 import re
-import six
 
 from copy import deepcopy
 
@@ -543,7 +542,7 @@
 def runTest(self):
 pass
 
-self.assertIsInstance(Foo().id(), six.string_types)
+self.assertIsInstance(Foo().id(), str)
 
 # "If result is omitted or None, a temporary result object is created
 # and used, but is not made available to the caller. As TestCase owns the
Index: lldb/third_party/Python/module/unittest2/unittest2/suite.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/suite.py
+++ lldb/third_party/Python/module/unittest2/unittest2/suite.py
@@ -3,7 +3,6 @@
 import sys
 import unittest
 from unittest2 import case, util
-import six
 
 __unittest = True
 
@@ -50,7 +49,7 @@
 self._tests.append(test)
 
 def addTests(self, tests):
-if isinstance(tests, six.string_types):
+if isinstance(tests, str):
 raise TypeError("tests must be an iterable of tests, not a string")
 for test in tests:
 self.addTest(test)
Index: lldb/third_party/Python/module/unittest2/unittest2/result.py
===
--- lldb/third_party/Python/module/unittest2/unittest2/result.py
+++ lldb/third_party/Python/mod

[Lldb-commits] [lldb] 95367da - [lldb] Remove unused "import unittest2" statements

2022-08-11 Thread Dave Lee via lldb-commits

Author: Dave Lee
Date: 2022-08-11T19:11:01-07:00
New Revision: 95367da43ddd16fc9c4cbe06a1823119f7841f48

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

LOG: [lldb] Remove unused "import unittest2" statements

Added: 


Modified: 
lldb/test/API/commands/expression/ir-interpreter/TestIRInterpreter.py
lldb/test/API/commands/expression/test/TestExprs.py
lldb/test/API/commands/expression/top-level/TestTopLevelExprs.py
lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py

lldb/test/API/commands/watchpoints/variable_out_of_scope/TestWatchedVarHitWhenInScope.py

lldb/test/API/functionalities/breakpoint/breakpoint_in_delayslot/TestAvoidBreakpointInDelaySlot.py

lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
lldb/test/API/functionalities/breakpoint/move_nearest/TestMoveNearest.py

lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py
lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
lldb/test/API/functionalities/pre_run_dylibs/TestPreRunDylibs.py
lldb/test/API/functionalities/thread/backtrace_limit/TestBacktraceLimit.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/TestConcurrentManyBreakpoints.py

lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py

lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentManySignals.py

lldb/test/API/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.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/functionalities/thread/state/TestThreadStates.py
lldb/test/API/lang/c/blocks/TestBlocks.py
lldb/test/API/lang/c/shared_lib/TestSharedLib.py

l

[Lldb-commits] [lldb] b2cb417 - [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)

2022-08-11 Thread Slava Gurevich via lldb-commits

Author: Slava Gurevich
Date: 2022-08-11T21:08:18-07:00
New Revision: b2cb417ed9a69528ddd9abac704ba12ef5b8f932

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

LOG: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)

Add the fixes suggested post-push in D131554

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

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index e4832dad1e476..dbf3afff7b0da 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4114,16 +4114,15 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
 switch (n_type) {
 case N_INDR: {
   const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-  if (reexport_name_cstr && reexport_name_cstr[0]) {
+  if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
 type = eSymbolTypeReExported;
 ConstString reexport_name(reexport_name_cstr +
   ((reexport_name_cstr[0] == '_') ? 1 : 
0));
 sym[sym_idx].SetReExportedSymbolName(reexport_name);
 set_value = false;
 reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-indirect_symbol_names.insert(ConstString(
-symbol_name +
-((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+indirect_symbol_names.insert(
+ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
   } else
 type = eSymbolTypeUndefined;
 } break;
@@ -6898,10 +6897,9 @@ ObjectFileMachO::GetCorefileAllImageInfos() {
 }
 uint32_t imgcount = m_data.GetU32(&offset);
 uint64_t entries_fileoff = m_data.GetU64(&offset);
-/* leaving the following dead code as comments for spec documentation
-offset += 4; // uint32_t entries_size;
-offset += 4; // uint32_t unused;
-*/
+// 'entries_size' is not used, nor is the 'unused' entry.
+//  offset += 4; // uint32_t entries_size;
+//  offset += 4; // uint32_t unused;
 
 offset = entries_fileoff;
 for (uint32_t i = 0; i < imgcount; i++) {



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


[Lldb-commits] [PATCH] D131743: [LLDB][NFC] Reliability fixes for ObjectFileMachO.cpp (part 2)

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb2cb417ed9a6: [LLDB][NFC] Reliability fixes for 
ObjectFileMachO.cpp (part 2) (authored by fixathon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131743

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


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4114,16 +4114,15 @@
 switch (n_type) {
 case N_INDR: {
   const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-  if (reexport_name_cstr && reexport_name_cstr[0]) {
+  if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
 type = eSymbolTypeReExported;
 ConstString reexport_name(reexport_name_cstr +
   ((reexport_name_cstr[0] == '_') ? 1 : 
0));
 sym[sym_idx].SetReExportedSymbolName(reexport_name);
 set_value = false;
 reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-indirect_symbol_names.insert(ConstString(
-symbol_name +
-((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+indirect_symbol_names.insert(
+ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
   } else
 type = eSymbolTypeUndefined;
 } break;
@@ -6898,10 +6897,9 @@
 }
 uint32_t imgcount = m_data.GetU32(&offset);
 uint64_t entries_fileoff = m_data.GetU64(&offset);
-/* leaving the following dead code as comments for spec documentation
-offset += 4; // uint32_t entries_size;
-offset += 4; // uint32_t unused;
-*/
+// 'entries_size' is not used, nor is the 'unused' entry.
+//  offset += 4; // uint32_t entries_size;
+//  offset += 4; // uint32_t unused;
 
 offset = entries_fileoff;
 for (uint32_t i = 0; i < imgcount; i++) {


Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -4114,16 +4114,15 @@
 switch (n_type) {
 case N_INDR: {
   const char *reexport_name_cstr = strtab_data.PeekCStr(nlist.n_value);
-  if (reexport_name_cstr && reexport_name_cstr[0]) {
+  if (reexport_name_cstr && reexport_name_cstr[0] && symbol_name) {
 type = eSymbolTypeReExported;
 ConstString reexport_name(reexport_name_cstr +
   ((reexport_name_cstr[0] == '_') ? 1 : 0));
 sym[sym_idx].SetReExportedSymbolName(reexport_name);
 set_value = false;
 reexport_shlib_needs_fixup[sym_idx] = reexport_name;
-indirect_symbol_names.insert(ConstString(
-symbol_name +
-((symbol_name && (symbol_name[0] == '_')) ? 1 : 0)));
+indirect_symbol_names.insert(
+ConstString(symbol_name + ((symbol_name[0] == '_') ? 1 : 0)));
   } else
 type = eSymbolTypeUndefined;
 } break;
@@ -6898,10 +6897,9 @@
 }
 uint32_t imgcount = m_data.GetU32(&offset);
 uint64_t entries_fileoff = m_data.GetU64(&offset);
-/* leaving the following dead code as comments for spec documentation
-offset += 4; // uint32_t entries_size;
-offset += 4; // uint32_t unused;
-*/
+// 'entries_size' is not used, nor is the 'unused' entry.
+//  offset += 4; // uint32_t entries_size;
+//  offset += 4; // uint32_t unused;
 
 offset = entries_fileoff;
 for (uint32_t i = 0; i < imgcount; i++) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3934a31 - [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via lldb-commits

Author: Slava Gurevich
Date: 2022-08-11T21:10:53-07:00
New Revision: 3934a31cfa024edfaa406c3706dc943e59f9049c

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

LOG: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

- checking retval of function calls
- dead code removal
- null dereference fix

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

Added: 


Modified: 
lldb/source/Core/IOHandlerCursesGUI.cpp

Removed: 




diff  --git a/lldb/source/Core/IOHandlerCursesGUI.cpp 
b/lldb/source/Core/IOHandlerCursesGUI.cpp
index f96073ab698cb..c37c8106224fd 100644
--- a/lldb/source/Core/IOHandlerCursesGUI.cpp
+++ b/lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@ class ProcessLaunchFormDelegate : public FormDelegate {
 
 FileAction action;
 if (m_standard_input_field->IsSpecified()) {
-  action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-  false);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), 
true,
+  false))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_output_field->IsSpecified()) {
-  action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_error_field->IsSpecified()) {
-  action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
   }
 
@@ -6821,7 +6821,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
 bool set_selected_line_to_pc = false;
 
 if (update_location) {
-  const bool process_alive = process ? process->IsAlive() : false;
+  const bool process_alive = process->IsAlive();
   bool thread_changed = false;
   if (process_alive) {
 thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@ class SourceFileWindowDelegate : public WindowDelegate {
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 15,
   line_y);
-window.PrintfTruncated(1, "<<< Thread %u: %s ",
-   thread->GetIndexID(), stop_description);
+if (thread)
+  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+ thread->GetIndexID(),
+ stop_description);
   }
 } else {
   window.Printf("%*s", window_width - window.GetCursorX() - 1, "");



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


[Lldb-commits] [PATCH] D131615: [LLDB][NFC] Reliability fixes for IOHandlerCursesGUI

2022-08-11 Thread Slava Gurevich via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
fixathon marked an inline comment as done.
Closed by commit rG3934a31cfa02: [LLDB][NFC] Reliability fixes for 
IOHandlerCursesGUI (authored by fixathon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131615

Files:
  lldb/source/Core/IOHandlerCursesGUI.cpp


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@
 
 FileAction action;
 if (m_standard_input_field->IsSpecified()) {
-  action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-  false);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), 
true,
+  false))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_output_field->IsSpecified()) {
-  action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_error_field->IsSpecified()) {
-  action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
   }
 
@@ -6821,7 +6821,7 @@
 bool set_selected_line_to_pc = false;
 
 if (update_location) {
-  const bool process_alive = process ? process->IsAlive() : false;
+  const bool process_alive = process->IsAlive();
   bool thread_changed = false;
   if (process_alive) {
 thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 15,
   line_y);
-window.PrintfTruncated(1, "<<< Thread %u: %s ",
-   thread->GetIndexID(), stop_description);
+if (thread)
+  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+ thread->GetIndexID(),
+ stop_description);
   }
 } else {
   window.Printf("%*s", window_width - window.GetCursorX() - 1, "");


Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ lldb/source/Core/IOHandlerCursesGUI.cpp
@@ -3500,19 +3500,19 @@
 
 FileAction action;
 if (m_standard_input_field->IsSpecified()) {
-  action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
-  false);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDIN_FILENO, m_standard_input_field->GetFileSpec(), true,
+  false))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_output_field->IsSpecified()) {
-  action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDOUT_FILENO, m_standard_output_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
 if (m_standard_error_field->IsSpecified()) {
-  action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(), false,
-  true);
-  launch_info.AppendFileAction(action);
+  if (action.Open(STDERR_FILENO, m_standard_error_field->GetFileSpec(),
+  false, true))
+launch_info.AppendFileAction(action);
 }
   }
 
@@ -6821,7 +6821,7 @@
 bool set_selected_line_to_pc = false;
 
 if (update_location) {
-  const bool process_alive = process ? process->IsAlive() : false;
+  const bool process_alive = process->IsAlive();
   bool thread_changed = false;
   if (process_alive) {
 thread = exe_ctx.GetThreadPtr();
@@ -7209,8 +7209,10 @@
   window.Printf("%*s", desc_x - window.GetCursorX(), "");
 window.MoveCursor(window_width - stop_description_len - 15,
   line_y);
-window.PrintfTruncated(1, "<<< Thread %u: %s ",
-   thread->GetIndexID(), stop_description);
+if (thread)
+  window.PrintfTruncated(1, "<<< Thread %u: %s ",
+  

[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D131741#3717992 , @JDevlieghere 
wrote:

> In D131741#3717974 , @jasonmolenda 
> wrote:
>
>> We already skip these tests for arm64 & arm64e because of the chained fixups 
>> and arm64e fixups before that -- and now we're going to skip them on x86_64 
>> if the deployment target is new enough (that's the right way to do it, not 
>> the linker version) -- I say we skip them on Darwin outright.  
>> Pre-execution, we can't reliably view global variables, unless we talk with 
>> the ld64/dyld folks and see if we can reliably get the file offset out of 
>> these fields and work out the file address ourselves.
>
> They're XFAILed rather than skipped on Apple Silicon. We can't XFAIL them 
> outright on Intel because the bots are running an older OS/Xcode, but you're 
> totally right that we could skip them. I'd still like to get this working 
> (although I'm not that motivated) once the linker folks finish upstreaming 
> support for chained fixups in llvm. That + the fact that skipped tests bit 
> rot much faster made me stick with XFAIL. WDYT?

After thinking about it some more, it's a lot easier to skip the test. When 
using Xcode 13.4 on Ventura, you'll still get the old behavior unless you 
explicitly raise the deployment target.


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

https://reviews.llvm.org/D131741

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


[Lldb-commits] [PATCH] D131741: [lldb] XFAIL target variable tests on Intel/Darwin when using Xcode 14

2022-08-11 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 452077.

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

https://reviews.llvm.org/D131741

Files:
  lldb/test/API/commands/target/basic/TestTargetCommand.py
  lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
  lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,8 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+@skipIfDarwin # Chained Fixups
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,8 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+@skipIfDarwin # Chained Fixups
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,7 @@
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +51,7 @@
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 

+@skipIfDarwin # Chained Fixups
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}


Index: lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
===
--- lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -12,8 +12,8 @@
 
 class CxxChar8_tTestCase(TestBase):
 
+@skipIfDarwin # Chained Fixups
 @skipIf(compiler="clang", compiler_version=['<', '7.0'])
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that C++ supports char8_t without a running process."""
 self.build()
Index: lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
===
--- lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -18,8 +18,8 @@
 self.source, '// Set break point at this line.')
 self.shlib_names = ["a"]
 
+@skipIfDarwin # Chained Fixups
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""
Index: lldb/test/API/commands/target/basic/TestTargetCommand.py
===
--- lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -42,7 +42,7 @@
 self.buildAll()
 self.do_target_command()
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@skipIfDarwin # Chained Fixups
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -51,7 +51,7 @@
 
 self.do_target_variable_command('globals')
 
-@expectedFailureDarwin(archs=["arm64", "arm64e"]) # 
+@skipIfDarwin # Chained Fixups
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
___
lldb-commits mailing list
lldb

[Lldb-commits] [PATCH] D131086: [lldb/crashlog] Improve exception reporting for interactive mode

2022-08-11 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 452078.

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

https://reviews.llvm.org/D131086

Files:
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
  lldb/source/Plugins/Process/Utility/StopInfoMachException.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -10,11 +10,11 @@
 
 process status
 # CHECK: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 thread backtrace
-# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
@@ -10,11 +10,11 @@
 
 # CHECK: (lldb) process status
 # CHECK-NEXT: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 # CHECK: (lldb) thread backtrace
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK-NEXT: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 # CHECK: (lldb) bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT:frame #1: 0x000100ec591b multithrea

[Lldb-commits] [lldb] 300e393 - [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-08-11T22:29:06-07:00
New Revision: 300e393092e39c8efc76f807671b11309fb4b98e

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

LOG: [lldb/crashlog] Adapt raw text crashlog exception to json format

This patch parses CrashLog exception data from the raw
text format and adapts it to the new JSON format.

This is necessary for feature parity between the 2 formats.

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index ad0d70a669a8..eb43e07d27f4 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@ def __init__(self, debugger, path, verbose):
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
 self.errors = list()
+self.exception = dict()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@ def parse_process_info(self, json_data):
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@ class CrashLogParseMode:
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@ class TextCrashLogParser(CrashLogParser):
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception 
Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
+exception_codes_regex = re.compile(r'^Exception 
Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -650,9 +654,9 @@ def parse(self):
 if self.parse_mode == CrashLogParseMode.THREAD:
 if self.thread.index == 
self.crashlog.crashed_thread_idx:
 self.thread.reason = ''
-if self.crashlog.thread_exception:
+if hasattr(self.crashlog, 'thread_exception'):
 self.thread.reason += 
self.crashlog.thread_exception
-if self.crashlog.thread_exception_data:
+if hasattr(self.crashlog, 'thread_exception_data'):
 self.thread.reason += " (%s)" % 
self.crashlog.thread_exception_data
 if self.app_specific_backtrace:
 self.crashlog.backtraces.append(self.thread)
@@ -670,6 +674,37 @@ def parse(self):
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+exc_type, exc_signal = exception_type_match.groups()
+self.crashlog.exception['type'] = exc_type
+if exc_signal:
+self.crashlog.exception['signal'] = exc_signal
+elif line.startswith('Exception Subtype:'):
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if 'type' in self.crashlog.exception:
+self.crashlog.exception['subtype'] = 
self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+if 'type' not in self.crashlog.exception:
+return
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+self.crashlog.exception['codes'] = 
self.crashlog.thread_exception_data
+code, subcode = exception_codes_match.groups()
+self.crashlog.exception['rawCodes'] = [int(code, base=16),
+   int(subcode, base=16)]

[Lldb-commits] [lldb] edc7735 - [lldb/crashlog] Improve exception reporting for interactive mode

2022-08-11 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-08-11T22:29:06-07:00
New Revision: edc77353daa707712fc92a31edb5b27ad103ba30

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

LOG: [lldb/crashlog] Improve exception reporting for interactive mode

This patch improve exception reporting when loading a crash report in a
scripted process. Now, we parse the `exception` dictionary from the
crash report use it the create a higher fidelity `MachException` stop info.

This patch also updates the test to reflect that change.

rdar://97096486

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

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
lldb/source/Plugins/Process/Utility/StopInfoMachException.h
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Removed: 




diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
index ffdd43d7c5d8a..e64b9b7822af1 100644
--- a/lldb/examples/python/scripted_process/crashlog_scripted_process.py
+++ b/lldb/examples/python/scripted_process/crashlog_scripted_process.py
@@ -17,6 +17,7 @@ def parse_crashlog(self):
 self.addr_mask = crash_log.addr_mask
 self.crashed_thread_idx = crash_log.crashed_thread_idx
 self.loaded_images = []
+self.exception = crash_log.exception
 
 def load_images(self, images):
 #TODO: Add to self.loaded_images and load images in lldb
@@ -69,6 +70,7 @@ def __init__(self, target: lldb.SBTarget, args : 
lldb.SBStructuredData):
 
 self.pid = super().get_process_id()
 self.crashed_thread_idx = 0
+self.exception = None
 self.parse_crashlog()
 
 def get_memory_region_containing_address(self, addr: int) -> 
lldb.SBMemoryRegionInfo:
@@ -154,9 +156,12 @@ def get_state(self):
 
 def get_stop_reason(self) -> Dict[str, Any]:
 if not self.has_crashed:
-return { "type": lldb.eStopReasonNone, "data": {  }}
+return { "type": lldb.eStopReasonNone }
 # TODO: Investigate what stop reason should be reported when crashed
-return { "type": lldb.eStopReasonException, "data": { "desc": 
"EXC_BAD_ACCESS" }}
+stop_reason = { "type": lldb.eStopReasonException, "data": {  }}
+if self.scripted_process.exception:
+stop_reason['data']['mach_exception'] = 
self.scripted_process.exception
+return stop_reason
 
 def get_register_context(self) -> str:
 if not self.register_ctx:

diff  --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp 
b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index 4623a50537eb6..04614ea3f6625 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -522,6 +522,78 @@ static StopInfoSP GetStopInfoForHardwareBP(Thread &thread, 
Target *target,
   return nullptr;
 }
 
+#if defined(__APPLE__)
+const char *
+StopInfoMachException::MachException::Name(exception_type_t exc_type) {
+  switch (exc_type) {
+  case EXC_BAD_ACCESS:
+return "EXC_BAD_ACCESS";
+  case EXC_BAD_INSTRUCTION:
+return "EXC_BAD_INSTRUCTION";
+  case EXC_ARITHMETIC:
+return "EXC_ARITHMETIC";
+  case EXC_EMULATION:
+return "EXC_EMULATION";
+  case EXC_SOFTWARE:
+return "EXC_SOFTWARE";
+  case EXC_BREAKPOINT:
+return "EXC_BREAKPOINT";
+  case EXC_SYSCALL:
+return "EXC_SYSCALL";
+  case EXC_MACH_SYSCALL:
+return "EXC_MACH_SYSCALL";
+  case EXC_RPC_ALERT:
+return "EXC_RPC_ALERT";
+#ifdef EXC_CRASH
+  case EXC_CRASH:
+return "EXC_CRASH";
+#endif
+  case EXC_RESOURCE:
+return "EXC_RESOURCE";
+#ifdef EXC_GUARD
+  case EXC_GUARD:
+return "EXC_GUARD";
+#endif
+#ifdef EXC_CORPSE_NOTIFY
+  case EXC_CORPSE_NOTIFY:
+return "EXC_CORPSE_NOTIFY";
+#endif
+#ifdef EXC_CORPSE_VARIANT_BIT
+  case EXC_CORPSE_VARIANT_BIT:
+return "EXC_CORPSE_VARIANT_BIT";
+#endif
+  default:
+break;
+  }
+  return NULL;
+}
+
+llvm::Optional
+StopInfoMachException::MachException::ExceptionCode(const char *name) {
+  return llvm::StringSwitch>(name)
+  .Case("EXC_BAD_ACCESS", EXC_BAD_ACCESS)
+  .Case("EXC_BAD_INSTRUCTION", EXC_BAD_INSTRUCTION)
+  .Case("EXC_ARITHMETIC", EXC_ARITHMETIC)
+  .Case("EXC_EMULATION", EXC_EMULATION)
+  .Case("EXC_SOFTWARE", EXC_SOFTWARE)
+  .Case("EXC_BREAKPOINT", EXC_BREAKPOINT)
+  .Cas

[Lldb-commits] [lldb] 603f44a - [lldb/test] Fix interactive crashlog test failure (NFC)

2022-08-11 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-08-11T22:29:06-07:00
New Revision: 603f44acc6ec31a274c554f0647630c10a114a6b

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

LOG: [lldb/test] Fix interactive crashlog test failure (NFC)

This patch removes the system library names and mangled symbol from
the expected output for the interactive crashlog tests.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test

lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Removed: 




diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
index d8c91675e159..3faff2cec20f 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
@@ -21,23 +21,23 @@
 
 # CHECK: (lldb) thread list
 # CHECK-NEXT: Process 22511 stopped
-# CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84 
libsystem_kernel.dylib`__ulock_wait{{.*}}, queue = 'com.apple.main-thread'
-# CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c 
libsystem_kernel.dylib`{{.*}}
+# CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 
'com.apple.main-thread'
+# CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
 # CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 
multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
 
 # CHECK: (lldb) bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
-# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84 
libsystem_kernel.dylib`__ulock_wait{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5b3b multithread-test`main{{.*}} 
[artificial]
-# CHECK:frame #{{[0-9]+}}: 0x0002230f8da7 dyld`start{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x0002230f8da7{{.*}} [artificial]
 # CHECK-NEXT:  thread #2
-# CHECK-NEXT:frame #0: 0x00019cc42c9c 
libsystem_kernel.dylib`__write_nocancel{{.*}} [artificial]
+# CHECK-NEXT:frame #0: 0x00019cc42c9c{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 
multithread-test`call_and_wait{{.*}} [artificial]
-# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b 
libsystem_pthread.dylib`_pthread_start{{.*}} [artificial]
-# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b 
libsystem_pthread.dylib`thread_start{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
 # CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
 # CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} 
[artificial]
 # CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} 
[artificial]
 # CHECK-NEXT:frame #2: 0x000100ec5a87 
multithread-test`compute_pow{{.*}} [artificial]
-# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b 
libsystem_pthread.dylib`_pthread_start{{.*}} [artificial]
-# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b 
libsystem_pthread.dylib`thread_start{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
index f32c2d94aad7..7e57b07bb1cf 100644
--- 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -21,23 +21,23 @@ thread backtrace
 
 thread list
 # CHECK: Process 22511 stopped
-# CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84 
libsystem_kernel.dylib`__ulock_wait{{.*}}, queue = 'com.apple.main-thread'
-# CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c 
libsystem_kernel.dylib`{{.*}}
+# CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 
'com.apple.main-thread'
+# CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
 # CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 
multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
 
 bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
-# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84 
libsystem_kernel.dylib`__ulock_wait{{.*}} [artificial]
+# CHECK:frame #{{[0-9]+}}: 0x00019cc40b84{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x0

[Lldb-commits] [lldb] 6c58f12 - [lldb/Symbol] Fix null-deref in TypeList::Dump

2022-08-11 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2022-08-11T22:29:06-07:00
New Revision: 6c58f12d07612a4d2bc9abdc5bb545cbb4810f0e

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

LOG: [lldb/Symbol] Fix null-deref in TypeList::Dump

This patch should just a crash caused by a null pointer dereferencing
when dumping a type. It makes sure that the pointer is valid.

rdar://97455134

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/source/Symbol/TypeList.cpp

Removed: 




diff  --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp
index 494e59e3a0fc2..2e101e0a8f574 100644
--- a/lldb/source/Symbol/TypeList.cpp
+++ b/lldb/source/Symbol/TypeList.cpp
@@ -92,9 +92,9 @@ void TypeList::ForEach(
 }
 
 void TypeList::Dump(Stream *s, bool show_context) {
-  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos) 
{
-pos->get()->Dump(s, show_context);
-  }
+  for (iterator pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+if (Type *t = pos->get())
+  t->Dump(s, show_context);
 }
 
 void TypeList::RemoveMismatchedTypes(llvm::StringRef qualified_typename,



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


[Lldb-commits] [PATCH] D131719: [lldb/crashlog] Adapt raw text crashlog exception to json format

2022-08-11 Thread Med Ismail Bennani 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 rG300e393092e3: [lldb/crashlog] Adapt raw text crashlog 
exception to json format (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D131719?vs=452042&id=452081#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131719

Files:
  lldb/examples/python/crashlog.py

Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -340,6 +340,7 @@
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing all stack backtraces
 self.errors = list()
+self.exception = dict()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -483,6 +484,7 @@
 self.crashlog.process_identifier = json_data['procName']
 
 def parse_crash_reason(self, json_exception):
+self.crashlog.exception = json_exception
 exception_type = json_exception['type']
 exception_signal = " "
 if 'signal' in json_exception:
@@ -601,7 +603,6 @@
 SYSTEM = 4
 INSTRS = 5
 
-
 class TextCrashLogParser(CrashLogParser):
 parent_process_regex = re.compile(r'^Parent Process:\s*(.*)\[(\d+)\]')
 thread_state_regex = re.compile(r'^Thread \d+ crashed with')
@@ -624,6 +625,9 @@
   r'(?:<([-0-9a-fA-F]+)>\s+)?' # img_uuid
   r'(/.*)' # img_path
  )
+exception_type_regex = re.compile(r'^Exception Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?')
+exception_codes_regex = re.compile(r'^Exception Codes:\s+(0x[0-9a-fA-F]+),\s*(0x[0-9a-fA-F]+)')
+exception_extra_regex = re.compile(r'^Exception\s+.*:\s+(.*)')
 
 def __init__(self, debugger, path, verbose):
 super().__init__(debugger, path, verbose)
@@ -650,9 +654,9 @@
 if self.parse_mode == CrashLogParseMode.THREAD:
 if self.thread.index == self.crashlog.crashed_thread_idx:
 self.thread.reason = ''
-if self.crashlog.thread_exception:
+if hasattr(self.crashlog, 'thread_exception'):
 self.thread.reason += self.crashlog.thread_exception
-if self.crashlog.thread_exception_data:
+if hasattr(self.crashlog, 'thread_exception_data'):
 self.thread.reason += " (%s)" % self.crashlog.thread_exception_data
 if self.app_specific_backtrace:
 self.crashlog.backtraces.append(self.thread)
@@ -670,6 +674,37 @@
 
 return self.crashlog
 
+def parse_exception(self, line):
+if not line.startswith('Exception'):
+return
+if line.startswith('Exception Type:'):
+self.crashlog.thread_exception = line[15:].strip()
+exception_type_match = self.exception_type_regex.search(line)
+if exception_type_match:
+exc_type, exc_signal = exception_type_match.groups()
+self.crashlog.exception['type'] = exc_type
+if exc_signal:
+self.crashlog.exception['signal'] = exc_signal
+elif line.startswith('Exception Subtype:'):
+self.crashlog.thread_exception_subtype = line[18:].strip()
+if 'type' in self.crashlog.exception:
+self.crashlog.exception['subtype'] = self.crashlog.thread_exception_subtype
+elif line.startswith('Exception Codes:'):
+self.crashlog.thread_exception_data = line[16:].strip()
+if 'type' not in self.crashlog.exception:
+return
+exception_codes_match = self.exception_codes_regex.search(line)
+if exception_codes_match:
+self.crashlog.exception['codes'] = self.crashlog.thread_exception_data
+code, subcode = exception_codes_match.groups()
+self.crashlog.exception['rawCodes'] = [int(code, base=16),
+   int(subcode, base=16)]
+else:
+if 'type' not in self.crashlog.exception:
+return
+exception_extra_match = self.exception_extra_regex.search(line)
+if exception_extra_match:
+self.crashlog.exception['message'] = exception_extra_match.group(1)
 
 def parse_normal(self, line):
 if line.startswith('Process:'):
@@ -693,14 +728,8 @@
 line)
 self.crashlog.parent_process_name = parent_process_match.group(

[Lldb-commits] [PATCH] D131086: [lldb/crashlog] Improve exception reporting for interactive mode

2022-08-11 Thread Med Ismail Bennani 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 rGedc77353daa7: [lldb/crashlog] Improve exception reporting 
for interactive mode (authored by mib).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131086

Files:
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
  lldb/source/Plugins/Process/Utility/StopInfoMachException.h
  lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
  
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/skipped_status_interactive_crashlog.test
@@ -10,11 +10,11 @@
 
 process status
 # CHECK: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 thread backtrace
-# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT:* thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:  * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT:frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT:frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/scripted_crashlog_json.test
@@ -10,11 +10,11 @@
 
 # CHECK: (lldb) process status
 # CHECK-NEXT: Process 22511 stopped
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT: frame #0: 0x000100ec58f4 multithread-test`bar
 
 # CHECK: (lldb) thread backtrace
-# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 # CHECK-NEXT:   * frame #0: 0x000100ec58f4 multithread-test`bar{{.*}} [artificial]
 # CHECK-NEXT: frame #1: 0x000100ec591b multithread-test`foo{{.*}} [artificial]
 # CHECK-NEXT: frame #2: 0x000100ec5a87 multithread-test`compute_pow{{.*}} [artificial]
@@ -23,7 +23,7 @@
 # CHECK-NEXT: Process 22511 stopped
 # CHECK-NEXT:   thread #1: tid = 0x23c7fe, 0x00019cc40b84{{.*}}, queue = 'com.apple.main-thread'
 # CHECK-NEXT:   thread #2: tid = 0x23c800, 0x00019cc42c9c{{.*}}
-# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS
+# CHECK-NEXT: * thread #3: tid = 0x23c801, 0x000100ec58f4 multithread-test`bar{{.*}}, stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
 
 # CHECK: (lldb) bt all
 # CHECK:  thread #1, queue = 'com.apple.main-thread'
@@ -35,7 +35,7 @@
 # CHECK:frame #{{[0-9]+}}: 0x000100ec5957 multithread-test`call_and_wait{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc7e06b{{.*}} [artificial]
 # CHECK:frame #{{[0-9]+}}: 0x00019cc78e2b{{.*}} [artificial]
-# CHECK-NEXT:* thread #3, stop r