[Lldb-commits] [lldb] 5e004b0 - [lldb/test] Update test/API/functionalities/load_lazy to macOS 12

2021-10-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-10-19T13:25:14-07:00
New Revision: 5e004b03f72a17f916b93792eb778dfa9e7a09cc

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

LOG: [lldb/test] Update test/API/functionalities/load_lazy to macOS 12

In macOS 12, dyld switched to using chained fixups. As a result, all symbols
are bound at launch and there are no lazy pointers any more. Since we wish to
import/dlopen() a dylib with missing symbols, we need to use a weak import.
This applies to all macOS 12-aligned OS releases, e.g. iOS 15, etc.

rdar://81295101

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

Added: 


Modified: 
lldb/test/API/functionalities/load_lazy/Makefile

Removed: 




diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
index 7200114d03aeb..81bc7dcb4d05f 100644
--- a/lldb/test/API/functionalities/load_lazy/Makefile
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -5,9 +5,20 @@ all: t2_0 t2_1 t1 a.out
 
 include Makefile.rules
 
+ifeq "$(OS)" "Darwin"
+   # In macOS 12, dyld switched to using chained fixups. As a result, all
+   # symbols are bound at launch and there are no lazy pointers any more.
+   # Since we wish to import/dlopen() a dylib with missing symbols, we need
+   # to use a weak import. This applies to all macOS 12-aligned OS 
releases,
+   # e.g. iOS 15, etc.
+   LINKFLAGS := "-Wl,-weak-lt2_0"
+else
+   LINKFLAGS := "-lt2_0"
+endif
+
 t1: t2_0
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. $(LINKFLAGS)"
 
 t2_0:
$(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \



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


[Lldb-commits] [lldb] e31b2d7 - [lldb][crashlog] Avoid specifying arch for image when a UUID is present

2021-09-20 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-20T10:23:35-07:00
New Revision: e31b2d7d7be98cbbaa665b2702cd0ed2975da4cc

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

LOG: [lldb][crashlog] Avoid specifying arch for image when a UUID is present

When adding an image to a target for crashlog purposes, avoid specifying
the architecture of the image.

This has the effect of making SBTarget::AddModule infer the ArchSpec for
the image based on the SBTarget's architecture, which LLDB puts serious
effort into calculating correctly (in TargetList::CreateTargetInternal).

The status quo is that LLDB randomly guesses the ArchSpec for a module
if its architecture is specified, via:

```
  SBTarget::AddModule -> Platform::GetAugmentedArchSpec -> 
Platform::IsCompatibleArchitecture ->
GetSupportedArchitectureAtIndex -> {ARM,x86}GetSupportedArchitectureAtIndex
```

... which means that the same crashlog can fail to load on an Apple
Silicon Mac (due to the random guess of arm64e-apple-macosx for the
module's ArchSpec not being compatible with the SBTarget's (correct)
ArchSpec), while loading just fine on an Intel Mac.

I'm not sure how to add a test for this (it doesn't look like there's
test coverage of this path in-tree). It seems like it would be pretty
complicated to regression test: the host LLDB would need to be built for
arm64e, we'd need a hand-crafted arm64e iOS crashlog, and we'd need a
binary with an iOS deployment target. I'm open to other / simpler
options.

rdar://82679400

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

Added: 


Modified: 
lldb/examples/python/symbolication.py

Removed: 




diff  --git a/lldb/examples/python/symbolication.py 
b/lldb/examples/python/symbolication.py
index 70f2ff3bb27c3..e15f7f4eaa3cf 100755
--- a/lldb/examples/python/symbolication.py
+++ b/lldb/examples/python/symbolication.py
@@ -379,7 +379,7 @@ def add_module(self, target):
 return None
 resolved_path = self.get_resolved_path()
 self.module = target.AddModule(
-resolved_path, str(self.arch), uuid_str, self.symfile)
+resolved_path, None, uuid_str, self.symfile)
 if not self.module:
 return 'error: unable to get module for (%s) "%s"' % (
 self.arch, self.get_resolved_path())



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


[Lldb-commits] [lldb] 3b14d80 - [MachCore] Report arm64 thread exception state

2021-09-17 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-17T16:45:03-07:00
New Revision: 3b14d80ad4af303c9f7df189b8b7eee528d0ec8d

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

LOG: [MachCore] Report arm64 thread exception state

A MachO userspace corefile may contain LC_THREAD commands which specify
thread exception state.

For arm64* only (for now), report a human-readable version of this state
as the thread stop reason, instead of 'SIGSTOP'.

As a follow-up, similar functionality can be implemented for x86 cores
by translating the trapno/err exception registers.

rdar://82898146

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

Added: 
lldb/include/lldb/Target/AppleArm64ExceptionClass.def
lldb/include/lldb/Target/AppleArm64ExceptionClass.h
lldb/test/API/macosx/corefile-exception-reason/Makefile

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
lldb/test/API/macosx/corefile-exception-reason/main.cpp

Modified: 
lldb/include/lldb/module.modulemap
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp
lldb/test/API/functionalities/postmortem/mach-core/TestMachCore.py
lldb/test/API/functionalities/postmortem/mach-core/operating_system.py

Removed: 




diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
new file mode 100644
index 0..9a938c3b302c8
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
@@ -0,0 +1,50 @@
+/*===-- AppleArm64ExceptionClass.def ---*- C++ -*-=== 
*\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===--===*/
+
+// Defines ESR exception classes for Apple arm64* targets.
+// These largely map 1:1 to the exception classes defined in ARM's architecture
+// reference manual, but there are some Apple-specific additions.
+
+#ifndef APPLE_ARM64_EXCEPTION_CLASS
+#error "APPLE_ARM64_EXCEPTION_CLASS(Name, Code) not defined."
+#endif
+
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_UNCATEGORIZED, 0x00)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WFI_WFE, 0x01)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP15_TRAP, 0x03)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP15_TRAP, 0x04)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP14_TRAP, 0x05)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_LDC_STC_CP14_TRAP, 0x06)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_TRAP_SIMD_FP, 0x07)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PTRAUTH_INSTR_TRAP, 0x09)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP14_TRAP, 0x0c)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_ILLEGAL_INSTR_SET, 0x0e)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_32, 0x11)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_64, 0x15)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MSR_TRAP, 0x18)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PAC_FAIL, 0x1C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL0, 0x20)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL1, 0x21)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PC_ALIGN, 0x22)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL0, 0x24)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL1, 0x25)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SP_ALIGN, 0x26)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_32, 0x28)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_64, 0x2C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SERROR_INTERRUPT, 0x2F)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL0, 0x30)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL1, 0x31)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL0, 0x32)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL1, 0x33)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL0, 0x34)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL1, 0x35)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_AARCH32, 0x38)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BRK_AARCH64, 0x3C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PRIV, 0x3F)
+
+#undef APPLE_ARM64_EXCEPTION_CLASS

diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
new file mode 100644
index 0..95f58ee081abf
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
@@ -0,0 +1,50 @@
+//===-- AppleArm64ExceptionClass.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+

[Lldb-commits] [lldb] 79e48f3 - Revert "[MachCore] Report arm64 thread exception state"

2021-09-16 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-16T13:43:35-07:00
New Revision: 79e48f3c7c8ca205048f584b7658ef001a677c6d

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

LOG: Revert "[MachCore] Report arm64 thread exception state"

This reverts commit 7eb67748f9d7186419d678e807c01fc2a3811a80. It causes
TestMachCore.MachCoreTestCase to fail.

Added: 


Modified: 
lldb/include/lldb/module.modulemap
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp

Removed: 
lldb/include/lldb/Target/AppleArm64ExceptionClass.def
lldb/include/lldb/Target/AppleArm64ExceptionClass.h
lldb/test/API/macosx/corefile-exception-reason/Makefile

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
lldb/test/API/macosx/corefile-exception-reason/main.cpp



diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
deleted file mode 100644
index 9a938c3b302c8..0
--- a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
+++ /dev/null
@@ -1,50 +0,0 @@
-/*===-- AppleArm64ExceptionClass.def ---*- C++ -*-=== 
*\
-|*
-|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-|* See https://llvm.org/LICENSE.txt for license information.
-|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-|*
-\*===--===*/
-
-// Defines ESR exception classes for Apple arm64* targets.
-// These largely map 1:1 to the exception classes defined in ARM's architecture
-// reference manual, but there are some Apple-specific additions.
-
-#ifndef APPLE_ARM64_EXCEPTION_CLASS
-#error "APPLE_ARM64_EXCEPTION_CLASS(Name, Code) not defined."
-#endif
-
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_UNCATEGORIZED, 0x00)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WFI_WFE, 0x01)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP15_TRAP, 0x03)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP15_TRAP, 0x04)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP14_TRAP, 0x05)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_LDC_STC_CP14_TRAP, 0x06)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_TRAP_SIMD_FP, 0x07)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PTRAUTH_INSTR_TRAP, 0x09)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP14_TRAP, 0x0c)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_ILLEGAL_INSTR_SET, 0x0e)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_32, 0x11)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_64, 0x15)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MSR_TRAP, 0x18)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PAC_FAIL, 0x1C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL0, 0x20)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL1, 0x21)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PC_ALIGN, 0x22)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL0, 0x24)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL1, 0x25)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SP_ALIGN, 0x26)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_32, 0x28)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_64, 0x2C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SERROR_INTERRUPT, 0x2F)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL0, 0x30)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL1, 0x31)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL0, 0x32)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL1, 0x33)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL0, 0x34)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL1, 0x35)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_AARCH32, 0x38)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BRK_AARCH64, 0x3C)
-APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PRIV, 0x3F)
-
-#undef APPLE_ARM64_EXCEPTION_CLASS

diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
deleted file mode 100644
index 95f58ee081abf..0
--- a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- AppleArm64ExceptionClass.h --*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#ifndef LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
-#define LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
-
-#include 
-
-namespace lldb_private {
-
-enum class AppleArm64ExceptionClass : unsigned {
-#define APPLE_ARM64_EXCEPTION_CLASS(Name, Code) Name = Code,
-#include "AppleArm64ExceptionClass.def"
-};
-
-/// Get the Apple ARM64 exception class encoded within \p esr.
-inline AppleArm64ExceptionClass getAppleArm64ExceptionClass(uint32_t es

[Lldb-commits] [lldb] 7eb6774 - [MachCore] Report arm64 thread exception state

2021-09-16 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-16T13:35:06-07:00
New Revision: 7eb67748f9d7186419d678e807c01fc2a3811a80

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

LOG: [MachCore] Report arm64 thread exception state

A MachO userspace corefile may contain LC_THREAD commands which specify
thread exception state.

For arm64* only (for now), report a human-readable version of this state
as the thread stop reason, instead of 'SIGSTOP'.

As a follow-up, similar functionality can be implemented for x86 cores
by translating the trapno/err exception registers.

rdar://82898146

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

Added: 
lldb/include/lldb/Target/AppleArm64ExceptionClass.def
lldb/include/lldb/Target/AppleArm64ExceptionClass.h
lldb/test/API/macosx/corefile-exception-reason/Makefile

lldb/test/API/macosx/corefile-exception-reason/TestCorefileExceptionReason.py
lldb/test/API/macosx/corefile-exception-reason/main.cpp

Modified: 
lldb/include/lldb/module.modulemap
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/Process/mach-core/ThreadMachCore.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.def 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
new file mode 100644
index 0..9a938c3b302c8
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.def
@@ -0,0 +1,50 @@
+/*===-- AppleArm64ExceptionClass.def ---*- C++ -*-=== 
*\
+|*
+|* Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+|* See https://llvm.org/LICENSE.txt for license information.
+|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+|*
+\*===--===*/
+
+// Defines ESR exception classes for Apple arm64* targets.
+// These largely map 1:1 to the exception classes defined in ARM's architecture
+// reference manual, but there are some Apple-specific additions.
+
+#ifndef APPLE_ARM64_EXCEPTION_CLASS
+#error "APPLE_ARM64_EXCEPTION_CLASS(Name, Code) not defined."
+#endif
+
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_UNCATEGORIZED, 0x00)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WFI_WFE, 0x01)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP15_TRAP, 0x03)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP15_TRAP, 0x04)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCR_MRC_CP14_TRAP, 0x05)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_LDC_STC_CP14_TRAP, 0x06)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_TRAP_SIMD_FP, 0x07)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PTRAUTH_INSTR_TRAP, 0x09)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MCRR_MRRC_CP14_TRAP, 0x0c)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_ILLEGAL_INSTR_SET, 0x0e)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_32, 0x11)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SVC_64, 0x15)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_MSR_TRAP, 0x18)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PAC_FAIL, 0x1C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL0, 0x20)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_IABORT_EL1, 0x21)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PC_ALIGN, 0x22)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL0, 0x24)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_DABORT_EL1, 0x25)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SP_ALIGN, 0x26)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_32, 0x28)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_FLOATING_POINT_64, 0x2C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SERROR_INTERRUPT, 0x2F)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL0, 0x30)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_REG_MATCH_EL1, 0x31)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL0, 0x32)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_SW_STEP_DEBUG_EL1, 0x33)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL0, 0x34)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_WATCHPT_MATCH_EL1, 0x35)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BKPT_AARCH32, 0x38)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_BRK_AARCH64, 0x3C)
+APPLE_ARM64_EXCEPTION_CLASS(ESR_EC_PRIV, 0x3F)
+
+#undef APPLE_ARM64_EXCEPTION_CLASS

diff  --git a/lldb/include/lldb/Target/AppleArm64ExceptionClass.h 
b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
new file mode 100644
index 0..95f58ee081abf
--- /dev/null
+++ b/lldb/include/lldb/Target/AppleArm64ExceptionClass.h
@@ -0,0 +1,50 @@
+//===-- AppleArm64ExceptionClass.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
+#define LLDB_TARGET_APPLEARM64EXCEPTIONCLASS_H
+
+#include 
+
+namespace lldb_private {
+
+enum c

[Lldb-commits] [lldb] 66902a3 - [StopInfoMachException] Summarize arm64e BLRAx/LDRAx auth failures

2021-09-14 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-09-14T13:31:52-07:00
New Revision: 66902a32c83809d26662f76e4107d5dd777610c3

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

LOG: [StopInfoMachException] Summarize arm64e BLRAx/LDRAx auth failures

Upstream lldb support for summarizing BLRAx and LDRAx auth failures.

rdar://41615322

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

Added: 
lldb/test/API/functionalities/ptrauth_diagnostics/BLRAA_error/Makefile

lldb/test/API/functionalities/ptrauth_diagnostics/BLRAA_error/TestPtrauthBLRAADiagnostic.py
lldb/test/API/functionalities/ptrauth_diagnostics/BLRAA_error/blraa.c
lldb/test/API/functionalities/ptrauth_diagnostics/BRAA_error/Makefile

lldb/test/API/functionalities/ptrauth_diagnostics/BRAA_error/TestPtrauthBRAADiagnostic.py
lldb/test/API/functionalities/ptrauth_diagnostics/BRAA_error/braa.c
lldb/test/API/functionalities/ptrauth_diagnostics/LDRAA_error/Makefile

lldb/test/API/functionalities/ptrauth_diagnostics/LDRAA_error/TestPtrauthLDRAADiagnostic.py
lldb/test/API/functionalities/ptrauth_diagnostics/LDRAA_error/ldraa.c
lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_code/Makefile

lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_code/TestPtrauthBRKc47xDiagnostic.py
lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_code/brkC47x.c

lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_x16_invalid/Makefile

lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_x16_invalid/TestPtrauthBRKc47xX16Invalid.py

lldb/test/API/functionalities/ptrauth_diagnostics/brkC47x_x16_invalid/brkC47x.c

Modified: 
lldb/include/lldb/Core/Address.h
lldb/include/lldb/Core/Disassembler.h
lldb/source/Core/Address.cpp
lldb/source/Core/Disassembler.cpp
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
lldb/source/Plugins/Process/Utility/StopInfoMachException.h

Removed: 




diff  --git a/lldb/include/lldb/Core/Address.h 
b/lldb/include/lldb/Core/Address.h
index ec393a1871e35..dc50e27ca277a 100644
--- a/lldb/include/lldb/Core/Address.h
+++ b/lldb/include/lldb/Core/Address.h
@@ -210,6 +210,10 @@ class Address {
 }
   };
 
+  /// Write a description of this object to a Stream.
+  bool GetDescription(Stream &s, Target &target,
+  lldb::DescriptionLevel level) const;
+
   /// Dump a description of this object to a Stream.
   ///
   /// Dump a description of the contents of this object to the supplied stream

