@@ -16,41 +16,22 @@ using namespace lldb;
1616using namespace lldb_private ;
1717
1818namespace 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-
3919// / Fetches the abort frame location depending on the current platform.
4020// /
4121// / \param[in] process_sp
4222// / The process that is currently aborting. This will give us information on
4323// / the target and the platform.
4424// / \return
4525// / 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.
4728// / Otherwise, returns \a llvm::None.
48- llvm::Optional<std::tuple<FileSpec, StringRef>>
29+ llvm::Optional<std::tuple<FileSpec, StringRef, StringRef >>
4930GetAbortLocation (Process *process) {
5031 Target &target = process->GetTarget ();
5132
5233 FileSpec module_spec;
53- StringRef symbol_name;
34+ StringRef symbol_name, alternate_symbol_name ;
5435
5536 switch (target.GetArchitecture ().GetTriple ().getOS ()) {
5637 case llvm::Triple::Darwin:
@@ -60,17 +41,16 @@ GetAbortLocation(Process *process) {
6041 break ;
6142 case llvm::Triple::Linux:
6243 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" ;
6646 break ;
6747 default :
6848 Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
6949 LLDB_LOG (log, " AssertFrameRecognizer::GetAbortLocation Unsupported OS" );
7050 return llvm::None;
7151 }
7252
73- return std::make_tuple (module_spec, symbol_name);
53+ return std::make_tuple (module_spec, symbol_name, alternate_symbol_name );
7454}
7555
7656// / Fetches the assert frame location depending on the current platform.
@@ -80,15 +60,15 @@ GetAbortLocation(Process *process) {
8060// / the target and the platform.
8161// / \return
8262// / 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 .
8565// / Otherwise, returns \a llvm::None.
86- llvm::Optional<std::tuple<FileSpec, StringRef>>
66+ llvm::Optional<std::tuple<FileSpec, StringRef, StringRef >>
8767GetAssertLocation (Process *process) {
8868 Target &target = process->GetTarget ();
8969
9070 FileSpec module_spec;
91- StringRef symbol_name;
71+ StringRef symbol_name, alternate_symbol_name ;
9272
9373 switch (target.GetArchitecture ().GetTriple ().getOS ()) {
9474 case llvm::Triple::Darwin:
@@ -98,17 +78,16 @@ GetAssertLocation(Process *process) {
9878 break ;
9979 case llvm::Triple::Linux:
10080 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" ;
10483 break ;
10584 default :
10685 Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND));
10786 LLDB_LOG (log, " AssertFrameRecognizer::GetAssertLocation Unsupported OS" );
10887 return llvm::None;
10988 }
11089
111- return std::make_tuple (module_spec, symbol_name);
90+ return std::make_tuple (module_spec, symbol_name, alternate_symbol_name );
11291}
11392
11493void RegisterAssertFrameRecognizer (Process *process) {
@@ -120,12 +99,14 @@ void RegisterAssertFrameRecognizer(Process *process) {
12099 return ;
121100
122101 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;
125105
126106 StackFrameRecognizerManager::AddRecognizer (
127107 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 );
129110 });
130111}
131112
@@ -142,8 +123,9 @@ AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
142123 return RecognizedStackFrameSP ();
143124
144125 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;
147129
148130 const uint32_t frames_to_fetch = 5 ;
149131 const uint32_t last_frame_index = frames_to_fetch - 1 ;
@@ -163,8 +145,13 @@ AssertFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
163145 SymbolContext sym_ctx =
164146 prev_frame_sp->GetSymbolContext (eSymbolContextEverything);
165147
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)) {
168155
169156 // We go a frame beyond the assert location because the most relevant
170157 // frame for the user is the one in which the assert function was called.
0 commit comments