diff --git a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp index e03fa63624f..71f17bbb06d 100644 --- a/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/BacktraceModel.cpp @@ -39,22 +39,26 @@ Vector BacktraceModel::create_backtrace(Debug::Proces size_t frame_index = 0; do { auto lib = inspector.library_at(current_program_counter); - if (!lib) - continue; - // After the first frame, current_instruction holds the return address from the function call. - // We need to go back to the 'call' instruction to get accurate source position information. - if (frame_index > 0) - --current_program_counter; - ByteString name = lib->debug_info->elf().symbolicate(current_program_counter - lib->base_address); - if (name.is_empty()) { - dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_program_counter, lib->name); - name = ""; + if (lib) { + // After the first frame, current_instruction holds the return address from the function call. + // We need to go back to the 'call' instruction to get accurate source position information. + if (frame_index > 0) + --current_program_counter; + ByteString name = lib->debug_info->elf().symbolicate(current_program_counter - lib->base_address); + if (name.is_empty()) { + dbgln("BacktraceModel: couldn't find containing function for address: {:p} (library={})", current_program_counter, lib->name); + name = ""; + } + + auto source_position = lib->debug_info->get_source_position(current_program_counter - lib->base_address); + + frames.append({ name, current_program_counter, current_frame_pointer, source_position }); + } else { + dbgln("BacktraceModel: couldn't find containing library for address: {:p}", current_program_counter); + frames.append({ "", current_program_counter, current_frame_pointer, {} }); } - auto source_position = lib->debug_info->get_source_position(current_program_counter - lib->base_address); - - frames.append({ name, current_program_counter, current_frame_pointer, source_position }); auto frame_info = Debug::StackFrameUtils::get_info(inspector, current_frame_pointer); VERIFY(frame_info.has_value()); current_program_counter = frame_info.value().return_address;