[Lldb-commits] [PATCH] D98822: [lldb] [Process] Watch for fork/vfork notifications

2021-03-27 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 333671.
mgorny added a comment.

Complete FreeBSD and NetBSD support. Includes a fix to `Detach()` on NetBSD.


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

https://reviews.llvm.org/D98822

Files:
  lldb/include/lldb/Host/common/NativeProcessProtocol.h
  lldb/include/lldb/Host/linux/Host.h
  lldb/source/Host/common/NativeProcessProtocol.cpp
  lldb/source/Host/linux/Host.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_arm64.h
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.cpp
  lldb/source/Plugins/Process/FreeBSD/NativeRegisterContextFreeBSD_x86_64.h
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
  lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
  lldb/test/Shell/Subprocess/Inputs/clone.c
  lldb/test/Shell/Subprocess/Inputs/fork.c
  lldb/test/Shell/Subprocess/Inputs/vfork.c
  lldb/test/Shell/Subprocess/clone-follow-parent-softbp.test
  lldb/test/Shell/Subprocess/clone-follow-parent-wp.test
  lldb/test/Shell/Subprocess/clone-follow-parent.test
  lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
  lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
  lldb/test/Shell/Subprocess/fork-follow-parent.test
  lldb/test/Shell/Subprocess/vfork-follow-parent-softbp.test
  lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
  lldb/test/Shell/Subprocess/vfork-follow-parent.test

Index: lldb/test/Shell/Subprocess/vfork-follow-parent.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/vfork-follow-parent.test
@@ -0,0 +1,10 @@
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/vfork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+process launch
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/vfork-follow-parent-wp.test
@@ -0,0 +1,12 @@
+# REQUIRES: native && (target-x86 || target-x86_64 || target-aarch64) && dbregs-set
+# RUN: %clang_host -g %p/Inputs/vfork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch -s
+watchpoint set variable -w write g_val
+# CHECK: Watchpoint created:
+continue
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = watchpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/vfork-follow-parent-softbp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/vfork-follow-parent-softbp.test
@@ -0,0 +1,11 @@
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/vfork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+b child_func
+process launch
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-parent.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent.test
@@ -0,0 +1,11 @@
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+process launch
+# CHECK: function run in child
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = breakpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent-wp.test
@@ -0,0 +1,13 @@
+# REQUIRES: native && (target-x86 || target-x86_64 || target-aarch64) && dbregs-set
+# RUN: %clang_host -g %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch -s
+watchpoint set variable -w write g_val
+# CHECK: Watchpoint created:
+continue
+# CHECK: function run in child
+# CHECK-NOT: function run in parent
+# CHECK: stop reason = watchpoint
+continue
+# CHECK: function run in parent
+# CHECK: child exited: 0
Index: lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
===
--- /dev/null
+++ lldb/test/Shell/Subprocess/fork-follow-parent-softbp.test
@@ -0,0 +1,12 @@
+# REQUIRES: native
+# RUN: %clang_host %p/Inputs/fork.c -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+b parent_func
+b child_func

