Skip to content

Commit 9959c2e

Browse files
authored
Merge pull request #11743 from swiftlang/lldb/move-recognizer-to-21.x
🍒[lldb][Runtime] Move VerboseTrapFrameRecognizer into CPPLanguageRuntime
2 parents b787ea4 + c254ab8 commit 9959c2e

File tree

9 files changed

+90
-8
lines changed

9 files changed

+90
-8
lines changed

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
add_lldb_library(lldbPluginCPPRuntime
22
CPPLanguageRuntime.cpp
3+
VerboseTrapFrameRecognizer.cpp
34

45
LINK_LIBS
56
lldbCore

lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <memory>
1313

1414
#include "CPPLanguageRuntime.h"
15+
#include "VerboseTrapFrameRecognizer.h"
1516

1617
#include "llvm/ADT/StringRef.h"
1718

@@ -107,12 +108,15 @@ class LibCXXFrameRecognizer : public StackFrameRecognizer {
107108

108109
CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
109110
: LanguageRuntime(process) {
110-
if (process)
111+
if (process) {
111112
process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
112113
StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},
113114
std::make_shared<RegularExpression>("^std::__[^:]*::"),
114115
/*mangling_preference=*/Mangled::ePreferDemangledWithoutArguments,
115116
/*first_instruction_only=*/false);
117+
118+
RegisterVerboseTrapFrameRecognizer(*process);
119+
}
116120
}
117121

118122
bool CPPLanguageRuntime::IsAllowedRuntimeValue(ConstString name) {

lldb/source/Target/VerboseTrapFrameRecognizer.cpp renamed to lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "lldb/Target/VerboseTrapFrameRecognizer.h"
1+
#include "VerboseTrapFrameRecognizer.h"
22

33
#include "lldb/Core/Module.h"
44
#include "lldb/Symbol/Function.h"

lldb/include/lldb/Target/VerboseTrapFrameRecognizer.h renamed to lldb/source/Plugins/LanguageRuntime/CPlusPlus/VerboseTrapFrameRecognizer.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
#ifndef LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
2-
#define LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
1+
//===-- VerboseTrapFrameRecognizer.h --------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H
10+
#define LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H
311

412
#include "lldb/Target/StackFrameRecognizer.h"
513

@@ -36,4 +44,4 @@ class VerboseTrapFrameRecognizer : public StackFrameRecognizer {
3644

3745
} // namespace lldb_private
3846

39-
#endif // LLDB_TARGET_VERBOSETRAPFRAMERECOGNIZER_H
47+
#endif // LLDB_SOURCE_PLUGINS_LANGUAGERUNTIME_C_PLUS_PLUS_VERBOSETRAPFRAMERECOGNIZER_H

lldb/source/Target/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ add_lldb_library(lldbTarget
8181
UnixSignals.cpp
8282
UnwindAssembly.cpp
8383
UnwindLLDB.cpp
84-
VerboseTrapFrameRecognizer.cpp
8584

8685
ADDITIONAL_HEADER_DIRS
8786
${LLDB_INCLUDE_DIR}/lldb/Target

lldb/source/Target/Process.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#include "lldb/Target/ThreadPlanCallFunction.h"
6767
#include "lldb/Target/ThreadPlanStack.h"
6868
#include "lldb/Target/UnixSignals.h"
69-
#include "lldb/Target/VerboseTrapFrameRecognizer.h"
7069
#include "lldb/Utility/AddressableBits.h"
7170
#include "lldb/Utility/Event.h"
7271
#include "lldb/Utility/LLDBLog.h"
@@ -527,7 +526,6 @@ Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp,
527526
// We should have a plugin do the registration instead, for example, a
528527
// common C LanguageRuntime plugin.
529528
RegisterAssertFrameRecognizer(this);
530-
RegisterVerboseTrapFrameRecognizer(*this);
531529
}
532530

533531
Process::~Process() {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
int main() {
2+
__builtin_verbose_trap("Foo", "Bar");
3+
return 0;
4+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# UNSUPPORTED: system-windows
2+
3+
# Checks that the recognizers that should work across language runtimes
4+
# are only registered once with the target.
5+
6+
# RUN: split-file %s %t
7+
8+
# RUN: %clang_host %t/main.cpp -g -o %t/cpp.out
9+
# RUN: %lldb -b -s %t/commands.input %t/cpp.out | FileCheck %s
10+
11+
# RUN: %clang_host -x objective-c++ %t/main.mm -g -o %t/objcxx.out
12+
# RUN: %lldb -b -s %t/commands.input %t/objcxx.out | FileCheck %s
13+
14+
# RUN: %clang_host %t/main.c -g -o %t/c.out
15+
# RUN: %lldb -b -s %t/commands.input %t/c.out | FileCheck %s
16+
17+
# RUN: %clang_host -x objective-c %t/main.m -g -o %t/objc.out
18+
# RUN: %lldb -b -s %t/commands.input %t/objc.out | FileCheck %s
19+
20+
#--- main.m
21+
int main() {}
22+
23+
#--- main.c
24+
int main() {}
25+
26+
#--- main.mm
27+
int main() {}
28+
29+
#--- main.cpp
30+
int main() {}
31+
32+
#--- commands.input
33+
34+
b main
35+
frame recognizer list
36+
run
37+
frame recognizer list
38+
continue
39+
run
40+
frame recognizer list
41+
42+
# CHECK: frame recognizer list
43+
# CHECK-NEXT: no matching results found.
44+
45+
# CHECK: frame recognizer list
46+
# CHECK: Verbose Trap StackFrame Recognizer
47+
# CHECK: Assert StackFrame Recognizer
48+
# CHECK-NOT: Verbose Trap StackFrame Recognizer
49+
# CHECK-NOT: Assert StackFrame Recognizer
50+
51+
# FIXME: avoid duplicate frame recognizers in the target: https://github.com/llvm/llvm-project/issues/166341
52+
# CHECK: frame recognizer list
53+
# CHECK: Verbose Trap StackFrame Recognizer
54+
# CHECK: Assert StackFrame Recognizer
55+
# CHECK: Verbose Trap StackFrame Recognizer
56+
# CHECK: Assert StackFrame Recognizer
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# REQUIRES: system-darwin
2+
#
3+
# RUN: %clangxx_host -x objective-c -g %S/Inputs/verbose_trap.m -o %t.out
4+
# RUN: %lldb -b -s %s %t.out | FileCheck %s
5+
6+
run
7+
# CHECK: thread #{{.*}}stop reason = Foo: Bar
8+
frame info
9+
# CHECK: frame #{{.*}}`main at verbose_trap.m
10+
frame recognizer info 0
11+
# CHECK: frame 0 is recognized by Verbose Trap StackFrame Recognizer
12+
q

0 commit comments

Comments
 (0)