Skip to content

Commit b575463

Browse files
jankratochvilmemfrob
authored and
memfrob
committed
[lldb] Fix Recognizer/assert.test with glibc-2.33.9000-31.fc35.x86_64
While on regular Linux system (Fedora 34 GA, not updated): * thread #1, name = '1', stop reason = hit program assert frame #0: 0x00007ffff7e242a2 libc.so.6`raise + 322 frame #1: 0x00007ffff7e0d8a4 libc.so.6`abort + 278 frame #2: 0x00007ffff7e0d789 libc.so.6`__assert_fail_base.cold + 15 frame #3: 0x00007ffff7e1ca16 libc.so.6`__assert_fail + 70 * frame #4: 0x00000000004011bd 1`main at assert.c:7:3 On Fedora 35 pre-release one gets: * thread #1, name = '1', stop reason = signal SIGABRT * frame #0: 0x00007ffff7e48ee3 libc.so.6`pthread_kill@GLIBC_2.2.5 + 67 frame #1: 0x00007ffff7dfb986 libc.so.6`raise + 22 frame #2: 0x00007ffff7de5806 libc.so.6`abort + 230 frame #3: 0x00007ffff7de571b libc.so.6`__assert_fail_base.cold + 15 frame #4: 0x00007ffff7df4646 libc.so.6`__assert_fail + 70 frame #5: 0x00000000004011bd 1`main at assert.c:7:3 I did not write a testcase as one needs the specific glibc. An artificial test would just copy the changed source. Reviewed By: mib Differential Revision: https://reviews.llvm.org/D105133
1 parent 38dc885 commit b575463

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

lldb/source/Target/AssertFrameRecognizer.cpp

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ namespace lldb_private {
2222
struct SymbolLocation {
2323
FileSpec module_spec;
2424
std::vector<ConstString> symbols;
25+
26+
// The symbols are regular expressions. In such case all symbols are matched
27+
// with their trailing @VER symbol version stripped.
28+
bool symbols_are_regex = false;
2529
};
2630

2731
/// Fetches the abort frame location depending on the current platform.
@@ -45,6 +49,8 @@ bool GetAbortLocation(llvm::Triple::OSType os, SymbolLocation &location) {
4549
location.symbols.push_back(ConstString("raise"));
4650
location.symbols.push_back(ConstString("__GI_raise"));
4751
location.symbols.push_back(ConstString("gsignal"));
52+
location.symbols.push_back(ConstString("pthread_kill"));
53+
location.symbols_are_regex = true;
4854
break;
4955
default:
5056
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_UNWIND));
@@ -93,9 +99,33 @@ void RegisterAssertFrameRecognizer(Process *process) {
9399
if (!GetAbortLocation(os, location))
94100
return;
95101

102+
if (!location.symbols_are_regex) {
103+
target.GetFrameRecognizerManager().AddRecognizer(
104+
std::make_shared<AssertFrameRecognizer>(),
105+
location.module_spec.GetFilename(), location.symbols,
106+
/*first_instruction_only*/ false);
107+
return;
108+
}
109+
std::string module_re = "^";
110+
for (char c : location.module_spec.GetFilename().GetStringRef()) {
111+
if (c == '.')
112+
module_re += '\\';
113+
module_re += c;
114+
}
115+
module_re += '$';
116+
std::string symbol_re = "^(";
117+
for (auto it = location.symbols.cbegin(); it != location.symbols.cend();
118+
++it) {
119+
if (it != location.symbols.cbegin())
120+
symbol_re += '|';
121+
symbol_re += it->GetStringRef();
122+
}
123+
// Strip the trailing @VER symbol version.
124+
symbol_re += ")(@.*)?$";
96125
target.GetFrameRecognizerManager().AddRecognizer(
97-
StackFrameRecognizerSP(new AssertFrameRecognizer()),
98-
location.module_spec.GetFilename(), location.symbols,
126+
std::make_shared<AssertFrameRecognizer>(),
127+
std::make_shared<RegularExpression>(std::move(module_re)),
128+
std::make_shared<RegularExpression>(std::move(symbol_re)),
99129
/*first_instruction_only*/ false);
100130
}
101131

@@ -112,7 +142,7 @@ AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
112142
if (!GetAssertLocation(os, location))
113143
return RecognizedStackFrameSP();
114144

115-
const uint32_t frames_to_fetch = 5;
145+
const uint32_t frames_to_fetch = 6;
116146
const uint32_t last_frame_index = frames_to_fetch - 1;
117147
StackFrameSP prev_frame_sp = nullptr;
118148

0 commit comments

Comments
 (0)