@@ -16,41 +16,22 @@ using namespace lldb;
16
16
using namespace lldb_private ;
17
17
18
18
namespace lldb_private {
19
- // / Checkes if the module containing a symbol has debug info.
20
- // /
21
- // / \param[in] target
22
- // / The target containing the module.
23
- // / \param[in] module_spec
24
- // / The module spec that should contain the symbol.
25
- // / \param[in] symbol_name
26
- // / The symbol's name that should be contained in the debug info.
27
- // / \return
28
- // / If \b true the symbol was found, \b false otherwise.
29
- bool ModuleHasDebugInfo (Target &target, FileSpec &module_spec,
30
- StringRef symbol_name) {
31
- ModuleSP module_sp = target.GetImages ().FindFirstModule (module_spec);
32
-
33
- if (!module_sp)
34
- return false ;
35
-
36
- return module_sp->FindFirstSymbolWithNameAndType (ConstString (symbol_name));
37
- }
38
-
39
19
// / Fetches the abort frame location depending on the current platform.
40
20
// /
41
21
// / \param[in] process_sp
42
22
// / The process that is currently aborting. This will give us information on
43
23
// / the target and the platform.
44
24
// / \return
45
25
// / If the platform is supported, returns an optional tuple containing
46
- // / the abort module as a \a FileSpec and the symbol name as a \a StringRef.
26
+ // / the abort module as a \a FileSpec and two symbol names as two \a
27
+ // / StringRef. The second \a StringRef may be empty.
47
28
// / Otherwise, returns \a llvm::None.
48
- llvm::Optional<std::tuple<FileSpec, StringRef>>
29
+ llvm::Optional<std::tuple<FileSpec, StringRef, StringRef >>
49
30
GetAbortLocation (Process *process) {
50
31
Target &target = process->GetTarget ();
51
32
52
33
FileSpec module_spec;
53
- StringRef symbol_name;
34
+ StringRef symbol_name, alternate_symbol_name ;
54
35
55
36
switch (target.GetArchitecture ().GetTriple ().getOS ()) {
56
37
case llvm::Triple::Darwin:
@@ -60,17 +41,16 @@ GetAbortLocation(Process *process) {
60
41
break ;
61
42
case llvm::Triple::Linux:
62
43
module_spec = FileSpec (" libc.so.6" );
63
- symbol_name = " __GI_raise" ;
64
- if (!ModuleHasDebugInfo (target, module_spec, symbol_name))
65
- symbol_name = " raise" ;
44
+ symbol_name = " raise" ;
45
+ alternate_symbol_name = " __GI_raise" ;
66
46
break ;
67
47
default :
68
48
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
69
49
LLDB_LOG (log, " AssertFrameRecognizer::GetAbortLocation Unsupported OS" );
70
50
return llvm::None;
71
51
}
72
52
73
- return std::make_tuple (module_spec, symbol_name);
53
+ return std::make_tuple (module_spec, symbol_name, alternate_symbol_name );
74
54
}
75
55
76
56
// / Fetches the assert frame location depending on the current platform.
@@ -80,15 +60,15 @@ GetAbortLocation(Process *process) {
80
60
// / the target and the platform.
81
61
// / \return
82
62
// / If the platform is supported, returns an optional tuple containing
83
- // / the asserting frame module as a \a FileSpec and the symbol name as a \a
84
- // / StringRef.
63
+ // / the asserting frame module as a \a FileSpec and two possible symbol
64
+ // / names as two \a StringRef. The second \a StringRef may be empty .
85
65
// / Otherwise, returns \a llvm::None.
86
- llvm::Optional<std::tuple<FileSpec, StringRef>>
66
+ llvm::Optional<std::tuple<FileSpec, StringRef, StringRef >>
87
67
GetAssertLocation (Process *process) {
88
68
Target &target = process->GetTarget ();
89
69
90
70
FileSpec module_spec;
91
- StringRef symbol_name;
71
+ StringRef symbol_name, alternate_symbol_name ;
92
72
93
73
switch (target.GetArchitecture ().GetTriple ().getOS ()) {
94
74
case llvm::Triple::Darwin:
@@ -98,17 +78,16 @@ GetAssertLocation(Process *process) {
98
78
break ;
99
79
case llvm::Triple::Linux:
100
80
module_spec = FileSpec (" libc.so.6" );
101
- symbol_name = " __GI___assert_fail" ;
102
- if (!ModuleHasDebugInfo (target, module_spec, symbol_name))
103
- symbol_name = " __assert_fail" ;
81
+ symbol_name = " __assert_fail" ;
82
+ alternate_symbol_name = " __GI___assert_fail" ;
104
83
break ;
105
84
default :
106
85
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
107
86
LLDB_LOG (log, " AssertFrameRecognizer::GetAssertLocation Unsupported OS" );
108
87
return llvm::None;
109
88
}
110
89
111
- return std::make_tuple (module_spec, symbol_name);
90
+ return std::make_tuple (module_spec, symbol_name, alternate_symbol_name );
112
91
}
113
92
114
93
void RegisterAssertFrameRecognizer (Process *process) {
@@ -120,12 +99,14 @@ void RegisterAssertFrameRecognizer(Process *process) {
120
99
return ;
121
100
122
101
FileSpec module_spec;
123
- StringRef function_name;
124
- std::tie (module_spec, function_name) = *abort_location;
102
+ StringRef function_name, alternate_function_name;
103
+ std::tie (module_spec, function_name, alternate_function_name) =
104
+ *abort_location;
125
105
126
106
StackFrameRecognizerManager::AddRecognizer (
127
107
StackFrameRecognizerSP (new AssertFrameRecognizer ()),
128
- module_spec.GetFilename (), ConstString (function_name), false );
108
+ module_spec.GetFilename (), ConstString (function_name),
109
+ ConstString (alternate_function_name), /* first_instruction_only*/ false );
129
110
});
130
111
}
131
112
@@ -142,8 +123,9 @@ AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
142
123
return RecognizedStackFrameSP ();
143
124
144
125
FileSpec module_spec;
145
- StringRef function_name;
146
- std::tie (module_spec, function_name) = *assert_location;
126
+ StringRef function_name, alternate_function_name;
127
+ std::tie (module_spec, function_name, alternate_function_name) =
128
+ *assert_location;
147
129
148
130
const uint32_t frames_to_fetch = 5 ;
149
131
const uint32_t last_frame_index = frames_to_fetch - 1 ;
@@ -163,8 +145,13 @@ AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
163
145
SymbolContext sym_ctx =
164
146
prev_frame_sp->GetSymbolContext (eSymbolContextEverything);
165
147
166
- if (sym_ctx.module_sp ->GetFileSpec ().FileEquals (module_spec) &&
167
- sym_ctx.GetFunctionName () == ConstString (function_name)) {
148
+ if (!sym_ctx.module_sp ->GetFileSpec ().FileEquals (module_spec))
149
+ continue ;
150
+
151
+ ConstString func_name = sym_ctx.GetFunctionName ();
152
+ if (func_name == ConstString (function_name) ||
153
+ alternate_function_name.empty () ||
154
+ func_name == ConstString (alternate_function_name)) {
168
155
169
156
// We go a frame beyond the assert location because the most relevant
170
157
// frame for the user is the one in which the assert function was called.
0 commit comments