mirror of
https://github.com/RGBCube/serenity
synced 2025-05-21 20:35:06 +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,9 +39,8 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(Debug::Proces
|
||||||
size_t frame_index = 0;
|
size_t frame_index = 0;
|
||||||
do {
|
do {
|
||||||
auto lib = inspector.library_at(current_program_counter);
|
auto lib = inspector.library_at(current_program_counter);
|
||||||
if (!lib)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
|
if (lib) {
|
||||||
// After the first frame, current_instruction holds the return address from the function call.
|
// 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.
|
// We need to go back to the 'call' instruction to get accurate source position information.
|
||||||
if (frame_index > 0)
|
if (frame_index > 0)
|
||||||
|
@ -55,6 +54,11 @@ Vector<BacktraceModel::FrameInfo> BacktraceModel::create_backtrace(Debug::Proces
|
||||||
auto source_position = lib->debug_info->get_source_position(current_program_counter - lib->base_address);
|
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 });
|
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 frame_info = Debug::StackFrameUtils::get_info(inspector, current_frame_pointer);
|
auto frame_info = Debug::StackFrameUtils::get_info(inspector, current_frame_pointer);
|
||||||
VERIFY(frame_info.has_value());
|
VERIFY(frame_info.has_value());
|
||||||
current_program_counter = frame_info.value().return_address;
|
current_program_counter = frame_info.value().return_address;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue