[Lldb-commits] [PATCH] D100164: Don't treat corefile binaries like dylibs in the shared cache, even if they say they are

2021-04-09 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda created this revision.
jasonmolenda added a reviewer: friss.
jasonmolenda added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jasonmolenda requested review of this revision.

There is a corefile writer that is including uninitialized data in the Mach-O 
header 'flags' field. I'll work with them to fix that, but it only causes a 
problem in one part of lldb today, in ObjectFileMachO::SanitizeSegmentCommand 
where there is code that is trying to detect an LC_SEGMENT in a binary in the 
shared cache.  The shared cache flag bit is set in this corefile, so we adjust 
the offsets and the corefile parsing fails big time.

lldb doesn't make a lot of decisions based on the mach header flags field, and 
even fewer of them when dealing with corefiles, so to handle these corefiles 
that are floating around, I'd like to add a guard to the code to explicitly opt 
out when working on a corefile, to work around this.

Fred, this is an edit to your change from last summer in  
https://reviews.llvm.org/D83023 .  Are you OK with this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100164

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
@@ -1330,7 +1330,8 @@
   if (m_length == 0 || seg_cmd.filesize == 0)
 return;
 
-  if ((m_header.flags & MH_DYLIB_IN_CACHE) && !IsInMemory()) {
+  if (m_header.filetype != MH_CORE && (m_header.flags & MH_DYLIB_IN_CACHE) &&
+  !IsInMemory()) {
 // In shared cache images, the load commands are relative to the
 // shared cache file, and not the the specific image we are
 // examining. Let's fix this up so that it looks like a normal


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
@@ -1330,7 +1330,8 @@
   if (m_length == 0 || seg_cmd.filesize == 0)
 return;
 
-  if ((m_header.flags & MH_DYLIB_IN_CACHE) && !IsInMemory()) {
+  if (m_header.filetype != MH_CORE && (m_header.flags & MH_DYLIB_IN_CACHE) &&
+  !IsInMemory()) {
 // In shared cache images, the load commands are relative to the
 // shared cache file, and not the the specific image we are
 // examining. Let's fix this up so that it looks like a normal
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 39ae25f - [lldb] Update object.test after 'nosync' inference was enabled.

2021-04-09 Thread Alexander Belyaev via lldb-commits

Author: Alexander Belyaev
Date: 2021-04-09T10:04:15+02:00
New Revision: 39ae25fb8c648b0e710ba2d2d46e7a5b7fafff19

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

LOG: [lldb] Update object.test after 'nosync' inference was enabled.

https://reviews.llvm.org/D99769

Added: 


Modified: 
lldb/test/Shell/ObjectFile/PDB/object.test

Removed: 




diff  --git a/lldb/test/Shell/ObjectFile/PDB/object.test 
b/lldb/test/Shell/ObjectFile/PDB/object.test
index 304872ac30160..35373d52a3931 100644
--- a/lldb/test/Shell/ObjectFile/PDB/object.test
+++ b/lldb/test/Shell/ObjectFile/PDB/object.test
@@ -3,7 +3,7 @@
 
 # CHECK: Plugin name: pdb
 # CHECK: Architecture: x86_64-pc-windows-msvc
-# CHECK: UUID: 3F58AF61-A829-6C7A-4C4C-44205044422E-0001
+# CHECK: UUID: 61AF583F-29A8-7A6C-4C4C-44205044422E-0001
 # CHECK: Executable: false
 # CHECK: Stripped: false
 # CHECK: Type: debug info



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


[Lldb-commits] [PATCH] D100191: [lldb] [llgs] Support owning and detaching extra processes

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

Add a NativeDelegate API to pass new processes (forks) to LLGS,
and support detaching them via the 'D' packet.  A 'D' packet without
a specific PID detaches all processes, otherwise it detaches either
the specified subprocess or the main process, depending on the passed
PID.  However, the main process can only be detached if all subprocesses
were detached as well.


https://reviews.llvm.org/D100191

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h

Index: lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
===
--- lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
+++ lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
@@ -25,6 +25,9 @@
   MOCK_METHOD2(ProcessStateChanged,
void(NativeProcessProtocol *Process, StateType State));
   MOCK_METHOD1(DidExec, void(NativeProcessProtocol *Process));
+  MOCK_METHOD2(NewSubprocess,
+   void(NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process));
 };
 
 // NB: This class doesn't use the override keyword to avoid
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -78,6 +78,10 @@
 
   void DidExec(NativeProcessProtocol *process) override;
 
+  void
+  NewSubprocess(NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process) override;
+
   Status InitializeConnection(std::unique_ptr connection);
 
 protected:
@@ -88,6 +92,8 @@
   lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID;
   std::recursive_mutex m_debugged_process_mutex;
   std::unique_ptr m_debugged_process_up;
+  std::unordered_map>
+  m_additional_processes;
 
   Communication m_stdio_communication;
   MainLoop::ReadHandleUP m_stdio_handle_up;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1030,6 +1030,18 @@
   ClearProcessSpecificData();
 }
 
+void GDBRemoteCommunicationServerLLGS::NewSubprocess(
+NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process) {
+  // Apparently the process has been dealt with by another delegate.
+  if (!child_process)
+return;
+  lldb::pid_t child_pid = child_process->GetID();
+  assert(child_pid != LLDB_INVALID_PROCESS_ID);
+  assert(m_additional_processes.find(child_pid) == m_additional_processes.end());
+  m_additional_processes[child_pid] = std::move(child_process);
+}
+
 void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() {
   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_COMM));
 
@@ -3213,19 +3225,43 @@
   return SendIllFormedResponse(packet, "D failed to parse the process id");
   }
 