diff  --git a/lldb/include/lldb/Core/Disassembler.h 
b/lldb/include/lldb/Core/Disassembler.h
index 622c23ff64928..0925bf358b9c3 100644
--- a/lldb/include/lldb/Core/Disassembler.h
+++ b/lldb/include/lldb/Core/Disassembler.h
@@ -150,6 +150,10 @@ class Instruction {
 
   virtual bool HasDelaySlot();
 
+  virtual bool IsLoad() = 0;
+
+  virtual bool IsAuthenticated() = 0;
+
   bool CanSetBreakpoint ();
 
   virtual size_t Decode(const Disassembler &disassembler,
@@ -336,6 +340,10 @@ class PseudoInstruction : public Instruction {
 
   bool HasDelaySlot() override;
 
+  bool IsLoad() override;
+
+  bool IsAuthenticated() override;
+
   void CalculateMnemonicOperandsAndComment(
   const ExecutionContext *exe_ctx) override {
 // TODO: fill this in and put opcode name into Instruction::m_opcode_name,

diff  --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index f0c7e2b34f99c..122bed924b420 100644
--- a/lldb/source/Core/Address.cpp
+++ b/lldb/source/Core/Address.cpp
@@ -389,6 +389,19 @@ bool Address::SetOpcodeLoadAddress(lldb::addr_t load_addr, 
Target *target,
   return false;
 }
 
+bool Address::GetDescription(Stream &s, Target &target,
+ DescriptionLevel level) const {
+  assert(level == eDescriptionLevelBrief &&
+ "Non-brief descriptions not implemented");
+  LineEntry line_entry;
+  if (CalculateSymbolContextLineEntry(line_entry)) {
+s.Printf(" (%s:%u:%u)", line_entry.file.GetFilename().GetCString(),
+ line_entry.line, line_entry.column);
+return true;
+  }
+  return false;
+}
+
 bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle 
style,
DumpStyle fallback_style, uint32_t addr_size) const {
   // If the section was nullptr, only load address is going to work unless we

diff  --git a/lldb/source/Core/Disassembler.cpp 
b/lldb/source/Core/Disassembler.cpp
index 704b3df4b2ac8..d147f8fbb0dba 100644
--- a/lldb/source/Core/Disassembler.cpp
+++ b/lldb/source/Core/Disassembler.cpp
@@ -1123,6 +1123,10 @@ bool PseudoInstruction::HasDelaySlot() {
   return false;
 }
 
+bool PseudoInstruction::IsLoad() { return false; }
+
+bool PseudoInstruction::Is

[Lldb-commits] [lldb] 7d15fb5 - [lldb/test] Respect --apple-sdk path when querying SDK info

2021-04-01 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-04-01T10:15:25-07:00
New Revision: 7d15fb5779452c5efbceb82ce0e1f8724a82d290

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

LOG: [lldb/test] Respect --apple-sdk path when querying SDK info

Respect --apple-sdk  if it's specified. If the SDK is simply
mounted from some disk image, and not actually installed, this is the
only way to use it.

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

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index d4fd7f4b1f654..06a84c2554000 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -21,6 +21,7 @@
 # LLDB modules
 import lldb
 from . import lldbtest_config
+from . import configuration
 
 # How often failed simulator process launches are retried.
 SIMULATOR_RETRY = 3
@@ -62,6 +63,11 @@ def mkdir_p(path):
 # 
 
 def get_xcode_sdk(os, env):
+# Respect --apple-sdk  if it's specified. If the SDK is simply
+# mounted from some disk image, and not actually installed, this is the
+# only way to use it.
+if configuration.apple_sdk:
+return configuration.apple_sdk
 if os == "ios":
 if env == "simulator":
 return "iphonesimulator"



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


[Lldb-commits] [lldb] 414412d - [lldb/Commands] Fix spelling of target.move-to-nearest-code in helptext

2021-03-25 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-25T14:25:10-07:00
New Revision: 414412d3dcbcf1fae0dc217085b63ab08ac41f37

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

LOG: [lldb/Commands] Fix spelling of target.move-to-nearest-code in helptext

Added: 


Modified: 
lldb/source/Commands/Options.td

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index c19874f73120..1cc190ebc211 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -200,7 +200,7 @@ let Command = "breakpoint set" in {
   def breakpoint_set_move_to_nearest_code : Option<"move-to-nearest-code", 
"m">,
 Groups<[1,9,12]>, Arg<"Boolean">,
 Desc<"Move breakpoints to nearest code. If not set the "
-"target.move-to-nearest-codesetting is used.">;
+"target.move-to-nearest-code setting is used.">;
   def breakpoint_set_file_colon_line : Option<"joint-specifier", "y">, 
Group<12>, Arg<"FileLineColumn">,
 Required, Completion<"SourceFile">,
 Desc<"A specifier in the form filename:line[:column] for setting file & 
line breakpoints.">;



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


[Lldb-commits] [lldb] 4bd2bfb - [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T16:06:00-07:00
New Revision: 4bd2bfb6ec0980853d7f9d1874e0547b68b7a61e

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

LOG: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY (reapply)

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

This was previously committed as cb8c1ee269da and reverted due to
unknown failures on the Linux bots. This version adds additional asserts
to check that the shared objects are where we expect them & that calling
f1() from libt1 produces the expected value. The Linux failure is
tracked by https://bugs.llvm.org/show_bug.cgi?id=49656.

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

Added: 
lldb/test/API/.lit_test_times.txt
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c

Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index c8a006001fcb..3e5f1451ef5f 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // about unavailable symbols.
+  //
+  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
+  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
+  const int RTLD_LAZY = 1;
+
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -595,7 +607,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, 2);
+  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -609,7 +621,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, 2);
+  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/.lit_test_times.txt 
b/lldb/test/API/.lit_test_times.txt
new file mode 100644
index ..5b848a0183c9
--- /dev/null
+++ b/lldb/test/API/.lit_test_times.txt
@@ -0,0 +1 @@
+2.777875e+00 functionalities/load_lazy/TestLoadUsingLazyBind.py

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
new file mode 100644
index ..7200114d03ae
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,18 @@
+CXX_SOURCES := main.cpp
+USE_LIBDL := 1
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff

[Lldb-commits] [lldb] d8d5ef2 - Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T15:26:16-07:00
New Revision: d8d5ef2e9d84fbbc2878b3fd977f9c62ea0661d7

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

LOG: Revert "[lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY"

This reverts commit cb8c1ee269da72eb6e2c18800cd8ab0a74050785. The test
is failing on Debian for unknown reasons.

https://lab.llvm.org/buildbot/#/builders/68/builds/8990

Added: 


Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c



diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index 3e5f1451ef5f..c8a006001fcb 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,19 +578,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
-  //
-  // Use lazy binding so as to not make dlopen()'s success conditional on
-  // forcing every symbol in the library.
-  //
-  // In general, the debugger should allow programs to load & run with
-  // libraries as far as they can, instead of defaulting to being super-picky
-  // about unavailable symbols.
-  //
-  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
-  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
-  const int RTLD_LAZY = 1;
-
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -607,7 +595,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
+  result_ptr->image_ptr = dlopen(name, 2);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -621,7 +609,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
+  result_ptr->image_ptr = dlopen(buffer, 2);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
deleted file mode 100644
index 14eff232bb6d..
--- a/lldb/test/API/functionalities/load_lazy/Makefile
+++ /dev/null
@@ -1,17 +0,0 @@
-CXX_SOURCES := main.cpp
-
-all: t2_0 t2_1 t1 a.out
-
-include Makefile.rules
-
-t1: t2_0
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
-
-t2_0:
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
-
-t2_1:
-   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
-   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff  --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py 
b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
deleted file mode 100644
index 18135a18bdaf..
--- a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""
-Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
-"""
-
-
-
-import os
-import shutil
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-@skipIfRemote
-@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
-class LoadUsingLazyBind(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-NO_DEBUG_INFO_TESTCASE = True
-
-def setUp(self):
-# Call super's setUp().
-TestBase.setUp(self)
-
-# Invoke the default build rule.
-self.build()
-
-self.wd = os.path.realpath(self.getBuildDir())
-
-self.ext = 'so'
-if self.platformIsDarwin():
-self.ext = 'dylib'
-
-# Overwrite t2_0 with t2_1 to delete the definition of `use`.
-shutil.copy(os.path.join(self.wd, 'libt2_1.{}'.fo

[Lldb-commits] [lldb] cb8c1ee - [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

2021-03-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-19T15:13:43-07:00
New Revision: cb8c1ee269da72eb6e2c18800cd8ab0a74050785

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

LOG: [lldb/PlatformPOSIX] Change LoadImage default to RTLD_LAZY

In general, it seems like the debugger should allow programs to load & run with
libraries as far as possible, instead of defaulting to being super-picky about
unavailable symbols.

This is critical on macOS/Darwin, as libswiftCore.dylib may 1) export a version
symbol using @available markup and then 2) expect that other exported APIs are
only dynamically used once the version symbol is checked. We can't open a
version of the library built with a bleeding-edge SDK on an older OS without
RTLD_LAXY (or pervasive/expensive @available markup added to dyld APIs).

See: https://lists.llvm.org/pipermail/lldb-dev/2021-March/016796.html

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

Added: 
lldb/test/API/functionalities/load_lazy/Makefile
lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
lldb/test/API/functionalities/load_lazy/categories
lldb/test/API/functionalities/load_lazy/main.cpp
lldb/test/API/functionalities/load_lazy/t1.c
lldb/test/API/functionalities/load_lazy/t2_0.c
lldb/test/API/functionalities/load_lazy/t2_1.c

Modified: 
lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp 
b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
index c8a006001fcb..3e5f1451ef5f 100644
--- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
@@ -578,7 +578,19 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   // __lldb_dlopen_result for consistency. The wrapper returns a void * but
   // doesn't use it because UtilityFunctions don't work with void returns at
   // present.
+  //
+  // Use lazy binding so as to not make dlopen()'s success conditional on
+  // forcing every symbol in the library.
+  //
+  // In general, the debugger should allow programs to load & run with
+  // libraries as far as they can, instead of defaulting to being super-picky
+  // about unavailable symbols.
+  //
+  // The value "1" appears to imply lazy binding (RTLD_LAZY) on both Darwin
+  // and other POSIX OSes.
   static const char *dlopen_wrapper_code = R"(
+  const int RTLD_LAZY = 1;
+
   struct __lldb_dlopen_result {
 void *image_ptr;
 const char *error_str;
@@ -595,7 +607,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   {
 // This is the case where the name is the full path:
 if (!path_strings) {
-  result_ptr->image_ptr = dlopen(name, 2);
+  result_ptr->image_ptr = dlopen(name, RTLD_LAZY);
   if (result_ptr->image_ptr)
 result_ptr->error_str = nullptr;
   return nullptr;
@@ -609,7 +621,7 @@ 
PlatformPOSIX::MakeLoadImageUtilityFunction(ExecutionContext &exe_ctx,
   buffer[path_len] = '/';
   char *target_ptr = buffer+path_len+1; 
   memcpy((void *) target_ptr, (void *) name, name_len + 1);
-  result_ptr->image_ptr = dlopen(buffer, 2);
+  result_ptr->image_ptr = dlopen(buffer, RTLD_LAZY);
   if (result_ptr->image_ptr) {
 result_ptr->error_str = nullptr;
 break;

diff  --git a/lldb/test/API/functionalities/load_lazy/Makefile 
b/lldb/test/API/functionalities/load_lazy/Makefile
new file mode 100644
index ..14eff232bb6d
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/Makefile
@@ -0,0 +1,17 @@
+CXX_SOURCES := main.cpp
+
+all: t2_0 t2_1 t1 a.out
+
+include Makefile.rules
+
+t1: t2_0
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t1.c DYLIB_NAME=t1 
LD_EXTRAS="-L. -lt2_0"
+
+t2_0:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_0.c DYLIB_NAME=t2_0
+
+t2_1:
+   $(MAKE) VPATH=$(SRCDIR) -f $(MAKEFILE_RULES) \
+   DYLIB_ONLY=YES DYLIB_C_SOURCES=t2_1.c DYLIB_NAME=t2_1

diff  --git a/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py 
b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
new file mode 100644
index ..18135a18bdaf
--- /dev/null
+++ b/lldb/test/API/functionalities/load_lazy/TestLoadUsingLazyBind.py
@@ -0,0 +1,54 @@
+"""
+Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
+"""
+
+
+
+import os
+import shutil
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+@skipIfRemote
+@skipIfWindows # The Windows platform doesn't implement DoLoadImage.
+class LoadUsingLazyBind(TestBase):
+
+mydir = Test

[Lldb-commits] [lldb] ac29c35 - [lldb/Platform] Skip very slow xcrun queries for simulator platforms, NFC

2021-03-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2021-03-10T13:57:10-08:00
New Revision: ac29c35207a506eedaaea8a4196b83facbf978da

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

LOG: [lldb/Platform] Skip very slow xcrun queries for simulator platforms, NFC

GetXcodeSDK() consistently takes over 1 second to complete if the
queried SDK is missing, because `xcrun` doesn't cache negative lookups.

Because there are multiple simulator platforms, this can add 4+ seconds
to `lldb -b some_object_file.o`.

To work around this, skip the call to GetXcodeSDK() when setting up
simulator platforms if the specified arch doesn't have what looks like a
simulator triple.

Some other ways to fix this:
- Fix caching in xcrun (rdar://74882205)
- Test for arch compat before calling SomePlatform::CreateInstance() (much
  larger change)

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

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index 342f7c214a76..afbffc2ef0a3 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -505,6 +505,16 @@ uint32_t PlatformAppleSimulator::FindProcesses(
   return process_infos.size();
 }
 
+/// Whether to skip creating a simulator platform.
+static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
+  // If the arch is known not to specify a simulator environment, skip creating
+  // the simulator platform (we can create it later if there's a matching 
arch).
+  // This avoids very slow xcrun queries for non-simulator archs (the slowness
+  // is due to xcrun not caching negative queries (rdar://74882205)).
+  return !force && arch && arch->IsValid() &&
+ !arch->TripleEnvironmentWasSpecified();
+}
+
 static llvm::StringRef GetXcodeSDKDir(std::string preferred,
   std::string secondary) {
   llvm::StringRef sdk;
@@ -530,6 +540,8 @@ struct PlatformiOSSimulator {
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+if (shouldSkipSimulatorPlatform(force, arch))
+  return nullptr;
 llvm::StringRef sdk;
 sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.Internal.sdk"));
 if (sdk.empty())
@@ -578,6 +590,8 @@ struct PlatformAppleTVSimulator {
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+if (shouldSkipSimulatorPlatform(force, arch))
+  return nullptr;
 return PlatformAppleSimulator::CreateInstance(
 "PlatformAppleTVSimulator", g_tvos_description,
 ConstString(g_tvos_plugin_name),
@@ -619,6 +633,8 @@ struct PlatformAppleWatchSimulator {
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+if (shouldSkipSimulatorPlatform(force, arch))
+  return nullptr;
 return PlatformAppleSimulator::CreateInstance(
 "PlatformAppleWatchSimulator", g_watchos_description,
 ConstString(g_watchos_plugin_name),



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


[Lldb-commits] [lldb] fc8c1ea - [lldb/test] Add missing decorators import

2020-11-11 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-11T10:48:27-08:00
New Revision: fc8c1ea9aff376526e5e18f60caaf84b81785886

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

LOG: [lldb/test] Add missing decorators import

Added: 


Modified: 
lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py

Removed: 




diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
index ca58b4afcb57..36588606b651 100644
--- a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -7,6 +7,7 @@
 import lldb
 from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.decorators import *
 
 
 class ThreadStepInAvoidRegexTestCase(TestBase):



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


[Lldb-commits] [lldb] b7c06dc - [ThreadPlan] Add a test for `thread step-in -r`, NFC (reapply)

2020-11-11 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-11T10:43:38-08:00
New Revision: b7c06dcb739f8a30c8dc9d4cc8832a9c939a1c49

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

LOG: [ThreadPlan] Add a test for `thread step-in -r`, NFC (reapply)

Adds test coverage for ThreadPlanStepInRange::SetAvoidRegexp, but
disables the test on Windows.

See:
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Target/ThreadPlanStepInRange.cpp.html#L309

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

Added: 
lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/lang/c/stepping/main.c

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f7d59a8a065c..89c25eb55516 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"

diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
new file mode 100644
index ..ca58b4afcb57
--- /dev/null
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,34 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+@skipIfWindows
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])

diff  --git a/lldb/test/API/lang/c/stepping/main.c 
b/lldb/test/API/lang/c/stepping/main.c
index 43b5cfab183a..8237ebf984c9 100644
--- a/lldb/test/API/lang/c/stepping/main.c
+++ b/lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@ int main (int argc, char const *argv[])
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 



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


Re: [Lldb-commits] [lldb] d9624f4 - Revert "[ThreadPlan] Add a test for `thread step-in -r`, NFC"

2020-11-11 Thread Vedant Kumar via lldb-commits
Thanks for the revert.

Do you know anyone actively working on ThreadPlan support for Windows?

vedant

> On Nov 11, 2020, at 9:10 AM, Stella Stamenova via lldb-commits 
>  wrote:
> 
> 
> Author: Stella Stamenova
> Date: 2020-11-11T09:09:43-08:00
> New Revision: d9624f444807bdac92e37f85ab07db1eb8a2bdf2
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/d9624f444807bdac92e37f85ab07db1eb8a2bdf2
> DIFF: 
> https://github.com/llvm/llvm-project/commit/d9624f444807bdac92e37f85ab07db1eb8a2bdf2.diff
> 
> LOG: Revert "[ThreadPlan] Add a test for `thread step-in -r`, NFC"
> 
> This reverts commit ae3640e386ccfbe0e984cc8c4b0399006ed835c7.
> 
> The new test is failing on the Windows LLDB buildbot.
> 
> Added: 
> 
> 
> Modified: 
>lldb/packages/Python/lldbsuite/test/lldbtest.py
>lldb/test/API/lang/c/stepping/main.c
> 
> Removed: 
>lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
> 
> 
> 
> diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
> b/lldb/packages/Python/lldbsuite/test/lldbtest.py
> index 89c25eb55516..f7d59a8a065c 100644
> --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
> +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
> @@ -126,8 +126,6 @@
> 
> SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
> 
> -STEP_IN_SUCCEEDED = "Thread step-in succeeded"
> -
> STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
> 
> STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
> exception"
> 
> diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py 
> b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
> deleted file mode 100644
> index 0b59f625bd69..
> --- a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -"""
> -Test thread step-in [ -r | --step-over-regexp ].
> -"""
> -
> -
> -
> -import lldb
> -from lldbsuite.test.lldbtest import *
> -import lldbsuite.test.lldbutil as lldbutil
> -
> -
> -class ThreadStepInAvoidRegexTestCase(TestBase):
> -
> -mydir = TestBase.compute_mydir(__file__)
> -
> -def setUp(self):
> -TestBase.setUp(self)
> -self.line2 = line_number('main.c', '// assignment to B2')
> -
> -def test_step_out_avoid_regexp(self):
> -"""Exercise thread step-in -r"""
> -self.build()
> -lldbutil.run_to_source_breakpoint(self,
> -'frame select 2, thread step-out while stopped',
> -lldb.SBFileSpec('main.c'))
> -
> -# Now step in, skipping the frames for 'b' and 'a'.
> -self.runCmd("thread step-in -r 'a'")
> -
> -# We should be at the assignment to B2.
> -self.expect("thread backtrace", STEP_IN_SUCCEEDED,
> -substrs=["stop reason = step in"],
> -patterns=["frame #0.*main.c:%d" % self.line2])
> 
> diff  --git a/lldb/test/API/lang/c/stepping/main.c 
> b/lldb/test/API/lang/c/stepping/main.c
> index 8237ebf984c9..43b5cfab183a 100644
> --- a/lldb/test/API/lang/c/stepping/main.c
> +++ b/lldb/test/API/lang/c/stepping/main.c
> @@ -39,7 +39,7 @@ int main (int argc, char const *argv[])
> {
> int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
> 
> -int B2 = b(2); // assignment to B2
> +int B2 = b(2);
> 
> int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
> 
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] 9922dde - [test] Delete redundant lldbutil import, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:37:47-08:00
New Revision: 9922dded4737ff640f046f62f83bf1d05f26d97d

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

LOG: [test] Delete redundant lldbutil import, NFC

Added: 


Modified: 
lldb/test/API/lang/c/stepping/TestThreadStepping.py

Removed: 




diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepping.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepping.py
index 43ed10d8b1a8..c134c95cf485 100644
--- a/lldb/test/API/lang/c/stepping/TestThreadStepping.py
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepping.py
@@ -5,7 +5,6 @@
 
 
 import lldb
-import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
 import lldbsuite.test.lldbutil as lldbutil
 



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


[Lldb-commits] [lldb] ae3640e - [ThreadPlan] Add a test for `thread step-in -r`, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:37:47-08:00
New Revision: ae3640e386ccfbe0e984cc8c4b0399006ed835c7

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

LOG: [ThreadPlan] Add a test for `thread step-in -r`, NFC

Adds test coverage for ThreadPlanStepInRange::SetAvoidRegexp.

See:
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Target/ThreadPlanStepInRange.cpp.html#L309

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

Added: 
lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py

Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/test/API/lang/c/stepping/main.c

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index f7d59a8a065c..89c25eb55516 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -126,6 +126,8 @@
 
 SOURCE_DISPLAYED_CORRECTLY = "Source code displayed correctly"
 
+STEP_IN_SUCCEEDED = "Thread step-in succeeded"
+
 STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
 
 STOPPED_DUE_TO_EXC_BAD_ACCESS = "Process should be stopped due to bad access 
exception"

diff  --git a/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py 
b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
new file mode 100644
index ..0b59f625bd69
--- /dev/null
+++ b/lldb/test/API/lang/c/stepping/TestThreadStepInAvoidRegexp.py
@@ -0,0 +1,33 @@
+"""
+Test thread step-in [ -r | --step-over-regexp ].
+"""
+
+
+
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+
+class ThreadStepInAvoidRegexTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.line2 = line_number('main.c', '// assignment to B2')
+
+def test_step_out_avoid_regexp(self):
+"""Exercise thread step-in -r"""
+self.build()
+lldbutil.run_to_source_breakpoint(self,
+'frame select 2, thread step-out while stopped',
+lldb.SBFileSpec('main.c'))
+
+# Now step in, skipping the frames for 'b' and 'a'.
+self.runCmd("thread step-in -r 'a'")
+
+# We should be at the assignment to B2.
+self.expect("thread backtrace", STEP_IN_SUCCEEDED,
+substrs=["stop reason = step in"],
+patterns=["frame #0.*main.c:%d" % self.line2])

diff  --git a/lldb/test/API/lang/c/stepping/main.c 
b/lldb/test/API/lang/c/stepping/main.c
index 43b5cfab183a..8237ebf984c9 100644
--- a/lldb/test/API/lang/c/stepping/main.c
+++ b/lldb/test/API/lang/c/stepping/main.c
@@ -39,7 +39,7 @@ int main (int argc, char const *argv[])
 {
 int A1 = a(1); // frame select 2, thread step-out while stopped at "c(1)"
 
-int B2 = b(2);
+int B2 = b(2); // assignment to B2
 
 int A3 = a(3); // frame select 1, thread step-out while stopped at "c(3)"
 



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


[Lldb-commits] [lldb] 34d56b0 - [ThreadPlan] Reflow docs to fit the 80 column limit, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:14:52-08:00
New Revision: 34d56b05fd78f0d3043f7f02badf7067cecadb30

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

LOG: [ThreadPlan] Reflow docs to fit the 80 column limit, NFC

Added: 


Modified: 
lldb/include/lldb/Target/ThreadPlan.h

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlan.h 
b/lldb/include/lldb/Target/ThreadPlan.h
index 8c2f9776eeb3..f4cd2b18f01a 100644
--- a/lldb/include/lldb/Target/ThreadPlan.h
+++ b/lldb/include/lldb/Target/ThreadPlan.h
@@ -23,310 +23,260 @@
 namespace lldb_private {
 
 //  ThreadPlan:
+//
 //  This is the pure virtual base class for thread plans.
 //
-//  The thread plans provide the "atoms" of behavior that
-//  all the logical process control, either directly from commands or through
-//  more complex composite plans will rely on.
+//  The thread plans provide the "atoms" of behavior that all the logical
+//  process control, either directly from commands or through more complex
+//  composite plans will rely on.
 //
 //  Plan Stack:
 //
-//  The thread maintaining a thread plan stack, and you program the actions of 
a
-//  particular thread
-//  by pushing plans onto the plan stack.
-//  There is always a "Current" plan, which is the top of the plan stack,
-//  though in some cases
+//  The thread maintaining a thread plan stack, and you program the actions of
+//  a particular thread by pushing plans onto the plan stack.  There is always
+//  a "Current" plan, which is the top of the plan stack, though in some cases
 //  a plan may defer to plans higher in the stack for some piece of information
 //  (let us define that the plan stack grows downwards).
 //
 //  The plan stack is never empty, there is always a Base Plan which persists
-//  through the life
-//  of the running process.
+//  through the life of the running process.
 //
 //
 //  Creating Plans:
 //
-//  The thread plan is generally created and added to the plan stack through 
the
-//  QueueThreadPlanFor... API
-//  in lldb::Thread.  Those API's will return the plan that performs the named
-//  operation in a manner
-//  appropriate for the current process.  The plans in lldb/source/Target are
-//  generic
+//  The thread plan is generally created and added to the plan stack through
+//  the QueueThreadPlanFor... API in lldb::Thread.  Those API's will return the
+//  plan that performs the named operation in a manner appropriate for the
+//  current process.  The plans in lldb/source/Target are generic
 //  implementations, but a Process plugin can override them.
 //
 //  ValidatePlan is then called.  If it returns false, the plan is unshipped.
-//  This is a little
-//  convenience which keeps us from having to error out of the constructor.
+//  This is a little convenience which keeps us from having to error out of the
+//  constructor.
 //
 //  Then the plan is added to the plan stack.  When the plan is added to the
-//  plan stack its DidPush
-//  will get called.  This is useful if a plan wants to push any additional
-//  plans as it is constructed,
-//  since you need to make sure you're already on the stack before you push
-//  additional plans.
+//  plan stack its DidPush will get called.  This is useful if a plan wants to
+//  push any additional plans as it is constructed, since you need to make sure
+//  you're already on the stack before you push additional plans.
 //
 //  Completed Plans:
 //
-//  When the target process stops the plans are queried, among other things, 
for
-//  whether their job is done.
-//  If it is they are moved from the plan stack to the Completed Plan stack in
-//  reverse order from their position
-//  on the plan stack (since multiple plans may be done at a given stop.)  This
-//  is used primarily so that
-//  the lldb::Thread::StopInfo for the thread can be set properly.  If one plan
-//  pushes another to achieve part of
-//  its job, but it doesn't want that sub-plan to be the one that sets the
-//  StopInfo, then call SetPrivate on the
-//  sub-plan when you create it, and the Thread will pass over that plan in
-//  reporting the reason for the stop.
+//  When the target process stops the plans are queried, among other things,
+//  for whether their job is done.  If it is they are moved from the plan stack
+//  to the Completed Plan stack in reverse order from their position on the
+//  plan stack (since multiple plans may be done at a given stop.)  This is
+//  used primarily so that the lldb::Thread::StopInfo for the thread can be set
+//  properly.  If one plan pushes another to achieve part of its job, but it
+//  doesn't want that sub-plan to be the one that sets the StopInfo, then call
+//  SetPrivate on the sub-plan when you create it, and the Thread will pass
+//  over 

[Lldb-commits] [lldb] ba21376 - [Command] Fix accidental word concatenation in Options.td

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:13:39-08:00
New Revision: ba21376883d4527204ab6716597ca179e0b76157

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

LOG: [Command] Fix accidental word concatenation in Options.td

Split up words that appear to have been accidentally concatenated.

This looks to be exhaustive: to find these in vim, use:

/\v[^ ]"\n +"[^ ]

Added: 


Modified: 
lldb/source/Commands/Options.td

Removed: 




diff  --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 0be497e4759e..7522f47ca57d 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -372,7 +372,7 @@ let Command = "expression" in {
 "top-level entities without a $ prefix.">;
   def expression_options_allow_jit : Option<"allow-jit", "j">, Groups<[1,2]>,
 Arg<"Boolean">,
-Desc<"Controls whether the expression can fall back to being JITted if 
it's"
+Desc<"Controls whether the expression can fall back to being JITted if 
it's "
 "not supported by the interpreter (defaults to true).">;
 }
 
@@ -952,7 +952,7 @@ let Command = "thread step scope" in {
 EnumArg<"RunMode", "TriRunningModes()">, Desc<"Determine how to run other "
 "threads while stepping the current thread.">;
   def thread_step_scope_step_over_regexp : Option<"step-over-regexp", "r">,
-Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that 
defines"
+Group<1>, Arg<"RegularExpression">, Desc<"A regular expression that 
defines "
 "function names to not to stop at when stepping in.">;
   def thread_step_scope_step_in_target : Option<"step-in-target", "t">,
 Group<1>, Arg<"FunctionName">, Desc<"The name of the directly called "
@@ -965,10 +965,10 @@ let Command = "thread until" in {
   def thread_until_thread : Option<"thread", "t">, Group<1>, 
Arg<"ThreadIndex">,
 Desc<"Thread index for the thread for until operation">;
   def thread_until_run_mode : Option<"run-mode", "m">, Group<1>,
-EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other"
+EnumArg<"RunMode", "DuoRunningModes()">, Desc<"Determine how to run other "
 "threads while stepping this one">;
   def thread_until_address : Option<"address", "a">, Group<1>,
-Arg<"AddressOrExpression">, Desc<"Run until we reach the specified 
address,"
+Arg<"AddressOrExpression">, Desc<"Run until we reach the specified 
address, "
 "or leave the function - can be specified multiple times.">;
 }
 
@@ -1158,7 +1158,7 @@ let Command = "watchpoint list" in {
 "brief description of the watchpoint (no location info).">;
   def watchpoint_list_full : Option<"full", "f">, Group<2>, Desc<"Give a full "
 "description of the watchpoint and its locations.">;
-  def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, 
Desc<"Explain"
+  def watchpoint_list_verbose : Option<"verbose", "v">, Group<3>, 
Desc<"Explain "
 "everything we know about the watchpoint (for debugging debugger bugs).">;
 }
 



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


[Lldb-commits] [lldb] 04cd6c6 - [ThreadPlan] Delete unused ThreadPlanStepInRange code, NFC

2020-11-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-10T16:15:03-08:00
New Revision: 04cd6c62176ce027af2d343044b84ce5d317aee7

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

LOG: [ThreadPlan] Delete unused ThreadPlanStepInRange code, NFC

Added: 


Modified: 
lldb/include/lldb/Target/ThreadPlanStepInRange.h
lldb/source/Target/ThreadPlanStepInRange.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/ThreadPlanStepInRange.h 
b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
index 59b5721998b5..a26b0fb87b3a 100644
--- a/lldb/include/lldb/Target/ThreadPlanStepInRange.h
+++ b/lldb/include/lldb/Target/ThreadPlanStepInRange.h
@@ -26,13 +26,6 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
 LazyBool step_in_avoids_code_without_debug_info,
 LazyBool step_out_avoids_code_without_debug_info);
 
-  ThreadPlanStepInRange(Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context,
-const char *step_into_function_name,
-lldb::RunMode stop_others,
-LazyBool step_in_avoids_code_without_debug_info,
-LazyBool step_out_avoids_code_without_debug_info);
-
   ~ThreadPlanStepInRange() override;
 
   void GetDescription(Stream *s, lldb::DescriptionLevel level) override;
@@ -78,17 +71,6 @@ class ThreadPlanStepInRange : public ThreadPlanStepRange,
   bool FrameMatchesAvoidCriteria();
 
 private:
-  friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepOverRange(
-  bool abort_other_plans, const AddressRange &range,
-  const SymbolContext &addr_context, lldb::RunMode stop_others,
-  Status &status, LazyBool avoid_code_without_debug_info);
-  friend lldb::ThreadPlanSP Thread::QueueThreadPlanForStepInRange(
-  bool abort_other_plans, const AddressRange &range,
-  const SymbolContext &addr_context, const char *step_in_target,
-  lldb::RunMode stop_others, Status &status,
-  LazyBool step_in_avoids_code_without_debug_info,
-  LazyBool step_out_avoids_code_without_debug_info);
-
   void SetupAvoidNoDebug(LazyBool step_in_avoids_code_without_debug_info,
  LazyBool step_out_avoids_code_without_debug_info);
   // Need an appropriate marker for the current stack so we can tell step out

diff  --git a/lldb/source/Target/ThreadPlanStepInRange.cpp 
b/lldb/source/Target/ThreadPlanStepInRange.cpp
index c5f81d6665a1..a03bd93ac638 100644
--- a/lldb/source/Target/ThreadPlanStepInRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepInRange.cpp
@@ -47,22 +47,6 @@ ThreadPlanStepInRange::ThreadPlanStepInRange(
 step_out_avoids_code_without_debug_info);
 }
 
-ThreadPlanStepInRange::ThreadPlanStepInRange(
-Thread &thread, const AddressRange &range,
-const SymbolContext &addr_context, const char *step_into_target,
-lldb::RunMode stop_others, LazyBool step_in_avoids_code_without_debug_info,
-LazyBool step_out_avoids_code_without_debug_info)
-: ThreadPlanStepRange(ThreadPlan::eKindStepInRange,
-  "Step Range stepping in", thread, range, 
addr_context,
-  stop_others),
-  ThreadPlanShouldStopHere(this), m_step_past_prologue(true),
-  m_virtual_step(false), m_step_into_target(step_into_target) {
-  SetCallbacks();
-  SetFlagsToDefault();
-  SetupAvoidNoDebug(step_in_avoids_code_without_debug_info,
-step_out_avoids_code_without_debug_info);
-}
-
 ThreadPlanStepInRange::~ThreadPlanStepInRange() = default;
 
 void ThreadPlanStepInRange::SetupAvoidNoDebug(



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


[Lldb-commits] [lldb] 65d15fe - [TargetList] Delete the destructor

2020-11-05 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-05T16:56:37-08:00
New Revision: 65d15fefe3392b1db2f679b3df029d43d8d26d2d

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

LOG: [TargetList] Delete the destructor

AFAICT, ~TargetList simply implements the default destructor, plus some
locking.

The history is murky, so I'm not sure why we do this locking. Perhaps,
at some point, it was possible to delete the same TargetList instance
from two different threads, setting up a race. If that were true, then
the locking would protect against the race.

Since TargetList is uniquely owned by Debugger (m_target_list), no such
race is possible today.

Testing: check-lldb

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

Added: 


Modified: 
lldb/include/lldb/Target/TargetList.h
lldb/source/Target/TargetList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/TargetList.h 
b/lldb/include/lldb/Target/TargetList.h
index ff7fbd2753ab..94b25f65863a 100644
--- a/lldb/include/lldb/Target/TargetList.h
+++ b/lldb/include/lldb/Target/TargetList.h
@@ -42,8 +42,6 @@ class TargetList : public Broadcaster {
 return GetStaticBroadcasterClass();
   }
 
-  ~TargetList() override;
-
   /// Create a new Target.
   ///
   /// Clients must use this function to create a Target. This allows

diff  --git a/lldb/source/Target/TargetList.cpp 
b/lldb/source/Target/TargetList.cpp
index ce9661ce63c2..2be32c53da9f 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -42,12 +42,6 @@ TargetList::TargetList(Debugger &debugger)
   CheckInWithManager();
 }
 
-// Destructor
-TargetList::~TargetList() {
-  std::lock_guard guard(m_target_list_mutex);
-  m_target_list.clear();
-}
-
 Status TargetList::CreateTarget(Debugger &debugger,
 llvm::StringRef user_exe_path,
 llvm::StringRef triple_str,



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


[Lldb-commits] [lldb] 16e5a34 - [TargetList] Simplify dummy target creation

2020-11-05 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-11-05T16:04:02-08:00
New Revision: 16e5a347e70b4c819ff4402320457cc2c8ca

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

LOG: [TargetList] Simplify dummy target creation

Factor out dummy target creation from CreateTargetInternal.

This makes it impossible for dummy target creation to accidentally fail
due to too-strict checking in one of the CreateTargetInternal overloads.

Testing: check-lldb

rdar://70630655

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

Added: 


Modified: 
lldb/include/lldb/Target/Target.h
lldb/include/lldb/Target/TargetList.h
lldb/source/Core/Debugger.cpp
lldb/source/Target/TargetList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 6a392a508f4c..41c07b7aa83f 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -441,6 +441,7 @@ class Target : public std::enable_shared_from_this,
public ModuleList::Notifier {
 public:
   friend class TargetList;
+  friend class Debugger;
 
   /// Broadcaster event bits definitions.
   enum {

diff  --git a/lldb/include/lldb/Target/TargetList.h 
b/lldb/include/lldb/Target/TargetList.h
index 5ed0344f175c..ff7fbd2753ab 100644
--- a/lldb/include/lldb/Target/TargetList.h
+++ b/lldb/include/lldb/Target/TargetList.h
@@ -183,28 +183,21 @@ class TargetList : public Broadcaster {
   typedef std::vector collection;
   // Member variables.
   collection m_target_list;
-  lldb::TargetSP m_dummy_target_sp;
   mutable std::recursive_mutex m_target_list_mutex;
   uint32_t m_selected_target_idx;
 
 private:
-  lldb::TargetSP GetDummyTarget(lldb_private::Debugger &debugger);
-
-  Status CreateDummyTarget(Debugger &debugger,
-   llvm::StringRef specified_arch_name,
-   lldb::TargetSP &target_sp);
-
   Status CreateTargetInternal(Debugger &debugger, llvm::StringRef 
user_exe_path,
   llvm::StringRef triple_str,
   LoadDependentFiles load_dependent_files,
   const OptionGroupPlatform *platform_options,
-  lldb::TargetSP &target_sp, bool is_dummy_target);
+  lldb::TargetSP &target_sp);
 
   Status CreateTargetInternal(Debugger &debugger, llvm::StringRef 
user_exe_path,
   const ArchSpec &arch,
   LoadDependentFiles get_dependent_modules,
   lldb::PlatformSP &platform_sp,
-  lldb::TargetSP &target_sp, bool is_dummy_target);
+  lldb::TargetSP &target_sp);
 
   TargetList(const TargetList &) = delete;
   const TargetList &operator=(const TargetList &) = delete;

diff  --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index f51754e15d9b..5f75ac246b80 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -682,7 +682,16 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, 
void *baton)
   assert(default_platform_sp);
   m_platform_list.Append(default_platform_sp, true);
 
-  m_dummy_target_sp = m_target_list.GetDummyTarget(*this);
+  // Create the dummy target.
+  {
+ArchSpec arch(Target::GetDefaultArchitecture());
+if (!arch.IsValid())
+  arch = HostInfo::GetArchitecture();
+assert(arch.IsValid() && "No valid default or host archspec");
+const bool is_dummy_target = true;
+m_dummy_target_sp.reset(
+new Target(*this, arch, default_platform_sp, is_dummy_target));
+  }
   assert(m_dummy_target_sp.get() && "Couldn't construct dummy target?");
 
   m_collection_sp->Initialize(g_debugger_properties);

diff  --git a/lldb/source/Target/TargetList.cpp 
b/lldb/source/Target/TargetList.cpp
index d4d3740286b7..ce9661ce63c2 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -55,8 +55,8 @@ Status TargetList::CreateTarget(Debugger &debugger,
 const OptionGroupPlatform *platform_options,
 TargetSP &target_sp) {
   return CreateTargetInternal(debugger, user_exe_path, triple_str,
-  load_dependent_files, platform_options, 
target_sp,
-  false);
+  load_dependent_files, platform_options,
+  target_sp);
 }
 
 Status TargetList::CreateTarget(Debugger &debugger,
@@ -65,15 +65,13 @@ Status TargetList::CreateTarget(Debugger &debugger,
 LoadDependentFiles load_dependent_files,
 PlatformSP &platform_sp, TargetSP &target_sp) 

[Lldb-commits] [lldb] 158f336 - [lldb] Delete lldb/utils/test

2020-10-28 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-10-28T12:06:02-07:00
New Revision: 158f3360438f92cefc60041dcb8db980d7d1c744

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

LOG: [lldb] Delete lldb/utils/test

These utilities aren't useful any more -- delete them as a cleanup.

Discussion:
http://lists.llvm.org/pipermail/lldb-dev/2020-October/016536.html

Added: 


Modified: 


Removed: 
lldb/utils/test/README-disasm
lldb/utils/test/README-lldb-disasm
lldb/utils/test/README-run-until-faulted
lldb/utils/test/disasm.py
lldb/utils/test/lldb-disasm.py
lldb/utils/test/llvm-mc-shell.py
lldb/utils/test/main.c
lldb/utils/test/ras.py
lldb/utils/test/run-dis.py
lldb/utils/test/run-until-faulted.py



diff  --git a/lldb/utils/test/README-disasm b/lldb/utils/test/README-disasm
deleted file mode 100644
index 00e9ab681a24..
--- a/lldb/utils/test/README-disasm
+++ /dev/null
@@ -1,406 +0,0 @@
-This README describes a sample invocation of disasm.py whose purpose is to test
-the low level ARM/Thumb disassembly functionality from llvm using the llvm-mc
-command line.  We invoke gdb on an executable, try to disassemble a function,
-and then read the memory contents of the disassembled function.
-
-The byte contents are written into a file named disasm-input.txt and then we
-invoke llvm-mc -disassemble plus options (set with the -o/--options) on the
-byte contents.
-
-See the following for a sample session using this command:
-
-[16:26:57] johnny:/Volumes/data/Radar/9131529 $ 
/Volumes/data/lldb/svn/trunk/utils/test/disasm.py -C 'set 
shlib-path-substitutions /usr 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr 
/System 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System 
/Library 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library' 
-O '-arch armv7' -m /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc -e 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
 -f printf --options='-triple=thumb-apple-darwin -debug-only=arm-disassembler'
-gdb commands: ['set shlib-path-substitutions /usr 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr 
/System 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/System 
/Library 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/Library']
-gdb options: -arch armv7
-executable: 
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk/usr/lib/libSystem.B.dylib
-function: printf
-llvm-mc: /Volumes/data/lldb/llvm/Debug+Asserts/bin/llvm-mc
-llvm-mc options: -triple=thumb-apple-darwin -debug-only=arm-disassembler
-GNU gdb 6.3.50-20050815 (Apple version gdb-1518) (Sat Feb 12 02:56:02 UTC 2011)
-Copyright 2004 Free Software Foundation, Inc.
-GDB is free software, covered by the GNU General Public License, and you are
-welcome to change it and/or distribute copies of it under certain conditions.
-Type "show copying" to see the conditions.
-There is absolutely no warranty for GDB.  Type "show warranty" for details.
-This GDB was configured as "--host=x86_64-apple-darwin 
--target=arm-apple-darwin".
-: push{r0, r1, r2, r3}
-0x0704cdd2 : push{r4, r5, r7, lr}
-0x0704cdd4 : add r7, sp, #8
-0x0704cdd6 : sub sp, #4
-0x0704cdd8 : add r3, sp, #20
-0x0704cdda :ldr.w   r5, [r3], #4
-0x0704cdde :str r3, [sp, #0]
-0x0704cde0 :ldr r3, [pc, #52]   (0x704ce18 )
-0x0704cde2 :add r3, pc
-0x0704cde4 :ldr r0, [r3, #0]
-0x0704cde6 :ldr r4, [r0, #0]
-0x0704cde8 :ldr r0, [pc, #48]   (0x704ce1c )
-0x0704cdea :add r0, pc
-0x0704cdec :ldr r0, [r0, #0]
-0x0704cdee :ldr r0, [r0, #0]
-0x0704cdf0 :blx 0x707ba30 
-0x0704cdf4 :cbnzr0, 0x704cdfe 
-0x0704cdf6 :ldr r1, [pc, #40]   (0x704ce20 )
-0x0704cdf8 :add r1, pc
-0x0704cdfa :ldr r1, [r1, #0]
-0x0704cdfc :b.n 0x704ce00 
-0x0704cdfe :mov r1, r0
-0x0704ce00 :mov r0, r4
-0x0704ce02 :mov r2, r5
-0x0704ce04 :ldr r3, [sp, #0]
-0x0704ce06 :bl  0x704ad44 
-0x0704ce0a :sub.w   sp, r7, #8  ; 0x8
-0x0704ce0e :ldmia.w sp!, {r4, r5, r7, lr}
-0x0704ce12 :add sp, #16
-0x0704ce14 :bx  lr
-0x0704ce16 :nop
-0x0704ce18 :movsr3, #142
-0x0704ce1a :lslsr5, r0, #0
-0x0704ce1c :addsr1, #122
-0x0704ce1e :lslsr5, r0, #0
-0x0704ce20 :addsr1, #104
-0x0704ce22 :lslsr5, r0, #0
-End of assembler dump.
-(gdb) x /2b 0x0704cdd0
-0x704cdd0 :0x0f0xb4
-(gdb) x /2b 0x0704

Re: [Lldb-commits] [lldb] 74c9395 - Add a "Trace" plug-in to LLDB to add process trace support in stages.

2020-09-28 Thread Vedant Kumar via lldb-commits
Hey Walter,

Really excited to see that this landed! I have one post-commit review comment 
inline --

> On Sep 21, 2020, at 5:13 PM, Walter Erquinigo via lldb-commits 
>  wrote:
> 
> 
> Author: Walter Erquinigo
> Date: 2020-09-21T17:13:18-07:00
> New Revision: 74c93956e1c1f1054dfb040ce26830016e0f3095
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/74c93956e1c1f1054dfb040ce26830016e0f3095
> DIFF: 
> https://github.com/llvm/llvm-project/commit/74c93956e1c1f1054dfb040ce26830016e0f3095.diff
> 
> LOG: Add a "Trace" plug-in to LLDB to add process trace support in stages.
> 
> This is the first in a series of patches that will adds a new processor trace 
> plug-in to LLDB.
> 
> The idea for this first patch to to add the plug-in interface with simple 
> commands for the trace files that can "load" and "dump" the trace 
> information. We can test the functionality and ensure people are happy with 
> the way things are done and how things are organized before moving on to 
> adding more functionality.
> 
> Processor trace information can be view in a few different ways:
> - post mortem where a trace is saved off that can be viewed later in the 
> debugger
> - gathered while a process is running and allow the user to step back in time 
> (with no variables, memory or registers) to see how each thread arrived at 
> where it is currently stopped.
> 
> This patch attempts to start with the first solution of loading a trace file 
> after the fact. The idea is that we will use a JSON file to load the trace 
> information. JSON allows us to specify information about the trace like:
> - plug-in name in LLDB
> - path to trace file
> - shared library load information so we can re-create a target and 
> symbolicate the information in the trace
> - any other info that the trace plug-in will need to be able to successfully 
> parse the trace information
>  - cpu type
>  - version info
>  - ???
> 
> A new "trace" command was added at the top level of the LLDB commmands:
> - "trace load"
> - "trace dump"
> 
> I did this because if we load trace information we don't need to have a 
> process and we might end up creating a new target for the trace information 
> that will become active. If anyone has any input on where this would be 
> better suited, please let me know. Walter Erquinigo will end up filling in 
> the Intel PT specific plug-in so that it works and is tested once we can 
> agree that the direction of this patch is the correct one, so please feel 
> free to chime in with ideas on comments!
> 
> Reviewed By: clayborg
> 
> Differential Revision: https://reviews.llvm.org/D85705
> 
> Added: 
>lldb/include/lldb/Target/Trace.h
>lldb/include/lldb/Target/TraceSettingsParser.h
>lldb/source/Commands/CommandObjectTrace.cpp
>lldb/source/Commands/CommandObjectTrace.h
>lldb/source/Plugins/Trace/CMakeLists.txt
>lldb/source/Plugins/Trace/intel-pt/CMakeLists.txt
>lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
>lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.h
>lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.cpp
>lldb/source/Plugins/Trace/intel-pt/TraceIntelPTSettingsParser.h
>lldb/source/Target/Trace.cpp
>lldb/source/Target/TraceSettingsParser.cpp
>lldb/test/API/commands/trace/TestTraceLoad.py
>lldb/test/API/commands/trace/TestTraceSchema.py
>lldb/test/API/commands/trace/intelpt-trace/3842849.trace
>lldb/test/API/commands/trace/intelpt-trace/a.out
>lldb/test/API/commands/trace/intelpt-trace/main.cpp
>lldb/test/API/commands/trace/intelpt-trace/trace.json
>lldb/test/API/commands/trace/intelpt-trace/trace_bad.json
>lldb/test/API/commands/trace/intelpt-trace/trace_bad2.json
>lldb/test/API/commands/trace/intelpt-trace/trace_bad3.json
> 
> Modified: 
>lldb/include/lldb/Core/PluginManager.h
>lldb/include/lldb/lldb-forward.h
>lldb/include/lldb/lldb-private-interfaces.h
>lldb/source/Commands/CMakeLists.txt
>lldb/source/Commands/Options.td
>lldb/source/Core/PluginManager.cpp
>lldb/source/Interpreter/CommandInterpreter.cpp
>lldb/source/Plugins/CMakeLists.txt
>lldb/source/Target/CMakeLists.txt
>lldb/source/Utility/StructuredData.cpp
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/include/lldb/Core/PluginManager.h 
> b/lldb/include/lldb/Core/PluginManager.h
> index 5e0c9395dae0..cd962b668163 100644
> --- a/lldb/include/lldb/Core/PluginManager.h
> +++ b/lldb/include/lldb/Core/PluginManager.h
> @@ -330,6 +330,14 @@ class PluginManager {
>   static SymbolVendorCreateInstance
>   GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
> 
> +  // Trace
> +  static bool RegisterPlugin(ConstString name, const char *description,
> + TraceCreateInstance create_callback);
> +
> +  static bool UnregisterPlugin(TraceCreateInstance create_callback);
> +
> +  static TraceCreateInstance GetTraceCreateCallback(C

[Lldb-commits] [lldb] 4926a5e - [lldb] Clarify docstring for SBBlock::IsInlined, NFC

2020-09-17 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-09-17T16:54:58-07:00
New Revision: 4926a5ee63017396e1c55b1505f9fd2bed858218

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

LOG: [lldb] Clarify docstring for SBBlock::IsInlined, NFC

Previously, there was a little ambiguity about whether IsInlined should
return true for an inlined lexical block, since technically the lexical
block would not represent an inlined function (it'd just be contained
within one).

Edit suggested by Jim Ingham.

Added: 


Modified: 
lldb/bindings/interface/SBBlock.i

Removed: 




diff  --git a/lldb/bindings/interface/SBBlock.i 
b/lldb/bindings/interface/SBBlock.i
index 812b41fe5c3e..3972b939b18b 100644
--- a/lldb/bindings/interface/SBBlock.i
+++ b/lldb/bindings/interface/SBBlock.i
@@ -22,7 +22,7 @@ public:
 ~SBBlock ();
 
 %feature("docstring",
-"Does this block represent an inlined function?"
+"Is this block contained within an inlined function?"
 ) IsInlined;
 bool
 IsInlined () const;



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


[Lldb-commits] [lldb] d49aedd - Build a flat LLDB.framework for embedded Darwin targets

2020-08-12 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-08-12T13:34:29-07:00
New Revision: d49aedd315e35180b1df19476353ebe2558a318b

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

LOG: Build a flat LLDB.framework for embedded Darwin targets

This patch configures LLDB.framework to build as a flat unversioned
framework on non-macOS Darwin targets, which have never supported the
macOS framework layout.

This patch also renames the 'IOS' cmake variable to 'APPLE_EMBEDDED' to
reflect the fact that lldb is built for several different kinds of embedded
Darwin targets, not just iOS.

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

Added: 


Modified: 
lldb/cmake/modules/LLDBConfig.cmake
lldb/cmake/modules/LLDBFramework.cmake
lldb/source/Host/CMakeLists.txt
lldb/tools/debugserver/source/CMakeLists.txt
lldb/tools/lldb-server/CMakeLists.txt
lldb/unittests/debugserver/CMakeLists.txt

Removed: 




diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 7e5848c800f8..ed77e188c107 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -267,7 +267,7 @@ endif()
 
 # Find Apple-specific libraries or frameworks that may be needed.
 if (APPLE)
-  if(NOT IOS)
+  if(NOT APPLE_EMBEDDED)
 find_library(CARBON_LIBRARY Carbon)
 find_library(CORE_SERVICES_LIBRARY CoreServices)
   endif()

diff  --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index c52daaa4fa8b..43af71b78f24 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -3,22 +3,38 @@ message(STATUS "LLDB.framework: install path is 
'${LLDB_FRAMEWORK_INSTALL_DIR}'"
 message(STATUS "LLDB.framework: resources subdirectory is 
'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
 # Configure liblldb as a framework bundle
-set_target_properties(liblldb PROPERTIES
-  FRAMEWORK ON
-  FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+if(NOT APPLE_EMBEDDED)
+  set_target_properties(liblldb PROPERTIES
+FRAMEWORK ON
+FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
 
-  OUTPUT_NAME LLDB
-  VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+OUTPUT_NAME LLDB
+VERSION ${LLDB_VERSION}
+LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
-  # Compatibility version
-  SOVERSION "1.0.0"
+# Compatibility version
+SOVERSION "1.0.0"
 
-  MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
-  MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
-  MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
-  MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
-)
+MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
+MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
+MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
+MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
+  )
+else()
+  set_target_properties(liblldb PROPERTIES
+FRAMEWORK ON
+FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
+
+# Note: iOS doesn't specify version, as the framework layout is flat.
+OUTPUT_NAME LLDB
+LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+
+MACOSX_FRAMEWORK_IDENTIFIER com.apple.LLDB.framework
+MACOSX_FRAMEWORK_BUNDLE_VERSION ${LLDB_VERSION}
+MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${LLDB_VERSION}
+MACOSX_FRAMEWORK_INFO_PLIST ${LLDB_SOURCE_DIR}/resources/LLDB-Info.plist.in
+  )
+endif()
 
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
@@ -30,7 +46,7 @@ set_output_directory(liblldb
 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
 
 # Affects the layout of the framework bundle (default is macOS layout).
-if(IOS)
+if(APPLE_EMBEDDED)
   set_target_properties(liblldb PROPERTIES
 XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "${IPHONEOS_DEPLOYMENT_TARGET}")
 else()
@@ -41,13 +57,16 @@ endif()
 # Add -Wdocumentation parameter
 set(CMAKE_XCODE_ATTRIBUTE_CLANG_WARN_DOCUMENTATION_COMMENTS "YES")
 
-# Apart from this one, CMake creates all required symlinks in the framework 
bundle.
-add_custom_command(TARGET liblldb POST_BUILD
-  COMMAND ${CMAKE_COMMAND} -E create_symlink
-  Versions/Current/Headers
-  ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
-  COMMENT "LLDB.framework: create Headers symlink"
-)
+# On iOS, there is no versioned framework layout. Skip this symlink step.
+if(NOT APPLE_EMBEDDED)
+  # Apart from this one, CMake creates all required symlinks in the framework 
bundle.
+  add_custom_command(TARGET liblldb POST_BUILD
+COMMAND ${CMAKE_COMMAND} -E create_symlink
+

Re: [Lldb-commits] [PATCH] D79219: [CMake] Simplify CMake handling for zlib

2020-07-24 Thread Vedant Kumar via lldb-commits
Thanks, that addressed the issue.

> On Jul 24, 2020, at 1:41 PM, Petr Hosek  wrote:
> 
> Thanks for the heads up, this should be addressed by 
> c86f56e32e724c6018e579bb2bc11e667c96fc96, let me know if there are other 
> issues.
> 
> On Fri, Jul 24, 2020 at 12:33 PM Vedant Kumar via Phabricator 
> mailto:revi...@reviews.llvm.org>> wrote:
> vsk added a comment.
> 
> @phosek I suspect this is causing a cmake error on the lldb standalone bot, 
> would you mind taking a look?
> 
> http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake-standalone/1858/ 
> 
> 
>   CMake Error at 
> /Users/buildslave/jenkins/workspace/lldb-cmake-standalone/clang-build/lib/cmake/llvm/AddLLVM.cmake:823
>  (add_executable):
> Target "lit-cpuid" links to target "ZLIB::ZLIB" but the target was not
> found.  Perhaps a find_package() call is missing for an IMPORTED target, 
> or
> an ALIAS target is missing?
>   Call Stack (most recent call first):
> cmake/modules/AddLLDB.cmake:165 (add_llvm_executable)
> utils/lit-cpuid/CMakeLists.txt:1 (add_lldb_executable)
> 
> 
> Repository:
>   rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D79219/new/ 
> 
> https://reviews.llvm.org/D79219 
> 
> 
> 

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


[Lldb-commits] [lldb] 46334df - [lldb/test] Skip test in TestBitfieldIvars.py instead of xfailing it

2020-07-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-07-21T11:29:09-07:00
New Revision: 46334dfc3ba99ee5300675f8300b9044e350f2ff

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

LOG: [lldb/test] Skip test in TestBitfieldIvars.py instead of xfailing it

The test triggers an ASan exception, causing job failures on the
sanitizer bot.

As suggested by Shafik.

Added: 


Modified: 
lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py

Removed: 




diff  --git a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py 
b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
index 0cc3cef76ea1..611885413102 100644
--- a/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
+++ b/lldb/test/API/lang/objc/bitfield_ivars/TestBitfieldIvars.py
@@ -27,7 +27,9 @@ def test(self):
  'field2 =', '3',
  'field3 =', '4'])
 
-@expectedFailureAll()
+# This test is meant to be xfailed, but running the test triggers an ASan
+# issue, so it must be skipped for now.
+@skipIf
 def testExprWholeObject(self):
 self.build()
 lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.m"))



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


[Lldb-commits] [lldb] f8f259c - [lldb/Function] Reflow doxygen comments for member variables, NFC

2020-07-09 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-07-09T10:37:09-07:00
New Revision: f8f259ce4aca381896c114738a3d83a90c5c32be

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

LOG: [lldb/Function] Reflow doxygen comments for member variables, NFC

As suggested in the review for https://reviews.llvm.org/D83359.

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index bfaa1a13359c..300d829219d4 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -115,10 +115,11 @@ class FunctionInfo {
   virtual size_t MemorySize() const;
 
 protected:
-  // Member variables.
-  ConstString m_name;///< Function method name (not a mangled name).
-  Declaration m_declaration; ///< Information describing where this function
- ///information was defined.
+  /// Function method name (not a mangled name).
+  ConstString m_name;
+
+  /// Information describing where this function information was defined.
+  Declaration m_declaration;
 };
 
 /// \class InlineFunctionInfo Function.h "lldb/Symbol/Function.h"
@@ -242,9 +243,10 @@ class InlineFunctionInfo : public FunctionInfo {
   size_t MemorySize() const override;
 
 private:
-  // Member variables.
-  Mangled m_mangled; ///< Mangled inlined function name (can be empty if there
- ///is no mangled information).
+  /// Mangled inlined function name (can be empty if there is no mangled
+  /// information).
+  Mangled m_mangled;
+
   Declaration m_call_decl;
 };
 
@@ -636,33 +638,50 @@ class Function : public UserID, public SymbolContextScope 
{
 
 protected:
   enum {
-flagsCalculatedPrologueSize =
-(1 << 0) ///< Have we already tried to calculate the prologue size?
+/// Whether we already tried to calculate the prologue size.
+flagsCalculatedPrologueSize = (1 << 0)
   };
 
-  // Member variables.
-  CompileUnit *m_comp_unit; ///< The compile unit that owns this function.
-  lldb::user_id_t
-  m_type_uid; ///< The user ID of for the prototype Type for this function.
-  Type *m_type; ///< The function prototype type for this function that include
-///the function info (FunctionInfo), return type and 
parameters.
-  Mangled m_mangled; ///< The mangled function name if any, if empty, there is
- ///no mangled information.
-  Block m_block; ///< All lexical blocks contained in this function.
-  AddressRange m_range; ///< The function address range that covers the widest
-///range needed to contain all blocks
-  DWARFExpression m_frame_base; ///< The frame base expression for variables
-///that are relative to the frame pointer.
+  /// The compile unit that owns this function.
+  CompileUnit *m_comp_unit;
+
+  /// The user ID of for the prototype Type for this function.
+  lldb::user_id_t m_type_uid;
+
+  /// The function prototype type for this function that includes the function
+  /// info (FunctionInfo), return type and parameters.
+  Type *m_type;
+
+  /// The mangled function name if any. If empty, there is no mangled
+  /// information.
+  Mangled m_mangled;
+
+  /// All lexical blocks contained in this function.
+  Block m_block;
+
+  /// The function address range that covers the widest range needed to contain
+  /// all blocks
+  AddressRange m_range;
+
+  /// The frame base expression for variables that are relative to the frame
+  /// pointer.
+  DWARFExpression m_frame_base;
+
   Flags m_flags;
-  uint32_t
-  m_prologue_byte_size; ///< Compute the prologue size once and cache it
-
-  std::mutex
-  m_call_edges_lock; ///< Exclusive lock that controls read/write
- ///  access to m_call_edges and m_call_edges_resolved.
-  bool m_call_edges_resolved = false; ///< Whether call site info has been
-  ///  parsed.
-  std::vector> m_call_edges; ///< Outgoing call 
edges.
+
+  /// Compute the prologue size once and cache it.
+  uint32_t m_prologue_byte_size;
+
+  /// Exclusive lock that controls read/write access to m_call_edges and
+  /// m_call_edges_resolved.
+  std::mutex m_call_edges_lock;
+
+  /// Whether call site info has been parsed.
+  bool m_call_edges_resolved = false;
+
+  /// Outgoing call edges.
+  std::vector> m_call_edges;
+
 private:
   Function(const Function &) = delete;
   const Function &operator=(const Function &) = delete;



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


[Lldb-commits] [lldb] 6cfc90b - [Function] Lock the function when parsing call site info

2020-07-09 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-07-09T10:37:09-07:00
New Revision: 6cfc90b9b791a023368b9384f57c2c3120894247

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

LOG: [Function] Lock the function when parsing call site info

Summary:
DWARF-parsing methods in SymbolFileDWARF which update module state
typically take the module lock. ParseCallEdgesInFunction doesn't do
this, but higher-level locking within lldb::Function (which owns the
storage for parsed call edges) is necessary.

The lack of locking could explain some as-of-yet unreproducible crashes
which occur in Function::GetTailCallingEdges(). In these crashes, the
`m_call_edges` vector is non-empty but contains a nullptr, which
shouldn't be possible. (If this vector is non-empty, it _must_ contain a
non-null unique_ptr.)

This may address rdar://55622443 and rdar://65119458.

Reviewers: jasonmolenda, friss, jingham

Subscribers: aprantl, lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/Function.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index e548b8d626a3..bfaa1a13359c 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -17,6 +17,8 @@
 #include "lldb/Utility/UserID.h"
 #include "llvm/ADT/ArrayRef.h"
 
+#include 
+
 namespace lldb_private {
 
 class ExecutionContext;
@@ -655,6 +657,9 @@ class Function : public UserID, public SymbolContextScope {
   uint32_t
   m_prologue_byte_size; ///< Compute the prologue size once and cache it
 
+  std::mutex
+  m_call_edges_lock; ///< Exclusive lock that controls read/write
+ ///  access to m_call_edges and m_call_edges_resolved.
   bool m_call_edges_resolved = false; ///< Whether call site info has been
   ///  parsed.
   std::vector> m_call_edges; ///< Outgoing call 
edges.

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 7dd084f24e3e..9f64e5255fd5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3844,6 +3844,11 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 
 std::vector>
 SymbolFileDWARF::ParseCallEdgesInFunction(UserID func_id) {
+  // ParseCallEdgesInFunction must be called at the behest of an exclusively
+  // locked lldb::Function instance. Storage for parsed call edges is owned by
+  // the lldb::Function instance: locking at the SymbolFile level would be too
+  // late, because the act of storing results from ParseCallEdgesInFunction
+  // would be racy.
   DWARFDIE func_die = GetDIE(func_id.GetID());
   if (func_die.IsValid())
 return CollectCallEdges(GetObjectFile()->GetModule(), func_die);

diff  --git a/lldb/source/Symbol/Function.cpp b/lldb/source/Symbol/Function.cpp
index 533fdd465c42..67013f6dd8b1 100644
--- a/lldb/source/Symbol/Function.cpp
+++ b/lldb/source/Symbol/Function.cpp
@@ -290,6 +290,8 @@ void Function::GetEndLineSourceInfo(FileSpec &source_file, 
uint32_t &line_no) {
 }
 
 llvm::ArrayRef> Function::GetCallEdges() {
+  std::lock_guard guard(m_call_edges_lock);
+
   if (m_call_edges_resolved)
 return m_call_edges;
 



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


[Lldb-commits] [lldb] 7822b8a - [lldb/StringPrinter] Convert DecodedCharBuffer to a class, NFC

2020-06-03 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-06-03T12:24:23-07:00
New Revision: 7822b8a817d85827110f3047f4ec63f6825743a4

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

LOG: [lldb/StringPrinter] Convert DecodedCharBuffer to a class, NFC

The m_size and m_data members of DecodedCharBuffer are meant to be
private.

Added: 


Modified: 
lldb/source/DataFormatters/StringPrinter.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/StringPrinter.cpp 
b/lldb/source/DataFormatters/StringPrinter.cpp
index 53dbc8d76a99..7f7d6c1639f0 100644
--- a/lldb/source/DataFormatters/StringPrinter.cpp
+++ b/lldb/source/DataFormatters/StringPrinter.cpp
@@ -30,9 +30,7 @@ using StringElementType = StringPrinter::StringElementType;
 /// DecodedCharBuffer stores the decoded contents of a single character. It
 /// avoids managing memory on the heap by copying decoded bytes into an in-line
 /// buffer.
-struct DecodedCharBuffer {
-  static constexpr unsigned MaxLength = 16;
-
+class DecodedCharBuffer {
 public:
   DecodedCharBuffer(std::nullptr_t) {}
 
@@ -50,6 +48,8 @@ struct DecodedCharBuffer {
   size_t GetSize() const { return m_size; }
 
 private:
+  static constexpr unsigned MaxLength = 16;
+
   size_t m_size = 0;
   uint8_t m_data[MaxLength] = {0};
 };



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


[Lldb-commits] [lldb] 4699a7e - [lldb/StringPrinter] Support strings with invalid utf8 sub-sequences

2020-06-03 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-06-03T12:24:23-07:00
New Revision: 4699a7e23010b7c0df49b64f8bea63919825a787

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

LOG: [lldb/StringPrinter] Support strings with invalid utf8 sub-sequences

Support printing strings which contain invalid utf8 sub-sequences, e.g.
strings like "hello world \xfe", instead of bailing out with "Summary
Unavailable".

I took the opportunity here to delete some hand-rolled utf8 -> utf32
conversion code and replace it with calls into llvm's Support library.

rdar://61554346

Added: 


Modified: 
lldb/source/DataFormatters/StringPrinter.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp
lldb/unittests/DataFormatter/StringPrinterTests.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/StringPrinter.cpp 
b/lldb/source/DataFormatters/StringPrinter.cpp
index 7f7d6c1639f0..139f1ec0554f 100644
--- a/lldb/source/DataFormatters/StringPrinter.cpp
+++ b/lldb/source/DataFormatters/StringPrinter.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Target/Target.h"
 #include "lldb/Utility/Status.h"
 
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/ConvertUTF.h"
 
 #include 
@@ -92,7 +93,7 @@ static bool isprint32(char32_t codepoint) {
   return true;
 }
 
-DecodedCharBuffer attemptASCIIEscape(char32_t c,
+DecodedCharBuffer attemptASCIIEscape(llvm::UTF32 c,
  StringPrinter::EscapeStyle escape_style) {
   const bool is_swift_escape_style =
   escape_style == StringPrinter::EscapeStyle::Swift;
@@ -141,7 +142,10 @@ DecodedCharBuffer 
GetPrintableImpl(
   DecodedCharBuffer retval = attemptASCIIEscape(*buffer, escape_style);
   if (retval.GetSize())
 return retval;
-  if (isprint(*buffer))
+
+  // Use llvm's locale-independent isPrint(char), instead of the libc
+  // implementation which may give 
diff erent results on 
diff erent platforms.
+  if (llvm::isPrint(*buffer))
 return {buffer, 1};
 
   unsigned escaped_len;
@@ -161,60 +165,30 @@ DecodedCharBuffer 
GetPrintableImpl(
   return {data, escaped_len};
 }
 
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1) {
-  return (c0 - 192) * 64 + (c1 - 128);
-}
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1,
-   unsigned char c2) {
-  return (c0 - 224) * 4096 + (c1 - 128) * 64 + (c2 - 128);
-}
-static char32_t ConvertUTF8ToCodePoint(unsigned char c0, unsigned char c1,
-   unsigned char c2, unsigned char c3) {
-  return (c0 - 240) * 262144 + (c2 - 128) * 4096 + (c2 - 128) * 64 + (c3 - 
128);
-}
-
 template <>
 DecodedCharBuffer GetPrintableImpl(
 uint8_t *buffer, uint8_t *buffer_end, uint8_t *&next,
 StringPrinter::EscapeStyle escape_style) {
-  const unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer);
-
-  // If the utf8 encoded length is invalid, or if there aren't enough bytes to
-  // print, this is some kind of corrupted string.
-  if (utf8_encoded_len == 0 || utf8_encoded_len > 4)
-return nullptr;
-  if ((buffer_end - buffer) < utf8_encoded_len)
-// There's no room in the buffer for the utf8 sequence.
-return nullptr;
-
-  char32_t codepoint = 0;
-  switch (utf8_encoded_len) {
-  case 1:
-// this is just an ASCII byte - ask ASCII
+  // If the utf8 encoded length is invalid (i.e., not in the closed interval
+  // [1;4]), or if there aren't enough bytes to print, or if the subsequence
+  // isn't valid utf8, fall back to printing an ASCII-escaped subsequence.
+  if (!llvm::isLegalUTF8Sequence(buffer, buffer_end))
 return GetPrintableImpl(buffer, buffer_end, next,
   escape_style);
-  case 2:
-codepoint = ConvertUTF8ToCodePoint((unsigned char)*buffer,
-   (unsigned char)*(buffer + 1));
-break;
-  case 3:
-codepoint = ConvertUTF8ToCodePoint((unsigned char)*buffer,
-   (unsigned char)*(buffer + 1),
-   (unsigned char)*(buffer + 2));
-break;
-  case 4:
-codepoint = ConvertUTF8ToCodePoint(
-(unsigned char)*buffer, (unsigned char)*(buffer + 1),
-(unsigned char)*(buffer + 2), (unsigned char)*(buffer + 3));
-break;
-  }
 
-  // We couldn't figure out how to print this codepoint.
-  if (!codepoint)
-return nullptr;
+  // Convert the valid utf8 sequence to a utf32 codepoint. This cannot fail.
+  llvm::UTF32 codepoint = 0;
+  const llvm::UTF8 *buffer_for_conversion = buffer;
+  llvm::ConversionResult result = llvm::co

[Lldb-commits] [lldb] 6e39379 - [DwarfExpression] Support entry values for indirect parameters

2020-05-26 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-26T14:22:28-07:00
New Revision: 6e39379bbbe1d8aba658f638dfc42f0ba0cbb926

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

LOG: [DwarfExpression] Support entry values for indirect parameters

Summary:
A struct argument can be passed-by-value to a callee via a pointer to a
temporary stack copy. Add support for emitting an entry value DBG_VALUE
when an indirect parameter DBG_VALUE becomes unavailable. This is done
by omitting DW_OP_stack_value from the entry value expression, to make
the expression describe the location of an object.

rdar://63373691

Reviewers: djtodoro, aprantl, dstenb

Subscribers: hiraditya, lldb-commits, llvm-commits

Tags: #lldb, #llvm

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

Added: 
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-indirect-param-with-offset.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-indirect-param.mir

Modified: 
lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp
llvm/docs/LangRef.rst
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
llvm/lib/CodeGen/LiveDebugValues.cpp

Removed: 




diff  --git 
a/lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp 
b/lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp
index c739a05f421e..83f622cadf14 100644
--- a/lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp
+++ b/lldb/test/API/functionalities/param_entry_vals/basic_entry_values/main.cpp
@@ -137,6 +137,30 @@ func14(int &sink, void (*target_no_tailcall)(int &, int)) {
   target_no_tailcall(sink, 123);
 }
 
+/// A structure that is guaranteed -- when passed to a callee by value -- to be
+/// passed via a pointer to a temporary copy in the caller. On x86_64 & aarch64
+/// only.
+struct StructPassedViaPointerToTemporaryCopy {
+  // Under the 64-bit AAPCS, a struct larger than 16 bytes is not SROA'd, and
+  // is instead passed via pointer to a temporary copy.
+  long a, b, c;
+  StructPassedViaPointerToTemporaryCopy() : a(1), b(2), c(3) {}
+
+  // Failing that, a virtual method forces passing via pointer to a temporary
+  // copy under the common calling conventions (e.g. 32/64-bit x86, Linux/Win,
+  // according to https://www.agner.org/optimize/calling_conventions.pdf).
+  virtual void add_vtable() {}
+};
+
+__attribute__((noinline)) void func15(StructPassedViaPointerToTemporaryCopy S) 
{
+  use(S);
+  use(dummy);
+
+  ++global;
+  //% self.filecheck("expr S", "main.cpp", "-check-prefix=FUNC15-EXPR")
+  // FUNC15-EXPR: (a = 1, b = 2, c = 3)
+}
+
 __attribute__((disable_tail_calls)) int main() {
   int sink = 0;
   S1 s1;
@@ -169,5 +193,9 @@ __attribute__((disable_tail_calls)) int main() {
   // Test that evaluation can "see through" an indirect tail call.
   func14(sink, func13);
 
+  // Test evaluation of an entry value that dereferences a temporary stack
+  // slot set up by the caller for a StructPassedViaPointerToTemporaryCopy.
+  func15(StructPassedViaPointerToTemporaryCopy());
+
   return 0;
 }

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 01f41a7ea3f1..0891392b1e61 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -5104,9 +5104,11 @@ The current supported opcode vocabulary is limited:
 
   ``DW_OP_LLVM_entry_value`` is only legal in MIR. The operation is introduced
   by the ``LiveDebugValues`` pass; currently only for function parameters that
-  are unmodified throughout a function and that are described as simple
-  register location descriptions. The operation is also introduced by the
-  ``AsmPrinter`` pass when a call site parameter value
+  are unmodified throughout a function. Support is limited to function
+  parameter that are described as simple register location descriptions, or as
+  indirect locations (e.g. when a struct is passed-by-value to a callee via a
+  pointer to a temporary copy made in the caller). The entry value op is also
+  introduced by the ``AsmPrinter`` pass when a call site parameter value
   (``DW_AT_call_site_parameter_value``) is represented as entry value of the
   parameter.
 - ``DW_OP_breg`` (or ``DW_OP_bregx``) represents a content on the provided

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 93bf9d6c2f71..dce90b3c17c0 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -1285,15 +1285,12 @@ void DwarfCompileUnit::addComplexAddress(const 
DbgVariable &DV, DIE &Die,
   DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
   const

Re: [Lldb-commits] [PATCH] D80150: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-22 Thread Vedant Kumar via lldb-commits
There were several things off here, both in the tests and the Cocoa.cpp change. 
Sorry for all the breakage.

I’ve updated https://reviews.llvm.org/D80150 
 to address these issues and written 
up a summary there of what went wrong.

vedant

> On May 20, 2020, at 9:23 AM, Eric Christopher  wrote:
> 
> Agreed. Something is off here. My change was only to silence a few warnings, 
> but they're definitely highlighting a conversion issue. What's up with NSDate 
> conversions here. Does the API have a way to convert from time_t?
> 
> On Wed, May 20, 2020, 2:07 AM Pavel Labath via Phabricator via lldb-commits 
> mailto:lldb-commits@lists.llvm.org>> wrote:
> labath added a comment.
> 
> In D80150#2045364  >, @vsk wrote:
> 
> > @labath Agreed on all points, I've addressed the feedback in 82dbf4aca84 
> >  > > by 
> > moving "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h", and 
> > adding a separate LanguageObjCTests unit test.
> 
> 
> Cool. Thanks.
> 
> 
> 
> 
> Comment at: lldb/unittests/DataFormatter/MockTests.cpp:30
> +  // Can't convert the date_value to a time_t.
> +  EXPECT_EQ(formatDateValue(std::numeric_limits::max() + 1),
> +llvm::None);
> 
> vsk wrote:
> > labath wrote:
> > > Isn't this actually `std::numeric_limits::min()` (and UB due to 
> > > singed wraparound) ? Did you want to convert to double before doing the 
> > > `+1` ?
> > Yes, thank you! It looks like Eric caught this before I did.
> Actually, thinking about that further, (for 64-bit `time_t`s), 
> `double(numeric_limits::max())` is [[ https://godbolt.org/z/t3iSd7 
>  | exactly the same value ]] as 
> `double(numeric_limits::max())+1.0` because `double` doesn't have 
> enough bits to represent the value precisely. So, I have a feeling these 
> checks are still not testing the exact thing you want to test (though I'm not 
> sure what that is exactly).
> 
> 
> Repository:
>   rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D80150/new/ 
> 
> https://reviews.llvm.org/D80150 
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org 
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits 
> 

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


[Lldb-commits] [lldb] 82dbf4a - [lldb/test] Move "DataFormatters/Mock.h" to "Plugins/Language/ObjC/Utilities.h"

2020-05-19 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-19T16:09:42-07:00
New Revision: 82dbf4aca84ec889d0dc390674ff44e30441bcfd

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

LOG: [lldb/test] Move "DataFormatters/Mock.h" to 
"Plugins/Language/ObjC/Utilities.h"

This addresses some post-commit review feedback from
https://reviews.llvm.org/D80150 by renaming "Mock.h" to something less
misleading, and keeping logic related to the ObjC plugin separate from
the generic DataFormatters library.

Added: 
lldb/source/Plugins/Language/ObjC/Utilities.h
lldb/unittests/Language/ObjC/CMakeLists.txt
lldb/unittests/Language/ObjC/UtilitiesTests.cpp

Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/unittests/DataFormatter/CMakeLists.txt
lldb/unittests/Language/CMakeLists.txt

Removed: 
lldb/include/lldb/DataFormatters/Mock.h
lldb/unittests/DataFormatter/MockTests.cpp



diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 37b352263260..5128f2865879 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -8,12 +8,12 @@
 
 #include "Cocoa.h"
 
+#include "Plugins/Language/ObjC/Utilities.h"
 #include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
 #include "lldb/Core/Mangled.h"
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
-#include "lldb/DataFormatters/Mock.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeSummary.h"
 #include "lldb/Host/Time.h"

diff  --git a/lldb/include/lldb/DataFormatters/Mock.h 
b/lldb/source/Plugins/Language/ObjC/Utilities.h
similarity index 73%
rename from lldb/include/lldb/DataFormatters/Mock.h
rename to lldb/source/Plugins/Language/ObjC/Utilities.h
index b3fc10cd2e51..4cfeb2b28bfd 100644
--- a/lldb/include/lldb/DataFormatters/Mock.h
+++ b/lldb/source/Plugins/Language/ObjC/Utilities.h
@@ -1,4 +1,4 @@
-//===-- Mock.h --*- C++ 
-*-===//
+//===-- Utilities.h -*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,8 @@
 //
 
//===--===//
 
-#ifndef LLDB_DATAFORMATTERS_MOCK_H
-#define LLDB_DATAFORMATTERS_MOCK_H
+#ifndef LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
+#define LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H
 
 namespace lldb_private {
 
@@ -23,4 +23,4 @@ bool FormatDateValue(double date_value, Stream &stream);
 } // namespace formatters
 } // namespace lldb_private
 
-#endif // LLDB_DATAFORMATTERS_MOCK_H
+#endif // LLDB_PLUGINS_LANGUAGE_OBJC_UTILITIES_H

diff  --git a/lldb/unittests/DataFormatter/CMakeLists.txt 
b/lldb/unittests/DataFormatter/CMakeLists.txt
index 716c8e735287..45011c56b0b0 100644
--- a/lldb/unittests/DataFormatter/CMakeLists.txt
+++ b/lldb/unittests/DataFormatter/CMakeLists.txt
@@ -1,6 +1,5 @@
 add_lldb_unittest(LLDBFormatterTests
   FormatManagerTests.cpp
-  MockTests.cpp
   StringPrinterTests.cpp
 
   LINK_LIBS

diff  --git a/lldb/unittests/Language/CMakeLists.txt 
b/lldb/unittests/Language/CMakeLists.txt
index 3a6e5de785e5..51421bd84984 100644
--- a/lldb/unittests/Language/CMakeLists.txt
+++ b/lldb/unittests/Language/CMakeLists.txt
@@ -1,2 +1,3 @@
 add_subdirectory(CPlusPlus)
 add_subdirectory(Highlighting)
+add_subdirectory(ObjC)

diff  --git a/lldb/unittests/Language/ObjC/CMakeLists.txt 
b/lldb/unittests/Language/ObjC/CMakeLists.txt
new file mode 100644
index ..e61ced1d5bfb
--- /dev/null
+++ b/lldb/unittests/Language/ObjC/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_lldb_unittest(LanguageObjCTests
+  UtilitiesTests.cpp
+
+  LINK_LIBS
+lldbPluginObjCLanguage
+  )

diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/Language/ObjC/UtilitiesTests.cpp
similarity index 84%
rename from lldb/unittests/DataFormatter/MockTests.cpp
rename to lldb/unittests/Language/ObjC/UtilitiesTests.cpp
index f7daaf22d140..b28060973d86 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/Language/ObjC/UtilitiesTests.cpp
@@ -1,4 +1,4 @@
-//===-- MockTests.cpp 
-===//
+//===-- UtilitiesTests.cpp 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 
//===--===//
 
-#include "lldb/DataFormatters/Mock.h"
+#include "Plugins/Langua

[Lldb-commits] [lldb] e3aa4cd - [lldb/test] Disable NSDate format check under _WIN32

2020-05-18 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-18T16:51:47-07:00
New Revision: e3aa4cd9dbcee6441f51102e3958c35321698c67

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

LOG: [lldb/test] Disable NSDate format check under _WIN32

Disable the test which attempts to format an NSDate with a date_value of
0 on _WIN32.

When _WIN32 is defined, GetOSXEpoch returns a date that should be in
2001, but after this is passed through timegm (which, afaict isn't
portable?) the result is a date in 1970:

```
lldb-x64-windows-ninja\llvm-project\lldb\unittests\DataFormatter\MockTests.cpp(39):
 error:   Expected: *formatDateValue(0)
  Which is: "1970-01-01 00:00:00 Pacific Standard Time"
  To be equal to: "2001-01-01 00:00:00 UTC"
```

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/4520/steps/test/logs/stdio

Added: 


Modified: 
lldb/unittests/DataFormatter/MockTests.cpp

Removed: 




diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
index 752e3987dac9..1185d7bf2c9c 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -37,6 +37,10 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(formatDateValue(std::numeric_limits::max()), llvm::None);
   EXPECT_EQ(formatDateValue(std::numeric_limits::min()), llvm::None);
 
+  // FIXME: The formatting result is wrong on Windows because we adjust the
+  // epoch when _WIN32 is defined (see GetOSXEpoch).
+#ifndef _WIN32
   EXPECT_TRUE(
   llvm::StringRef(*formatDateValue(0)).startswith("2001-01-01 00:00:00"));
+#endif
 }



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


[Lldb-commits] [lldb] fff3a84 - [lldb/test] Relax NSDate mock test for non-Apple platforms

2020-05-18 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-18T16:00:10-07:00
New Revision: fff3a8464d4d518c7086c928fba967908eb294d7

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

LOG: [lldb/test] Relax NSDate mock test for non-Apple platforms

On Ubuntu, a formatted date prints as "GMT" instead of "UTC", which is
ok.

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/4520/steps/test/logs/stdio

Added: 


Modified: 
lldb/unittests/DataFormatter/MockTests.cpp

Removed: 




diff  --git a/lldb/unittests/DataFormatter/MockTests.cpp 
b/lldb/unittests/DataFormatter/MockTests.cpp
index 0042888243f7..752e3987dac9 100644
--- a/lldb/unittests/DataFormatter/MockTests.cpp
+++ b/lldb/unittests/DataFormatter/MockTests.cpp
@@ -9,6 +9,7 @@
 #include "lldb/DataFormatters/Mock.h"
 #include "lldb/Utility/StreamString.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
 #include "gtest/gtest.h"
 #include 
 
@@ -36,5 +37,6 @@ TEST(DataFormatterMockTest, NSDate) {
   EXPECT_EQ(formatDateValue(std::numeric_limits::max()), llvm::None);
   EXPECT_EQ(formatDateValue(std::numeric_limits::min()), llvm::None);
 
-  EXPECT_EQ(*formatDateValue(0), "2001-01-01 00:00:00 UTC");
+  EXPECT_TRUE(
+  llvm::StringRef(*formatDateValue(0)).startswith("2001-01-01 00:00:00"));
 }



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


[Lldb-commits] [lldb] b783f70 - [lldb/DataFormatter] Check for overflow when finding NSDate epoch

2020-05-18 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-18T13:12:00-07:00
New Revision: b783f70a42575a5d9147bea1ac97e872370fe55b

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

LOG: [lldb/DataFormatter] Check for overflow when finding NSDate epoch

Summary:
Fixes UBSan-reported issues where the date value inside of an
uninitialized NSDate overflows the 64-bit epoch.

rdar://61774575

Reviewers: JDevlieghere, mib, teemperor

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 
lldb/include/lldb/DataFormatters/Mock.h
lldb/unittests/DataFormatter/MockTests.cpp

Modified: 
lldb/source/Plugins/Language/ObjC/Cocoa.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/Mock.h 
b/lldb/include/lldb/DataFormatters/Mock.h
new file mode 100644
index ..b3fc10cd2e51
--- /dev/null
+++ b/lldb/include/lldb/DataFormatters/Mock.h
@@ -0,0 +1,26 @@
+//===-- Mock.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_DATAFORMATTERS_MOCK_H
+#define LLDB_DATAFORMATTERS_MOCK_H
+
+namespace lldb_private {
+
+class Stream;
+
+namespace formatters {
+namespace NSDate {
+
+/// Format the date_value field of a NSDate.
+bool FormatDateValue(double date_value, Stream &stream);
+
+} // namespace NSDate
+} // namespace formatters
+} // namespace lldb_private
+
+#endif // LLDB_DATAFORMATTERS_MOCK_H

diff  --git a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp 
b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
index 8a44811dd36b..1ad443b8b74e 100644
--- a/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
+++ b/lldb/source/Plugins/Language/ObjC/Cocoa.cpp
@@ -13,6 +13,7 @@
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectConstResult.h"
 #include "lldb/DataFormatters/FormattersHelpers.h"
+#include "lldb/DataFormatters/Mock.h"
 #include "lldb/DataFormatters/StringPrinter.h"
 #include "lldb/DataFormatters/TypeSummary.h"
 #include "lldb/Host/Time.h"
@@ -27,6 +28,7 @@
 
 #include "llvm/ADT/APInt.h"
 #include "llvm/ADT/bit.h"
+#include "llvm/Support/CheckedArithmetic.h"
 
 #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
 
@@ -785,6 +787,34 @@ static double decodeTaggedTimeInterval(uint64_t 
encodedTimeInterval) {
   return llvm::bit_cast(decodedBits);
 }
 
+bool lldb_private::formatters::NSDate::FormatDateValue(double date_value,
+   Stream &stream) {
+  if (date_value == -63114076800) {
+stream.Printf("0001-12-30 00:00:00 +");
+return true;
+  }
+
+  if (date_value > std::numeric_limits::max() ||
+  date_value < std::numeric_limits::min())
+return false;
+
+  time_t epoch = GetOSXEpoch();
+  if (auto osx_epoch = llvm::checkedAdd(epoch, (time_t)date_value))
+epoch = *osx_epoch;
+  else
+return false;
+  tm *tm_date = gmtime(&epoch);
+  if (!tm_date)
+return false;
+  std::string buffer(1024, 0);
+  if (strftime(&buffer[0], 1023, "%Z", tm_date) == 0)
+return false;
+  stream.Printf("%04d-%02d-%02d %02d:%02d:%02d %s", tm_date->tm_year + 1900,
+tm_date->tm_mon + 1, tm_date->tm_mday, tm_date->tm_hour,
+tm_date->tm_min, tm_date->tm_sec, buffer.c_str());
+  return true;
+}
+
 bool lldb_private::formatters::NSDateSummaryProvider(
 ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
   ProcessSP process_sp = valobj.GetProcessSP();
@@ -828,6 +858,16 @@ bool lldb_private::formatters::NSDateSummaryProvider(
 if (descriptor->GetTaggedPointerInfo(&info_bits, &value_bits)) {
   date_value_bits = ((value_bits << 8) | (info_bits << 4));
   memcpy(&date_value, &date_value_bits, sizeof(date_value_bits));
+
+  // Accomodate the __NSTaggedDate format introduced in Foundation 1600.
+  if (class_name == g___NSTaggedDate) {
+auto *apple_runtime = llvm::dyn_cast_or_null(
+ObjCLanguageRuntime::Get(*process_sp));
+if (!apple_runtime)
+  return false;
+if (apple_runtime->GetFoundationVersion() >= 1600)
+  date_value = decodeTaggedTimeInterval(value_bits << 4);
+  }
 } else {
   llvm::Triple triple(
   process_sp->GetTarget().GetArchitecture().GetTriple());
@@ -850,34 +890,7 @@ bool lldb_private::formatters::NSDateSummaryProvider(
   } else
 return false;
 
-  if (date_value == -63114076800) {
-stream.Printf("0001-12-30 00:00:00 +");
-   

[Lldb-commits] [lldb] f807d0b - [lldb/test] Fix for flakiness in TestNSDictionarySynthetic

2020-05-11 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-11T09:53:48-07:00
New Revision: f807d0b4acdb70c5a15919f6e9b02d8b212d1088

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

LOG: [lldb/test] Fix for flakiness in TestNSDictionarySynthetic

Summary:
TestNSDictionarySynthetic sets up an NSURL which does not initialize its
_baseURL member. When the test runs and we print out the NSURL, we print
out some garbage memory pointed-to by the _baseURL member, like:

```
_baseURL = 0x0800010020004029 @"d��qX"
```

and this can cause a python unicode decoding error like:

```
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa0 in position
10309: invalid start byte
```

There's a discrepancy here because lldb's StringPrinter facility tries
to only print out "printable" sequences (see: isprint32()), whereas python
rejects the StringPrinter output as invalid utf8. For the specific error
seen above, lldb's `isprint32(0xa0) = true`, even though 0xa0 is not
really "printable" in the usual sense.

The problem is that lldb and python disagree on what exactly is
"printable". Both have dismayingly hand-rolled utf8 validation code
(c.f. _Py_DecodeUTF8Ex), and I can't really tell which one is more
correct.

I tried replacing lldb's isprint32() with a call to libc's iswprint():
this satisfied python, but broke emoji printing :|.

Now, I believe that lldb (and python too) ought to just call into some
battle-tested utf library, and that we shouldn't aim for compatibility
with python's strict unicode decoding mode until then.

FWIW I ran this test under an ASanified lldb hundreds of times but
didn't turn up any other issues.

rdar://62941711

Reviewers: JDevlieghere, jingham, shafik

Subscribers: lldb-commits

Tags: #lldb

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

Added: 


Modified: 
lldb/test/API/lldbtest.py

Removed: 




diff  --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index c6331f6a0cac..fcc13a07eded 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -119,9 +119,14 @@ def execute(self, test, litConfig):
 litConfig.maxIndividualTestTime)
 
 if sys.version_info.major == 2:
-# In Python 2, string objects can contain Unicode characters.
-out = out.decode('utf-8')
-err = err.decode('utf-8')
+# In Python 2, string objects can contain Unicode characters. Use
+# the non-strict 'replace' decoding mode. We cannot use the strict
+# mode right now because lldb's StringPrinter facility and the
+# Python utf8 decoder have 
diff erent interpretations of which
+# characters are "printable". This leads to Python utf8 decoding
+# exceptions even though lldb is behaving as expected.
+out = out.decode('utf-8', 'replace')
+err = err.decode('utf-8', 'replace')
 
 output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
 ' '.join(cmd), exitCode)



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


[Lldb-commits] [lldb] 8cb86ea - [lldb/test][Darwin] Ask dyld where the real python is

2020-05-08 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-08T10:22:58-07:00
New Revision: 8cb86ead77417f889bf32a8f83da299215f78545

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

LOG: [lldb/test][Darwin] Ask dyld where the real python is

Summary:
On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
python binary as the ASan interceptors get loaded too late. Find the
"real" python binary, copy it, and invoke it.

Hopefully this makes the GreenDragon and swift-ci sanitizer bots
happy...

I tested this out by running `../llvm-macosx-x86_64/bin/llvm-lit test
--filter TestNSDictionarySynthetic.py` in an ASanified swift-lldb build
directory and it worked (i.e. no more "interceptors loaded too late"
messages).

Reviewers: JDevlieghere

Subscribers: lldb-commits

Tags: #lldb

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

Added: 
lldb/test/API/get_darwin_real_python.py

Modified: 
lldb/test/API/lldbtest.py

Removed: 




diff  --git a/lldb/test/API/get_darwin_real_python.py 
b/lldb/test/API/get_darwin_real_python.py
new file mode 100644
index ..3521fab67579
--- /dev/null
+++ b/lldb/test/API/get_darwin_real_python.py
@@ -0,0 +1,14 @@
+# On macOS, system python binaries like /usr/bin/python and $(xcrun -f python3)
+# are shims. They do some light validation work and then spawn the "real" 
python
+# binary. Find the "real" python by asking dyld -- sys.executable reports the
+# wrong thing more often than not. This is also useful when we're running under
+# a Homebrew python3 binary, which also appears to be some kind of shim.
+def getDarwinRealPythonExecutable():
+import ctypes
+dyld = ctypes.cdll.LoadLibrary('/usr/lib/system/libdyld.dylib')
+namelen = ctypes.c_ulong(1024)
+name = ctypes.create_string_buffer(b'\000', namelen.value)
+dyld._NSGetExecutablePath(ctypes.byref(name), ctypes.byref(namelen))
+return name.value.decode('utf-8').strip()
+
+print(getDarwinRealPythonExecutable())

diff  --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
index 77654e4082eb..c6331f6a0cac 100644
--- a/lldb/test/API/lldbtest.py
+++ b/lldb/test/API/lldbtest.py
@@ -3,6 +3,7 @@
 import tempfile
 import subprocess
 import sys
+import platform
 
 import lit.Test
 import lit.TestRunner
@@ -75,19 +76,21 @@ def execute(self, test, litConfig):
 builddir = getBuildDir(cmd)
 mkdir_p(builddir)
 
-# The macOS system integrity protection (SIP) doesn't allow injecting
-# libraries into system binaries, but this can be worked around by
-# copying the binary into a 
diff erent location.
+# On macOS, we can't do the DYLD_INSERT_LIBRARIES trick with a shim
+# python binary as the ASan interceptors get loaded too late. Also,
+# when SIP is enabled, we can't inject libraries into system binaries
+# at all, so we need a copy of the "real" python to work with.
+#
+# Find the "real" python binary, copy it, and invoke it.
 if 'DYLD_INSERT_LIBRARIES' in test.config.environment and \
-(executable.startswith('/System/') or \
-executable.startswith('/usr/bin/')):
+platform.system() == 'Darwin':
 copied_python = os.path.join(builddir, 'copied-system-python')
 if not os.path.isfile(copied_python):
 import shutil, subprocess
 python = subprocess.check_output([
 executable,
-'-c',
-'import sys; print(sys.executable)'
+os.path.join(os.path.dirname(os.path.realpath(__file__)),
+'get_darwin_real_python.py')
 ]).decode('utf-8').strip()
 shutil.copy(python, copied_python)
 cmd[0] = copied_python



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


[Lldb-commits] [lldb] c05f354 - [lldb/unittest] Avoid relying on compiler character encoding in unicode test

2020-05-05 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-05T09:18:35-07:00
New Revision: c05f35443c3bc6dc69e060c766b23669a33e14ac

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

LOG: [lldb/unittest] Avoid relying on compiler character encoding in unicode 
test

This is a speculative fix for a unit test failure on a Win/MSVC2017 bot
(http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/16106/steps/test/logs/stdio).

Added: 


Modified: 
lldb/unittests/DataFormatter/StringPrinterTests.cpp

Removed: 




diff  --git a/lldb/unittests/DataFormatter/StringPrinterTests.cpp 
b/lldb/unittests/DataFormatter/StringPrinterTests.cpp
index 4b01f5c1dbe2..180b13772af5 100644
--- a/lldb/unittests/DataFormatter/StringPrinterTests.cpp
+++ b/lldb/unittests/DataFormatter/StringPrinterTests.cpp
@@ -74,8 +74,8 @@ TEST(StringPrinterTests, CxxASCII) {
   EXPECT_EQ(fmt("🥑"), QUOTE("🥑"));
 
   // Octal (\nnn), hex (\xnn), extended octal (\u or \U).
-  EXPECT_EQ(fmt("\uD55C"), QUOTE("한"));
-  EXPECT_EQ(fmt("\U00010348"), QUOTE("𐍈"));
+  EXPECT_EQ(fmt("\uD55C"), QUOTE("\uD55C"));
+  EXPECT_EQ(fmt("\U00010348"), QUOTE("\U00010348"));
 
   // FIXME: These strings are all rejected, but shouldn't be AFAICT. LLDB finds
   // that these are not valid utf8 sequences, but that's OK, the raw values
@@ -111,8 +111,8 @@ TEST(StringPrinterTests, CxxUTF8) {
   EXPECT_EQ(fmt("🥑"), QUOTE("🥑"));
 
   // Octal (\nnn), hex (\xnn), extended octal (\u or \U).
-  EXPECT_EQ(fmt("\uD55C"), QUOTE("한"));
-  EXPECT_EQ(fmt("\U00010348"), QUOTE("𐍈"));
+  EXPECT_EQ(fmt("\uD55C"), QUOTE("\uD55C"));
+  EXPECT_EQ(fmt("\U00010348"), QUOTE("\U00010348"));
 
   // FIXME: These strings are all rejected, but shouldn't be AFAICT. LLDB finds
   // that these are not valid utf8 sequences, but that's OK, the raw values
@@ -148,8 +148,8 @@ TEST(StringPrinterTests, SwiftUTF8) {
   EXPECT_EQ(fmt("🥑"), QUOTE("🥑"));
 
   // Octal (\nnn), hex (\xnn), extended octal (\u or \U).
-  EXPECT_EQ(fmt("\uD55C"), QUOTE("한"));
-  EXPECT_EQ(fmt("\U00010348"), QUOTE("𐍈"));
+  EXPECT_EQ(fmt("\uD55C"), QUOTE("\uD55C"));
+  EXPECT_EQ(fmt("\U00010348"), QUOTE("\U00010348"));
 
   // FIXME: These strings are all rejected, but shouldn't be AFAICT. LLDB finds
   // that these are not valid utf8 sequences, but that's OK, the raw values



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


[Lldb-commits] [lldb] 9e35498 - [lldb/Expression] Make Language() const, NFC

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:42:01-07:00
New Revision: 9e3549804672c79d64eececab39019f4dfd2b7ea

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

LOG: [lldb/Expression] Make Language() const, NFC

Allow Language() to be called from const methods within UserExpression.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 1e4453de04ff..aaac889e6ed2 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,7 +51,9 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+  virtual lldb::LanguageType Language() const {
+return lldb::eLanguageTypeUnknown;
+  }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8f3a505addea..8236c417f73a 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() override { return m_language; }
+  lldb::LanguageType Language() const override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] a37caeb - [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:06:55-07:00
New Revision: a37caebc2d2d93573075633493e104e8664cf9e9

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

LOG: [lldb/DataFormatters] Delete GetStringPrinterEscapingHelper

Summary:
Languages can have different ways of formatting special characters.
E.g. when debugging C++ code a string might look like "\b", but when
debugging Swift code the same string would look like "\u{8}".

To make this work, plugins override GetStringPrinterEscapingHelper.
However, because there's a large amount of subtly divergent work done in
each override, we end up with large amounts of duplicated code. And all
the memory smashers fixed in one copy of the logic (see D73860) don't
get fixed in the others.

IMO the GetStringPrinterEscapingHelper is overly general and hard to
use. I propose deleting it and replacing it with an EscapeStyle enum,
which can be set as needed by each plugin.

A fix for some swift-lldb memory smashers falls out fairly naturally
from this deletion (https://github.com/apple/llvm-project/pull/1046). As
the swift logic becomes really tiny, I propose moving it upstream as
part of this change. I've added unit tests to cover it.

rdar://61419673

Reviewers: JDevlieghere, davide

Subscribers: mgorny, lldb-commits

Tags: #lldb

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

Added: 
lldb/unittests/DataFormatter/StringPrinterTests.cpp

Modified: 
lldb/include/lldb/DataFormatters/StringPrinter.h
lldb/include/lldb/Target/Language.h
lldb/source/DataFormatters/StringPrinter.cpp
lldb/source/Plugins/Language/ObjC/NSString.cpp
lldb/source/Target/Language.cpp
lldb/unittests/DataFormatter/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/StringPrinter.h 
b/lldb/include/lldb/DataFormatters/StringPrinter.h
index 5842cde893d8..17c645f8637a 100644
--- a/lldb/include/lldb/DataFormatters/StringPrinter.h
+++ b/lldb/include/lldb/DataFormatters/StringPrinter.h
@@ -24,6 +24,8 @@ class StringPrinter {
 
   enum class GetPrintableElementType { ASCII, UTF8 };
 
+  enum class EscapeStyle { CXX, Swift };
+
   class DumpToStreamOptions {
   public:
 DumpToStreamOptions() = default;
@@ -68,9 +70,9 @@ class StringPrinter {
 
 bool GetIgnoreMaxLength() const { return m_ignore_max_length; }
 
-void SetLanguage(lldb::LanguageType l) { m_language_type = l; }
+void SetEscapeStyle(EscapeStyle style) { m_escape_style = style; }
 
-lldb::LanguageType GetLanguage() const { return m_language_type; }
+EscapeStyle GetEscapeStyle() const { return m_escape_style; }
 
   private:
 /// The used output stream.
@@ -93,12 +95,8 @@ class StringPrinter {
 /// True iff a zero bytes ('\0') should terminate the memory region that
 /// is being dumped.
 bool m_zero_is_terminator = true;
-/// The language that the generated string literal is supposed to be valid
-/// for. This changes for example what and how certain characters are
-/// escaped.
-/// For example, printing the a string containing only a quote (") char
-/// with eLanguageTypeC would escape the quote character.
-lldb::LanguageType m_language_type = lldb::eLanguageTypeUnknown;
+/// The language-specific style for escaping special characters.
+EscapeStyle m_escape_style = EscapeStyle::CXX;
   };
 
   class ReadStringAndDumpToStreamOptions : public DumpToStreamOptions {
@@ -147,71 +145,6 @@ class StringPrinter {
 bool m_is_truncated = false;
   };
 
-  // I can't use a std::unique_ptr for this because the Deleter is a template
-  // argument there
-  // and I want the same type to represent both pointers I want to free and
-  // pointers I don't need to free - which is what this class essentially is
-  // It's very specialized to the needs of this file, and not suggested for
-  // general use
-  struct StringPrinterBufferPointer {
-  public:
-typedef std::function Deleter;
-
-StringPrinterBufferPointer(std::nullptr_t ptr)
-: m_data(nullptr), m_size(0), m_deleter() {}
-
-StringPrinterBufferPointer(const uint8_t *bytes, size_t size,
-   Deleter deleter = nullptr)
-: m_data(bytes), m_size(size), m_deleter(deleter) {}
-
-StringPrinterBufferPointer(const char *bytes, size_t size,
-   Deleter deleter = nullptr)
-: m_data(reinterpret_cast(bytes)), m_size(size),
-  m_deleter(deleter) {}
-
-StringPrinterBufferPointer(StringPrinterBufferPointer &&rhs)
-: m_data(rhs.m_data), m_size(rhs.m_size), m_deleter(rhs.m_deleter) {
-  rhs.m_data = nullptr;
-}
-
-~StringPrinterBufferPointer() {
-  if (m_data && m_deleter)
-m_deleter(m_data);
-  m_data = nullptr;
-}
-
-cons

[Lldb-commits] [lldb] 47e9fd4 - Revert "[lldb/Expression] Make Language() const, NFC"

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:03:22-07:00
New Revision: 47e9fd47c71830e7a8987ef633f827cf4aff38fc

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

LOG: Revert "[lldb/Expression] Make Language() const, NFC"

This reverts commit 88d9e4326f48041056c4db3506d30574c6e1d83c. Revert an
accidental commit.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index aaac889e6ed2..1e4453de04ff 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,9 +51,7 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() const {
-return lldb::eLanguageTypeUnknown;
-  }
+  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8236c417f73a..8f3a505addea 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() const override { return m_language; }
+  lldb::LanguageType Language() override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] 88d9e43 - [lldb/Expression] Make Language() const, NFC

2020-05-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-05-04T14:02:43-07:00
New Revision: 88d9e4326f48041056c4db3506d30574c6e1d83c

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

LOG: [lldb/Expression] Make Language() const, NFC

Allow Language() to be called from const methods within UserExpression.

Added: 


Modified: 
lldb/include/lldb/Expression/Expression.h
lldb/include/lldb/Expression/UserExpression.h

Removed: 




diff  --git a/lldb/include/lldb/Expression/Expression.h 
b/lldb/include/lldb/Expression/Expression.h
index 1e4453de04ff..aaac889e6ed2 100644
--- a/lldb/include/lldb/Expression/Expression.h
+++ b/lldb/include/lldb/Expression/Expression.h
@@ -51,7 +51,9 @@ class Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  virtual lldb::LanguageType Language() { return lldb::eLanguageTypeUnknown; }
+  virtual lldb::LanguageType Language() const {
+return lldb::eLanguageTypeUnknown;
+  }
 
   /// Return the Materializer that the parser should use when registering
   /// external values.

diff  --git a/lldb/include/lldb/Expression/UserExpression.h 
b/lldb/include/lldb/Expression/UserExpression.h
index 8f3a505addea..8236c417f73a 100644
--- a/lldb/include/lldb/Expression/UserExpression.h
+++ b/lldb/include/lldb/Expression/UserExpression.h
@@ -194,7 +194,7 @@ class UserExpression : public Expression {
 
   /// Return the language that should be used when parsing.  To use the
   /// default, return eLanguageTypeUnknown.
-  lldb::LanguageType Language() override { return m_language; }
+  lldb::LanguageType Language() const override { return m_language; }
 
   /// Return the desired result type of the function, or eResultTypeAny if
   /// in
diff erent.



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


[Lldb-commits] [lldb] f203100 - Reapply: [Host.mm] Check for the right macro instead of inlining it

2020-04-01 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-04-01T15:23:07-07:00
New Revision: f203100ebe22bf97a4268a562cdbef22d14db915

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

LOG: Reapply: [Host.mm] Check for the right macro instead of inlining it

Previously, this was reverted in bf65f19b becuase it checked whether
TARGET_OS_EMBEDDED is defined, but that macro is always defined.

Update the condition to check that TARGET_OS_OSX is true.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index eba3060f8ec6..045ba7f3671f 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -9,13 +9,9 @@
 #include "lldb/Host/Host.h"
 
 #include 
+#include 
 
-// On device doesn't have supporty for XPC.
-#if defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__))
-#define NO_XPC_SERVICES 1
-#endif
-
-#if !defined(NO_XPC_SERVICES)
+#if TARGET_OS_OSX
 #define __XPC_PRIVATE_H__
 #include 
 
@@ -135,6 +131,8 @@
   return false;
 }
 
+#if TARGET_OS_OSX
+
 static void *AcceptPIDFromInferior(void *arg) {
   const char *connect_url = (const char *)arg;
   ConnectionFileDescriptor file_conn;
@@ -153,8 +151,6 @@
   return NULL;
 }
 
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
-
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
 "   activate\n"
 "  do script \"/bin/bash -c '%s';exit\"\n"
@@ -307,13 +303,13 @@ repeat with the_window in (get windows)\n\
   return error;
 }
 
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // TARGET_OS_OSX
 
 bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
 uint32_t line_no) {
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#if !TARGET_OS_OSX
   return false;
-#else
+#else // !TARGET_OS_OSX
   // We attach this to an 'odoc' event to specify a particular selection
   typedef struct {
 int16_t reserved0; // must be zero
@@ -404,7 +400,7 @@ repeat with the_window in (get windows)\n\
   }
 
   return true;
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // TARGET_OS_OSX
 }
 
 Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); }
@@ -689,7 +685,7 @@ static bool 
GetMacOSXProcessUserAndGroup(ProcessInstanceInfo &process_info) {
   return false;
 }
 
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
 static void PackageXPCArguments(xpc_object_t message, const char *prefix,
 const Args &args) {
   size_t count = args.GetArgumentCount();
@@ -841,7 +837,7 @@ static short GetPosixspawnFlags(const ProcessLaunchInfo 
&launch_info) {
 static Status LaunchProcessXPC(const char *exe_path,
ProcessLaunchInfo &launch_info,
lldb::pid_t &pid) {
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
   Status error = getXPCAuthorization(launch_info);
   if (error.Fail())
 return error;
@@ -1194,7 +1190,7 @@ static Status LaunchProcessPosixSpawn(const char 
*exe_path,
 static bool ShouldLaunchUsingXPC(ProcessLaunchInfo &launch_info) {
   bool result = false;
 
-#if !NO_XPC_SERVICES
+#if TARGET_OS_OSX
   bool launchingAsRoot = launch_info.GetUserID() == 0;
   bool currentUserIsRoot = HostInfo::GetEffectiveUserID() == 0;
 
@@ -1226,7 +1222,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo 
&launch_info) {
   }
 
   if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#if TARGET_OS_OSX
 return LaunchInNewTerminalWithAppleScript(exe_spec.GetPath().c_str(),
   launch_info);
 #else



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


[Lldb-commits] [lldb] 03e29e2 - [lldb/DWARF] Reland: Use DW_AT_call_pc to determine artificial frame address

2020-03-24 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-03-24T12:54:40-07:00
New Revision: 03e29e2c19a8e1f6a225b1878df3eed4e54891e5

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

LOG: [lldb/DWARF] Reland: Use DW_AT_call_pc to determine artificial frame 
address

Reland with changes: the test modified in this change originally failed
on a Debian/x86_64 builder, and I suspect the cause was that lldb looked
up the line location for an artificial frame by subtracting 1 from the
frame's address. For artificial frames, the subtraction must not happen
because the address is already exact.

---

lldb currently guesses the address to use when creating an artificial
frame (i.e., a frame constructed by determining the sequence of (tail)
calls which must have happened).

Guessing the address creates problems -- use the actual address provided
by the DW_AT_call_pc attribute instead.

Depends on D76336.

rdar://60307600

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

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Target/StackFrameList.cpp
lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 0db9a5116d25..40d316fa78eb 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -284,19 +284,33 @@ class CallEdge {
   /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
+  /// Get the load PC address of the call instruction (or 
LLDB_INVALID_ADDRESS).
+  lldb::addr_t GetCallInstPC(Function &caller, Target &target) const;
+
   /// Get the call site parameters available at this call edge.
   llvm::ArrayRef GetCallSiteParameters() const {
 return parameters;
   }
 
 protected:
-  CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters)
-  : return_pc(return_pc), parameters(std::move(parameters)) {}
+  CallEdge(lldb::addr_t return_pc, lldb::addr_t call_inst_pc,
+   CallSiteParameterArray &¶meters)
+  : return_pc(return_pc), call_inst_pc(call_inst_pc),
+parameters(std::move(parameters)) {}
+
+  /// Helper that finds the load address of \p unresolved_pc, a file address
+  /// which refers to an instruction within \p caller.
+  static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc,
+ Function &caller, Target &target);
 
   /// An invalid address if this is a tail call. Otherwise, the return PC for
   /// the call. Note that this is a file address which must be resolved.
   lldb::addr_t return_pc;
 
+  /// The address of the call instruction. Usually an invalid address, unless
+  /// this is a tail call.
+  lldb::addr_t call_inst_pc;
+
   CallSiteParameterArray parameters;
 };
 
@@ -308,8 +322,8 @@ class DirectCallEdge : public CallEdge {
   /// Construct a call edge using a symbol name to identify the callee, and a
   /// return PC within the calling function to identify a specific call site.
   DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc,
- CallSiteParameterArray &¶meters)
-  : CallEdge(return_pc, std::move(parameters)) {
+ lldb::addr_t call_inst_pc, CallSiteParameterArray 
&¶meters)
+  : CallEdge(return_pc, call_inst_pc, std::move(parameters)) {
 lazy_callee.symbol_name = symbol_name;
   }
 
@@ -339,8 +353,9 @@ class IndirectCallEdge : public CallEdge {
   /// Construct a call edge using a DWARFExpression to identify the callee, and
   /// a return PC within the calling function to identify a specific call site.
   IndirectCallEdge(DWARFExpression call_target, lldb::addr_t return_pc,
+   lldb::addr_t call_inst_pc,
CallSiteParameterArray &¶meters)
-  : CallEdge(return_pc, std::move(parameters)),
+  : CallEdge(return_pc, call_inst_pc, std::move(parameters)),
 call_target(std::move(call_target)) {}
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index a703b1e1217d..c98694fca6b5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3737,6 +3737,7 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 llvm::Optional call_origin;
 llvm::Optional call_target;
 addr_t return_pc = LLDB_INVALID_ADDRESS;
+addr_t call_inst_pc = LLDB_INVALID_ADDRESS;
 
 DWAR

[Lldb-commits] [lldb] 0a9b91c - Revert "[lldb/DWARF] Use DW_AT_call_pc to determine artificial frame address"

2020-03-24 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-03-24T12:22:12-07:00
New Revision: 0a9b91c390b281e90e51d5839557c5a189dd5401

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

LOG: Revert "[lldb/DWARF] Use DW_AT_call_pc to determine artificial frame 
address"

This reverts commit 6905394d153960ded3a7b884a9747ed2d4a6e8d8. The
changed test is failing on Debian/x86_64, possibly because lldb is
subtracting an offset from the DW_AT_call_pc address used for the
artificial frame:

http://lab.llvm.org:8011/builders/lldb-x86_64-debian/builds/7171/steps/test/logs/stdio

/home/worker/lldb-x86_64-debian/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/main.cpp:6:17:
 error: CHECK-NEXT: expected string not found in input
 // CHECK-NEXT: frame #1: 0x{{[0-9a-f]+}} a.out`func3() at main.cpp:14:3 [opt] 
[artificial]
^
:3:2: note: scanning from here
 frame #1: 0x00401127 a.out`func3() at main.cpp:13:4 [opt] [artificial]

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Target/StackFrameList.cpp
lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 40d316fa78eb..0db9a5116d25 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -284,33 +284,19 @@ class CallEdge {
   /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
-  /// Get the load PC address of the call instruction (or 
LLDB_INVALID_ADDRESS).
-  lldb::addr_t GetCallInstPC(Function &caller, Target &target) const;
-
   /// Get the call site parameters available at this call edge.
   llvm::ArrayRef GetCallSiteParameters() const {
 return parameters;
   }
 
 protected:
-  CallEdge(lldb::addr_t return_pc, lldb::addr_t call_inst_pc,
-   CallSiteParameterArray &¶meters)
-  : return_pc(return_pc), call_inst_pc(call_inst_pc),
-parameters(std::move(parameters)) {}
-
-  /// Helper that finds the load address of \p unresolved_pc, a file address
-  /// which refers to an instruction within \p caller.
-  static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc,
- Function &caller, Target &target);
+  CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters)
+  : return_pc(return_pc), parameters(std::move(parameters)) {}
 
   /// An invalid address if this is a tail call. Otherwise, the return PC for
   /// the call. Note that this is a file address which must be resolved.
   lldb::addr_t return_pc;
 
-  /// The address of the call instruction. Usually an invalid address, unless
-  /// this is a tail call.
-  lldb::addr_t call_inst_pc;
-
   CallSiteParameterArray parameters;
 };
 
@@ -322,8 +308,8 @@ class DirectCallEdge : public CallEdge {
   /// Construct a call edge using a symbol name to identify the callee, and a
   /// return PC within the calling function to identify a specific call site.
   DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc,
- lldb::addr_t call_inst_pc, CallSiteParameterArray 
&¶meters)
-  : CallEdge(return_pc, call_inst_pc, std::move(parameters)) {
+ CallSiteParameterArray &¶meters)
+  : CallEdge(return_pc, std::move(parameters)) {
 lazy_callee.symbol_name = symbol_name;
   }
 
@@ -353,9 +339,8 @@ class IndirectCallEdge : public CallEdge {
   /// Construct a call edge using a DWARFExpression to identify the callee, and
   /// a return PC within the calling function to identify a specific call site.
   IndirectCallEdge(DWARFExpression call_target, lldb::addr_t return_pc,
-   lldb::addr_t call_inst_pc,
CallSiteParameterArray &¶meters)
-  : CallEdge(return_pc, call_inst_pc, std::move(parameters)),
+  : CallEdge(return_pc, std::move(parameters)),
 call_target(std::move(call_target)) {}
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index c98694fca6b5..a703b1e1217d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3737,7 +3737,6 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 llvm::Optional call_origin;
 llvm::Optional call_target;
 addr_t return_pc = LLDB_INVALID_ADDRESS;
-addr_t call_inst_pc = LLDB_INVALID_AD

[Lldb-commits] [lldb] 6905394 - [lldb/DWARF] Use DW_AT_call_pc to determine artificial frame address

2020-03-24 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-03-24T12:02:03-07:00
New Revision: 6905394d153960ded3a7b884a9747ed2d4a6e8d8

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

LOG: [lldb/DWARF] Use DW_AT_call_pc to determine artificial frame address

lldb currently guesses the address to use when creating an artificial
frame (i.e., a frame constructed by determining the sequence of (tail)
calls which must have happened).

Guessing the address creates problems -- use the actual address provided
by the DW_AT_call_pc attribute instead.

Depends on D76336.

rdar://60307600

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

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/Function.cpp
lldb/source/Target/StackFrameList.cpp
lldb/test/API/functionalities/tail_call_frames/unambiguous_sequence/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 0db9a5116d25..40d316fa78eb 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -284,19 +284,33 @@ class CallEdge {
   /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
+  /// Get the load PC address of the call instruction (or 
LLDB_INVALID_ADDRESS).
+  lldb::addr_t GetCallInstPC(Function &caller, Target &target) const;
+
   /// Get the call site parameters available at this call edge.
   llvm::ArrayRef GetCallSiteParameters() const {
 return parameters;
   }
 
 protected:
-  CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters)
-  : return_pc(return_pc), parameters(std::move(parameters)) {}
+  CallEdge(lldb::addr_t return_pc, lldb::addr_t call_inst_pc,
+   CallSiteParameterArray &¶meters)
+  : return_pc(return_pc), call_inst_pc(call_inst_pc),
+parameters(std::move(parameters)) {}
+
+  /// Helper that finds the load address of \p unresolved_pc, a file address
+  /// which refers to an instruction within \p caller.
+  static lldb::addr_t GetLoadAddress(lldb::addr_t unresolved_pc,
+ Function &caller, Target &target);
 
   /// An invalid address if this is a tail call. Otherwise, the return PC for
   /// the call. Note that this is a file address which must be resolved.
   lldb::addr_t return_pc;
 
+  /// The address of the call instruction. Usually an invalid address, unless
+  /// this is a tail call.
+  lldb::addr_t call_inst_pc;
+
   CallSiteParameterArray parameters;
 };
 
@@ -308,8 +322,8 @@ class DirectCallEdge : public CallEdge {
   /// Construct a call edge using a symbol name to identify the callee, and a
   /// return PC within the calling function to identify a specific call site.
   DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc,
- CallSiteParameterArray &¶meters)
-  : CallEdge(return_pc, std::move(parameters)) {
+ lldb::addr_t call_inst_pc, CallSiteParameterArray 
&¶meters)
+  : CallEdge(return_pc, call_inst_pc, std::move(parameters)) {
 lazy_callee.symbol_name = symbol_name;
   }
 
@@ -339,8 +353,9 @@ class IndirectCallEdge : public CallEdge {
   /// Construct a call edge using a DWARFExpression to identify the callee, and
   /// a return PC within the calling function to identify a specific call site.
   IndirectCallEdge(DWARFExpression call_target, lldb::addr_t return_pc,
+   lldb::addr_t call_inst_pc,
CallSiteParameterArray &¶meters)
-  : CallEdge(return_pc, std::move(parameters)),
+  : CallEdge(return_pc, call_inst_pc, std::move(parameters)),
 call_target(std::move(call_target)) {}
 
   Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index a703b1e1217d..c98694fca6b5 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -3737,6 +3737,7 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
 llvm::Optional call_origin;
 llvm::Optional call_target;
 addr_t return_pc = LLDB_INVALID_ADDRESS;
+addr_t call_inst_pc = LLDB_INVALID_ADDRESS;
 
 DWARFAttributes attributes;
 const size_t num_attributes = child.GetAttributes(attributes);
@@ -3765,6 +3766,12 @@ SymbolFileDWARF::CollectCallEdges(ModuleSP module, 
DWARFDIE function_die) {
   if (attr == DW_AT_call_return_pc)
 return_pc = form_value.Address();
 
+  // Extract DW_AT_call_pc (the PC at the call/branch inst

[Lldb-commits] [lldb] 7822c8c - [lldb/test] Skip running a test under ASan, it intentionally double-frees

2020-02-26 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-26T10:11:39-08:00
New Revision: 7822c8c03e9fe8c857da21c4ccbe28396b43130d

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

LOG: [lldb/test] Skip running a test under ASan, it intentionally double-frees

Added: 


Modified: 
lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py 
b/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
index 3caa7c5d905a..d0f47de83eea 100644
--- a/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
+++ b/lldb/test/API/functionalities/process_crash_info/TestProcessCrashInfo.py
@@ -25,6 +25,7 @@ def tearDown(self):
 self.runCmd("settings clear auto-confirm")
 TestBase.tearDown(self)
 
+@skipIfAsan # The test process intentionally double-frees.
 @skipUnlessDarwin
 def test_cli(self):
 """Test that `process status --verbose` fetches the extended crash
@@ -41,6 +42,7 @@ def test_cli(self):
 patterns=["\"message\".*pointer being freed was not 
allocated"])
 
 
+@skipIfAsan # The test process intentionally hits a memory bug.
 @skipUnlessDarwin
 def test_api(self):
 """Test that lldb can fetch a crashed process' extended crash 
information



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


[Lldb-commits] [lldb] 8a0f0e2 - [lldb/test] Tweak libcxx string test on Apple+ARM devices

2020-02-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-21T15:54:38-08:00
New Revision: 8a0f0e2656abf76b771037c6543caf9a31744120

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

LOG: [lldb/test] Tweak libcxx string test on Apple+ARM devices

On Apple platforms, is __arm__ isn't defined and we're not on Intel, we use an
alternate std::string layout. I.e., the libcxx string test fails on phones
because the hand-crafted "garbage" string structs are actually valid strings.

See:

```
  // _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for
  // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility.
  #if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) &&  
 \
   (!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) ||  
 \
  defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
  #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
  #endif
```

Disable inspection of the garbage structs on Apple+ARM devices.

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
index 3753067113b1..c6f95d7e8593 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py
@@ -116,7 +116,9 @@ def cleanup():
 '%s::allocator >) uchar = "a"'%(ns,ns,ns),
 ])
 
-if is_64_bit:
+# The test assumes that std::string is in its cap-size-data layout.
+is_alternate_layout = ('arm' in self.getArchitecture()) and 
self.platformIsDarwin()
+if is_64_bit and not is_alternate_layout:
 self.expect("frame variable garbage1", substrs=['garbage1 = 
Summary Unavailable'])
 self.expect("frame variable garbage2", substrs=['garbage2 = 
Summary Unavailable'])
 self.expect("frame variable garbage3", substrs=['garbage3 = 
Summary Unavailable'])



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


[Lldb-commits] [lldb] 7aabad1 - [lldb/StringPrinter] Avoid reading garbage in uninitialized strings

2020-02-12 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-12T11:24:03-08:00
New Revision: 7aabad131288a598c90903ae7d96383105ae3fc2

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

LOG: [lldb/StringPrinter] Avoid reading garbage in uninitialized strings

This patch fixes a few related out-of-bounds read bugs in the
string data formatters. These issues have to do with mishandling of un-
initialized strings. These manifest as ASan exceptions when debugging a
clang binary.

The first issue was that the std::string formatter treated strings in
"short mode" with length greater than the size of the inline buffer as
valid.

The second issue was that the StringPrinter facility did not check that
a full utf8 codepoint sequence can be read from the buffer (i.e. there
are some missing range checks). I took the opportunity here to delete
some untested code that was meant to deal with invalid input and replace
it with fail-on-invalid logic ([1][2][3]). This means we'll give up on
formatting an invalid string instead of guessing our way through it.

The third issue is that StringPrinter did not check that a utf8 sequence
could actually be fully read from the string payload. This one is especially
tricky as we may overflow the buffer pointer while reading the sequence.

I also noticed that the std::string formatter would spew the raw version of
the underlying ValueObject when garbage is detected. I've changed this to
just print "Summary Unavailable" instead, as we do elsewhere.

I've added regression tests for these issues to
test/functionalities/data-formatter/data-formatter-stl/libcxx/string.

[1]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L136
[2]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L163
[3]
http://lab.llvm.org:8080/coverage/coverage-reports/coverage/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/DataFormatters/StringPrinter.cpp.html#L357

rdar://59080026

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

Added: 


Modified: 
lldb/source/DataFormatters/StringPrinter.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/StringPrinter.cpp 
b/lldb/source/DataFormatters/StringPrinter.cpp
index 1e05c7106c60..92dd71d17b8c 100644
--- a/lldb/source/DataFormatters/StringPrinter.cpp
+++ b/lldb/source/DataFormatters/StringPrinter.cpp
@@ -131,14 +131,15 @@ 
GetPrintableImpl(uint8_t *buffer,
  uint8_t *&next) {
   StringPrinter::StringPrinterBufferPointer retval{nullptr};
 
-  unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer);
+  const unsigned utf8_encoded_len = llvm::getNumBytesForUTF8(*buffer);
 
-  if (1u + std::distance(buffer, buffer_end) < utf8_encoded_len) {
-// I don't have enough bytes - print whatever I have left
-retval = {buffer, static_cast(1 + buffer_end - buffer)};
-next = buffer_end + 1;
+  // If the utf8 encoded length is invalid, or if there aren't enough bytes to
+  // print, this is some kind of corrupted string.
+  if (utf8_encoded_len == 0 || utf8_encoded_len > 4)
+return retval;
+  if ((buffer_end - buffer) < utf8_encoded_len)
+// There's no room in the buffer for the utf8 sequence.
 return retval;
-  }
 
   char32_t codepoint = 0;
   switch (utf8_encoded_len) {
@@ -160,12 +161,6 @@ 
GetPrintableImpl(uint8_t *buffer,
 (unsigned char)*buffer, (unsigned char)*(buffer + 1),
 (unsigned char)*(buffer + 2), (unsigned char)*(buffer + 3));
 break;
-  default:
-// this is probably some bogus non-character thing just print it as-is and
-// hope to sync up again soon
-retval = {buffer, 1};
-next = buffer + 1;
-return retval;
   }
 
   if (codepoint) {
@@ -215,9 +210,7 @@ 
GetPrintableImpl(uint8_t *buffer,
 return retval;
   }
 
-  // this should not happen - but just in case.. try to resync at some point
-  retval = {buffer, 1};
-  next = buffer + 1;
+  // We couldn't figure out how to print this string.
   return retval;
 }
 
@@ -227,7 +220,7 @@ 
GetPrintableImpl(uint8_t *buffer,
 static StringPrinter::StringPrinterBufferPointer
 GetPrintable(StringPrinter::StringElementType type, uint8_t *buffer,
  uint8_t *buffer_end, uint8_t *&next) {
-  if (!buffer)
+  if (!buffer || buffer >= buffer_end)
 return {nullptr};
 
   switc

[Lldb-commits] [lldb] 90a94c0 - [lldb/LibCxx] Have ExtractLibcxxStringInfo return an Optional result, NFC

2020-02-12 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-12T11:24:03-08:00
New Revision: 90a94c02fb243f0b49ee9933b0e8145147f84e32

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

LOG: [lldb/LibCxx] Have ExtractLibcxxStringInfo return an Optional result, NFC

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

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index e9e4db97ebbe..7152ff407f29 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -468,22 +468,20 @@ enum LibcxxStringLayoutMode {
   eLibcxxStringLayoutModeInvalid = 0x
 };
 
-// this function abstracts away the layout and mode details of a libc++ string
-// and returns the address of the data and the size ready for callers to
-// consume
-static bool ExtractLibcxxStringInfo(ValueObject &valobj,
-ValueObjectSP &location_sp,
-uint64_t &size) {
+/// Determine the size in bytes of \p valobj (a libc++ std::string object) and
+/// extract its data payload. Return the size + payload pair.
+static llvm::Optional>
+ExtractLibcxxStringInfo(ValueObject &valobj) {
   ValueObjectSP D(valobj.GetChildAtIndexPath({0, 0, 0, 0}));
   if (!D)
-return false;
+return {};
 
   ValueObjectSP layout_decider(
 D->GetChildAtIndexPath(llvm::ArrayRef({0, 0})));
 
   // this child should exist
   if (!layout_decider)
-return false;
+return {};
 
   ConstString g_data_name("__data_");
   ConstString g_size_name("__size_");
@@ -497,13 +495,13 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
   if (layout == eLibcxxStringLayoutModeDSC) {
 ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 1, 0}));
 if (!size_mode)
-  return false;
+  return {};
 
 if (size_mode->GetName() != g_size_name) {
   // we are hitting the padding structure, move along
   size_mode = D->GetChildAtIndexPath({1, 1, 1});
   if (!size_mode)
-return false;
+return {};
 }
 
 size_mode_value = (size_mode->GetValueAsUnsigned(0));
@@ -511,7 +509,7 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
   } else {
 ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 0, 0}));
 if (!size_mode)
-  return false;
+  return {};
 
 size_mode_value = (size_mode->GetValueAsUnsigned(0));
 short_mode = ((size_mode_value & 1) == 0);
@@ -520,12 +518,12 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
   if (short_mode) {
 ValueObjectSP s(D->GetChildAtIndex(1, true));
 if (!s)
-  return false;
-location_sp = s->GetChildAtIndex(
+  return {};
+ValueObjectSP location_sp = s->GetChildAtIndex(
 (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
-size = (layout == eLibcxxStringLayoutModeDSC)
-   ? size_mode_value
-   : ((size_mode_value >> 1) % 256);
+const uint64_t size = (layout == eLibcxxStringLayoutModeDSC)
+  ? size_mode_value
+  : ((size_mode_value >> 1) % 256);
 
 // When the small-string optimization takes place, the data must fit in the
 // inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's
@@ -534,39 +532,44 @@ static bool ExtractLibcxxStringInfo(ValueObject &valobj,
 const llvm::Optional max_bytes =
 location_sp->GetCompilerType().GetByteSize(
 exe_ctx.GetBestExecutionContextScope());
-if (!max_bytes || size > *max_bytes)
-  return false;
+if (!max_bytes || size > *max_bytes || !location_sp)
+  return {};
 
-return (location_sp.get() != nullptr);
-  } else {
-ValueObjectSP l(D->GetChildAtIndex(0, true));
-if (!l)
-  return false;
-// we can use the layout_decider object as the data pointer
-location_sp = (layout == eLibcxxStringLayoutModeDSC)
-  ? layout_decider
-  : l->GetChildAtIndex(2, true);
-ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
-const unsigned capacity_index =
-(layout == eLibcxxStringLayoutModeDSC) ? 2 : 0;
-ValueObjectSP capacity_vo(l->GetChildAtIndex(capacity_index, true));
-if (!size_vo || !location_sp || !capacity_vo)
-  return false;
-size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
-const uint64_t cap = capacity_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
-if (size == LLDB_INVALID_OFFSET || cap == LLDB_INVALID_OFFSET || cap < 
size)
-  return false;
-return true;
+return std::make_pair(size, location_sp);
   }
+
+  ValueObjectSP l(D->GetChildAtIndex(0, true

[Lldb-commits] [lldb] d6e47a4 - [lldb/TypeSystemClang] Supply trivial TypeSourceInfo to NonTypeTemplateParmDecl::Create

2020-02-12 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-12T11:24:02-08:00
New Revision: d6e47a405a3481c9c40ebe1c339349c01c504bd6

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

LOG: [lldb/TypeSystemClang] Supply trivial TypeSourceInfo to 
NonTypeTemplateParmDecl::Create

This fixes a UBSan error seen while debugging clang:

Member call on null pointer of type 'clang::TypeSourceInfo'

rdar://58783517

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

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 3d9a80dd3f73..cbe0301fe162 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1277,11 +1277,12 @@ static TemplateParameterList 
*CreateTemplateParameterList(
 if (name && name[0])
   identifier_info = &ast.Idents.get(name);
 if (IsValueParam(template_param_infos.args[i])) {
+  QualType template_param_type =
+  template_param_infos.args[i].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,
-  identifier_info, template_param_infos.args[i].getIntegralType(),
-  parameter_pack, nullptr));
-
+  identifier_info, template_param_type, parameter_pack,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth, i,

diff  --git a/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp 
b/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
index 9278d01f8c57..836a8301658a 100644
--- a/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
+++ b/lldb/test/API/lang/cpp/class-template-parameter-pack/main.cpp
@@ -34,6 +34,11 @@ template <> struct D : D {
   bool isIntBool() { return true; }
 };
 
+template struct array {
+  int Arr[Size];
+  array() {}
+};
+
 int main (int argc, char const *argv[])
 {
 C myC;
@@ -53,12 +58,15 @@ int main (int argc, char const *argv[])
 D myLesserD;
 myD.member = 64;
 (void)D().isIntBool();
-(void)D().isIntBool();
-return myD.member != 64;   //% self.expect("expression -- myD", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
+(void)D().isIntBool(); //% self.expect("expression -- myD", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["64"])
 //% self.expect("expression -- 
myLesserD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
 //% self.expect("expression -- 
myD.isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
 
 // See comment above.
 //#% self.expect("expression -- D().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["false"])
 //#% self.expect("expression -- D().isIntBool()", DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["true"])
+
+array<3> myArray; //% self.expect("expression -- myArray", 
DATA_TYPES_DISPLAYED_CORRECTLY, substrs = ["Arr"])
+
+return 1;
 }



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


[Lldb-commits] [lldb] bf65f19 - Revert "[Host.mm] Check for the right macro instead of inlining it"

2020-02-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-10T14:34:48-08:00
New Revision: bf65f19bce88fd9f1a74154d92afe37193ecd7a5

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

LOG: Revert "[Host.mm] Check for the right macro instead of inlining it"

This breaks macOS, because TARGET_OS_EMBEDDED is always defined. Thanks
to Jason Molenda for pointing this out.

Revert "Do not define AcceptPIDFromInferior when it will not be used"

This reverts commit d23c15a687ff15327b88fa64da3184395012c2dc.
This reverts commit 936d1427da1432d724dfa5851097347bcdf7c521.

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 778cf3d90869..233734109c41 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -9,10 +9,9 @@
 #include "lldb/Host/Host.h"
 
 #include 
-#include 
 
 // On device doesn't have supporty for XPC.
-#if defined(__APPLE__) && defined(TARGET_OS_EMBEDDED)
+#if defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__))
 #define NO_XPC_SERVICES 1
 #endif
 
@@ -136,8 +135,6 @@
   return false;
 }
 
-#if !NO_XPC_SERVICES
-
 static void *AcceptPIDFromInferior(void *arg) {
   const char *connect_url = (const char *)arg;
   ConnectionFileDescriptor file_conn;
@@ -156,6 +153,8 @@
   return NULL;
 }
 
+#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
 "   activate\n"
 "  do script \"/bin/bash -c '%s';exit\"\n"
@@ -308,11 +307,11 @@ repeat with the_window in (get windows)\n\
   return error;
 }
 
-#endif // #if !NO_XPC_SERVICES
+#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 
 bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
 uint32_t line_no) {
-#if NO_XPC_SERVICES
+#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
   return false;
 #else
   // We attach this to an 'odoc' event to specify a particular selection
@@ -405,7 +404,7 @@ repeat with the_window in (get windows)\n\
   }
 
   return true;
-#endif // #if !NO_XPC_SERVICES
+#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 }
 
 Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); }
@@ -1264,7 +1263,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo 
&launch_info) {
   }
 
   if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
-#if !NO_XPC_SERVICES
+#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
 return LaunchInNewTerminalWithAppleScript(exe_spec.GetPath().c_str(),
   launch_info);
 #else



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


[Lldb-commits] [lldb] d23c15a - Do not define AcceptPIDFromInferior when it will not be used

2020-02-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-10T12:06:46-08:00
New Revision: d23c15a687ff15327b88fa64da3184395012c2dc

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

LOG: Do not define AcceptPIDFromInferior when it will not be used

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 8c22b57d09d8..778cf3d90869 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -136,6 +136,8 @@
   return false;
 }
 
+#if !NO_XPC_SERVICES
+
 static void *AcceptPIDFromInferior(void *arg) {
   const char *connect_url = (const char *)arg;
   ConnectionFileDescriptor file_conn;
@@ -154,8 +156,6 @@
   return NULL;
 }
 
-#if !NO_XPC_SERVICES
-
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
 "   activate\n"
 "  do script \"/bin/bash -c '%s';exit\"\n"



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


[Lldb-commits] [lldb] eaeb561 - debugserver: Rely on mig architectures being specified externally

2020-02-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-10T10:13:05-08:00
New Revision: eaeb5610ced23404f2c799d6e0c46c05f06ac3b5

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

LOG: debugserver: Rely on mig architectures being specified externally

Look up the -arch flags to pass to the mig invocation from an
optionally-defined MIG_ARCHS variable. We can't use CMAKE_OSX_ARCHS
because the {i,tv,watch}OS builds don't use this mechanism to achieve
fat builds (they build each slice separately & then lipo them together).

This supercedes the mig -arch/-isysroot fix from
510758dae2a8fa4b0b26dea89d4d1efd576b8ad6.

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index ef8dcd1f5353..151386d0c130 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -136,9 +136,11 @@ set(generated_mach_interfaces
   )
 
 set(MIG_ARCH_FLAGS "")
-foreach(ARCH ${CMAKE_OSX_ARCHITECTURES})
-  set(MIG_ARCH_FLAGS "${MIG_ARCH_FLAGS} -arch ${ARCH}")
-endforeach()
+if (DEFINED MIG_ARCHS)
+  foreach(ARCH ${MIG_ARCHS})
+set(MIG_ARCH_FLAGS "${MIG_ARCH_FLAGS} -arch ${ARCH}")
+  endforeach()
+endif()
 separate_arguments(MIG_ARCH_FLAGS_SEPARTED NATIVE_COMMAND "${MIG_ARCH_FLAGS}")
 
 add_custom_command(OUTPUT ${generated_mach_interfaces}



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


[Lldb-commits] [lldb] 936d142 - [Host.mm] Check for the right macro instead of inlining it

2020-02-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-10T10:06:40-08:00
New Revision: 936d1427da1432d724dfa5851097347bcdf7c521

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

LOG: [Host.mm] Check for the right macro instead of inlining it

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

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/Host.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/Host.mm 
b/lldb/source/Host/macosx/objcxx/Host.mm
index 233734109c41..8c22b57d09d8 100644
--- a/lldb/source/Host/macosx/objcxx/Host.mm
+++ b/lldb/source/Host/macosx/objcxx/Host.mm
@@ -9,9 +9,10 @@
 #include "lldb/Host/Host.h"
 
 #include 
+#include 
 
 // On device doesn't have supporty for XPC.
-#if defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__))
+#if defined(__APPLE__) && defined(TARGET_OS_EMBEDDED)
 #define NO_XPC_SERVICES 1
 #endif
 
@@ -153,7 +154,7 @@
   return NULL;
 }
 
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#if !NO_XPC_SERVICES
 
 const char *applscript_in_new_tty = "tell application \"Terminal\"\n"
 "   activate\n"
@@ -307,11 +308,11 @@ repeat with the_window in (get windows)\n\
   return error;
 }
 
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // #if !NO_XPC_SERVICES
 
 bool Host::OpenFileInExternalEditor(const FileSpec &file_spec,
 uint32_t line_no) {
-#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
+#if NO_XPC_SERVICES
   return false;
 #else
   // We attach this to an 'odoc' event to specify a particular selection
@@ -404,7 +405,7 @@ repeat with the_window in (get windows)\n\
   }
 
   return true;
-#endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#endif // #if !NO_XPC_SERVICES
 }
 
 Environment Host::GetEnvironment() { return Environment(*_NSGetEnviron()); }
@@ -1263,7 +1264,7 @@ static bool ShouldLaunchUsingXPC(ProcessLaunchInfo 
&launch_info) {
   }
 
   if (launch_info.GetFlags().Test(eLaunchFlagLaunchInTTY)) {
-#if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__)
+#if !NO_XPC_SERVICES
 return LaunchInNewTerminalWithAppleScript(exe_spec.GetPath().c_str(),
   launch_info);
 #else



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


[Lldb-commits] [lldb] e05af08 - [lldb/StackFrameList] Convert assert to defensive check in SynthesizeTailCallFrames

2020-02-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-04T10:43:50-08:00
New Revision: e05af081bf7cbc738b2e4cdfa91054fff0153ce3

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

LOG: [lldb/StackFrameList] Convert assert to defensive check in 
SynthesizeTailCallFrames

In order to synthesize tail call frames, the stack frame list must not
be empty (otherwise, there is no "previous" frame to infer a tail call
from).

This case is hard to hit. To trigger it, we must first fail to push
`unwind_frame_sp` because we either fail to get its SymbolContext, or
given its SymbolContext the GetParentOfInlineScope call fails. This
causes m_concrete_frames_fetched to be incremented while m_frames
remains empty. Then, the next frame in the stack may fail within
SynthesizeTailCallFrames. This crash arose during a kernel debugging
session.

rdar://59147051

Added: 


Modified: 
lldb/source/Target/StackFrameList.cpp

Removed: 




diff  --git a/lldb/source/Target/StackFrameList.cpp 
b/lldb/source/Target/StackFrameList.cpp
index 13df807c3be4..0047697f7070 100644
--- a/lldb/source/Target/StackFrameList.cpp
+++ b/lldb/source/Target/StackFrameList.cpp
@@ -348,6 +348,11 @@ static void FindInterveningFrames(Function &begin, 
Function &end,
 ///   |... | <- Not-yet-visited frames.
 ///   --
 void StackFrameList::SynthesizeTailCallFrames(StackFrame &next_frame) {
+  // Cannot synthesize tail call frames when the stack is empty (there is no
+  // "previous" frame).
+  if (m_frames.empty())
+return;
+
   TargetSP target_sp = next_frame.CalculateTarget();
   if (!target_sp)
 return;
@@ -358,7 +363,6 @@ void StackFrameList::SynthesizeTailCallFrames(StackFrame 
&next_frame) {
 
   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_STEP));
 
-  assert(!m_frames.empty() && "Cannot synthesize frames in an empty stack");
   StackFrame &prev_frame = *m_frames.back().get();
 
   // Find the functions prev_frame and next_frame are stopped in. The function



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


[Lldb-commits] [lldb] 047c041 - [lldb/test] Skip TestBasicEntryValuesX86_64 due to llvm.org/PR44774

2020-02-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-04T10:43:50-08:00
New Revision: 047c041277543564d482cdc297c4e82de0fd2758

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

LOG: [lldb/test] Skip TestBasicEntryValuesX86_64 due to llvm.org/PR44774

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
index e0285e6d626d..5cb092377cd0 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
@@ -6,7 +6,8 @@
 supported_platforms.extend(lldbplatformutil.getDarwinOSTriples())
 
 lldbinline.MakeInlineTest(__file__, globals(),
-[decorators.skipUnlessPlatform(supported_platforms),
+[decorators.skipIf(bugnumber="llvm.org/PR44774"),
+ decorators.skipUnlessPlatform(supported_platforms),
  decorators.skipIf(compiler="clang", compiler_version=['<', '10.0']),
  decorators.skipUnlessArch('x86_64'),
  decorators.skipUnlessHasCallSiteInfo,



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


[Lldb-commits] [lldb] bb6646c - [lldb/DataExtractor] Use an early return in GetMaxS64Bitfield, NFC

2020-02-03 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-02-03T15:57:32-08:00
New Revision: bb6646ce0a2e59eda682f63696915d2dc7db40db

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

LOG: [lldb/DataExtractor] Use an early return in GetMaxS64Bitfield, NFC

Shafik suggested this cleanup in https://reviews.llvm.org/D73913.

Added: 


Modified: 
lldb/source/Utility/DataExtractor.cpp

Removed: 




diff  --git a/lldb/source/Utility/DataExtractor.cpp 
b/lldb/source/Utility/DataExtractor.cpp
index 794deedac24b..da886201dfc7 100644
--- a/lldb/source/Utility/DataExtractor.cpp
+++ b/lldb/source/Utility/DataExtractor.cpp
@@ -607,19 +607,18 @@ int64_t DataExtractor::GetMaxS64Bitfield(offset_t 
*offset_ptr, size_t size,
   assert(size >= 1 && "GetMaxS64Bitfield size must be >= 1");
   assert(size <= 8 && "GetMaxS64Bitfield size must be <= 8");
   int64_t sval64 = GetMaxS64(offset_ptr, size);
-  if (bitfield_bit_size > 0) {
-int32_t lsbcount = bitfield_bit_offset;
-if (m_byte_order == eByteOrderBig)
-  lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
-if (lsbcount > 0)
-  sval64 >>= lsbcount;
-uint64_t bitfield_mask =
-llvm::maskTrailingOnes(bitfield_bit_size);
-sval64 &= bitfield_mask;
-// sign extend if needed
-if (sval64 & ((static_cast(1)) << (bitfield_bit_size - 1)))
-  sval64 |= ~bitfield_mask;
-  }
+  if (bitfield_bit_size == 0)
+return sval64;
+  int32_t lsbcount = bitfield_bit_offset;
+  if (m_byte_order == eByteOrderBig)
+lsbcount = size * 8 - bitfield_bit_offset - bitfield_bit_size;
+  if (lsbcount > 0)
+sval64 >>= lsbcount;
+  uint64_t bitfield_mask = llvm::maskTrailingOnes(bitfield_bit_size);
+  sval64 &= bitfield_mask;
+  // sign extend if needed
+  if (sval64 & ((static_cast(1)) << (bitfield_bit_size - 1)))
+sval64 |= ~bitfield_mask;
   return sval64;
 }
 



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


[Lldb-commits] [lldb] 009e3e5 - [lldb/MCDisasm] Simplify predicates in MCDisasmInstance, NFC

2020-01-31 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-31T16:33:12-08:00
New Revision: 009e3e53c1fe4848916a3b7de1dff60a2644fa46

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

LOG: [lldb/MCDisasm] Simplify predicates in MCDisasmInstance, NFC

Added: 


Modified: 
lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp 
b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index e9399c368e73..ea4b4cde7036 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -86,76 +86,18 @@ class InstructionLLVMC : public lldb_private::Instruction {
   : Instruction(address, addr_class),
 m_disasm_wp(std::static_pointer_cast(
 disasm.shared_from_this())),
-m_does_branch(eLazyBoolCalculate), 
m_has_delay_slot(eLazyBoolCalculate),
-m_is_call(eLazyBoolCalculate), m_is_valid(false),
 m_using_file_addr(false) {}
 
   ~InstructionLLVMC() override = default;
 
   bool DoesBranch() override {
-if (m_does_branch == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  const size_t opcode_data_len = data.GetByteSize();
-  llvm::MCInst inst;
-  const size_t inst_size =
-  mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst);
-  // Be conservative, if we didn't understand the instruction, say it
-  // might branch...
-  if (inst_size == 0)
-m_does_branch = eLazyBoolYes;
-  else {
-const bool can_branch = mc_disasm_ptr->CanBranch(inst);
-if (can_branch)
-  m_does_branch = eLazyBoolYes;
-else
-  m_does_branch = eLazyBoolNo;
-  }
-}
-  }
-}
-return m_does_branch == eLazyBoolYes;
+VisitInstruction();
+return m_does_branch;
   }
 
   bool HasDelaySlot() override {
-if (m_has_delay_slot == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  const size_t opcode_data_len = data.GetByteSize();
-  llvm::MCInst inst;
-  const size_t inst_size =
-  mc_disasm_ptr->GetMCInst(opcode_data, opcode_data_len, pc, inst);
-  // if we didn't understand the instruction, say it doesn't have a
-  // delay slot...
-  if (inst_size == 0)
-m_has_delay_slot = eLazyBoolNo;
-  else {
-const bool has_delay_slot = mc_disasm_ptr->HasDelaySlot(inst);
-if (has_delay_slot)
-  m_has_delay_slot = eLazyBoolYes;
-else
-  m_has_delay_slot = eLazyBoolNo;
-  }
-}
-  }
-}
-return m_has_delay_slot == eLazyBoolYes;
+VisitInstruction();
+return m_has_delay_slot;
   }
 
   DisassemblerLLVMC::MCDisasmInstance *GetDisasmToUse(bool &is_alternate_isa) {
@@ -369,14 +311,6 @@ class InstructionLLVMC : public lldb_private::Instruction {
   }
   m_mnemonics = std::string(mnemonic_strm.GetString());
   return;
-} else {
-  if (m_does_branch == eLazyBoolCalculate) {
-const bool can_branch = mc_disasm_ptr->CanBranch(inst);
-if (can_branch)
-  m_does_branch = eLazyBoolYes;
-else
-  m_does_branch = eLazyBoolNo;
-  }
 }
 
 static RegularExpression s_regex(
@@ -866,42 +800,54 @@ class InstructionLLVMC : public lldb_private::Instruction 
{
   }
 
   bool IsCall() override {
-if (m_is_call == eLazyBoolCalculate) {
-  DisassemblerScope disasm(*this);
-  if (disasm) {
-DataExtractor data;
-if (m_opcode.GetData(data)) {
-  bool is_alternate_isa;
-  lldb::addr_t pc = m_address.GetFileAddress();
-
-  DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
-  GetDisasmToUse(is_alternate_isa, disasm);
-  const uint8_t *opcode_data = data.GetDataStart();
-  con

[Lldb-commits] [lldb] 14135f5 - [lldb/Value] Avoid reading more data than the host has available

2020-01-31 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-31T16:33:12-08:00
New Revision: 14135f50a036af4d3a64b8e2e0dc2ecda5260533

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

LOG: [lldb/Value] Avoid reading more data than the host has available

Value::GetValueByteSize() reports the size of a Value as the size of its
underlying CompilerType. However, a host buffer that backs a Value may
be smaller than GetValueByteSize().

This situation arises when the host is only able to partially evaluate a
Value, e.g. because the expression contains DW_OP_piece.

The cleanest fix I've found to this problem is Greg's suggestion, which
is to resize the Value if (after evaluating an expression) it's found to
be too small. I've tried several alternatives which all (in one way or
the other) tried to teach the Value/ValueObjectChild system not to read
past the end of a host buffer, but this was flaky and impractical as it
isn't easy to figure out the host buffer's size (Value::GetScalar() can
point to somewhere /inside/ a host buffer, but you need to walk up the
ValueObject hierarchy to try and find its size).

This fixes an ASan error in lldb seen when debugging a clang binary.
I've added a regression test in test/functionalities/optimized_code. The
point of that test is not specifically to check that DW_OP_piece is
handled a particular way, but rather to check that lldb doesn't crash on
an input that it used to crash on.

Testing: check-lldb, and running the added tests using a sanitized lldb

--

Thanks to Jim for pointing out that an earlier version of this patch,
which simply changed the definition of Value::GetValueByteSize(), would
interact poorly with the ValueObject machinery.

Thanks also to Pavel who suggested a neat way to test this change
(which, incidentally, caught another ASan issue still present in the
original version of this patch).

rdar://58665925

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

Added: 
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
lldb/test/Shell/SymbolFile/DWARF/DW_OP_piece-smaller-than-struct.s

Modified: 
lldb/source/Core/ValueObjectVariable.cpp

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
new file mode 100644
index ..129330fd9faf
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -O2
+include Makefile.rules

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
new file mode 100644
index ..c8308c16011e
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/TestNoASanExceptionAfterEvalOP_piece.py
@@ -0,0 +1,4 @@
+from lldbsuite.test import lldbinline
+from lldbsuite.test import decorators
+
+lldbinline.MakeInlineTest(__file__, globals())

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
new file mode 100644
index ..f1beaf3020d5
--- /dev/null
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/optimized_code/main.cpp
@@ -0,0 +1,31 @@
+// This is a regression test that checks whether lldb can inspect the variables
+// in this program without triggering an ASan exception.
+
+__attribute__((noinline, optnone)) int use(int x) { return x; }
+
+volatile int sink;
+
+struct S1 {
+  int f1;
+  int *f2;
+};
+
+struct S2 {
+  char a, b;
+  int pad;
+  S2(int x) {
+a = x & 0xff;
+b = x & 0xff00;
+  }
+};
+
+int main() {
+  S1 v1;
+  v1.f1 = sink;
+  v1.f2 = nullptr;
+  sink++; //% self.expect("frame variable v1", substrs=["S1"])
+  S2 v2(v1.f1);
+  sink += use(v2.a); //% self.expect("frame variable v2", substrs=["S2"])
+  sink += use(v2.pad); //% self.expect("frame variable v2", substrs=["S2"])
+  return 0;
+}

diff  --git a/lldb/source/Core/ValueObjectVariable.cpp 
b/lldb/source/Core/ValueObjectVariable.cpp
index 945e5c411ec1..d0664276dc17 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -166,6 +166,27 @@ bool ValueObjectVariable::UpdateValue() {
 
   Value::ValueType value_type = m_value.GetValueType();
 
+  // The size of the buffer within m_value can be less than the s

Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Vedant Kumar via lldb-commits
Interesting. I'll keep poking at this.

> On Jan 31, 2020, at 4:04 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> This could be the known bug where a CommandObject is scheduled while the same 
> CommandObject is already deeper on the command stack. I tried digging up the 
> bugreport for that, but I couldn't find it.
> 
> -- adrian
> 
>> On Jan 31, 2020, at 3:59 PM, Vedant Kumar > > wrote:
>> 
>> 
>> 
>>> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>>> mailto:lldb-commits@lists.llvm.org>> wrote:
>>> 
>>> Author: adrian
>>> Date: Tue Mar  5 17:07:45 2019
>>> New Revision: 355466
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev 
>>> 
>>> Log:
>>> Replace debug-only assert with a plain old assert.
>>> 
>>> Modified:
>>>   lldb/trunk/source/Interpreter/CommandObject.cpp
>>> 
>>> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
>>>  
>>> 
>>> ==
>>> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
>>> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
>>> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
>>> }
>>> 
>>> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
>>> -#ifdef LLDB_CONFIGURATION_DEBUG
>>>  // Nothing should be stored in m_exe_ctx between running commands as
>>>  // m_exe_ctx has shared pointers to the target, process, thread and frame 
>>> and
>>>  // we don't want any CommandObject instances to keep any of these objects
>>>  // around longer than for a single command. Every command should call
>>> -  // CommandObject::Cleanup() after it has completed
>>> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
>>> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
>>> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
>>> -  assert(m_exe_ctx.GetFramePtr() == NULL);
>>> -#endif
>>> +  // CommandObject::Cleanup() after it has completed.
>>> +  assert(!m_exe_ctx.GetTargetPtr());
>> 
>> Hi all,
>> 
>> I'm actually hitting this assert now when I try debugging clang with a 
>> sanitized lldb. Any advice appreciated!
>> 
>> Stop hook #1 added.
>> (lldb) s
>> * thread #1, queue = 'com.apple.main-thread', stop reason = step in
>>  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
>> Stack.cpp:42:8
>>frame #1: 0x00012295 clang-10`main(argc_=64, 
>> argv_=0x7ffeefbff160) at driver.cpp:342:3
>>frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1
>> 
>> Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, 
>> file 
>> /Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp,
>>  line 153.
>> Stack dump:
>> 0.  Program arguments: 
>> /Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o 
>> target stop-hook add -o bt -o v -o s -o s -- 
>> /Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
>> x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
>> -Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
>> sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
>> -mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
>> -target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
>> -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
>> -target-linker-version 556 -resource-dir 
>> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0 -isysroot 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
>> -internal-isystem 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
>> -internal-isystem 
>> /Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0/include 
>> -internal-externc-isystem 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -O2 
>> -fdebug-compilation-dir /Users/vsk/src/builds/llvm-project-master-RA 
>> -ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks 
>> -fencode-extended-block-signature -fregister-global-dtors-with-atexit 
>> -fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 
>> -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops 
>> -vectorize-slp -o /dev/null -x c 
>> /Users/vsk/Downloads/sqlite-amalgamation-3300100/sqlite3.c
>> zsh: abort  ~/src/builds/llvm-project-master-SAN/bin/lldb -o "b main" -o 
>> "r" -o  -o "s" -
>> 
>> vedant
>> 
>> 
>>> +  assert(!m_exe_ctx.GetProcessPtr());
>>> +  assert(!m_exe_ctx.GetThreadPtr());
>>> +  assert(!m_exe_ctx.GetFramePtr());
>>> 
>>>  // Lock down the interpreter's execution context prior to running the 
>>> com

Re: [Lldb-commits] [lldb] r355466 - Replace debug-only assert with a plain old assert.

2020-01-31 Thread Vedant Kumar via lldb-commits


> On Mar 5, 2019, at 5:07 PM, Adrian Prantl via lldb-commits 
>  wrote:
> 
> Author: adrian
> Date: Tue Mar  5 17:07:45 2019
> New Revision: 355466
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=355466&view=rev
> Log:
> Replace debug-only assert with a plain old assert.
> 
> Modified:
>lldb/trunk/source/Interpreter/CommandObject.cpp
> 
> Modified: lldb/trunk/source/Interpreter/CommandObject.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=355466&r1=355465&r2=355466&view=diff
> ==
> --- lldb/trunk/source/Interpreter/CommandObject.cpp (original)
> +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Mar  5 17:07:45 2019
> @@ -136,17 +136,15 @@ bool CommandObject::ParseOptions(Args &a
> }
> 
> bool CommandObject::CheckRequirements(CommandReturnObject &result) {
> -#ifdef LLDB_CONFIGURATION_DEBUG
>   // Nothing should be stored in m_exe_ctx between running commands as
>   // m_exe_ctx has shared pointers to the target, process, thread and frame 
> and
>   // we don't want any CommandObject instances to keep any of these objects
>   // around longer than for a single command. Every command should call
> -  // CommandObject::Cleanup() after it has completed
> -  assert(m_exe_ctx.GetTargetPtr() == NULL);
> -  assert(m_exe_ctx.GetProcessPtr() == NULL);
> -  assert(m_exe_ctx.GetThreadPtr() == NULL);
> -  assert(m_exe_ctx.GetFramePtr() == NULL);
> -#endif
> +  // CommandObject::Cleanup() after it has completed.
> +  assert(!m_exe_ctx.GetTargetPtr());

Hi all,

I'm actually hitting this assert now when I try debugging clang with a 
sanitized lldb. Any advice appreciated!

Stop hook #1 added.
(lldb) s
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
  * frame #0: 0x0001044d2268 clang-10`clang::noteBottomOfStack() at 
Stack.cpp:42:8
frame #1: 0x00012295 clang-10`main(argc_=64, 
argv_=0x7ffeefbff160) at driver.cpp:342:3
frame #2: 0x7fff722ba3d5 libdyld.dylib`start + 1

Assertion failed: (!m_exe_ctx.GetTargetPtr()), function CheckRequirements, file 
/Users/vsk/src/llvm-project-master/lldb/source/Interpreter/CommandObject.cpp, 
line 153.
Stack dump:
0.  Program arguments: 
/Users/vsk/src/builds/llvm-project-master-SAN/bin/lldb -o b main -o r -o target 
stop-hook add -o bt -o v -o s -o s -- 
/Users/vsk/src/builds/llvm-project-master-D/bin/clang-10 -cc1 -triple 
x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage 
-Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name 
sqlite3.c -mrelocation-model pic -pic-level 2 -mthread-model posix 
-mframe-pointer=all -fno-rounding-math -masm-verbose -munwind-tables 
-target-sdk-version=10.14 -target-cpu penryn -dwarf-column-info 
-debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb 
-target-linker-version 556 -resource-dir 
/Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0 -isysroot 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include 
-internal-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/include 
-internal-isystem 
/Users/vsk/src/builds/llvm-project-master-RA/lib/clang/11.0.0/include 
-internal-externc-isystem 
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -O2 
-fdebug-compilation-dir /Users/vsk/src/builds/llvm-project-master-RA 
-ferror-limit 19 -fmessage-length 178 -stack-protector 1 -fblocks 
-fencode-extended-block-signature -fregister-global-dtors-with-atexit 
-fgnuc-version=4.2.1 -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp 
-o /dev/null -x c /Users/vsk/Downloads/sqlite-amalgamation-3300100/sqlite3.c
zsh: abort  ~/src/builds/llvm-project-master-SAN/bin/lldb -o "b main" -o 
"r" -o  -o "s" -

vedant


> +  assert(!m_exe_ctx.GetProcessPtr());
> +  assert(!m_exe_ctx.GetThreadPtr());
> +  assert(!m_exe_ctx.GetFramePtr());
> 
>   // Lock down the interpreter's execution context prior to running the 
> command
>   // so we guarantee the selected target, process, thread and frame can't go
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


Re: [Lldb-commits] [lldb] e3a7c77 - [lldb/Lit] Change the lldbtest format to behave more like shell test.

2020-01-30 Thread Vedant Kumar via lldb-commits


> On Jan 24, 2020, at 4:18 PM, Jonas Devlieghere via lldb-commits 
>  wrote:
> 
> 
> Author: Jonas Devlieghere
> Date: 2020-01-24T16:17:55-08:00
> New Revision: e3a7c7713cd87e37a95a544373cd21f6f06ab94e
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/e3a7c7713cd87e37a95a544373cd21f6f06ab94e
> DIFF: 
> https://github.com/llvm/llvm-project/commit/e3a7c7713cd87e37a95a544373cd21f6f06ab94e.diff
> 
> LOG: [lldb/Lit] Change the lldbtest format to behave more like shell test.
> 
> The current lldbtest format has a number of shortcomings, all related to
> how we omit information based on why the test fails. For example, a
> successful test would print nothing, even when `-a` is passed to lit.
> It's not up to the test format to decide whether to print something or
> not, that's handled by lit itself. For other test results we would
> sometimes print stdout & stderr, but not always, such as when a timeout
> was reached or we couldn't parse the dotest output.
> 
> This patch changes the lldbtest format and makes it behave more like
> lit. We now always print the dotest invocation, the exit code, the
> output to stdout & stderr. If you're used to dealing with ShTests in
> lit, this will feel all very familiar.
> 
> Differential revision: https://reviews.llvm.org/D73384
> 
> Added: 
> 
> 
> Modified: 
>lldb/test/API/lldbtest.py
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/lldb/test/API/lldbtest.py b/lldb/test/API/lldbtest.py
> index 349a67f22fb3..864d5ea1df03 100644
> --- a/lldb/test/API/lldbtest.py
> +++ b/lldb/test/API/lldbtest.py
> @@ -86,33 +86,46 @@ def execute(self, test, litConfig):
> shutil.copy(python, copied_python)
> cmd[0] = copied_python
> 
> +timeoutInfo = None
> try:
> out, err, exitCode = lit.util.executeCommand(
> cmd,
> env=test.config.environment,
> timeout=litConfig.maxIndividualTestTime)
> except lit.util.ExecuteCommandTimeoutException:
> -return (lit.Test.TIMEOUT, 'Reached timeout of {} seconds'.format(
> -litConfig.maxIndividualTestTime))
> +timeoutInfo = 'Reached timeout of {} seconds'.format(
> +litConfig.maxIndividualTestTime)
> +
> +output = """Script:\n--\n%s\n--\nExit Code: %d\n""" % (
> +' '.join(cmd), exitCode)

Heads up, when a test times out this prints:

  File "/Users/vsk/src/llvm-project-master/lldb/test/API/lldbtest.py", line 
100, in execute
' '.join(cmd), exitCode)
UnboundLocalError: local variable 'exitCode' referenced before assignment


> +if timeoutInfo is not None:
> +output += """Timeout: %s\n""" % (timeoutInfo,)
> +output += "\n"
> +
> +if out:
> +output += """Command Output (stdout):\n--\n%s\n--\n""" % (out,)
> +if err:
> +output += """Command Output (stderr):\n--\n%s\n--\n""" % (err,)
> +
> +if timeoutInfo:
> +return lit.Test.TIMEOUT, output
> 
> if exitCode:
> # Match FAIL but not XFAIL.
> for line in out.splitlines() + err.splitlines():
> if line.startswith('FAIL:'):
> -return lit.Test.FAIL, out + err
> +return lit.Test.FAIL, output
> 
> if 'XPASS:' in out or 'XPASS:' in err:
> -return lit.Test.XPASS, out + err
> +return lit.Test.XPASS, output
> 
> has_unsupported_tests = 'UNSUPPORTED:' in out or 'UNSUPPORTED:' in err
> has_passing_tests = 'PASS:' in out or 'PASS:' in err
> if has_unsupported_tests and not has_passing_tests:
> -return lit.Test.UNSUPPORTED, out + err
> +return lit.Test.UNSUPPORTED, output
> 
> passing_test_line = 'RESULT: PASSED'
> if passing_test_line not in out and passing_test_line not in err:
> -msg = ('Unable to find %r in dotest output (exit code 
> %d):\n\n%s%s'
> -   % (passing_test_line, exitCode, out, err))
> -return lit.Test.UNRESOLVED, msg
> +return lit.Test.UNRESOLVED, output
> 
> -return lit.Test.PASS, ''
> +return lit.Test.PASS, output
> 
> 
> 
> ___
> lldb-commits mailing list
> lldb-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

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


[Lldb-commits] [lldb] 441aebc - [debugserver] Delete stale code referencing ppc

2020-01-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-21T11:04:04-08:00
New Revision: 441aebc5235af164a784d0b9bd460c07e01e9045

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

LOG: [debugserver] Delete stale code referencing ppc

Added: 


Modified: 
lldb/tools/debugserver/source/DNBArch.h
lldb/tools/debugserver/source/DNBDefs.h
lldb/tools/debugserver/source/RNBDefs.h
lldb/tools/debugserver/source/RNBServices.cpp

Removed: 




diff  --git a/lldb/tools/debugserver/source/DNBArch.h 
b/lldb/tools/debugserver/source/DNBArch.h
index b5e2e25ef47e..03b6b60ed86d 100644
--- a/lldb/tools/debugserver/source/DNBArch.h
+++ b/lldb/tools/debugserver/source/DNBArch.h
@@ -120,7 +120,6 @@ class DNBArchProtocol {
 #include "MacOSX/arm/DNBArchImpl.h"
 #include "MacOSX/arm64/DNBArchImplARM64.h"
 #include "MacOSX/i386/DNBArchImplI386.h"
-#include "MacOSX/ppc/DNBArchImpl.h"
 #include "MacOSX/x86_64/DNBArchImplX86_64.h"
 
 #endif

diff  --git a/lldb/tools/debugserver/source/DNBDefs.h 
b/lldb/tools/debugserver/source/DNBDefs.h
index 22cfce1757f7..2136eb6d5c44 100644
--- a/lldb/tools/debugserver/source/DNBDefs.h
+++ b/lldb/tools/debugserver/source/DNBDefs.h
@@ -20,15 +20,13 @@
 #include 
 
 // Define nub_addr_t and the invalid address value from the architecture
-#if defined(__x86_64__) || defined(__ppc64__) || defined(__arm64__) || 
\
-defined(__aarch64__)
+#if defined(__x86_64__) || defined(__arm64__) || defined(__aarch64__)
 
 // 64 bit address architectures
 typedef uint64_t nub_addr_t;
 #define INVALID_NUB_ADDRESS ((nub_addr_t)~0ull)
 
-#elif defined(__i386__) || defined(__powerpc__) || defined(__ppc__) || 
\
-defined(__arm__)
+#elif defined(__i386__) || defined(__powerpc__) || defined(__arm__)
 
 // 32 bit address architectures
 

diff  --git a/lldb/tools/debugserver/source/RNBDefs.h 
b/lldb/tools/debugserver/source/RNBDefs.h
index 4cc7c220b7f2..fe5d9de04cbe 100644
--- a/lldb/tools/debugserver/source/RNBDefs.h
+++ b/lldb/tools/debugserver/source/RNBDefs.h
@@ -50,14 +50,6 @@ extern "C" const double CONCAT(DEBUGSERVER_PROGRAM_SYMBOL, 
VersionNumber);
 
 #define RNB_ARCH "x86_64"
 
-#elif defined(__ppc64__)
-
-#define RNB_ARCH "ppc64"
-
-#elif defined(__powerpc__) || defined(__ppc__)
-
-#define RNB_ARCH "ppc"
-
 #elif defined(__arm64__) || defined(__aarch64__)
 
 #define RNB_ARCH "arm64"

diff  --git a/lldb/tools/debugserver/source/RNBServices.cpp 
b/lldb/tools/debugserver/source/RNBServices.cpp
index 085aaddfaf15..7b2ab7c9b737 100644
--- a/lldb/tools/debugserver/source/RNBServices.cpp
+++ b/lldb/tools/debugserver/source/RNBServices.cpp
@@ -62,9 +62,8 @@ int GetProcesses(CFMutableArrayRef plistMutableArray, bool 
all_users) {
   proc_info.kp_proc.p_stat ==
   SZOMB || // Zombies are bad, they like brains...
   proc_info.kp_proc.p_flag & P_TRACED || // Being debugged?
-  proc_info.kp_proc.p_flag & P_WEXIT ||  // Working on exiting?
-  proc_info.kp_proc.p_flag &
-  P_TRANSLATED) // Skip translated ppc (Rosetta)
+  proc_info.kp_proc.p_flag & P_WEXIT // Working on exiting?
+  )
 continue;
 
   // Create a new mutable dictionary for each application



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


[Lldb-commits] [lldb] 9aba2ce - [debugserver] Delete macOS/PPC debug server implementation

2020-01-21 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-21T10:59:38-08:00
New Revision: 9aba2ced34b295658f3f07311efe665495987426

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

LOG: [debugserver] Delete macOS/PPC debug server implementation

macOS/PPC support was dropped in 10.6 (Snow Leopard).

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

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/CMakeLists.txt

Removed: 
lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h



diff  --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt 
b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
index 73ba6492a0ef..001f861d2718 100644
--- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -26,11 +26,6 @@ if(NOT LLDB_DEBUGSERVER_ARCH OR "${LLDB_DEBUGSERVER_ARCH}" 
MATCHES ".*86.*")
   include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64)
 endif()
 
-if("${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*ppc.*")
-  list(APPEND SOURCES ppc/DNBArchImpl.cpp)
-  include_directories(${CURRENT_SOURCE_DIR}/ppc)
-endif()
-
 add_subdirectory(DarwinLog)
 
 include_directories(..)

diff  --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp 
b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
deleted file mode 100644
index c6671b5066a4..
--- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-//===-- DNBArchImpl.cpp -*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-//  Created by Greg Clayton on 6/25/07.
-//
-//===--===//
-
-#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__)
-
-#if __DARWIN_UNIX03
-#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) __##reg
-#else
-#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) reg
-#endif
-
-#include "MacOSX/ppc/DNBArchImpl.h"
-#include "DNBBreakpoint.h"
-#include "DNBLog.h"
-#include "DNBRegisterInfo.h"
-#include "MacOSX/MachThread.h"
-
-static const uint8_t g_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08};
-
-const uint8_t *DNBArchMachPPC::SoftwareBreakpointOpcode(nub_size_t size) {
-  if (size == 4)
-return g_breakpoint_opcode;
-  return NULL;
-}
-
-uint32_t DNBArchMachPPC::GetCPUType() { return CPU_TYPE_POWERPC; }
-
-uint64_t DNBArchMachPPC::GetPC(uint64_t failValue) {
-  // Get program counter
-  if (GetGPRState(false) == KERN_SUCCESS)
-return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0);
-  return failValue;
-}
-
-kern_return_t DNBArchMachPPC::SetPC(uint64_t value) {
-  // Get program counter
-  kern_return_t err = GetGPRState(false);
-  if (err == KERN_SUCCESS) {
-m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0) = value;
-err = SetGPRState();
-  }
-  return err == KERN_SUCCESS;
-}
-
-uint64_t DNBArchMachPPC::GetSP(uint64_t failValue) {
-  // Get stack pointer
-  if (GetGPRState(false) == KERN_SUCCESS)
-return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(r1);
-  return failValue;
-}
-
-kern_return_t DNBArchMachPPC::GetGPRState(bool force) {
-  if (force || m_state.GetError(e_regSetGPR, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeGPR;
-m_state.SetError(e_regSetGPR, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetGPR,
-(thread_state_t)&m_state.gpr, &count));
-  }
-  return m_state.GetError(e_regSetGPR, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetFPRState(bool force) {
-  if (force || m_state.GetError(e_regSetFPR, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeFPR;
-m_state.SetError(e_regSetFPR, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetFPR,
-(thread_state_t)&m_state.fpr, &count));
-  }
-  return m_state.GetError(e_regSetFPR, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetEXCState(bool force) {
-  if (force || m_state.GetError(e_regSetEXC, Read)) {
-mach_msg_type_number_t count = e_regSetWordSizeEXC;
-m_state.SetError(e_regSetEXC, Read,
- ::thread_get_state(m_thread->MachPortNumber(), 
e_regSetEXC,
-(thread_state_t)&m_state.exc, &count));
-  }
-  return m_state.GetError(e_regSetEXC, Read);
-}
-
-kern_return_t DNBArchMachPPC::GetVECState(bool force) {
-  if (force 

[Lldb-commits] [lldb] 510758d - debugserver: Pass -arch flags to mig invocation as needed

2020-01-17 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-17T13:11:54-08:00
New Revision: 510758dae2a8fa4b0b26dea89d4d1efd576b8ad6

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

LOG: debugserver: Pass -arch flags to mig invocation as needed

Specify -isysroot and any necessary -arch flags in the `mig` invocation
when CMAKE_OSX_ARCHITECTURES is set (needed for the bridgeOS build).

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index 607ac11ac96f..5b604126e47d 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -132,8 +132,15 @@ set(generated_mach_interfaces
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excServer.c
   ${CMAKE_CURRENT_BINARY_DIR}/mach_excUser.c
   )
+
+set(MIG_ARCH_FLAGS "")
+foreach(ARCH ${CMAKE_OSX_ARCHITECTURES})
+  set(MIG_ARCH_FLAGS "${MIG_ARCH_FLAGS} -arch ${ARCH}")
+endforeach()
+separate_arguments(MIG_ARCH_FLAGS_SEPARTED NATIVE_COMMAND "${MIG_ARCH_FLAGS}")
+
 add_custom_command(OUTPUT ${generated_mach_interfaces}
-  COMMAND mig ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
+  VERBATIM COMMAND mig ${MIG_ARCH_FLAGS_SEPARTED} -isysroot 
${CMAKE_OSX_SYSROOT} ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/MacOSX/dbgnub-mig.defs
   )
 



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


[Lldb-commits] [lldb] 6c4d377 - lldb: xfail TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on arm/aarch64

2020-01-16 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-16T14:48:51-08:00
New Revision: 6c4d37733403bf3fda260f1b05fc899427a61cdc

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

LOG: lldb: xfail TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on 
arm/aarch64

This effectively reverts commit
8d2f252bb8e4d199be8498c4ee2245117ef08fd2, which went a bit too far and
disabled these on all non-Darwin systems.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
index 4581a75fa0a5..3f7e060a9c9c 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
@@ -17,7 +17,8 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@skipUnlessDarwin # llvm.org/PR44561
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@expectedFailureAll(archs=['arm', 'aarch64'], bugnumber="llvm.org/PR44561")
 def test_cross_dso_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
index dcdf95911de2..e04ef96f2790 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
@@ -17,7 +17,8 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@skipUnlessDarwin # llvm.org/PR44561
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@expectedFailureAll(archs=['arm', 'aarch64'], bugnumber="llvm.org/PR44561")
 def test_cross_object_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] 1e89fb9 - debugserver: Cut dependency on intrinsics_gen

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T17:20:10-08:00
New Revision: 1e89fb947ed1f8042e13b5840751b73b18cd6534

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

LOG: debugserver: Cut dependency on intrinsics_gen

debugserver does not depend on intrinsics_gen or on llvm.

Added: 


Modified: 
lldb/tools/debugserver/source/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/CMakeLists.txt 
b/lldb/tools/debugserver/source/CMakeLists.txt
index a7d789dd9e19..607ac11ac96f 100644
--- a/lldb/tools/debugserver/source/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/CMakeLists.txt
@@ -56,6 +56,10 @@ function(get_debugserver_codesign_identity result)
   set(${result} "-" PARENT_SCOPE)
 endfunction()
 
+# debugserver does not depend on intrinsics_gen, or on llvm. Set the common
+# llvm dependencies in the current scope to the empty set.
+set(LLVM_COMMON_DEPENDS)
+
 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ 
-Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_SOURCE_DIR}/../resources/lldb-debugserver-Info.plist")
 
 check_cxx_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments"



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


[Lldb-commits] [lldb] 8d2f252 - lldb: Run TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on Darwin only

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T14:00:05-08:00
New Revision: 8d2f252bb8e4d199be8498c4ee2245117ef08fd2

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

LOG: lldb: Run TestCrossDSOTailCalls.py and TestCrossObjectTailCalls.py on 
Darwin only

See https://bugs.llvm.org/show_bug.cgi?id=44561, these tests are failing
on an aarch64/Linux bot:

http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/655

For some reason the backtrace the tests are expecting to find is
incomplete.

Added: 


Modified: 

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
index d0a4b69c27d4..4581a75fa0a5 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py
@@ -17,7 +17,7 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@skipUnlessDarwin # llvm.org/PR44561
 def test_cross_dso_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
index 80f20a874f06..dcdf95911de2 100644
--- 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
+++ 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py
@@ -17,7 +17,7 @@ def setUp(self):
 
 @skipIf(compiler="clang", compiler_version=['<', '8.0'])
 @skipIf(dwarf_version=['<', '4'])
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr26265")
+@skipUnlessDarwin # llvm.org/PR44561
 def test_cross_object_tail_calls(self):
 self.build()
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] f012055 - [DWARF] Emit DW_AT_call_return_pc as an address

2020-01-15 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-15T13:02:23-08:00
New Revision: f0120556c7e2ef14ff3da5bd7d5717cedf94b767

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

LOG: [DWARF] Emit DW_AT_call_return_pc as an address

This reverts D53469, which changed llvm's DWARF emission to emit
DW_AT_call_return_pc as a function-local offset. Such an encoding is not
compatible with post-link block re-ordering tools and isn't standards-
compliant.

In addition to reverting back to the original DW_AT_call_return_pc
encoding, teach lldb how to fix up DW_AT_call_return_pc when the address
comes from an object file pointed-to by a debug map. While doing this I
noticed that lldb's support for tail calls that cross a DSO/object file
boundary wasn't covered, so I added tests for that. This latter case
exercises the newly added return PC fixup.

The dsymutil changes in this patch were originally included in D49887:
the associated test should be sufficient to test DW_AT_call_return_pc
encoding purely on the llvm side.

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

Added: 

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One.mk

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/One/One.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/TestCrossDSOTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two.mk

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Two/Two.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/main.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/shared.h

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Makefile

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/One.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/TestCrossObjectTailCalls.py

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/Two.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/main.c

lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_object/shared.h
llvm/test/tools/dsymutil/Inputs/call-site-entry.c
llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64
llvm/test/tools/dsymutil/Inputs/call-site-entry.macho.x86_64.o
llvm/test/tools/dsymutil/call-site-entry-linking.test

Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Symbol/Function.cpp
llvm/include/llvm/CodeGen/DebugHandlerBase.h
llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/test/DebugInfo/X86/debug_addr.ll
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index f675b5fdffa6..c8f888c3bdd1 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -281,8 +281,7 @@ class CallEdge {
   /// made the call.
   lldb::addr_t GetReturnPCAddress(Function &caller, Target &target) const;
 
-  /// Like \ref GetReturnPCAddress, but returns an unslid function-local PC
-  /// offset.
+  /// Like \ref GetReturnPCAddress, but returns an unresolved file address.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
   /// Get the call site parameters available at this call edge.
@@ -294,9 +293,8 @@ class CallEdge {
   CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters)
   : return_pc(return_pc), parameters(std::move(parameters)) {}
 
-  /// An invalid address if this is a tail call. Otherwise, the function-local
-  /// PC offset. Adding this PC offset to the function's base load address
-  /// gives the return PC for the call.
+  /// An invalid address if this is a tail call. Otherwise, the return PC for
+  /// the call. Note that this is a file address which must be resolved.
   lldb::addr_t return_pc;
 
   CallSiteParameterArray parameters;

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
 
b/lldb/packages/Python/lldbsuite/test/functionalities/tail_call_frames/cross_dso/Makefile
new file mode 100644
index ..fd44eb4be9c3
--- /dev/null
+++ 
b/lldb/packages/Python/lldb

[Lldb-commits] [lldb] 4c00dbf - lldbutil: Forward ASan launch info to test inferiors

2020-01-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2020-01-10T14:52:51-08:00
New Revision: 4c00dbf22d7f0ad005444b412b450ee4b4779b6a

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

LOG: lldbutil: Forward ASan launch info to test inferiors

This allows an unsanitized test process which loads a sanitized DSO (the
motivating example is a Swift runtime dylib) to launch on Darwin.

rdar://57290132

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

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/lit.cfg.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 9deaed5cf50d..006362a4479c 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -19,6 +19,7 @@
 
 # LLDB modules
 import lldb
+from . import lldbtest_config
 
 
 # ===
@@ -758,6 +759,12 @@ def run_to_breakpoint_make_target(test, exe_name = 
"a.out", in_cwd = True):
 # Create the target
 target = test.dbg.CreateTarget(exe)
 test.assertTrue(target, "Target: %s is not valid."%(exe_name))
+
+# Set environment variables for the inferior.
+if lldbtest_config.inferior_env:
+test.runCmd('settings set target.env-vars {}'.format(
+lldbtest_config.inferior_env))
+
 return target
 
 def run_to_breakpoint_do_run(test, target, bkpt, launch_info = None,
@@ -765,7 +772,7 @@ def run_to_breakpoint_do_run(test, target, bkpt, 
launch_info = None,
 
 # Launch the process, and do not stop at the entry point.
 if not launch_info:
-launch_info = lldb.SBLaunchInfo(None)
+launch_info = target.GetLaunchInfo()
 launch_info.SetWorkingDirectory(test.get_process_working_directory())
 
 if extra_images and lldb.remote_platform:

diff  --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index aca13b9c64f8..631a8a4a33b8 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -87,6 +87,12 @@ def find_shlibpath_var():
 if config.llvm_libs_dir:
   dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
 
+# Forward ASan-specific environment variables to tests, as a test may load an
+# ASan-ified dylib.
+for env_var in ('ASAN_OPTIONS', 'DYLD_INSERT_LIBRARIES'):
+  if env_var in config.environment:
+dotest_cmd += ['--inferior-env', env_var + '=' + 
config.environment[env_var]]
+
 if config.lldb_build_directory:
   dotest_cmd += ['--build-dir', config.lldb_build_directory]
 



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


[Lldb-commits] [lldb] 46d970c - TypeCategory: Initialize m_enabled to false

2019-12-12 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-12-12T11:39:41-08:00
New Revision: 46d970cc436068af826e5f6a59033dd0f10c570d

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

LOG: TypeCategory: Initialize m_enabled to false

The initialization was accidentally lost in https://reviews.llvm.org/D71310, 
causing a ubsan failure:

/Users/buildslave/jenkins/workspace/lldb-cmake-sanitized/llvm-project/lldb/include/lldb/DataFormatters/TypeCategory.h:278:35:
 runtime error: load of value 190, which is not a valid value for type 'bool'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior 
/Users/buildslave/jenkins/workspace/lldb-cmake-sanitized/llvm-project/lldb/include/lldb/DataFormatters/TypeCategory.h:278:35
 in

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake-sanitized/621/consoleText

Added: 


Modified: 
lldb/source/DataFormatters/TypeCategory.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/TypeCategory.cpp 
b/lldb/source/DataFormatters/TypeCategory.cpp
index cc86983fbb99..85699691f52b 100644
--- a/lldb/source/DataFormatters/TypeCategory.cpp
+++ b/lldb/source/DataFormatters/TypeCategory.cpp
@@ -18,7 +18,7 @@ TypeCategoryImpl::TypeCategoryImpl(IFormatChangeListener 
*clist,
 : m_format_cont("format", "regex-format", clist),
   m_summary_cont("summary", "regex-summary", clist),
   m_filter_cont("filter", "regex-filter", clist),
-  m_synth_cont("synth", "regex-synth", clist),
+  m_synth_cont("synth", "regex-synth", clist), m_enabled(false),
   m_change_listener(clist), m_mutex(), m_name(name), m_languages() {}
 
 static bool IsApplicable(lldb::LanguageType category_lang,



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


[Lldb-commits] [lldb] 7ec933e - [lldb] Add #include to appease the modules build

2019-12-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-12-10T12:37:26-08:00
New Revision: 7ec933e50162e2ddc6204f0f1708b75309a9555a

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

LOG: [lldb] Add #include to appease the modules build

This #include appears to be completely unnecessary, but it does fix the
following build failure:

http://green.lab.llvm.org/green/job/lldb-cmake/4565/consoleText

FAILED: tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o
/Users/buildslave/jenkins/workspace/lldb-cmake/host-compiler/bin/clang++  
-DGTEST_HAS_RTTI=0 -DHAVE_ROUND -DLIBXML2_DEFINED -DLLDB_CONFIGURATION_RELEASE 
-DLLDB_USE_OS_LOG -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/lldb/source/Host 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host 
-Itools/lldb/source 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/include 
-Itools/lldb/include -Iinclude 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/include 
-I/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/llvm/../clang/include
 -Itools/lldb/../clang/include -I/usr/local/include 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/. 
-isystem 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/libxml2
 -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -fmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/module.cache
 -fcxx-modules -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color 
-Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-deprecated-register -Wno-vla-extension -O3  -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
   -UNDEBUG  -fno-exceptions -fno-rtti -std=c++14 -MD -MT 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -MF 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o.d -o 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoop.cpp.o -c 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:211:7:
 error: use of undeclared identifier 'ppoll'
  if (ppoll(read_fds.data(), read_fds.size(), nullptr, &sigmask) == -1 &&
  ^
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/source/Host/common/MainLoop.cpp:336:25:
 error: use of undeclared identifier 'HAVE_SYS_EVENT_H'
  ret = pthread_sigmask(HAVE_SYS_EVENT_H ? SIG_UNBLOCK : SIG_BLOCK,
^
2 errors generated.

Added: 


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

Removed: 




diff  --git a/lldb/source/Host/common/MainLoop.cpp 
b/lldb/source/Host/common/MainLoop.cpp
index 6f774451c8a4..240320f83242 100644
--- a/lldb/source/Host/common/MainLoop.cpp
+++ b/lldb/source/Host/common/MainLoop.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "llvm/Config/llvm-config.h"
+#include "lldb/Host/Config.h"
 
 #include "lldb/Host/MainLoop.h"
 #include "lldb/Host/PosixApi.h"



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


[Lldb-commits] [lldb] d0789e6 - Assert launch success in run_to_breakpoint_do_run

2019-12-10 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-12-10T11:19:17-08:00
New Revision: d0789e6346e489cd84b37ec58964feb0db015de7

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

LOG: Assert launch success in run_to_breakpoint_do_run

Added: 


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

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index 05d0c9f9d3e9..9deaed5cf50d 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -778,6 +778,8 @@ def run_to_breakpoint_do_run(test, target, bkpt, 
launch_info = None,
 test.assertTrue(process,
 "Could not create a valid process for %s: 
%s"%(target.GetExecutable().GetFilename(),
 error.GetCString()))
+test.assertFalse(error.Fail(),
+ "Process launch failed: %s" % (error.GetCString()))
 
 # Frame #0 should be at our breakpoint.
 threads = get_threads_stopped_at_breakpoint(



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


[Lldb-commits] [lldb] 4fdbc07 - [DWARF] Handle call sites with indirect call targets

2019-11-22 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-11-22T11:50:22-08:00
New Revision: 4fdbc0728d4b8acb1921fc48301622e971fc3961

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

LOG: [DWARF] Handle call sites with indirect call targets

Split CallEdge into DirectCallEdge and IndirectCallEdge. Teach
DWARFExpression how to evaluate entry values in cases where the current
activation was created by an indirect call.

rdar://57094085

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

Added: 


Modified: 
lldb/include/lldb/Symbol/Function.h
lldb/include/lldb/Symbol/SymbolFile.h

lldb/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Symbol/Function.cpp
lldb/source/Target/StackFrameList.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 1fef4f0177e3..f675b5fdffa6 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -19,6 +19,8 @@
 
 namespace lldb_private {
 
+class ExecutionContext;
+
 /// \class FunctionInfo Function.h "lldb/Symbol/Function.h"
 /// A class that contains generic function information.
 ///
@@ -264,23 +266,14 @@ using CallSiteParameterArray = 
llvm::SmallVector;
 /// in the call graph between two functions, or to evaluate DW_OP_entry_value.
 class CallEdge {
 public:
-  /// Construct a call edge using a symbol name to identify the calling
-  /// function, and a return PC within the calling function to identify a
-  /// specific call site.
-  ///
-  /// TODO: A symbol name may not be globally unique. To disambiguate ODR
-  /// conflicts, it's necessary to determine the \c Target a call edge is
-  /// associated with before resolving it.
-  CallEdge(const char *symbol_name, lldb::addr_t return_pc,
-   CallSiteParameterArray parameters);
-
-  CallEdge(CallEdge &&) = default;
-  CallEdge &operator=(CallEdge &&) = default;
+  virtual ~CallEdge() {}
 
   /// Get the callee's definition.
   ///
-  /// Note that this might lazily invoke the DWARF parser.
-  Function *GetCallee(ModuleList &images);
+  /// Note that this might lazily invoke the DWARF parser. A register context
+  /// from the caller's activation is needed to find indirect call targets.
+  virtual Function *GetCallee(ModuleList &images,
+  ExecutionContext &exe_ctx) = 0;
 
   /// Get the load PC address of the instruction which executes after the call
   /// returns. Returns LLDB_INVALID_ADDRESS iff this is a tail call. \p caller
@@ -293,29 +286,72 @@ class CallEdge {
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
   /// Get the call site parameters available at this call edge.
-  llvm::ArrayRef GetCallSiteParameters() const;
+  llvm::ArrayRef GetCallSiteParameters() const {
+return parameters;
+  }
+
+protected:
+  CallEdge(lldb::addr_t return_pc, CallSiteParameterArray &¶meters)
+  : return_pc(return_pc), parameters(std::move(parameters)) {}
+
+  /// An invalid address if this is a tail call. Otherwise, the function-local
+  /// PC offset. Adding this PC offset to the function's base load address
+  /// gives the return PC for the call.
+  lldb::addr_t return_pc;
+
+  CallSiteParameterArray parameters;
+};
+
+/// A direct call site. Used to represent call sites where the address of the
+/// callee is fixed (e.g. a function call in C in which the call target is not
+/// a function pointer).
+class DirectCallEdge : public CallEdge {
+public:
+  /// Construct a call edge using a symbol name to identify the callee, and a
+  /// return PC within the calling function to identify a specific call site.
+  DirectCallEdge(const char *symbol_name, lldb::addr_t return_pc,
+ CallSiteParameterArray &¶meters)
+  : CallEdge(return_pc, std::move(parameters)) {
+lazy_callee.symbol_name = symbol_name;
+  }
+
+  Function *GetCallee(ModuleList &images, ExecutionContext &exe_ctx) override;
 
 private:
   void ParseSymbolFileAndResolve(ModuleList &images);
 
-  /// Either the callee's mangled name or its definition, discriminated by
-  /// \ref resolved.
+  // Used to describe a direct call.
+  //
+  // Either the callee's mangled name or its definition, discriminated by
+  // \ref resolved.
   union {
 const char *symbol_name;
 Function *def;
   } lazy_callee;
 
-  /// An invalid address if this is a tail call. Otherwise, the function-local
-  /// PC offset. Adding th

[Lldb-commits] [lldb] af331cb - [debugserver] Set arch based on TARGET_TRIPLE

2019-11-20 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-11-20T12:12:47-08:00
New Revision: af331cbe14e8376c696441bb4c26a68be733b884

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

LOG: [debugserver] Set arch based on TARGET_TRIPLE

Use TARGET_TRIPLE instead of LLVM_DEFAULT_TARGET_TRIPLE, as the latter
isn't exported by LLVMConfig.cmake, which means arch detection fails if
lldb is built separately from llvm.

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt 
b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
index cf08985ed6f2..73ba6492a0ef 100644
--- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -1,17 +1,17 @@
 # The debugserver build needs to conditionally include files depending on the
 # target architecture.
 #
-# Switch on the architecture specified by LLVM_DEFAULT_TARGET_TRIPLE, as
+# Switch on the architecture specified by TARGET_TRIPLE, as
 # the llvm and swift build systems use this variable to identify the
-# target (the latter, indirectly, through LLVM_HOST_TRIPLE).
+# target (through LLVM_HOST_TRIPLE).
 #
 # It would be possible to switch on CMAKE_OSX_ARCHITECTURES, but the swift
 # build does not provide it, preferring instead to pass arch-specific
 # CFLAGS etc explicitly. Switching on LLVM_HOST_TRIPLE is also an option,
 # but it breaks down when cross-compiling.
 
-if(LLVM_DEFAULT_TARGET_TRIPLE)
-  string(REGEX MATCH "^[^-]*" LLDB_DEBUGSERVER_ARCH 
${LLVM_DEFAULT_TARGET_TRIPLE})
+if(TARGET_TRIPLE)
+  string(REGEX MATCH "^[^-]*" LLDB_DEBUGSERVER_ARCH ${TARGET_TRIPLE})
 else()
   set(LLDB_DEBUGSERVER_ARCH ${CMAKE_OSX_ARCHITECTURES})
 endif()



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


[Lldb-commits] [lldb] 4624e83 - [Signal] Allow llvm clients to opt into one-shot SIGPIPE handling

2019-11-18 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-11-18T10:27:27-08:00
New Revision: 4624e83ce7b124545b55e45ba13f2d900ed65654

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

LOG: [Signal] Allow llvm clients to opt into one-shot SIGPIPE handling

Allow clients of the llvm library to opt-in to one-shot SIGPIPE
handling, instead of forcing them to undo llvm's SIGPIPE handler
registration (which is brittle).

The current behavior is preserved for all llvm-derived tools (except
lldb) by means of a default-`true` flag in the InitLLVM constructor.

This prevents "IO error" crashes in long-lived processes (lldb is the
motivating example) which both a) load llvm as a dynamic library and b)
*really* need to ignore SIGPIPE.

As llvm signal handlers can be installed when calling into libclang
(say, via RemoveFileOnSignal), thereby overriding a previous SIG_IGN for
SIGPIPE, there is no clean way to opt-out of "exit-on-SIGPIPE" in the
current model.

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

Added: 


Modified: 
lldb/tools/driver/Driver.cpp
lldb/tools/lldb-server/lldb-server.cpp
llvm/include/llvm/Support/InitLLVM.h
llvm/include/llvm/Support/Signals.h
llvm/lib/Support/InitLLVM.cpp
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Support/Windows/Signals.inc

Removed: 




diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 2070e55d7d2b..b77350190be8 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -810,7 +810,7 @@ int main(int argc, char const *argv[])
 {
   // Setup LLVM signal handlers and make sure we call llvm_shutdown() on
   // destruction.
-  llvm::InitLLVM IL(argc, argv);
+  llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
 
   // Parse arguments.
   LLDBOptTable T;
@@ -841,25 +841,6 @@ int main(int argc, char const *argv[])
   }
   SBHostOS::ThreadCreated("");
 
-  // Install llvm's signal handlers up front to prevent lldb's handlers from
-  // being ignored. This is (hopefully) a stopgap workaround.
-  //
-  // When lldb invokes an llvm API that installs signal handlers (e.g.
-  // llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within
-  // lldb), lldb's signal handlers are overriden if llvm is installing its
-  // handlers for the first time.
-  //
-  // To work around llvm's behavior, force it to install its handlers up front,
-  // and *then* install lldb's handlers. In practice this is used to prevent
-  // lldb test processes from exiting due to IO_ERR when SIGPIPE is received.
-  //
-  // Note that when llvm installs its handlers, it 1) records the old handlers
-  // it replaces and 2) re-installs the old handlers when its new handler is
-  // invoked. That means that a signal not explicitly handled by lldb can fall
-  // back to being handled by llvm's handler the first time it is received,
-  // and then by the default handler the second time it is received.
-  llvm::sys::AddSignalHandler([](void *) -> void {}, nullptr);
-
   signal(SIGINT, sigint_handler);
 #if !defined(_MSC_VER)
   signal(SIGPIPE, SIG_IGN);

diff  --git a/lldb/tools/lldb-server/lldb-server.cpp 
b/lldb/tools/lldb-server/lldb-server.cpp
index ab32eefb518e..749a381ebca0 100644
--- a/lldb/tools/lldb-server/lldb-server.cpp
+++ b/lldb/tools/lldb-server/lldb-server.cpp
@@ -49,7 +49,7 @@ static void terminate_debugger() { 
g_debugger_lifetime->Terminate(); }
 
 // main
 int main(int argc, char *argv[]) {
-  llvm::InitLLVM IL(argc, argv);
+  llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);
   llvm::StringRef ToolName = argv[0];
   llvm::sys::PrintStackTraceOnErrorSignal(ToolName);
   llvm::PrettyStackTraceProgram X(argc, argv);

diff  --git a/llvm/include/llvm/Support/InitLLVM.h 
b/llvm/include/llvm/Support/InitLLVM.h
index 8069859a3e0b..3be8d6b6d2e0 100644
--- a/llvm/include/llvm/Support/InitLLVM.h
+++ b/llvm/include/llvm/Support/InitLLVM.h
@@ -17,7 +17,8 @@
 // the following one-time initializations:
 //
 //  1. Setting up a signal handler so that pretty stack trace is printed out
-// if a process crashes.
+// if a process crashes. A signal handler that exits when a failed write to
+// a pipe occurs may optionally be installed: this is on-by-default.
 //
 //  2. Set up the global new-handler which is called when a memory allocation
 // attempt fails.
@@ -32,9 +33,11 @@
 namespace llvm {
 class InitLLVM {
 public:
-  InitLLVM(int &Argc, const char **&Argv);
-  InitLLVM(int &Argc, char **&Argv)
-  : InitLLVM(Argc, const_cast(Argv)) {}
+  InitLLVM(int &Argc, const char **&Argv,
+   bool InstallPipeSignalExitHandler = true);
+  InitLLVM(int &Argc, char **&Argv, bool InstallPipeSignalExitHandler = true)
+  : InitLLVM(Argc, const_cast(Argv),
+

[Lldb-commits] [lldb] 610f80f - [cmake] Add an option to skip stripping before install

2019-11-04 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-11-04T17:38:13-08:00
New Revision: 610f80f7baea5e46c0ccd4cbb905a679c7c56a05

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

LOG: [cmake] Add an option to skip stripping before install

The swift build system has support for cross-compiling, installing, and
generating symbols for lldb. As the swift symbol-generation step occurs
after installation, we need to disable stripping during the install.

Added: 


Modified: 
lldb/cmake/modules/AddLLDB.cmake
lldb/cmake/modules/LLDBConfig.cmake

Removed: 




diff  --git a/lldb/cmake/modules/AddLLDB.cmake 
b/lldb/cmake/modules/AddLLDB.cmake
index b04441020606..b58a62ca7771 100644
--- a/lldb/cmake/modules/AddLLDB.cmake
+++ b/lldb/cmake/modules/AddLLDB.cmake
@@ -284,13 +284,15 @@ function(lldb_add_post_install_steps_darwin name 
install_prefix)
   install(CODE "execute_process(COMMAND xcrun dsymutil -o=${dsym_name} 
${buildtree_name})"
   COMPONENT ${name})
 
-  # Strip distribution binary with -ST (removing debug symbol table entries and
-  # Swift symbols). Avoid CMAKE_INSTALL_DO_STRIP and 
llvm_externalize_debuginfo()
-  # as they can't be configured sufficiently.
-  set(installtree_name 
"\$ENV\{DESTDIR\}${install_prefix}/${bundle_subdir}${output_name}")
-  install(CODE "message(STATUS \"Stripping: ${installtree_name}\")" COMPONENT 
${name})
-  install(CODE "execute_process(COMMAND xcrun strip -ST ${installtree_name})"
-  COMPONENT ${name})
+  if(NOT LLDB_SKIP_STRIP)
+# Strip distribution binary with -ST (removing debug symbol table entries 
and
+# Swift symbols). Avoid CMAKE_INSTALL_DO_STRIP and 
llvm_externalize_debuginfo()
+# as they can't be configured sufficiently.
+set(installtree_name 
"\$ENV\{DESTDIR\}${install_prefix}/${bundle_subdir}${output_name}")
+install(CODE "message(STATUS \"Stripping: ${installtree_name}\")" 
COMPONENT ${name})
+install(CODE "execute_process(COMMAND xcrun strip -ST ${installtree_name})"
+COMPONENT ${name})
+  endif()
 endfunction()
 
 # CMake's set_target_properties() doesn't allow to pass lists for RPATH

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 6c6930d86e8f..c042cbf1b22e 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -52,6 +52,7 @@ option(LLDB_USE_ENTITLEMENTS "When codesigning, use 
entitlements if available" O
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
 option(LLDB_NO_INSTALL_DEFAULT_RPATH "Disable default RPATH settings in 
binaries" OFF)
 option(LLDB_USE_SYSTEM_DEBUGSERVER "Use the system's debugserver for testing 
(Darwin only)." OFF)
+option(LLDB_SKIP_STRIP "Whether to skip stripping of binaries when installing 
lldb." OFF)
 
 if(LLDB_BUILD_FRAMEWORK)
   if(NOT APPLE)



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


[Lldb-commits] [lldb] 82d3ba8 - [debugserver] Detect arch from LLVM_DEFAULT_TARGET_TRIPLE

2019-10-28 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-10-28T15:34:39-07:00
New Revision: 82d3ba87d06f9e2abc6e27d8799587d433c56630

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

LOG: [debugserver] Detect arch from LLVM_DEFAULT_TARGET_TRIPLE

The debugserver build needs to conditionally include files depending on the
target architecture.

Switch on the architecture specified by LLVM_DEFAULT_TARGET_TRIPLE, as
the llvm and swift build systems use this variable to identify the
target (the latter, indirectly, through LLVM_HOST_TRIPLE).

It would be possible to switch on CMAKE_OSX_ARCHITECTURES, but the swift
build does not provide it, preferring instead to pass arch-specific
CFLAGS etc explicitly. Switching on LLVM_HOST_TRIPLE is also an option,
but it breaks down when cross-compiling.

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

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt 
b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
index 7ad4a06a4d36..6d8e1ee449e3 100644
--- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
+++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt
@@ -1,14 +1,28 @@
-if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*arm.*")
+# The debugserver build needs to conditionally include files depending on the
+# target architecture.
+#
+# Switch on the architecture specified by LLVM_DEFAULT_TARGET_TRIPLE, as
+# the llvm and swift build systems use this variable to identify the
+# target (the latter, indirectly, through LLVM_HOST_TRIPLE).
+#
+# It would be possible to switch on CMAKE_OSX_ARCHITECTURES, but the swift
+# build does not provide it, preferring instead to pass arch-specific
+# CFLAGS etc explicitly. Switching on LLVM_HOST_TRIPLE is also an option,
+# but it breaks down when cross-compiling.
+
+string(REGEX MATCH "^[^-]*" LLDB_DEBUGSERVER_ARCH 
${LLVM_DEFAULT_TARGET_TRIPLE})
+
+if("${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*arm.*")
   list(APPEND SOURCES arm/DNBArchImpl.cpp arm64/DNBArchImplARM64.cpp)
   include_directories(${CURRENT_SOURCE_DIR}/arm ${CURRENT_SOURCE_DIR}/arm64)
 endif()
 
-if(NOT CMAKE_OSX_ARCHITECTURES OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES 
".*86.*")
+if(NOT LLDB_DEBUGSERVER_ARCH OR "${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*86.*")
   list(APPEND SOURCES i386/DNBArchImplI386.cpp x86_64/DNBArchImplX86_64.cpp)
   include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64)
 endif()
 
-if("${CMAKE_OSX_ARCHITECTURES}" MATCHES ".*ppc.*")
+if("${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*ppc.*")
   list(APPEND SOURCES ppc/DNBArchImpl.cpp)
   include_directories(${CURRENT_SOURCE_DIR}/ppc)
 endif()



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


[Lldb-commits] [lldb] 0877dd1 - [Driver] Force llvm to install its handlers before lldb's

2019-10-25 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-10-25T11:19:10-07:00
New Revision: 0877dd14e4e85550f8e267b5ceeff1d3409c41ba

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

LOG: [Driver] Force llvm to install its handlers before lldb's

Install llvm's signal handlers up front to prevent lldb's handlers from being
ignored. This is (hopefully) a stopgap workaround.

When lldb invokes an llvm API that installs signal handlers (e.g.
llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within lldb),
lldb's signal handlers are overriden if llvm is installing its handlers for the
first time.

To work around llvm's behavior, force it to install its handlers up front, and
*then* install lldb's handlers. In practice this is used to prevent lldb test
processes from exiting due to IO_ERR when SIGPIPE is received.

Note that when llvm installs its handlers, it 1) records the old handlers it
replaces and 2) re-installs the old handlers when its new handler is invoked.
That means that a signal not explicitly handled by lldb can fall back to being
handled by llvm's handler the first time it is received, and then by the
default handler the second time it is received.

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

Added: 


Modified: 
lldb/tools/driver/Driver.cpp

Removed: 




diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 4a403a7ffb46..8140e2a04c6e 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -845,6 +845,25 @@ int main(int argc, char const *argv[])
   }
   SBHostOS::ThreadCreated("");
 
+  // Install llvm's signal handlers up front to prevent lldb's handlers from
+  // being ignored. This is (hopefully) a stopgap workaround.
+  //
+  // When lldb invokes an llvm API that installs signal handlers (e.g.
+  // llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within
+  // lldb), lldb's signal handlers are overriden if llvm is installing its
+  // handlers for the first time.
+  //
+  // To work around llvm's behavior, force it to install its handlers up front,
+  // and *then* install lldb's handlers. In practice this is used to prevent
+  // lldb test processes from exiting due to IO_ERR when SIGPIPE is received.
+  //
+  // Note that when llvm installs its handlers, it 1) records the old handlers
+  // it replaces and 2) re-installs the old handlers when its new handler is
+  // invoked. That means that a signal not explicitly handled by lldb can fall
+  // back to being handled by llvm's handler the first time it is received,
+  // and then by the default handler the second time it is received.
+  llvm::sys::AddSignalHandler([](void *) -> void {}, nullptr);
+
   signal(SIGINT, sigint_handler);
 #if !defined(_MSC_VER)
   signal(SIGPIPE, SIG_IGN);



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


[Lldb-commits] [lldb] 72105b9 - Fix compilation error in ObjectFileMachO::ParseSymtab

2019-10-25 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-10-25T11:16:51-07:00
New Revision: 72105b9dcd67eb539b77a77c5ed3530da1171724

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

LOG: Fix compilation error in ObjectFileMachO::ParseSymtab

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 70e0997e2d3b..d82a1addd334 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2737,9 +2737,12 @@ size_t ObjectFileMachO::ParseSymtab() {
  nlist_index++) {
   /
   {
-struct nlist_64 nlist;
-if (!ParseNList(dsc_local_symbols_data, nlist_data_offset, 
nlist_byte_size, nlist)
+llvm::Optional nlist_maybe =
+ParseNList(dsc_local_symbols_data, nlist_data_offset,
+   nlist_byte_size);
+if (!nlist_maybe)
   break;
+struct nlist_64 nlist = *nlist_maybe;
 
 SymbolType type = eSymbolTypeInvalid;
 const char *symbol_name = dsc_local_symbols_data.PeekCStr(



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


[Lldb-commits] [lldb] d0bd3fc - Revert "Disable exit-on-SIGPIPE in lldb"

2019-10-24 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-10-24T13:19:49-07:00
New Revision: d0bd3fc88be54c4e11f49cfa31e427700bb1e9af

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

LOG: Revert "Disable exit-on-SIGPIPE in lldb"

This reverts commit 32ce14e55e5a99dd99c3b4fd4bd0ccaaf2948c30.

In post-commit review, Pavel pointed out that there's a simpler way to
ignore SIGPIPE in lldb that doesn't rely on llvm's handlers.

Added: 


Modified: 
lldb/tools/driver/Driver.cpp
llvm/include/llvm/Support/Signals.h
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Support/Windows/Signals.inc
llvm/unittests/Support/CMakeLists.txt

Removed: 
llvm/unittests/Support/SignalsTest.cpp



diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 6ab2bd93659f..4a403a7ffb46 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -853,16 +853,6 @@ int main(int argc, char const *argv[])
   signal(SIGCONT, sigcont_handler);
 #endif
 
-  // Occasionally, during test teardown, LLDB writes to a closed pipe.
-  // Sometimes the communication is inherently unreliable, so LLDB tries to
-  // avoid being killed due to SIGPIPE. However, LLVM's default SIGPIPE 
behavior
-  // is to exit with IO_ERR. Opt LLDB out of that.
-  //
-  // We don't disable LLVM's signal handling entirely because we still want
-  // pretty stack traces, and file cleanup (for when, say, the clang embedded
-  // in LLDB leaves behind temporary objects).
-  llvm::sys::SetPipeSignalFunction(nullptr);
-
   int exit_code = 0;
   // Create a scope for driver so that the driver object will destroy itself
   // before SBDebugger::Terminate() is called.

diff  --git a/llvm/include/llvm/Support/Signals.h 
b/llvm/include/llvm/Support/Signals.h
index a4f1fad22dd5..a6b215a24311 100644
--- a/llvm/include/llvm/Support/Signals.h
+++ b/llvm/include/llvm/Support/Signals.h
@@ -84,17 +84,6 @@ namespace sys {
   /// function.  Note also that the handler may be executed on a 
diff erent
   /// thread on some platforms.
   void SetInfoSignalFunction(void (*Handler)());
-
-  /// Registers a function to be called when a "pipe" signal is delivered to
-  /// the process.
-  ///
-  /// The "pipe" signal typically indicates a failed write to a pipe (SIGPIPE).
-  /// The default installed handler calls `exit(EX_IOERR)`, causing the process
-  /// to immediately exit with an IO error exit code.
-  ///
-  /// This function is only applicable on POSIX systems.
-  void SetPipeSignalFunction(void (*Handler)());
-
 } // End sys namespace
 } // End llvm namespace
 

diff  --git a/llvm/lib/Support/Unix/Signals.inc 
b/llvm/lib/Support/Unix/Signals.inc
index 5e0cde4a81ed..be05eabfb2e2 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -82,18 +82,12 @@ using namespace llvm;
 static RETSIGTYPE SignalHandler(int Sig);  // defined below.
 static RETSIGTYPE InfoSignalHandler(int Sig);  // defined below.
 
-static void DefaultPipeSignalFunction() {
-  exit(EX_IOERR);
-}
-
 using SignalHandlerFunctionType = void (*)();
 /// The function to call if ctrl-c is pressed.
 static std::atomic InterruptFunction =
 ATOMIC_VAR_INIT(nullptr);
 static std::atomic InfoSignalFunction =
 ATOMIC_VAR_INIT(nullptr);
-static std::atomic PipeSignalFunction =
-ATOMIC_VAR_INIT(DefaultPipeSignalFunction);
 
 namespace {
 /// Signal-safe removal of files.
@@ -369,8 +363,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
 
   // Send a special return code that drivers can check for, from 
sysexits.h.
   if (Sig == SIGPIPE)
-if (SignalHandlerFunctionType CurrentPipeFunction = PipeSignalFunction)
-  CurrentPipeFunction();
+exit(EX_IOERR);
 
   raise(Sig);   // Execute the default handler.
   return;
@@ -410,11 +403,6 @@ void llvm::sys::SetInfoSignalFunction(void (*Handler)()) {
   RegisterHandlers();
 }
 
-void llvm::sys::SetPipeSignalFunction(void (*Handler)()) {
-  PipeSignalFunction.exchange(Handler);
-  RegisterHandlers();
-}
-
 // The public API
 bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
std::string* ErrMsg) {

diff  --git a/llvm/lib/Support/Windows/Signals.inc 
b/llvm/lib/Support/Windows/Signals.inc
index d962daf79348..6a820ef22b1e 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -560,9 +560,6 @@ void llvm::sys::SetInfoSignalFunction(void (*Handler)()) {
   // Unimplemented.
 }
 
-void llvm::sys::SetPipeSignalFunction(void (*Handler)()) {
-  // Unimplemented.
-}
 
 /// Add a function to be called when a signal is delivered to the process. The
 /// handler can have a cookie passed to it to identify what instance of the

diff  --git a/llvm/unittests/Support/CMakeLists.txt 
b/llvm/unittests/Su

[Lldb-commits] [lldb] 32ce14e - Disable exit-on-SIGPIPE in lldb

2019-10-18 Thread Vedant Kumar via lldb-commits

Author: Vedant Kumar
Date: 2019-10-18T21:05:30Z
New Revision: 32ce14e55e5a99dd99c3b4fd4bd0ccaaf2948c30

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

LOG: Disable exit-on-SIGPIPE in lldb

Occasionally, during test teardown, LLDB writes to a closed pipe.
Sometimes the communication is inherently unreliable, so LLDB tries to
avoid being killed due to SIGPIPE (it calls `signal(SIGPIPE, SIG_IGN)`).
However, LLVM's default SIGPIPE behavior overrides LLDB's, causing it to
exit with IO_ERR.

Opt LLDB out of the default SIGPIPE behavior. I expect that this will
resolve some LLDB test suite flakiness (tests randomly failing with
IO_ERR) that we've seen since r344372.

rdar://55750240

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

llvm-svn: 375288

Added: 
llvm/unittests/Support/SignalsTest.cpp

Modified: 
lldb/tools/driver/Driver.cpp
llvm/include/llvm/Support/Signals.h
llvm/lib/Support/Unix/Signals.inc
llvm/lib/Support/Windows/Signals.inc
llvm/unittests/Support/CMakeLists.txt

Removed: 




diff  --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index 4a403a7ffb46..6ab2bd93659f 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -853,6 +853,16 @@ int main(int argc, char const *argv[])
   signal(SIGCONT, sigcont_handler);
 #endif
 
+  // Occasionally, during test teardown, LLDB writes to a closed pipe.
+  // Sometimes the communication is inherently unreliable, so LLDB tries to
+  // avoid being killed due to SIGPIPE. However, LLVM's default SIGPIPE 
behavior
+  // is to exit with IO_ERR. Opt LLDB out of that.
+  //
+  // We don't disable LLVM's signal handling entirely because we still want
+  // pretty stack traces, and file cleanup (for when, say, the clang embedded
+  // in LLDB leaves behind temporary objects).
+  llvm::sys::SetPipeSignalFunction(nullptr);
+
   int exit_code = 0;
   // Create a scope for driver so that the driver object will destroy itself
   // before SBDebugger::Terminate() is called.

diff  --git a/llvm/include/llvm/Support/Signals.h 
b/llvm/include/llvm/Support/Signals.h
index a6b215a24311..a4f1fad22dd5 100644
--- a/llvm/include/llvm/Support/Signals.h
+++ b/llvm/include/llvm/Support/Signals.h
@@ -84,6 +84,17 @@ namespace sys {
   /// function.  Note also that the handler may be executed on a 
diff erent
   /// thread on some platforms.
   void SetInfoSignalFunction(void (*Handler)());
+
+  /// Registers a function to be called when a "pipe" signal is delivered to
+  /// the process.
+  ///
+  /// The "pipe" signal typically indicates a failed write to a pipe (SIGPIPE).
+  /// The default installed handler calls `exit(EX_IOERR)`, causing the process
+  /// to immediately exit with an IO error exit code.
+  ///
+  /// This function is only applicable on POSIX systems.
+  void SetPipeSignalFunction(void (*Handler)());
+
 } // End sys namespace
 } // End llvm namespace
 

diff  --git a/llvm/lib/Support/Unix/Signals.inc 
b/llvm/lib/Support/Unix/Signals.inc
index be05eabfb2e2..5e0cde4a81ed 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -82,12 +82,18 @@ using namespace llvm;
 static RETSIGTYPE SignalHandler(int Sig);  // defined below.
 static RETSIGTYPE InfoSignalHandler(int Sig);  // defined below.
 
+static void DefaultPipeSignalFunction() {
+  exit(EX_IOERR);
+}
+
 using SignalHandlerFunctionType = void (*)();
 /// The function to call if ctrl-c is pressed.
 static std::atomic InterruptFunction =
 ATOMIC_VAR_INIT(nullptr);
 static std::atomic InfoSignalFunction =
 ATOMIC_VAR_INIT(nullptr);
+static std::atomic PipeSignalFunction =
+ATOMIC_VAR_INIT(DefaultPipeSignalFunction);
 
 namespace {
 /// Signal-safe removal of files.
@@ -363,7 +369,8 @@ static RETSIGTYPE SignalHandler(int Sig) {
 
   // Send a special return code that drivers can check for, from 
sysexits.h.
   if (Sig == SIGPIPE)
-exit(EX_IOERR);
+if (SignalHandlerFunctionType CurrentPipeFunction = PipeSignalFunction)
+  CurrentPipeFunction();
 
   raise(Sig);   // Execute the default handler.
   return;
@@ -403,6 +410,11 @@ void llvm::sys::SetInfoSignalFunction(void (*Handler)()) {
   RegisterHandlers();
 }
 
+void llvm::sys::SetPipeSignalFunction(void (*Handler)()) {
+  PipeSignalFunction.exchange(Handler);
+  RegisterHandlers();
+}
+
 // The public API
 bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
std::string* ErrMsg) {

diff  --git a/llvm/lib/Support/Windows/Signals.inc 
b/llvm/lib/Support/Windows/Signals.inc
index 6a820ef22b1e..d962daf79348 100644
--- a/llvm/lib/Support/Windows/Signals.inc
+++ b/llvm/lib/Support/Windows/Signals.inc
@@ -560,6 +560,9 @@ void llvm::s

[Lldb-commits] [lldb] r374212 - [test] Skip entry value test when clang < 10.0.0

2019-10-09 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Oct  9 13:21:33 2019
New Revision: 374212

URL: http://llvm.org/viewvc/llvm-project?rev=374212&view=rev
Log:
[test] Skip entry value test when clang < 10.0.0

clang-9 emitted the wrong opcode for entry values on Darwin.

rdar://56119661

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py?rev=374212&r1=374211&r2=374212&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 Wed Oct  9 13:21:33 2019
@@ -7,6 +7,7 @@ supported_platforms.extend(lldbplatformu
 
 lldbinline.MakeInlineTest(__file__, globals(),
 [decorators.skipUnlessPlatform(supported_platforms),
+ decorators.skipIf(compiler="clang", compiler_version=['<', '10.0']),
  decorators.skipUnlessArch('x86_64'),
  decorators.skipUnlessHasCallSiteInfo,
  decorators.skipIf(dwarf_version=['<', '4'])])


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


[Lldb-commits] [lldb] r374114 - StopInfo/Mach: Delete PPC support

2019-10-08 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Oct  8 13:47:44 2019
New Revision: 374114

URL: http://llvm.org/viewvc/llvm-project?rev=374114&view=rev
Log:
StopInfo/Mach: Delete PPC support

LLDB appears to have at least partial support for PPC, but PPC on Mach
isn't a thing AFAIK.

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

Modified:
lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp

Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=374114&r1=374113&r2=374114&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Tue Oct 
 8 13:47:44 2019
@@ -78,21 +78,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 0x101:
-code_desc = "EXC_PPC_VM_PROT_READ";
-break;
-  case 0x102:
-code_desc = "EXC_PPC_BADSPACE";
-break;
-  case 0x103:
-code_desc = "EXC_PPC_UNALIGNED";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -107,30 +92,6 @@ const char *StopInfoMachException::GetDe
 code_desc = "EXC_I386_INVOP";
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_INVALID_SYSCALL";
-break;
-  case 2:
-code_desc = "EXC_PPC_UNIPL_INST";
-break;
-  case 3:
-code_desc = "EXC_PPC_PRIVINST";
-break;
-  case 4:
-code_desc = "EXC_PPC_PRIVREG";
-break;
-  case 5:
-code_desc = "EXC_PPC_TRACE";
-break;
-  case 6:
-code_desc = "EXC_PPC_PERFMON";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (m_exc_code == 1)
@@ -175,33 +136,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_OVERFLOW";
-break;
-  case 2:
-code_desc = "EXC_PPC_ZERO_DIVIDE";
-break;
-  case 3:
-code_desc = "EXC_PPC_FLT_INEXACT";
-break;
-  case 4:
-code_desc = "EXC_PPC_FLT_ZERO_DIVIDE";
-break;
-  case 5:
-code_desc = "EXC_PPC_FLT_UNDERFLOW";
-break;
-  case 6:
-code_desc = "EXC_PPC_FLT_OVERFLOW";
-break;
-  case 7:
-code_desc = "EXC_PPC_FLT_NOT_A_NUMBER";
-break;
-  }
-  break;
-
 default:
   break;
 }
@@ -235,15 +169,6 @@ const char *StopInfoMachException::GetDe
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (m_exc_code) {
-  case 1:
-code_desc = "EXC_PPC_BREAKPOINT";
-break;
-  }
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   switch (m_exc_code) {
@@ -384,30 +309,7 @@ StopInfoSP StopInfoMachException::Create
 
   switch (exc_type) {
   case 1: // EXC_BAD_ACCESS
-break;
-
   case 2: // EXC_BAD_INSTRUCTION
-switch (cpu) {
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  switch (exc_code) {
-  case 1: // EXC_PPC_INVALID_SYSCALL
-  case 2: // EXC_PPC_UNIPL_INST
-  case 3: // EXC_PPC_PRIVINST
-  case 4: // EXC_PPC_PRIVREG
-break;
-  case 5: // EXC_PPC_TRACE
-return StopInfo::CreateStopReasonToTrace(thread);
-  case 6: // EXC_PPC_PERFMON
-break;
-  }
-  break;
-
-default:
-  break;
-}
-break;
-
   case 3: // EXC_ARITHMETIC
   case 4: // EXC_EMULATION
 break;
@@ -478,11 +380,6 @@ StopInfoSP StopInfoMachException::Create
   }
   break;
 
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-  is_actual_breakpoint = exc_code == 1; // EXC_PPC_BREAKPOINT
-  break;
-
 case llvm::Triple::arm:
 case llvm::Triple::thumb:
   if (exc_code == 0x102) // EXC_ARM_DA_DEBUG


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


[Lldb-commits] [lldb] r374106 - StopInfo/Mach: Use early-exits, reflow messy comments, NFCI

2019-10-08 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Oct  8 12:40:13 2019
New Revision: 374106

URL: http://llvm.org/viewvc/llvm-project?rev=374106&view=rev
Log:
StopInfo/Mach: Use early-exits, reflow messy comments, NFCI

Modified:
lldb/trunk/include/lldb/Target/StopInfo.h
lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp

Modified: lldb/trunk/include/lldb/Target/StopInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=374106&r1=374105&r2=374106&view=diff
==
--- lldb/trunk/include/lldb/Target/StopInfo.h (original)
+++ lldb/trunk/include/lldb/Target/StopInfo.h Tue Oct  8 12:40:13 2019
@@ -33,10 +33,13 @@ public:
 
   lldb::ThreadSP GetThread() const { return m_thread_wp.lock(); }
 
-  // The value of the StopInfo depends on the StopReason. StopReason
-  // Meaning --
-  // eStopReasonBreakpoint   BreakpointSiteID eStopReasonSignal
-  // Signal number eStopReasonWatchpoint   WatchpointLocationID
+  // The value of the StopInfo depends on the StopReason.
+  //
+  // StopReason Meaning
+  // 
+  // eStopReasonBreakpoint   BreakpointSiteID
+  // eStopReasonSignal   Signal number
+  // eStopReasonWatchpoint   WatchpointLocationID
   // eStopReasonPlanComplete No significance
 
   uint64_t GetValue() const { return m_value; }

Modified: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=374106&r1=374105&r2=374106&view=diff
==
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp 
(original)
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp Tue Oct 
 8 12:40:13 2019
@@ -30,334 +30,341 @@ using namespace lldb;
 using namespace lldb_private;
 
 const char *StopInfoMachException::GetDescription() {
-  if (m_description.empty() && m_value != 0) {
-ExecutionContext exe_ctx(m_thread_wp.lock());
-Target *target = exe_ctx.GetTargetPtr();
-const llvm::Triple::ArchType cpu =
-target ? target->GetArchitecture().GetMachine()
-   : llvm::Triple::UnknownArch;
-
-const char *exc_desc = nullptr;
-const char *code_label = "code";
-const char *code_desc = nullptr;
-const char *subcode_label = "subcode";
-const char *subcode_desc = nullptr;
+  if (!m_description.empty())
+return m_description.c_str();
+  if (GetValue() == eStopReasonInvalid)
+return "invalid stop reason!";
+
+  ExecutionContext exe_ctx(m_thread_wp.lock());
+  Target *target = exe_ctx.GetTargetPtr();
+  const llvm::Triple::ArchType cpu =
+  target ? target->GetArchitecture().GetMachine()
+ : llvm::Triple::UnknownArch;
+
+  const char *exc_desc = nullptr;
+  const char *code_label = "code";
+  const char *code_desc = nullptr;
+  const char *subcode_label = "subcode";
+  const char *subcode_desc = nullptr;
 
 #if defined(__APPLE__)
-char code_desc_buf[32];
-char subcode_desc_buf[32];
+  char code_desc_buf[32];
+  char subcode_desc_buf[32];
 #endif
 
-switch (m_value) {
-case 1: // EXC_BAD_ACCESS
-  exc_desc = "EXC_BAD_ACCESS";
-  subcode_label = "address";
-  switch (cpu) {
-  case llvm::Triple::x86:
-  case llvm::Triple::x86_64:
-switch (m_exc_code) {
-case 0xd:
-  code_desc = "EXC_I386_GPFLT";
-  m_exc_data_count = 1;
-  break;
-}
-break;
-  case llvm::Triple::arm:
-  case llvm::Triple::thumb:
-switch (m_exc_code) {
-case 0x101:
-  code_desc = "EXC_ARM_DA_ALIGN";
-  break;
-case 0x102:
-  code_desc = "EXC_ARM_DA_DEBUG";
-  break;
-}
+  switch (m_value) {
+  case 1: // EXC_BAD_ACCESS
+exc_desc = "EXC_BAD_ACCESS";
+subcode_label = "address";
+switch (cpu) {
+case llvm::Triple::x86:
+case llvm::Triple::x86_64:
+  switch (m_exc_code) {
+  case 0xd:
+code_desc = "EXC_I386_GPFLT";
+m_exc_data_count = 1;
 break;
-
-  case llvm::Triple::ppc:
-  case llvm::Triple::ppc64:
-switch (m_exc_code) {
-case 0x101:
-  code_desc = "EXC_PPC_VM_PROT_READ";
-  break;
-case 0x102:
-  code_desc = "EXC_PPC_BADSPACE";
-  break;
-case 0x103:
-  code_desc = "EXC_PPC_UNALIGNED";
-  break;
-}
+  }
+  break;
+case llvm::Triple::arm:
+case llvm::Triple::thumb:
+  switch (m_exc_code) {
+  case 0x101:
+code_desc = "EXC_ARM_DA_ALIGN";
 break;
-
-  default:
+  case 0x102:
+code_desc = "EXC_ARM_DA_DEBUG";
 break;
   }
   break;
 
-case 2: // EXC_BAD_INSTRUCTION
-  exc_

[Lldb-commits] [lldb] r373927 - [DWARFASTParserClang] Factor out structure-like type parsing, NFC

2019-10-07 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Mon Oct  7 10:22:53 2019
New Revision: 373927

URL: http://llvm.org/viewvc/llvm-project?rev=373927&view=rev
Log:
[DWARFASTParserClang] Factor out structure-like type parsing, NFC

Split out the logic to parse structure-like types into a separate
function, in an attempt to reduce the complexity of ParseTypeFromDWARF.

Inspired by discussion in https://reviews.llvm.org/D68130.

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

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h?rev=373927&r1=373926&r2=373927&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h Mon Oct  7 
10:22:53 2019
@@ -28,7 +28,6 @@ public:
 
   virtual lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext 
&sc,
   const DWARFDIE &die,
-  lldb_private::Log *log,
   bool *type_is_new_ptr) = 0;
 
   virtual lldb_private::Function *

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp?rev=373927&r1=373926&r2=373927&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Mon Oct  
7 10:22:53 2019
@@ -9,7 +9,6 @@
 #include 
 
 #include "DWARFASTParserClang.h"
-#include "DWARFDIE.h"
 #include "DWARFDebugInfo.h"
 #include "DWARFDeclContext.h"
 #include "DWARFDefines.h"
@@ -232,42 +231,7 @@ static void CompleteExternalTagDeclType(
   }
 }
 
-namespace {
-/// Parsed form of all attributes that are relevant for type reconstruction.
-/// Some attributes are relevant for all kinds of types (declaration), while
-/// others are only meaningful to a specific type (is_virtual)
-struct ParsedTypeAttributes {
-  explicit ParsedTypeAttributes(const DWARFDIE &die);
-
-  AccessType accessibility = eAccessNone;
-  bool is_artificial = false;
-  bool is_complete_objc_class = false;
-  bool is_explicit = false;
-  bool is_forward_declaration = false;
-  bool is_inline = false;
-  bool is_scoped_enum = false;
-  bool is_vector = false;
-  bool is_virtual = false;
-  clang::StorageClass storage = clang::SC_None;
-  const char *mangled_name = nullptr;
-  ConstString name;
-  Declaration decl;
-  DWARFDIE object_pointer;
-  DWARFFormValue abstract_origin;
-  DWARFFormValue containing_type;
-  DWARFFormValue signature;
-  DWARFFormValue specification;
-  DWARFFormValue type;
-  LanguageType class_language = eLanguageTypeUnknown;
-  llvm::Optional byte_size;
-  size_t calling_convention = llvm::dwarf::DW_CC_normal;
-  uint32_t bit_stride = 0;
-  uint32_t byte_stride = 0;
-  uint32_t encoding = 0;
-};
-} // namespace
-
-ParsedTypeAttributes::ParsedTypeAttributes(const DWARFDIE &die) {
+ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
   DWARFAttributes attributes;
   size_t num_attributes = die.GetAttributes(attributes);
   for (size_t i = 0; i < num_attributes; ++i) {
@@ -394,13 +358,17 @@ static std::string GetUnitName(const DWA
 }
 
 TypeSP DWARFASTParserClang::ParseTypeFromDWARF(const SymbolContext &sc,
-   const DWARFDIE &die, Log *log,
+   const DWARFDIE &die,
bool *type_is_new_ptr) {
   if (type_is_new_ptr)
 *type_is_new_ptr = false;
 
   if (!die)
 return nullptr;
+
+  Log *log(LogChannelDWARF::GetLogIfAny(DWARF_LOG_TYPE_COMPLETION |
+DWARF_LOG_LOOKUPS));
+
   SymbolFileDWARF *dwarf = die.GetDWARF();
   if (log) {
 DWARFDIE context_die;
@@ -424,11 +392,11 @@ TypeSP DWARFASTParserClang::ParseTypeFro
   // Set a bit that lets us know that we are currently parsing this
   dwarf->GetDIEToType()[die.GetDIE()] = DIE_IS_BEING_PARSED;
 
-  ParsedTypeAttributes attrs(die);
+  ParsedDWARFTypeAttributes attrs(die);
 
   if (DWARFDIE signature_die = attrs.signature.Reference()) {
 if (TypeSP type_sp =
-ParseTypeFromDWARF(sc, signature_die, log, type_is_new_ptr)) {
+ParseTypeFromDWARF(sc, signature_die, type_is_new_ptr)) {
   dwarf->GetDIEToType()[die.GetDIE()] = type_sp.get();
   if (clan

[Lldb-commits] [lldb] r373926 - [DWARFASTParserClang] Delete commented-out typedef, NFC

2019-10-07 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Mon Oct  7 10:22:50 2019
New Revision: 373926

URL: http://llvm.org/viewvc/llvm-project?rev=373926&view=rev
Log:
[DWARFASTParserClang] Delete commented-out typedef, NFC

(& group together all the protected members & typedefs)

Modified:
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h?rev=373926&r1=373925&r2=373926&view=diff
==
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h Mon Oct  7 
10:22:50 2019
@@ -63,9 +63,28 @@ public:
   lldb_private::ClangASTImporter &GetClangASTImporter();
 
 protected:
+  /// Protected typedefs and members.
+  /// @{
   class DelayedAddObjCClassProperty;
   typedef std::vector DelayedPropertyList;
 
+  typedef llvm::SmallPtrSet DIEPointerSet;
+  typedef llvm::DenseMap
+  DIEToDeclContextMap;
+  typedef std::multimap
+  DeclContextToDIEMap;
+  typedef llvm::DenseMap
+  DIEToDeclMap;
+  typedef llvm::DenseMap DeclToDIEMap;
+
+  lldb_private::ClangASTContext &m_ast;
+  DIEToDeclMap m_die_to_decl;
+  DeclToDIEMap m_decl_to_die;
+  DIEToDeclContextMap m_die_to_decl_ctx;
+  DeclContextToDIEMap m_decl_ctx_to_die;
+  std::unique_ptr m_clang_ast_importer_up;
+  /// @}
+
   clang::DeclContext *GetDeclContextForBlock(const DWARFDIE &die);
 
   clang::BlockDecl *ResolveBlockDIE(const DWARFDIE &die);
@@ -128,24 +147,6 @@ protected:
   // Return true if this type is a declaration to a type in an external
   // module.
   lldb::ModuleSP GetModuleForType(const DWARFDIE &die);
-
-  typedef llvm::SmallPtrSet DIEPointerSet;
-  typedef llvm::DenseMap
-  DIEToDeclContextMap;
-  // typedef llvm::DenseMap
-  // DeclContextToDIEMap;
-  typedef std::multimap
-  DeclContextToDIEMap;
-  typedef llvm::DenseMap
-  DIEToDeclMap;
-  typedef llvm::DenseMap DeclToDIEMap;
-
-  lldb_private::ClangASTContext &m_ast;
-  DIEToDeclMap m_die_to_decl;
-  DeclToDIEMap m_decl_to_die;
-  DIEToDeclContextMap m_die_to_decl_ctx;
-  DeclContextToDIEMap m_decl_ctx_to_die;
-  std::unique_ptr m_clang_ast_importer_up;
 };
 
 #endif // SymbolFileDWARF_DWARFASTParserClang_h_


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


[Lldb-commits] [lldb] r373267 - [StackFrameList][DFS] Turn a few raw pointers into references, NFC

2019-09-30 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Mon Sep 30 14:20:14 2019
New Revision: 373267

URL: http://llvm.org/viewvc/llvm-project?rev=373267&view=rev
Log:
[StackFrameList][DFS] Turn a few raw pointers into references, NFC

Modified:
lldb/trunk/source/Symbol/Function.cpp
lldb/trunk/source/Target/StackFrameList.cpp

Modified: lldb/trunk/source/Symbol/Function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=373267&r1=373266&r2=373267&view=diff
==
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Mon Sep 30 14:20:14 2019
@@ -173,6 +173,7 @@ void CallEdge::ParseSymbolFileAndResolve
 
 Function *CallEdge::GetCallee(ModuleList &images) {
   ParseSymbolFileAndResolve(images);
+  assert(resolved && "Did not resolve lazy callee");
   return lazy_callee.def;
 }
 

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=373267&r1=373266&r2=373267&view=diff
==
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Mon Sep 30 14:20:14 2019
@@ -286,15 +286,15 @@ static void FindInterveningFrames(Functi
 
 DFS(Function *end, ModuleList &images) : end(end), images(images) {}
 
-void search(Function *first_callee, std::vector &path) {
+void search(Function &first_callee, std::vector &path) {
   dfs(first_callee);
   if (!ambiguous)
 path = std::move(solution_path);
 }
 
-void dfs(Function *callee) {
+void dfs(Function &callee) {
   // Found a path to the target function.
-  if (callee == end) {
+  if (&callee == end) {
 if (solution_path.empty())
   solution_path = active_path;
 else
@@ -306,19 +306,19 @@ static void FindInterveningFrames(Functi
   // there's more than one way to reach a target. This errs on the side of
   // caution: it conservatively stops searching when some solutions are
   // still possible to save time in the average case.
-  if (!visited_nodes.insert(callee).second) {
+  if (!visited_nodes.insert(&callee).second) {
 ambiguous = true;
 return;
   }
 
   // Search the calls made from this callee.
-  active_path.push_back(callee);
-  for (CallEdge &edge : callee->GetTailCallingEdges()) {
+  active_path.push_back(&callee);
+  for (CallEdge &edge : callee.GetTailCallingEdges()) {
 Function *next_callee = edge.GetCallee(images);
 if (!next_callee)
   continue;
 
-dfs(next_callee);
+dfs(*next_callee);
 if (ambiguous)
   return;
   }
@@ -326,7 +326,7 @@ static void FindInterveningFrames(Functi
 }
   };
 
-  DFS(&end, images).search(first_callee, path);
+  DFS(&end, images).search(*first_callee, path);
 }
 
 /// Given that \p next_frame will be appended to the frame list, synthesize


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


[Lldb-commits] [lldb] r373233 - [test] Make TestBasicEntryValuesX86_64 run on Linux as well as Darwin

2019-09-30 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Mon Sep 30 10:11:46 2019
New Revision: 373233

URL: http://llvm.org/viewvc/llvm-project?rev=373233&view=rev
Log:
[test] Make TestBasicEntryValuesX86_64 run on Linux as well as Darwin

I think a reasonable plan here is to add support for OSes following the
SysV ABI one by one, watching the bots as we go.

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py?rev=373233&r1=373232&r2=373233&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py
 Mon Sep 30 10:11:46 2019
@@ -1,8 +1,12 @@
 from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
+from lldbsuite.test import lldbplatformutil
+
+supported_platforms = ["linux"]
+supported_platforms.extend(lldbplatformutil.getDarwinOSTriples())
 
 lldbinline.MakeInlineTest(__file__, globals(),
-[decorators.skipUnlessDarwin,
+[decorators.skipUnlessPlatform(supported_platforms),
  decorators.skipUnlessArch('x86_64'),
  decorators.skipUnlessHasCallSiteInfo,
  decorators.skipIf(dwarf_version=['<', '4'])])


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


[Lldb-commits] [lldb] r372903 - [Mangle] Add flag to asm labels to disable '\01' prefixing

2019-09-25 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 25 11:00:31 2019
New Revision: 372903

URL: http://llvm.org/viewvc/llvm-project?rev=372903&view=rev
Log:
[Mangle] Add flag to asm labels to disable '\01' prefixing

LLDB synthesizes decls using asm labels. These decls cannot have a mangle
different than the one specified in the label name. I.e., the '\01' prefix
should not be added.

Fixes an expression evaluation failure in lldb's TestVirtual.py on iOS.

rdar://45827323

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

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

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=372903&r1=372902&r2=372903&view=diff
==
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Sep 25 11:00:31 2019
@@ -8301,8 +8301,8 @@ clang::CXXMethodDecl *ClangASTContext::A
 
cxx_method_decl->addAttr(clang::UsedAttr::CreateImplicit(*getASTContext()));
 
   if (mangled_name != nullptr) {
-cxx_method_decl->addAttr(
-clang::AsmLabelAttr::CreateImplicit(*getASTContext(), mangled_name));
+cxx_method_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
+*getASTContext(), mangled_name, /*literal=*/false));
   }
 
   // Populate the method decl with parameter decls


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


[Lldb-commits] [lldb] r371667 - [Status] Add a LLDB_ERRORF macro for error reporting (similar to LLDB_LOGF)

2019-09-11 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 11 14:23:42 2019
New Revision: 371667

URL: http://llvm.org/viewvc/llvm-project?rev=371667&view=rev
Log:
[Status] Add a LLDB_ERRORF macro for error reporting (similar to LLDB_LOGF)

Modified:
lldb/trunk/include/lldb/Utility/Status.h

Modified: lldb/trunk/include/lldb/Utility/Status.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/Status.h?rev=371667&r1=371666&r2=371667&view=diff
==
--- lldb/trunk/include/lldb/Utility/Status.h (original)
+++ lldb/trunk/include/lldb/Utility/Status.h Wed Sep 11 14:23:42 2019
@@ -212,4 +212,11 @@ template <> struct format_providerSetErrorStringWithFormat((fmt), __VA_ARGS__);  
\
+}  
\
+  } while (0);
+
 #endif // #ifndef LLDB_UTILITY_STATUS_H


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


[Lldb-commits] [lldb] r371668 - [DWARF] Evaluate DW_OP_entry_value

2019-09-11 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Wed Sep 11 14:23:45 2019
New Revision: 371668

URL: http://llvm.org/viewvc/llvm-project?rev=371668&view=rev
Log:
[DWARF] Evaluate DW_OP_entry_value

Add support for evaluating DW_OP_entry_value. This involves parsing
DW_TAG_call_site_parameter and wiring the information through to the expression
evaluator.

rdar://54496008

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

Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/TestBasicEntryValuesX86_64.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/param_entry_vals/basic_entry_values_x86_64/main.cpp
Modified:
lldb/trunk/include/lldb/Symbol/Function.h
lldb/trunk/packages/Python/lldbsuite/test/decorators.py
lldb/trunk/source/Expression/DWARFExpression.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Symbol/Function.cpp

Modified: lldb/trunk/include/lldb/Symbol/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=371668&r1=371667&r2=371668&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Function.h (original)
+++ lldb/trunk/include/lldb/Symbol/Function.h Wed Sep 11 14:23:45 2019
@@ -246,10 +246,22 @@ private:
 
 class Function;
 
+/// \class CallSiteParameter Function.h "lldb/Symbol/Function.h"
+///
+/// Represent the locations of a parameter at a call site, both in the caller
+/// and in the callee.
+struct CallSiteParameter {
+  DWARFExpression LocationInCallee;
+  DWARFExpression LocationInCaller;
+};
+
+/// A vector of \c CallSiteParameter.
+using CallSiteParameterArray = llvm::SmallVector;
+
 /// \class CallEdge Function.h "lldb/Symbol/Function.h"
 ///
 /// Represent a call made within a Function. This can be used to find a path
-/// in the call graph between two functions.
+/// in the call graph between two functions, or to evaluate DW_OP_entry_value.
 class CallEdge {
 public:
   /// Construct a call edge using a symbol name to identify the calling
@@ -259,7 +271,8 @@ public:
   /// TODO: A symbol name may not be globally unique. To disambiguate ODR
   /// conflicts, it's necessary to determine the \c Target a call edge is
   /// associated with before resolving it.
-  CallEdge(const char *symbol_name, lldb::addr_t return_pc);
+  CallEdge(const char *symbol_name, lldb::addr_t return_pc,
+   CallSiteParameterArray parameters);
 
   CallEdge(CallEdge &&) = default;
   CallEdge &operator=(CallEdge &&) = default;
@@ -279,6 +292,9 @@ public:
   /// offset.
   lldb::addr_t GetUnresolvedReturnPCAddress() const { return return_pc; }
 
+  /// Get the call site parameters available at this call edge.
+  llvm::ArrayRef GetCallSiteParameters() const;
+
 private:
   void ParseSymbolFileAndResolve(ModuleList &images);
 
@@ -294,6 +310,8 @@ private:
   /// gives the return PC for the call.
   lldb::addr_t return_pc;
 
+  CallSiteParameterArray parameters;
+
   /// Whether or not an attempt was made to find the callee's definition.
   bool resolved;
 
@@ -569,6 +587,8 @@ protected:
   uint32_t
   m_prologue_byte_size; ///< Compute the prologue size once and cache it
 
+  // TODO: Use a layer of indirection to point to call edges, to save space
+  // when call info hasn't been parsed.
   bool m_call_edges_resolved = false; ///< Whether call site info has been
   ///  parsed.
   std::vector m_call_edges; ///< Outgoing call edges.

Modified: lldb/trunk/packages/Python/lldbsuite/test/decorators.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/decorators.py?rev=371668&r1=371667&r2=371668&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/decorators.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/decorators.py Wed Sep 11 14:23:45 
2019
@@ -641,6 +641,16 @@ def skipUnlessPlatform(oslist):
 return unittest2.skipUnless(lldbplatformutil.getPlatform() in oslist,
 "requires one of %s" % (", ".join(oslist)))
 
+def skipUnlessArch(arch):
+"""Decorate the item to skip tests unless running on the specified 
architecture."""
+
+def arch_doesnt_match(self):
+target_arch = self.getArchitecture()
+if arch != target_arch:
+return "Test only runs on " + arch + ", but target arch is " + 
target_arch
+return None
+
+return skipTestIfFn(arch_doesnt_match)
 
 def skipIfTargetAndroid(bugnumber=Non

[Lldb-commits] [lldb] r371543 - [Function] Factor out GetCallEdgeForReturnAddress, NFC

2019-09-10 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Sep 10 11:36:50 2019
New Revision: 371543

URL: http://llvm.org/viewvc/llvm-project?rev=371543&view=rev
Log:
[Function] Factor out GetCallEdgeForReturnAddress, NFC

Finding the call edge in a function which corresponds to a particular
return address is a generic/useful operation.

Modified:
lldb/trunk/include/lldb/Symbol/Function.h
lldb/trunk/source/Symbol/Function.cpp
lldb/trunk/source/Target/StackFrameList.cpp

Modified: lldb/trunk/include/lldb/Symbol/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=371543&r1=371542&r2=371543&view=diff
==
--- lldb/trunk/include/lldb/Symbol/Function.h (original)
+++ lldb/trunk/include/lldb/Symbol/Function.h Tue Sep 10 11:36:50 2019
@@ -402,6 +402,11 @@ public:
   /// return None.
   llvm::MutableArrayRef GetTailCallingEdges();
 
+  /// Get the outgoing call edge from this function which has the given return
+  /// address \p return_pc, or return nullptr. Note that this will not return a
+  /// tail-calling edge.
+  CallEdge *GetCallEdgeForReturnAddress(lldb::addr_t return_pc, Target 
&target);
+
   /// Get accessor for the block list.
   ///
   /// \return

Modified: lldb/trunk/source/Symbol/Function.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=371543&r1=371542&r2=371543&view=diff
==
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Tue Sep 10 11:36:50 2019
@@ -276,6 +276,20 @@ llvm::MutableArrayRef Function
   });
 }
 
+CallEdge *Function::GetCallEdgeForReturnAddress(addr_t return_pc,
+Target &target) {
+  auto edges = GetCallEdges();
+  auto edge_it =
+  std::lower_bound(edges.begin(), edges.end(), return_pc,
+   [&](const CallEdge &edge, addr_t pc) {
+ return edge.GetReturnPCAddress(*this, target) < pc;
+   });
+  if (edge_it == edges.end() ||
+  edge_it->GetReturnPCAddress(*this, target) != return_pc)
+return nullptr;
+  return &const_cast(*edge_it);
+}
+
 Block &Function::GetBlock(bool can_create) {
   if (!m_block.BlockInfoHasBeenParsed() && can_create) {
 ModuleSP module_sp = CalculateSymbolContextModule();

Modified: lldb/trunk/source/Target/StackFrameList.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameList.cpp?rev=371543&r1=371542&r2=371543&view=diff
==
--- lldb/trunk/source/Target/StackFrameList.cpp (original)
+++ lldb/trunk/source/Target/StackFrameList.cpp Tue Sep 10 11:36:50 2019
@@ -250,26 +250,19 @@ static void FindInterveningFrames(Functi
begin.GetDisplayName(), end.GetDisplayName(), return_pc);
 
   // Find a non-tail calling edge with the correct return PC.
-  auto first_level_edges = begin.GetCallEdges();
   if (log)
-for (const CallEdge &edge : first_level_edges)
+for (const CallEdge &edge : begin.GetCallEdges())
   LLDB_LOG(log, "FindInterveningFrames: found call with retn-PC = {0:x}",
edge.GetReturnPCAddress(begin, target));
-  auto first_edge_it = std::lower_bound(
-  first_level_edges.begin(), first_level_edges.end(), return_pc,
-  [&](const CallEdge &edge, addr_t target_pc) {
-return edge.GetReturnPCAddress(begin, target) < target_pc;
-  });
-  if (first_edge_it == first_level_edges.end() ||
-  first_edge_it->GetReturnPCAddress(begin, target) != return_pc) {
+  CallEdge *first_edge = begin.GetCallEdgeForReturnAddress(return_pc, target);
+  if (!first_edge) {
 LLDB_LOG(log, "No call edge outgoing from {0} with retn-PC == {1:x}",
  begin.GetDisplayName(), return_pc);
 return;
   }
-  CallEdge &first_edge = const_cast(*first_edge_it);
 
   // The first callee may not be resolved, or there may be nothing to fill in.
-  Function *first_callee = first_edge.GetCallee(images);
+  Function *first_callee = first_edge->GetCallee(images);
   if (!first_callee) {
 LLDB_LOG(log, "Could not resolve callee");
 return;


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


[Lldb-commits] [lldb] r371544 - [lldbtest] Add an "expected_cmd_failure" option to the filecheck helper

2019-09-10 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Tue Sep 10 11:36:53 2019
New Revision: 371544

URL: http://llvm.org/viewvc/llvm-project?rev=371544&view=rev
Log:
[lldbtest] Add an "expected_cmd_failure" option to the filecheck helper

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

Modified: lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py?rev=371544&r1=371543&r2=371544&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py Tue Sep 10 11:36:53 
2019
@@ -2207,12 +2207,16 @@ class TestBase(Base):
 self,
 command,
 check_file,
-filecheck_options = ''):
+filecheck_options = '',
+expect_cmd_failure = False):
 # Run the command.
 self.runCmd(
 command,
+check=(not expect_cmd_failure),
 msg="FileCheck'ing result of `{0}`".format(command))
 
+self.assertTrue((not expect_cmd_failure) == self.res.Succeeded())
+
 # Get the error text if there was an error, and the regular text if 
not.
 output = self.res.GetOutput() if self.res.Succeeded() \
 else self.res.GetError()


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


[Lldb-commits] [lldb] r369987 - [build_exception] Decode build failure messages

2019-08-26 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Mon Aug 26 16:24:45 2019
New Revision: 369987

URL: http://llvm.org/viewvc/llvm-project?rev=369987&view=rev
Log:
[build_exception] Decode build failure messages

This is so that the test harness pretty-prints build error messages in
trace mode, instead of dumping a raw python bytes object.

Modified:
lldb/trunk/packages/Python/lldbsuite/test_event/build_exception.py

Modified: lldb/trunk/packages/Python/lldbsuite/test_event/build_exception.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test_event/build_exception.py?rev=369987&r1=369986&r2=369987&view=diff
==
--- lldb/trunk/packages/Python/lldbsuite/test_event/build_exception.py 
(original)
+++ lldb/trunk/packages/Python/lldbsuite/test_event/build_exception.py Mon Aug 
26 16:24:45 2019
@@ -13,4 +13,4 @@ class BuildError(Exception):
 @staticmethod
 def format_build_error(command, command_output):
 return "Error when building test subject.\n\nBuild 
Command:\n{}\n\nBuild Command Output:\n{}".format(
-command, command_output)
+command, command_output.decode("utf-8"))


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


[Lldb-commits] [lldb] r369821 - Skip tail call frame tests when dwarf_version < 4

2019-08-23 Thread Vedant Kumar via lldb-commits
Author: vedantk
Date: Fri Aug 23 15:28:46 2019
New Revision: 369821

URL: http://llvm.org/viewvc/llvm-project?rev=369821&view=rev
Log:
Skip tail call frame tests when dwarf_version < 4

rdar://problem/54656572

Modified:

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_tail_call_seq/TestDisambiguateTailCallSeq.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/inlining_and_tail_calls/TestInliningAndTailCalls.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/thread_step_out_message/TestArtificialFrameStepOutMessage.py

lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/unambiguous_sequence/TestUnambiguousTailCalls.py
lldb/trunk/packages/Python/lldbsuite/test/lldbtest.py

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py?rev=369821&r1=369820&r2=369821&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq1/TestAmbiguousTailCallSeq1.py
 Fri Aug 23 15:28:46 2019
@@ -2,4 +2,5 @@ from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(__file__, globals(),
-[decorators.skipUnlessHasCallSiteInfo])
+[decorators.skipUnlessHasCallSiteInfo,
+ decorators.skipIf(dwarf_version=['<', '4'])])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py?rev=369821&r1=369820&r2=369821&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/ambiguous_tail_call_seq2/TestAmbiguousTailCallSeq2.py
 Fri Aug 23 15:28:46 2019
@@ -2,4 +2,5 @@ from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(__file__, globals(),
-[decorators.skipUnlessHasCallSiteInfo])
+[decorators.skipUnlessHasCallSiteInfo,
+ decorators.skipIf(dwarf_version=['<', '4'])])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py?rev=369821&r1=369820&r2=369821&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
 (original)
+++ 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_call_site/TestDisambiguateCallSite.py
 Fri Aug 23 15:28:46 2019
@@ -2,4 +2,5 @@ from lldbsuite.test import lldbinline
 from lldbsuite.test import decorators
 
 lldbinline.MakeInlineTest(__file__, globals(),
-[decorators.skipUnlessHasCallSiteInfo])
+[decorators.skipUnlessHasCallSiteInfo,
+ decorators.skipIf(dwarf_version=['<', '4'])])

Modified: 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_frames/disambiguate_paths_to_common_sink/TestDisambiguatePathsToCommonSink.py?rev=369821&r1=369820&r2=369821&view=diff
==
--- 
lldb/trunk/packages/Python/lldbsuite/test/functionalities/tail_call_f

  1   2   3   >