Re: [Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-27 Thread Pavel Labath via lldb-commits

On 26/03/2021 23:04, Greg Clayton wrote:

I built on mac with ASAN and ran the tests and they passed just fine. I was 
also able to compile on Debian linux and the tests ran ok for me. Can anyone 
else reproduce this failure?




On an unloaded system the test seems to run fine, but as soon as I apply 
some load (e.g., an llvm compilation), it fails nearly always (in the 
same way as it does on the bot).


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


[Lldb-commits] [PATCH] D98826: [lldb] DWZ 6/9: Workaround DWZ bug dropping DW_TAG_namespace::DW_AT_export_symbols

2021-03-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 333692.
jankratochvil added a comment.

testcase: DWZ is unsupported on OSX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98826

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
  lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwz-namespace-inline.s
@@ -0,0 +1,198 @@
+# Workaround for DWZ tool bug producing corrupted DWARF:
+# Multifile drops DW_TAG_namespace::DW_AT_export_symbols
+# https://sourceware.org/bugzilla/show_bug.cgi?id=27572
+
+# REQUIRES: target-x86_64, system-linux, native
+
+# RUN: %clang_host -o %t %s
+# RUN: %lldb %t -o 'b main' -o r -o 'p N::A::m' -o 'p N::m' \
+# RUN:   -o exit | FileCheck %s
+
+# CHECK-LABEL: (lldb) p N::A::m
+# CHECK-NEXT: (int (*)()) $0 = 0x{{.*}}`N::A::m())
+# CHECK-LABEL: (lldb) p N::m
+# Failing case was:
+# error: :1:4: no member named 'm' in namespace 'N'
+# CHECK-NEXT: (int (*)()) $1 = 0x{{.*}}`N::A::m())
+
+	.text
+	.globl	main# -- Begin function main
+	.type	main,@function
+main:   # @main
+.Lfunc_begin0:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	popq	%rbp
+	retq
+.Lfunc_end0:
+	.size	main, .Lfunc_end0-main
+# -- End function
+	.type	_ZN1N1AL1mEv,@function
+_ZN1N1AL1mEv:   # @_ZN1N1AL1mEv
+.Lfunc_begin1:
+	pushq	%rbp
+	movq	%rsp, %rbp
+	movl	$42, %eax
+	popq	%rbp
+	retq
+.Lfunc_end1:
+	.size	_ZN1N1AL1mEv, .Lfunc_end1-_ZN1N1AL1mEv
+# -- End function
+	.section	.debug_abbrev,"",@progbits
+.Labbrev0:
+	.byte	1   # Abbreviation Code
+	.byte	17  # DW_TAG_compile_unit
+	.byte	1   # DW_CHILDREN_yes
+	.byte	37  # DW_AT_producer
+	.byte	8   # DW_FORM_string
+	.byte	19  # DW_AT_language
+	.byte	5   # DW_FORM_data2
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.byte	17  # DW_AT_low_pc
+	.byte	1   # DW_FORM_addr
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	3   # Abbreviation Code
+	.byte	57  # DW_TAG_namespace
+	.byte	1   # DW_CHILDREN_yes
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	4   # Abbreviation Code
+	.byte	57  # DW_TAG_namespace
+	.byte	1   # DW_CHILDREN_yes
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.ascii	"\211\001"  # DW_AT_export_symbols
+	.byte	25  # DW_FORM_flag_present
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	5   # Abbreviation Code
+	.byte	46  # DW_TAG_subprogram
+	.byte	0   # DW_CHILDREN_no
+	.byte	17  # DW_AT_low_pc
+	.byte	1   # DW_FORM_addr
+	.byte	18  # DW_AT_high_pc
+	.byte	6   # DW_FORM_data4
+	.byte	64  # DW_AT_frame_base
+	.byte	24  # DW_FORM_exprloc
+	.byte	0x47# DW_AT_specification
+	.byte	0x10# DW_FORM_ref_addr
+	.byte	0   # EOM(1)
+	.byte	0   # EOM(2)
+	.byte	6   # Abbreviation Code
+	.byte	36  # DW_TAG_base_type
+	.byte	0   # DW_CHILDREN_no
+	.byte	3   # DW_AT_name
+	.byte	8   # DW_FORM_string
+	.byte	62  # DW_AT_encoding
+	.byte	11  # DW_FORM_data1
+	.byte	11  # DW_AT_byte_size
+	.byte	11  # DW_FORM_data1
+	.byte	0   # EOM(1)
+	.byte	0   #

[Lldb-commits] [PATCH] D96242: [lldb] DWZ 8/9: New testcases

2021-03-27 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 333693.
jankratochvil added a comment.

testcases: -fdebug-types-section is unsupported on OSX, Repro was crashing with 
SymbolFileDWZTests.cpp so it is excluded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96242

Files:
  lldb/test/Shell/SymbolFile/DWARF/dump-debug-types.cpp
  lldb/unittests/SymbolFile/CMakeLists.txt
  lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.out
  lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,92 @@
+//===-- SymbolFileDWZTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "TestingSupport/TestUtilities.h"
+
+#include "Plugins/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/Reproducer.h"
+
+#if defined(_MSC_VER)
+#include "lldb/Host/windows/windows.h"
+#include 
+#endif
+
+#include 
+
+using namespace lldb_private;
+using namespace lldb_private::repro;
+
+class SymbolFileDWZTests : public testing::Test {
+public:
+  void SetUp() override {
+// Initialize and TearDown the plugin every time, so we get a brand new
+// AST every time so that modifications to the AST from each test don't
+// leak into the next test.
+#if defined(_MSC_VER)
+::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
+#endif
+
+llvm::cantFail(Reproducer::Initialize(ReproducerMode::Off, llvm::None));
+FileSystem::Initialize();
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+TypeSystemClang::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+TypeSystemClang::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+Reproducer::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolFile *symfile = module->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  symfile->FindTypes(ConstString("StructMovedToDWZCommonFile"),
+ CompilerDeclContext(), 0, searched_files, results);
+  EXPECT_EQ(1u, results.GetSize());
+  lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
+  EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName());
+  CompilerType compiler_type = udt_type->GetForwardCompilerType();
+  EXPECT_TRUE(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,11 @@
+// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f
+// dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m
+// dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup;
+// /usr/lib/rpm/sepdebugcrcfix . dwztest.out
+
+struct StructMovedToDWZCommonFile {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} VarWithStructMovedToDWZCommonFile;
+static const int sizeof_StructMovedToDWZCommonFile =
+sizeof(struct StructMovedToDWZCommonFile);
+int main() { return sizeof_StructMovedToDWZCommonFile; }
Index: lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_lldb_unittest(SymbolFileDWZTests
+  SymbolFileDWZTests.cpp
+
+  LINK_LIBS
+lldbCore
+  

[Lldb-commits] [lldb] 7f76c70 - [lldb] Fix capitalization in CMake status message

2021-03-27 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-27T21:39:39-07:00
New Revision: 7f76c70d85788adeff37a5b7a38236f1d1348e6f

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

LOG: [lldb] Fix capitalization in CMake status message

s/LLDB Tests/LLDB tests/

Added: 


Modified: 
lldb/test/API/CMakeLists.txt

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 2b7dba456b1a..ce7531fd9866 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -116,7 +116,7 @@ if(CMAKE_HOST_APPLE)
 list(APPEND LLDB_TEST_COMMON_ARGS --out-of-tree-debugserver)
 add_lldb_test_dependency(debugserver)
   else()
-message(STATUS "LLDB Tests use just-built debug server")
+message(STATUS "LLDB tests use just-built debug server")
   endif()
 endif()
 



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