-  if (pid != LLDB_INVALID_PROCESS_ID && m_debugged_process_up->GetID() != pid) {
-return SendIllFormedResponse(packet, "Invalid pid");
+  // Detach forked children if their PID was specified *or* no PID was requested
+  // (i.e. detach-all packet).
+  bool detached = false;
+  for (auto it = m_additional_processes.begin(); it != m_additional_processes.end();) {
+if (pid == LLDB_INVALID_PROCESS_ID || pid == it->first) {
+  const Status error = it->second->Detach();
+  if (error.Fail()) {
+LLDB_LOGF(log,
+  "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
+  "pid %" PRIu64 ": %s\n",
+  __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
+return SendErrorResponse(0x01);
+  }
+  it = m_additional_processes.erase(it);
+  detached = true;
+} else
+  ++it;
   }
 
-  const Status error = m_debugged_process_up->Detach();
-  if (error.Fail()) {
-LLDB_LOGF(log,
-  "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
-  "pid %" PRIu64 ": %s\n",
-  __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
-return SendErrorResponse(0x01);
+  // Detach the main process if PID matches or no PID was requested.
+  if (pid == LLDB_INVALID_PROCESS_ID || m_debugged_process_up->GetID() == pid) {
+if (!m_additional_processes.empty())
+  return SendErrorResponse(Status("Unable to detach the main process while children are still traced"

[Lldb-commits] [PATCH] D100192: [lldb][Arm/AArch64] Add basic disassemble tests for Arm/AArch64

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: danielkiss, pengfei, kristof.beyls.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Previously the test would fail if you built on Arm/AArch64
but did not have the x86 llvm backend enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100192

Files:
  lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py


Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -32,6 +32,12 @@
 elif re.match("powerpc64le", arch):
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", 
"powerpc64le")
 raw_bytes = bytearray([0x00, 0x00, 0x80, 0x38])
+elif arch == "aarch64":
+target = self.dbg.CreateTargetWithFileAndTargetTriple("", 
"aarch64")
+raw_bytes = bytearray([0x60, 0x0c, 0x80, 0x52])
+elif arch == "arm":
+target = self.dbg.CreateTargetWithFileAndTargetTriple("", "arm")
+raw_bytes = bytearray([0x63, 0x30, 0xa0, 0xe3])
 else:
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64")
 raw_bytes = bytearray([0x48, 0x89, 0xe5])
@@ -52,6 +58,12 @@
 elif re.match("powerpc64le", arch):
 self.assertEqual(inst.GetMnemonic(target), "li")
 self.assertEqual(inst.GetOperands(target), "4, 0")
+elif arch == "aarch64":
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+elif arch == "arm":
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetOperands(target), "r3, #99")
 else:
 self.assertEqual(inst.GetMnemonic(target), "movq")
 self.assertEqual(inst.GetOperands(target),


Index: lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
===
--- lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ lldb/test/API/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -32,6 +32,12 @@
 elif re.match("powerpc64le", arch):
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", "powerpc64le")
 raw_bytes = bytearray([0x00, 0x00, 0x80, 0x38])
+elif arch == "aarch64":
+target = self.dbg.CreateTargetWithFileAndTargetTriple("", "aarch64")
+raw_bytes = bytearray([0x60, 0x0c, 0x80, 0x52])
+elif arch == "arm":
+target = self.dbg.CreateTargetWithFileAndTargetTriple("", "arm")
+raw_bytes = bytearray([0x63, 0x30, 0xa0, 0xe3])
 else:
 target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64")
 raw_bytes = bytearray([0x48, 0x89, 0xe5])
@@ -52,6 +58,12 @@
 elif re.match("powerpc64le", arch):
 self.assertEqual(inst.GetMnemonic(target), "li")
 self.assertEqual(inst.GetOperands(target), "4, 0")
+elif arch == "aarch64":
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetOperands(target), "w0, #0x63")
+elif arch == "arm":
+self.assertEqual(inst.GetMnemonic(target), "mov")
+self.assertEqual(inst.GetOperands(target), "r3, #99")
 else:
 self.assertEqual(inst.GetMnemonic(target), "movq")
 self.assertEqual(inst.GetOperands(target),
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D100193: [lldb] Require x86 backend for a bunch of DWARF tests

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added subscribers: pengfei, arphaman.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

All these tests use x86 target triples.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100193

Files:
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_const_value-bitfields.s
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_data_bit_offset-DW_OP_stack_value.s
  lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-struct.s
  lldb/test/Shell/SymbolFile/DWARF/DW_TAG_basic_type_DW_ATE_UTF_nonC.ll
  lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-invalid_location.s
  lldb/test/Shell/SymbolFile/DWARF/apple-index-is-used.cpp
  lldb/test/Shell/SymbolFile/DWARF/compilercontext.ll
  lldb/test/Shell/SymbolFile/DWARF/debug-names-compressed.cpp
  lldb/test/Shell/SymbolFile/DWARF/debug-types-basic.test
  lldb/test/Shell/SymbolFile/DWARF/debug-types-dwarf5.s
  lldb/test/Shell/SymbolFile/DWARF/debug-types-dwo-cross-reference.cpp
  lldb/test/Shell/SymbolFile/DWARF/debug-types-missing-signature.test
  lldb/test/Shell/SymbolFile/DWARF/debug_line-tombstone.s
  lldb/test/Shell/SymbolFile/DWARF/debug_ranges_and_rnglists.test
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-index-is-used.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-partial-index.cpp
  lldb/test/Shell/SymbolFile/DWARF/dwarf5-split.s
  lldb/test/Shell/SymbolFile/DWARF/dwarf5_tu_index_abbrev_offset.s
  lldb/test/Shell/SymbolFile/DWARF/dwp-separate-debug-file.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-basic-function.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-basic-namespace.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-basic-type.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-basic-variable.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-function-regex.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-method-local-struct.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-method.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-qualified-variable.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp
  lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp
  lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp
  lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
  lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
  lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll

Index: lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll
===
--- lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll
+++ lldb/test/Shell/SymbolFile/DWARF/split-dwarf-multiple-cu.ll
@@ -1,6 +1,8 @@
 ; Check handling of dwo files with multiple compile units. Right now this is not
 ; supported, but it should not cause us to crash or misbehave either...
 
+; REQUIRES: x86
+
 ; RUN: llc %s -filetype=obj -o %t.o --split-dwarf-file=%t.o
 ; RUN: %lldb %t.o -o "image lookup -s x1 -v" -o "image lookup -s x2 -v" -b | FileCheck %s
 
Index: lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/split-dwarf-inlining.cpp
@@ -1,3 +1,5 @@
+// REQUIRES: x86
+
 // RUN: %clangxx -target x86_64-pc-linux -gsplit-dwarf -g -fsplit-dwarf-inlining \
 // RUN:   -c %s -o %t
 // RUN: %lldb %t -o "breakpoint set -n foo" -b | FileCheck %s
Index: lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
===
--- lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
+++ lldb/test/Shell/SymbolFile/DWARF/module-ownership.mm
@@ -1,3 +1,5 @@
+// REQUIRES: x86
+
 // RUN: %clang --target=x86_64-apple-macosx -g -gmodules -Wno-objc-root-class \
 // RUN:-fmodules -fmodules-cache-path=%t.cache \
 // RUN:-c -o %t.o %s -I%S/Inputs
Index: lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/gnu-style-compression.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: zlib
+// REQUIRES: zlib, x86
 
 // RUN: %clang %s -target x86_64-pc-linux -g -gsplit-dwarf -c -o %t \
 // RUN:   -Wa,--compress-debug-sections=zlib-gnu
Index: lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp
+++ lldb/test/Shell/SymbolFile/DWARF/find-variable-file.cpp
@@ -1,4 +1,4 @@
-// REQUIRES: lld
+// REQUIRES: lld, x86
 
 // RUN: %clang -g -c -o %t-1.o --target=x86_64-pc-linux -gno-pubnames %s
 // RUN: %clang -g -c -o %t-2.o --target=x86_64-pc-linux -gno-pubnames %S/Inputs/find-variable-file-2.cpp
Index: lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp
===
--- lldb/test/Shell/SymbolFile/DWARF/find-variable-dwo.cpp
+++ lldb/tes

[Lldb-commits] [PATCH] D100194: [lldb] Require x86 for various NativePDB, Breakpad and Minidump tests

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: pengfei.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

These tests fail if you build without the x86 llvm backend.
Either because they use an x86 triple or try to backtrace which
requires some x86 knowledge to see all frames.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100194

Files:
  lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
  lldb/test/Shell/Minidump/Windows/Sigsegv/sigsegv.test
  lldb/test/Shell/Minidump/disassemble-no-module.yaml
  lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
  lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml
  lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
  lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
  lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp
  lldb/test/Shell/SymbolFile/symbol-binding.test

Index: lldb/test/Shell/SymbolFile/symbol-binding.test
===
--- lldb/test/Shell/SymbolFile/symbol-binding.test
+++ lldb/test/Shell/SymbolFile/symbol-binding.test
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 # Some targets do not have the .size directive.
 # RUN: %clang -target x86_64-unknown-unknown-elf %S/Inputs/symbol-binding.s -c -o %t.o
 # RUN: %lldb %t.o -s %s -o quit | FileCheck %s
Index: lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/s_constant.cpp
@@ -1,5 +1,5 @@
 // clang-format off
-// REQUIRES: lld
+// REQUIRES: lld, x86
 
 // Test that we can display S_CONSTANT records.
 
Index: lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/function-types-calling-conv.cpp
@@ -1,5 +1,5 @@
 // clang-format off
-// REQUIRES: lld
+// REQUIRES: lld, x86
 
 // RUN: %clang_cl --target=i386-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
 // RUN: lld-link -debug:full -nodefaultlib -entry:main %t.obj -out:%t.exe -pdb:%t.pdb
Index: lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
===
--- lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
+++ lldb/test/Shell/SymbolFile/NativePDB/disassembly.cpp
@@ -1,5 +1,5 @@
 // clang-format off
-// REQUIRES: lld
+// REQUIRES: lld, x86
 
 // Test that we can show disassembly and source.
 // RUN: %clang_cl --target=x86_64-windows-msvc -Od -Z7 -c /Fo%t.obj -- %s
Index: lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml
===
--- lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml
+++ lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 # RUN: yaml2obj --docnum=1 %s -o %t.dmp
 # RUN: yaml2obj --docnum=2 %s -o %T/unwind-via-stack-win-no-memory-info.exe
 # RUN: %lldb -c %t.dmp %T/unwind-via-stack-win-no-memory-info.exe \
Index: lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
===
--- lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
+++ lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 # RUN: yaml2obj %S/Inputs/unwind-via-stack-win.yaml -o %t
 # RUN: %lldb -c %t \
 # RUN:   -o "target symbols add %S/Inputs/unwind-via-raSearch.syms" \
Index: lldb/test/Shell/Minidump/disassemble-no-module.yaml
===
--- lldb/test/Shell/Minidump/disassemble-no-module.yaml
+++ lldb/test/Shell/Minidump/disassemble-no-module.yaml
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 # RUN: yaml2obj %s -o %t
 # RUN: %lldb -c %t -o bt -o disassemble 2>&1 | FileCheck %s
 
Index: lldb/test/Shell/Minidump/Windows/Sigsegv/sigsegv.test
===
--- lldb/test/Shell/Minidump/Windows/Sigsegv/sigsegv.test
+++ lldb/test/Shell/Minidump/Windows/Sigsegv/sigsegv.test
@@ -1,3 +1,5 @@
+// REQUIRES: x86
+
 // RUN: cd %p/Inputs
 // RUN: env LLDB_USE_NATIVE_PDB_READER=1 \
 // RUN:   %lldb -c sigsegv.dmp -s sigsegv.lldbinit | FileCheck %s
Index: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
===
--- lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
+++ lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpNew.py
@@ -124,6 +124,7 @@
 stop_description = thread.GetStopDescription(256)
 self.assertIn("SIGSEGV", stop_description)
 
+  

[Lldb-commits] [PATCH] D100194: [lldb] Require x86 for various NativePDB, Breakpad and Minidump tests

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added reviewers: zturner, labath.
DavidSpickett added a comment.
Herald added a subscriber: JDevlieghere.

(not adding a reviewer for each file type since most are pretty straightforward 
I think)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100194

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


[Lldb-commits] [PATCH] D100194: [lldb] Require x86 for various NativePDB, Breakpad and Minidump tests

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/test/Shell/SymbolFile/Breakpad/unwind-via-raSearch.test:45
 # CHECK: frame #2: 0x000b1085 unwind-via-stack-win.exe`main + 5
 # CHECK: frame #3: 0x77278494 kernel32.dll
 # CHECK-NOT: frame

Same thing happens here if you don't have x86 enabled, this last frame is 
missing.



Comment at: 
lldb/test/Shell/SymbolFile/Breakpad/unwind-via-stack-win-no-memory-info.yaml:13
 # CHECK: frame #2: 0x000b1085 unwind-via-stack-win-no-memory-info.exe`main + 5
 # CHECK: frame #3: 0x77278494 kernel32.dll
 # CHECK-NOT: frame

@labath In this case, without the x86 backend we do get the first 3 frames just 
not the kernel32.dll frame.

```
(lldb) target symbols add 
../llvm-project/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-raSearch.syms
symbol file 
'/home/david.spickett/llvm-project/lldb/test/Shell/SymbolFile/Breakpad/Inputs/unwind-via-raSearch.syms'
 has been added to '/home/david.spickett/build-llvm-aarch64/foo/foo.exe'
(lldb) thread backtrace
* thread #1
  * frame #0: 0x000b1092 foo.exe`many_pointer_args + 2
frame #1: 0x000b1079 foo.exe`call_many + 105
frame #2: 0x000b1085 foo.exe`main + 
```

So my guess is that the last frame requires x86 specific knowledge to work out. 
If you think that's not the case or would prefer I investigate first I can 
remove it from this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100194

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


[Lldb-commits] [PATCH] D100195: [lldb] Require x86 for unwind no-return test

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett created this revision.
Herald added a subscriber: pengfei.
DavidSpickett requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

The core file used is built for i386 so we
need the x86 backend to be able to load it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100195

Files:
  
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py


Index: 
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
===
--- 
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
+++ 
lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
@@ -15,6 +15,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
+@skipIfLLVMTargetMissing("X86")
 def test(self):
 target = self.dbg.CreateTarget("test.out")
 process = target.LoadCore("test.core")


Index: lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
===
--- lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
+++ lldb/test/API/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py
@@ -15,6 +15,7 @@
 NO_DEBUG_INFO_TESTCASE = True
 mydir = TestBase.compute_mydir(__file__)
 
+@skipIfLLVMTargetMissing("X86")
 def test(self):
 target = self.dbg.CreateTarget("test.out")
 process = target.LoadCore("test.core")
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D100195: [lldb] Require x86 for unwind no-return test

2021-04-09 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: labath.
DavidSpickett added a comment.
Herald added a subscriber: JDevlieghere.

(apologies for the review spam, you're the author of the test in this case)

lldb in fact crashes when you try to load the core file. Would be nice to give 
a good failure message if we can but skipping this test makes sense anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100195

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


[Lldb-commits] [PATCH] D100196: [lldb] Introduce new stop reasons: fork and vfork

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

Introduce two new stop reasons for fork and vfork events.  This includes
server support for serializing fork/vfork events into gdb-remote
protocol, and client support for deserializing them.  The stop infos
for both events take a pair of PID and TID for the newly forked process.


https://reviews.llvm.org/D100196

Files:
  lldb/bindings/interface/SBThread.i
  lldb/bindings/interface/SBThreadPlan.i
  lldb/docs/python_api_enums.rst
  lldb/examples/python/performance.py
  lldb/include/lldb/API/SBThread.h
  lldb/include/lldb/API/SBThreadPlan.h
  lldb/include/lldb/Host/Debug.h
  lldb/include/lldb/Target/StopInfo.h
  lldb/include/lldb/lldb-enumerations.h
  lldb/packages/Python/lldbsuite/test/lldbutil.py
  lldb/source/API/SBThread.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/StackFrameList.cpp
  lldb/source/Target/StopInfo.cpp
  lldb/source/Target/Thread.cpp
  lldb/tools/lldb-vscode/JSONUtils.cpp
  lldb/tools/lldb-vscode/LLDBUtils.cpp

Index: lldb/tools/lldb-vscode/LLDBUtils.cpp
===
--- lldb/tools/lldb-vscode/LLDBUtils.cpp
+++ lldb/tools/lldb-vscode/LLDBUtils.cpp
@@ -56,6 +56,8 @@
   case lldb::eStopReasonException:
   case lldb::eStopReasonExec:
   case lldb::eStopReasonProcessorTrace:
+  case lldb::eStopReasonFork:
+  case lldb::eStopReasonVFork:
 return true;
   case lldb::eStopReasonThreadExiting:
   case lldb::eStopReasonInvalid:
Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -877,6 +877,12 @@
   case lldb::eStopReasonExec:
 body.try_emplace("reason", "entry");
 break;
+  case lldb::eStopReasonFork:
+body.try_emplace("reason", "fork");
+break;
+  case lldb::eStopReasonVFork:
+body.try_emplace("reason", "vfork");
+break;
   case lldb::eStopReasonThreadExiting:
   case lldb::eStopReasonInvalid:
   case lldb::eStopReasonNone:
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1679,6 +1679,10 @@
 return "exception";
   case eStopReasonExec:
 return "exec";
+  case eStopReasonFork:
+return "fork";
+  case eStopReasonVFork:
+return "vfork";
   case eStopReasonPlanComplete:
 return "plan complete";
   case eStopReasonThreadExiting:
Index: lldb/source/Target/StopInfo.cpp
===
--- lldb/source/Target/StopInfo.cpp
+++ lldb/source/Target/StopInfo.cpp
@@ -1145,6 +1145,48 @@
   bool m_performed_action;
 };
 
+// StopInfoFork
+
+class StopInfoFork : public StopInfo {
+public:
+  StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
+  : StopInfo(thread, child_pid), m_child_pid(child_pid),
+m_child_tid(child_tid) {}
+
+  ~StopInfoFork() override = default;
+
+  bool ShouldStop(Event *event_ptr) override { return false; }
+
+  StopReason GetStopReason() const override { return eStopReasonFork; }
+
+  const char *GetDescription() override { return "fork"; }
+
+private:
+  lldb::pid_t m_child_pid;
+  lldb::tid_t m_child_tid;
+};
+
+// StopInfoVFork
+
+class StopInfoVFork : public StopInfo {
+public:
+  StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
+  : StopInfo(thread, child_pid), m_child_pid(child_pid),
+m_child_tid(child_tid) {}
+
+  ~StopInfoVFork() override = default;
+
+  bool ShouldStop(Event *event_ptr) override { return false; }
+
+  StopReason GetStopReason() const override { return eStopReasonVFork; }
+
+  const char *GetDescription() override { return "vfork"; }
+
+private:
+  lldb::pid_t m_child_pid;
+  lldb::tid_t m_child_tid;
+};
+
 } // namespace lldb_private
 
 StopInfoSP StopInfo::CreateStopReasonWithBreakpointSiteID(Thread &thread,
@@ -1194,6 +1236,19 @@
   return StopInfoSP(new StopInfoExec(thread));
 }
 
+StopInfoSP StopInfo::CreateStopReasonFork(Thread &thread,
+  lldb::pid_t child_pid,
+  lldb::tid_t child_tid) {
+  return StopInfoSP(new StopInfoFork(thread, child_pid, child_tid));
+}
+
+
+StopInfoSP StopInfo::CreateStopReasonVFork(Thread &thread,
+   lldb::pid_t child_pid,
+   lldb::tid_t child_tid) {
+  return StopInfoSP(new StopInfoVFork(thread, child_pid, child_tid));
+}
+
 ValueObjectSP StopInfo::GetReturnValueObject(StopInfoSP &stop_info_sp) {
   if (stop_info_sp &&
   stop_info_sp->GetStopReason() == eStopReasonPlanComplete) {
Index: lldb/source/Ta

[Lldb-commits] [PATCH] D100191: [lldb] [llgs] Support owning and detaching extra processes

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 336443.
mgorny added a comment.

Permit more-than-one-char 'D' packets.


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

https://reviews.llvm.org/D100191

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h

Index: lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
===
--- lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
+++ lldb/unittests/TestingSupport/Host/NativeProcessTestUtils.h
@@ -25,6 +25,9 @@
   MOCK_METHOD2(ProcessStateChanged,
void(NativeProcessProtocol *Process, StateType State));
   MOCK_METHOD1(DidExec, void(NativeProcessProtocol *Process));
+  MOCK_METHOD2(NewSubprocess,
+   void(NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process));
 };
 
 // NB: This class doesn't use the override keyword to avoid
Index: lldb/source/Utility/StringExtractorGDBRemote.cpp
===
--- lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -378,9 +378,7 @@
 return eServerPacketType_C;
 
   case 'D':
-if (packet_size == 1)
-  return eServerPacketType_D;
-break;
+return eServerPacketType_D;
 
   case 'g':
 return eServerPacketType_g;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -78,6 +78,10 @@
 
   void DidExec(NativeProcessProtocol *process) override;
 
+  void
+  NewSubprocess(NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process) override;
+
   Status InitializeConnection(std::unique_ptr connection);
 
 protected:
@@ -88,6 +92,8 @@
   lldb::tid_t m_continue_tid = LLDB_INVALID_THREAD_ID;
   std::recursive_mutex m_debugged_process_mutex;
   std::unique_ptr m_debugged_process_up;
+  std::unordered_map>
+  m_additional_processes;
 
   Communication m_stdio_communication;
   MainLoop::ReadHandleUP m_stdio_handle_up;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -1030,6 +1030,18 @@
   ClearProcessSpecificData();
 }
 
+void GDBRemoteCommunicationServerLLGS::NewSubprocess(
+NativeProcessProtocol *parent_process,
+std::unique_ptr &child_process) {
+  // Apparently the process has been dealt with by another delegate.
+  if (!child_process)
+return;
+  lldb::pid_t child_pid = child_process->GetID();
+  assert(child_pid != LLDB_INVALID_PROCESS_ID);
+  assert(m_additional_processes.find(child_pid) == m_additional_processes.end());
+  m_additional_processes[child_pid] = std::move(child_process);
+}
+
 void GDBRemoteCommunicationServerLLGS::DataAvailableCallback() {
   Log *log(GetLogIfAnyCategoriesSet(GDBR_LOG_COMM));
 
@@ -3213,19 +3225,43 @@
   return SendIllFormedResponse(packet, "D failed to parse the process id");
   }
 
-  if (pid != LLDB_INVALID_PROCESS_ID && m_debugged_process_up->GetID() != pid) {
-return SendIllFormedResponse(packet, "Invalid pid");
+  // Detach forked children if their PID was specified *or* no PID was requested
+  // (i.e. detach-all packet).
+  bool detached = false;
+  for (auto it = m_additional_processes.begin(); it != m_additional_processes.end();) {
+if (pid == LLDB_INVALID_PROCESS_ID || pid == it->first) {
+  const Status error = it->second->Detach();
+  if (error.Fail()) {
+LLDB_LOGF(log,
+  "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
+  "pid %" PRIu64 ": %s\n",
+  __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
+return SendErrorResponse(0x01);
+  }
+  it = m_additional_processes.erase(it);
+  detached = true;
+} else
+  ++it;
   }
 
-  const Status error = m_debugged_process_up->Detach();
-  if (error.Fail()) {
-LLDB_LOGF(log,
-  "GDBRemoteCommunicationServerLLGS::%s failed to detach from "
-  "pid %" PRIu64 ": %s\n",
-  __FUNCTION__, m_debugged_process_up->GetID(), error.AsCString());
-return SendErrorResponse(0x01);
+  // Detach the main process if PID matches or no PID was requested.
+  if (pid == LLDB_INVALID_PROCESS_ID || m_

[Lldb-commits] [PATCH] D99864: [lldb] Fork/vfork support via gdb-remote protocol [WIP]

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

I've decided to take another approach for tracking forked processes. Rather 
than keeping them inside `NativeProcess*` and exposing via API to LLGS, I've 
decided to push them via `NativeDelegate` straight into LLGS and maintain 
there. This is now D100191 .

I've also split the fundamental support for new stop reasons into D100196 
.


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

https://reviews.llvm.org/D99864

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


[Lldb-commits] [PATCH] D100206: [lldb] [llgs client] Support minimal fork/vfork handling

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

Add a support for handling fork/vfork stops in LLGS client.  At this
point, it only sends a detach packet for the newly forked child
(and implicitly resumes the parent).


https://reviews.llvm.org/D100206

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/StopInfo.cpp

Index: lldb/source/Target/StopInfo.cpp
===
--- lldb/source/Target/StopInfo.cpp
+++ lldb/source/Target/StopInfo.cpp
@@ -1150,8 +1150,8 @@
 class StopInfoFork : public StopInfo {
 public:
   StopInfoFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
-  : StopInfo(thread, child_pid), m_child_pid(child_pid),
-m_child_tid(child_tid) {}
+  : StopInfo(thread, child_pid), m_performed_action(false),
+m_child_pid(child_pid), m_child_tid(child_tid) {}
 
   ~StopInfoFork() override = default;
 
@@ -1161,6 +1161,19 @@
 
   const char *GetDescription() override { return "fork"; }
 
+protected:
+  void PerformAction(Event *event_ptr) override {
+// Only perform the action once
+if (m_performed_action)
+  return;
+m_performed_action = true;
+ThreadSP thread_sp(m_thread_wp.lock());
+if (thread_sp)
+  thread_sp->GetProcess()->DidFork(m_child_pid, m_child_tid);
+  }
+
+  bool m_performed_action;
+
 private:
   lldb::pid_t m_child_pid;
   lldb::tid_t m_child_tid;
@@ -1171,8 +1184,8 @@
 class StopInfoVFork : public StopInfo {
 public:
   StopInfoVFork(Thread &thread, lldb::pid_t child_pid, lldb::tid_t child_tid)
-  : StopInfo(thread, child_pid), m_child_pid(child_pid),
-m_child_tid(child_tid) {}
+  : StopInfo(thread, child_pid), m_performed_action(false),
+m_child_pid(child_pid), m_child_tid(child_tid) {}
 
   ~StopInfoVFork() override = default;
 
@@ -1182,6 +1195,19 @@
 
   const char *GetDescription() override { return "vfork"; }
 
+protected:
+  void PerformAction(Event *event_ptr) override {
+// Only perform the action once
+if (m_performed_action)
+  return;
+m_performed_action = true;
+ThreadSP thread_sp(m_thread_wp.lock());
+if (thread_sp)
+  thread_sp->GetProcess()->DidVFork(m_child_pid, m_child_tid);
+  }
+
+  bool m_performed_action;
+
 private:
   lldb::pid_t m_child_pid;
   lldb::tid_t m_child_tid;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -230,6 +230,9 @@
   std::string HarmonizeThreadIdsForProfileData(
   StringExtractorGDBRemote &inputStringExtractor);
 
+  void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) override;
+  void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) override;
+
 protected:
   friend class ThreadGDBRemote;
   friend class GDBRemoteCommunicationClient;
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -5432,3 +5432,29 @@
 GetTarget().GetDebugger().GetCommandInterpreter());
   return m_command_sp.get();
 }
+
+void ProcessGDBRemote::DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
+  Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+
+  LLDB_LOG(log, "Detaching forked child {0}", child_pid);
+  Status error = m_gdb_comm.Detach(false, child_pid);
+  if (error.Fail()) {
+  LLDB_LOG(log,
+   "ProcessGDBRemote::DidFork() detach packet send failed: {0}",
+error.AsCString() ? error.AsCString() : "");
+  return;
+  }
+}
+
+void ProcessGDBRemote::DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {
+  Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS));
+
+  LLDB_LOG(log, "Detaching forked child {0}", child_pid);
+  Status error = m_gdb_comm.Detach(false, child_pid);
+  if (error.Fail()) {
+  LLDB_LOG(log,
+   "ProcessGDBRemote::DidFork() detach packet send failed: {0}",
+error.AsCString() ? error.AsCString() : "");
+  return;
+  }
+}
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -978,6 +978,12 @@
   /// anything after a process exec's itself.
   virtual void DoDidExec() {}
 
+  /// Called after a reported fork.
+  virtual void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid) {}
+
+  /// Called after a reported vfork.
+  virtual void DidVFork(lldb::pid_t child_pid, lldb

[Lldb-commits] [PATCH] D100208: [lldb] [Process/Linux] Report fork/vfork stop reason to client [WIP]

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski.
mgorny requested review of this revision.

Enable reporting fork/vfork events to the client when supported.  This
switches from implicit server-side handling to client-controlled
gdb-remote protocol exchange.


https://reviews.llvm.org/D100208

Files:
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeThreadLinux.h


Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -85,6 +85,10 @@
 
   void SetStoppedByTrace();
 
+  void SetStoppedByFork(lldb::pid_t child_pid);
+
+  void SetStoppedByVFork(lldb::pid_t child_pid);
+
   void SetStoppedWithNoReason();
 
   void SetStoppedByProcessorTrace(llvm::StringRef description);
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
@@ -394,6 +394,22 @@
   m_stop_info.details.signal.signo = SIGTRAP;
 }
 
+void NativeThreadLinux::SetStoppedByFork(lldb::pid_t child_pid) {
+  SetStopped();
+
+  m_stop_info.reason = StopReason::eStopReasonFork;
+  m_stop_info.details.fork.child_pid = child_pid;
+  m_stop_info.details.fork.child_tid = child_pid;
+}
+
+void NativeThreadLinux::SetStoppedByVFork(lldb::pid_t child_pid) {
+  SetStopped();
+
+  m_stop_info.reason = StopReason::eStopReasonVFork;
+  m_stop_info.details.fork.child_pid = child_pid;
+  m_stop_info.details.fork.child_tid = child_pid;
+}
+
 void NativeThreadLinux::SetStoppedWithNoReason() {
   SetStopped();
 
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
@@ -142,6 +142,9 @@
 
   lldb::tid_t m_pending_notification_tid = LLDB_INVALID_THREAD_ID;
 
+  // Dummy loop for subprocess instances.
+  MainLoop m_subprocess_loop;
+
   /// Inferior memory (allocated by us) and its size.
   llvm::DenseMap m_allocated_memory;
 
Index: lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -914,16 +914,26 @@
 LLVM_FALLTHROUGH;
   case PTRACE_EVENT_FORK:
   case PTRACE_EVENT_VFORK: {
-MainLoop unused_loop;
-NativeProcessLinux child_process{static_cast<::pid_t>(child_pid),
- m_terminal_fd,
- *m_delegates[0],
- m_arch,
- unused_loop,
- {static_cast<::pid_t>(child_pid)}};
-child_process.Detach();
-ResumeThread(*parent_thread, parent_thread->GetState(),
- LLDB_INVALID_SIGNAL_NUMBER);
+std::unique_ptr child_process{new 
NativeProcessLinux(
+static_cast<::pid_t>(child_pid), m_terminal_fd, *m_delegates[0], 
m_arch,
+m_subprocess_loop, {static_cast<::pid_t>(child_pid)})};
+Extension expected_ext = (clone_info->event != PTRACE_EVENT_VFORK)
+ ? Extension::fork
+ : Extension::vfork;
+if ((m_enabled_extensions & expected_ext) == expected_ext) {
+  for (auto &x : m_delegates)
+x->NewSubprocess(this, child_process);
+  // NB: non-vfork clone() is reported as fork
+  if (clone_info->event != PTRACE_EVENT_VFORK)
+parent_thread->SetStoppedByFork(child_pid);
+  else
+parent_thread->SetStoppedByVFork(child_pid);
+  StopRunningThreads(parent_thread->GetID());
+} else {
+  child_process->Detach();
+  ResumeThread(*parent_thread, parent_thread->GetState(),
+   LLDB_INVALID_SIGNAL_NUMBER);
+}
 break;
   }
   default:


Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeThreadLinux.h
@@ -85,6 +85,10 @@
 
   void SetStoppedByTrace();
 
+  void SetStoppedByFork(lldb::pid_t child_pid);
+
+  void SetStoppedByVFork(lldb::pid_t child_pid);
+
   void SetStoppedWithNoReason();
 
   void SetStoppedByProcessorTrace(llvm::StringRef description);
Index: lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
===
--- lldb/source/Plugins/

[Lldb-commits] [PATCH] D100208: [lldb] [Process/Linux] Report fork/vfork stop reason to client [WIP]

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

This is the final piece for moving minimal fork/vfork support to gdb-remote 
protocol. However, for some reason (unlike the original code in D99864 
), it crashes on random assertions about 
`m_enabled_extensions` value — probably memory corruption somewhere. I'm 
debugging it.


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

https://reviews.llvm.org/D100208

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


[Lldb-commits] [PATCH] D100193: [lldb] Require x86 backend for a bunch of DWARF tests

2021-04-09 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere requested changes to this revision.
JDevlieghere added a comment.
This revision now requires changes to proceed.

Rather than updating all the these tests, please move them into an x86 
subdirectory and add a `lit.local.cfg` to mark the whole folder as unsupported 
without x86 support. Something like:

  if not 'x86' in config.available_features:
config.unsupported = True


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100193

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


[Lldb-commits] [PATCH] D100212: [lldb] Delete dead StackFrameList::Merge

2021-04-09 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor created this revision.
teemperor added a reviewer: LLDB.
teemperor requested review of this revision.

That code is unused since it's check-in in 2010 (and I believe it would leak 
memory when called
as it releases the passed unique_ptr), so let's delete it.


https://reviews.llvm.org/D100212

Files:
  lldb/include/lldb/Target/StackFrameList.h
  lldb/source/Target/StackFrameList.cpp

Index: lldb/source/Target/StackFrameList.cpp
===
--- lldb/source/Target/StackFrameList.cpp
+++ lldb/source/Target/StackFrameList.cpp
@@ -823,105 +823,6 @@
   m_concrete_frames_fetched = 0;
 }
 
-void StackFrameList::Merge(std::unique_ptr &curr_up,
-   lldb::StackFrameListSP &prev_sp) {
-  std::unique_lock current_lock, previous_lock;
-  if (curr_up)
-current_lock = std::unique_lock(curr_up->m_mutex);
-  if (prev_sp)
-previous_lock = std::unique_lock(prev_sp->m_mutex);
-
-#if defined(DEBUG_STACK_FRAMES)
-  StreamFile s(stdout, false);
-  s.PutCString("\n\nStackFrameList::Merge():\nPrev:\n");
-  if (prev_sp)
-prev_sp->Dump(&s);
-  else
-s.PutCString("NULL");
-  s.PutCString("\nCurr:\n");
-  if (curr_up)
-curr_up->Dump(&s);
-  else
-s.PutCString("NULL");
-  s.EOL();
-#endif
-
-  if (!curr_up || curr_up->GetNumFrames(false) == 0) {
-#if defined(DEBUG_STACK_FRAMES)
-s.PutCString("No current frames, leave previous frames alone...\n");
-#endif
-curr_up.release();
-return;
-  }
-
-  if (!prev_sp || prev_sp->GetNumFrames(false) == 0) {
-#if defined(DEBUG_STACK_FRAMES)
-s.PutCString("No previous frames, so use current frames...\n");
-#endif
-// We either don't have any previous frames, or since we have more than one
-// current frames it means we have all the frames and can safely replace
-// our previous frames.
-prev_sp.reset(curr_up.release());
-return;
-  }
-
-  const uint32_t num_curr_frames = curr_up->GetNumFrames(false);
-
-  if (num_curr_frames > 1) {
-#if defined(DEBUG_STACK_FRAMES)
-s.PutCString(
-"We have more than one current frame, so use current frames...\n");
-#endif
-// We have more than one current frames it means we have all the frames and
-// can safely replace our previous frames.
-prev_sp.reset(curr_up.release());
-
-#if defined(DEBUG_STACK_FRAMES)
-s.PutCString("\nMerged:\n");
-prev_sp->Dump(&s);
-#endif
-return;
-  }
-
-  StackFrameSP prev_frame_zero_sp(prev_sp->GetFrameAtIndex(0));
-  StackFrameSP curr_frame_zero_sp(curr_up->GetFrameAtIndex(0));
-  StackID curr_stack_id(curr_frame_zero_sp->GetStackID());
-  StackID prev_stack_id(prev_frame_zero_sp->GetStackID());
-
-#if defined(DEBUG_STACK_FRAMES)
-  const uint32_t num_prev_frames = prev_sp->GetNumFrames(false);
-  s.Printf("\n%u previous frames with one current frame\n", num_prev_frames);
-#endif
-
-  // We have only a single current frame
-  // Our previous stack frames only had a single frame as well...
-  if (curr_stack_id == prev_stack_id) {
-#if defined(DEBUG_STACK_FRAMES)
-s.Printf("\nPrevious frame #0 is same as current frame #0, merge the "
- "cached data\n");
-#endif
-
-curr_frame_zero_sp->UpdateCurrentFrameFromPreviousFrame(
-*prev_frame_zero_sp);
-//prev_frame_zero_sp->UpdatePreviousFrameFromCurrentFrame
-//(*curr_frame_zero_sp);
-//prev_sp->SetFrameAtIndex (0, prev_frame_zero_sp);
-  } else if (curr_stack_id < prev_stack_id) {
-#if defined(DEBUG_STACK_FRAMES)
-s.Printf("\nCurrent frame #0 has a stack ID that is less than the previous "
- "frame #0, insert current frame zero in front of previous\n");
-#endif
-prev_sp->m_frames.insert(prev_sp->m_frames.begin(), curr_frame_zero_sp);
-  }
-
-  curr_up.release();
-
-#if defined(DEBUG_STACK_FRAMES)
-  s.PutCString("\nMerged:\n");
-  prev_sp->Dump(&s);
-#endif
-}
-
 lldb::StackFrameSP
 StackFrameList::GetStackFrameSPForStackFramePtr(StackFrame *stack_frame_ptr) {
   const_iterator pos;
Index: lldb/include/lldb/Target/StackFrameList.h
===
--- lldb/include/lldb/Target/StackFrameList.h
+++ lldb/include/lldb/Target/StackFrameList.h
@@ -89,9 +89,6 @@
 
   bool SetFrameAtIndex(uint32_t idx, lldb::StackFrameSP &frame_sp);
 
-  static void Merge(std::unique_ptr &curr_up,
-lldb::StackFrameListSP &prev_sp);
-
   void GetFramesUpTo(uint32_t end_idx);
 
   void GetOnlyConcreteFramesUpTo(uint32_t end_idx, Unwind &unwinder);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D100153: [lldb] [Process] Introduce protocol extension support API

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 336516.
mgorny added a comment.

Fix uninitialized `flags` variable in 
`GDBRemoteCommunicationServerLLGS::SetEnabledExtensions()`.


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

https://reviews.llvm.org/D100153

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -99,6 +99,9 @@
   uint32_t m_next_saved_registers_id = 1;
   bool m_handshake_completed = false;
 
+  bool m_fork_events_supported = false;
+  bool m_vfork_events_supported = false;
+
   PacketResult SendONotification(const char *buffer, uint32_t len);
 
   PacketResult SendWResponse(NativeProcessProtocol *process);
@@ -256,6 +259,9 @@
   llvm::Expected ReadTid(StringExtractorGDBRemote &packet,
   bool allow_all = false);
 
+  // Call SetEnabledExtensions() with appropriate flags on the process.
+  void SetEnabledExtensions(NativeProcessProtocol& process);
+
   // For GDBRemoteCommunicationServerLLGS only
   GDBRemoteCommunicationServerLLGS(const GDBRemoteCommunicationServerLLGS &) =
   delete;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -251,6 +251,8 @@
 m_debugged_process_up = std::move(*process_or);
   }
 
+  SetEnabledExtensions(*m_debugged_process_up);
+
   // Handle mirroring of inferior stdout/stderr over the gdb-remote protocol as
   // needed. llgs local-process debugging may specify PTY paths, which will
   // make these file actions non-null process launch -i/e/o will also make
@@ -318,6 +320,7 @@
 return status;
   }
   m_debugged_process_up = std::move(*process_or);
+  SetEnabledExtensions(*m_debugged_process_up);
 
   // Setup stdout/stderr mapping from inferior.
   auto terminal_fd = m_debugged_process_up->GetTerminalFileDescriptor();
@@ -3545,5 +3548,49 @@
 "QPassSignals+", "qXfer:auxv:read+", "qXfer:libraries-svr4:read+",
 #endif
   });
+
+  // check for platform features
+  auto process_features = m_process_factory.GetSupportedExtensions();
+
+  // reset to defaults
+  m_fork_events_supported = false;
+  m_vfork_events_supported = false;
+
+  // check for client features
+  for (auto x : client_features) {
+if (x == "fork-events+" &&
+(process_features & NativeProcessProtocol::Extension::fork) ==
+NativeProcessProtocol::Extension::fork)
+  m_fork_events_supported = true;
+else if (x == "vfork-events+" &&
+ (process_features & NativeProcessProtocol::Extension::vfork) ==
+ NativeProcessProtocol::Extension::vfork)
+  m_vfork_events_supported = true;
+  }
+
+  // report only if actually supported
+  if (m_fork_events_supported)
+ret.push_back("fork-events+");
+  if (m_vfork_events_supported)
+ret.push_back("vfork-events+");
+
+  if (m_debugged_process_up)
+SetEnabledExtensions(*m_debugged_process_up);
   return ret;
 }
+
+void GDBRemoteCommunicationServerLLGS::SetEnabledExtensions(
+NativeProcessProtocol &process) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS));
+
+  NativeProcessProtocol::Extension flags = {};
+  if (m_fork_events_supported)
+flags |= NativeProcessProtocol::Extension::fork;
+  if (m_vfork_events_supported)
+flags |= NativeProcessProtocol::Extension::vfork;
+
+  llvm::Error error = process.SetEnabledExtensions(flags);
+  if (error)
+LLDB_LOG_ERROR(log, std::move(error),
+   "Enabling protocol extensions failed: {0}");
+}
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -353,7 +353,9 @@
 
   // build the qSupported packet
   std::vector features = {"xmlRegisters=i386,arm,mips,arc",
-   "multiprocess+"};
+   "multiprocess+",
+   "fork-events+",
+   "vfork-events+"};
   StreamString packet;
   packet.PutCString("qSuppor

[Lldb-commits] [PATCH] D100208: [lldb] [Process/Linux] Report fork/vfork stop reason to client

2021-04-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Ok, found the culprit. Now it's ready ;-).


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

https://reviews.llvm.org/D100208

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


[Lldb-commits] [PATCH] D100212: [lldb] Delete dead StackFrameList::Merge

2021-04-09 Thread Vedant Kumar via Phabricator via lldb-commits
vsk accepted this revision as: vsk.
vsk added a comment.
This revision is now accepted and ready to land.

+1


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

https://reviews.llvm.org/D100212

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


[Lldb-commits] [PATCH] D100212: [lldb] Delete dead StackFrameList::Merge

2021-04-09 Thread Shafik Yaghmour via Phabricator via lldb-commits
shafik added a comment.

I think it is pretty safe to remove it after 10+ years is not being used.


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

https://reviews.llvm.org/D100212

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


[Lldb-commits] [PATCH] D99812: [PowerPC] [GlobalISel] Implementation of formal arguments lowering in the IRTranslator for the PPC backend

2021-04-09 Thread Anshil Gandhi via Phabricator via lldb-commits
gandhi21299 updated this revision to Diff 336249.
gandhi21299 added a comment.

- enclosing classes in PPCCallLowering,h within the llvm namespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99812

Files:
  llvm/lib/Target/PowerPC/GISel/PPCCallLowering.cpp
  llvm/lib/Target/PowerPC/GISel/PPCCallLowering.h
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-args-lowering.ll
  llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-ret.ll

Index: llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-ret.ll
===
--- llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-ret.ll
+++ /dev/null
@@ -1,7 +0,0 @@
-; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -global-isel -verify-machineinstrs -stop-after=irtranslator < %s | FileCheck %s
-
-; CHECK: name: f
-; CHECK: BLR8
-define void @f() {
-  ret void
-}
Index: llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-args-lowering.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/GlobalISel/irtranslator-args-lowering.ll
@@ -0,0 +1,188 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -global-isel -verify-machineinstrs -stop-after=irtranslator < %s | FileCheck %s
+
+%struct.A = type { i8, float, i32, i32, i32 }
+
+define void @f() {
+  ; CHECK-LABEL: name: f
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+  ret void
+}
+
+define void @foo1(i32 %x){
+  ; CHECK-LABEL: name: foo1
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $x3
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x3
+  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+ret void
+}
+
+define void @foo2(i64 %x){
+  ; CHECK-LABEL: name: foo2
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $x3
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x3
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+ret void
+}
+
+define void @foo3(<7 x i8> %x) {
+  ; CHECK-LABEL: name: foo3
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x3
+  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
+  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $x4
+  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
+  ; CHECK:   [[COPY2:%[0-9]+]]:_(s64) = COPY $x5
+  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY2]](s64)
+  ; CHECK:   [[COPY3:%[0-9]+]]:_(s64) = COPY $x6
+  ; CHECK:   [[TRUNC3:%[0-9]+]]:_(s32) = G_TRUNC [[COPY3]](s64)
+  ; CHECK:   [[COPY4:%[0-9]+]]:_(s64) = COPY $x7
+  ; CHECK:   [[TRUNC4:%[0-9]+]]:_(s32) = G_TRUNC [[COPY4]](s64)
+  ; CHECK:   [[COPY5:%[0-9]+]]:_(s64) = COPY $x8
+  ; CHECK:   [[TRUNC5:%[0-9]+]]:_(s32) = G_TRUNC [[COPY5]](s64)
+  ; CHECK:   [[COPY6:%[0-9]+]]:_(s64) = COPY $x9
+  ; CHECK:   [[TRUNC6:%[0-9]+]]:_(s32) = G_TRUNC [[COPY6]](s64)
+  ; CHECK:   [[BUILD_VECTOR:%[0-9]+]]:_(<7 x s32>) = G_BUILD_VECTOR [[TRUNC]](s32), [[TRUNC1]](s32), [[TRUNC2]](s32), [[TRUNC3]](s32), [[TRUNC4]](s32), [[TRUNC5]](s32), [[TRUNC6]](s32)
+  ; CHECK:   [[TRUNC7:%[0-9]+]]:_(<7 x s8>) = G_TRUNC [[BUILD_VECTOR]](<7 x s32>)
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+  ret void
+}
+
+define void @foo_notrunc(<7 x i64> %x) {
+  ; CHECK-LABEL: name: foo_notrunc
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x3
+  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $x4
+  ; CHECK:   [[COPY2:%[0-9]+]]:_(s64) = COPY $x5
+  ; CHECK:   [[COPY3:%[0-9]+]]:_(s64) = COPY $x6
+  ; CHECK:   [[COPY4:%[0-9]+]]:_(s64) = COPY $x7
+  ; CHECK:   [[COPY5:%[0-9]+]]:_(s64) = COPY $x8
+  ; CHECK:   [[COPY6:%[0-9]+]]:_(s64) = COPY $x9
+  ; CHECK:   [[BUILD_VECTOR:%[0-9]+]]:_(<7 x s64>) = G_BUILD_VECTOR [[COPY]](s64), [[COPY1]](s64), [[COPY2]](s64), [[COPY3]](s64), [[COPY4]](s64), [[COPY5]](s64), [[COPY6]](s64)
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+  ret void
+}
+
+define void @foo_pt(<7 x i8>* %x) {
+  ; CHECK-LABEL: name: foo_pt
+  ; CHECK: bb.1 (%ir-block.0):
+  ; CHECK:   liveins: $x3
+  ; CHECK:   [[COPY:%[0-9]+]]:_(p0) = COPY $x3
+  ; CHECK:   BLR8 implicit $lr8, implicit $rm
+  ret void
+}
+
+define dso_local void @foo_struct(%struct.A %a) #0 {
+  ; CHECK-LABEL: name: foo_struct
+  ; CHECK: bb.1.entry:
+  ; CHECK:   liveins: $f1, $x3, $x4, $x5, $x6
+  ; CHECK:   [[COPY:%[0-9]+]]:_(s64) = COPY $x3
+  ; CHECK:   [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s64)
+  ; CHECK:   [[COPY1:%[0-9]+]]:_(s64) = COPY $f1
+  ; CHECK:   [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
+  ; CHECK:   [[COPY2:%[0-9]+]]:_(s64) = COPY $x4
+  ; CHECK:   [[TRUNC2:%[0-9]+]]:_(s32) = G_TRUNC [[COPY2]](s64)
+

[Lldb-commits] [lldb] d9c9c0b - [LLDB][NFC] Add clarifying comments for AddCXXSummary and AddCXXSynthetic

2021-04-09 Thread Shafik Yaghmour via lldb-commits

Author: Shafik Yaghmour
Date: 2021-04-09T12:07:24-07:00
New Revision: d9c9c0b2db0dc4ddf407edcafba0a5a806850ddc

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

LOG: [LLDB][NFC] Add clarifying comments for AddCXXSummary and AddCXXSynthetic

Adding comments to AddCXXSynthetic and AddCXXSummary to better explain what 
they are doing.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/FormattersHelpers.h

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h 
b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
index a5b0da57e5d8b..892807063b9ce 100644
--- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h
+++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h
@@ -36,11 +36,13 @@ void AddOneLineSummary(TypeCategoryImpl::SharedPointer 
category_sp,
ConstString type_name, TypeSummaryImpl::Flags flags,
bool regex = false);
 
+/// Add a summary that is implemented by a C++ callback.
 void AddCXXSummary(TypeCategoryImpl::SharedPointer category_sp,
CXXFunctionSummaryFormat::Callback funct,
const char *description, ConstString type_name,
TypeSummaryImpl::Flags flags, bool regex = false);
 
+/// Add a synthetic that is implemented by a C++ callback.
 void AddCXXSynthetic(TypeCategoryImpl::SharedPointer category_sp,
  CXXSyntheticChildren::CreateFrontEndCallback generator,
  const char *description, ConstString type_name,



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