mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:25:08 +00:00
HackStudio: Correctly handle invalid addresses during backtrace creation
This fixes a bug where we previously would hang if we couldn't find a library containing the current program counter.
This commit is contained in:
parent
256f0c9064
commit
6f6a2dc319
1 changed files with 17 additions and 13 deletions
|
@ -39,22 +39,26 @@ Vector<BacktraceModel::FrameInfo> 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 = "<missing>";
|
||||
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 = "<missing>";
|
||||
}
|
||||
|
||||
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({ "<missing>", 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue