mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
LibDebug+Everywhere: Avoid void* -> FlatPtr -> void* dance
And limit the `void*` to the functions that interface the system (i.e. ptrace wrappers). This generally makes the code less riddled with casts.
This commit is contained in:
parent
b27b22a68c
commit
6d64b13a1b
15 changed files with 97 additions and 96 deletions
|
@ -113,7 +113,7 @@ RefPtr<GUI::Menu> DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode
|
|||
}));
|
||||
}
|
||||
|
||||
auto variable_address = (FlatPtr*)variable->location_data.address;
|
||||
auto variable_address = variable->location_data.address;
|
||||
if (Debugger::the().session()->watchpoint_exists(variable_address)) {
|
||||
context_menu->add_action(GUI::Action::create("Remove watchpoint", [variable_address](auto&) {
|
||||
Debugger::the().session()->remove_watchpoint(variable_address);
|
||||
|
|
|
@ -69,10 +69,10 @@ void Debugger::on_breakpoint_change(const String& file, size_t line, BreakpointC
|
|||
}
|
||||
|
||||
if (change_type == BreakpointChange::Added) {
|
||||
bool success = session->insert_breakpoint(reinterpret_cast<void*>(address.value().address));
|
||||
bool success = session->insert_breakpoint(address.value().address);
|
||||
VERIFY(success);
|
||||
} else {
|
||||
bool success = session->remove_breakpoint(reinterpret_cast<void*>(address.value().address));
|
||||
bool success = session->remove_breakpoint(address.value().address);
|
||||
VERIFY(success);
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ void Debugger::start()
|
|||
dbgln("inserting breakpoint at: {}:{}", breakpoint.file_path, breakpoint.line_number);
|
||||
auto address = m_debug_session->get_address_from_source_position(breakpoint.file_path, breakpoint.line_number);
|
||||
if (address.has_value()) {
|
||||
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address.value().address));
|
||||
bool success = m_debug_session->insert_breakpoint(address.value().address);
|
||||
VERIFY(success);
|
||||
} else {
|
||||
dbgln("couldn't insert breakpoint");
|
||||
|
@ -227,8 +227,8 @@ bool Debugger::DebuggingState::should_stop_single_stepping(const Debug::DebugInf
|
|||
void Debugger::remove_temporary_breakpoints()
|
||||
{
|
||||
for (auto breakpoint_address : m_state.temporary_breakpoints()) {
|
||||
VERIFY(m_debug_session->breakpoint_exists((void*)breakpoint_address));
|
||||
bool rc = m_debug_session->remove_breakpoint((void*)breakpoint_address);
|
||||
VERIFY(m_debug_session->breakpoint_exists(breakpoint_address));
|
||||
bool rc = m_debug_session->remove_breakpoint(breakpoint_address);
|
||||
VERIFY(rc);
|
||||
}
|
||||
m_state.clear_temporary_breakpoints();
|
||||
|
@ -281,9 +281,9 @@ void Debugger::insert_temporary_breakpoint_at_return_address(const PtraceRegiste
|
|||
|
||||
void Debugger::insert_temporary_breakpoint(FlatPtr address)
|
||||
{
|
||||
if (m_debug_session->breakpoint_exists((void*)address))
|
||||
if (m_debug_session->breakpoint_exists(address))
|
||||
return;
|
||||
bool success = m_debug_session->insert_breakpoint(reinterpret_cast<void*>(address));
|
||||
bool success = m_debug_session->insert_breakpoint(address);
|
||||
VERIFY(success);
|
||||
m_state.add_temporary_breakpoint(address);
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ JS::ThrowCompletionOr<bool> DebuggerGlobalJSObject::internal_set(JS::PropertyKey
|
|||
auto& target_variable = **it;
|
||||
auto debugger_value = js_to_debugger(value, target_variable);
|
||||
if (debugger_value.has_value())
|
||||
return Debugger::the().session()->poke((u32*)target_variable.location_data.address, debugger_value.value());
|
||||
return Debugger::the().session()->poke(target_variable.location_data.address, debugger_value.value());
|
||||
auto error_string = String::formatted("Cannot convert JS value {} to variable {} of type {}", value.to_string_without_side_effects(), property_name.as_string(), target_variable.type_name);
|
||||
return vm().throw_completion<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), move(error_string));
|
||||
}
|
||||
|
@ -66,19 +66,19 @@ Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInf
|
|||
auto variable_address = variable.location_data.address;
|
||||
|
||||
if (variable.is_enum_type() || variable.type_name == "int") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return JS::Value((i32)value.value());
|
||||
}
|
||||
|
||||
if (variable.type_name == "char") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return JS::Value((char)value.value());
|
||||
}
|
||||
|
||||
if (variable.type_name == "bool") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return JS::Value(value.value() != 0);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ JS::ThrowCompletionOr<bool> DebuggerVariableJSObject::internal_set(const JS::Pro
|
|||
if (!new_value.has_value())
|
||||
return vm.throw_completion<JS::TypeError>(global_object(), String::formatted("Cannot convert JS value {} to variable {} of type {}", value.to_string_without_side_effects(), name, member.type_name));
|
||||
|
||||
Debugger::the().session()->poke((u32*)member.location_data.address, new_value.value());
|
||||
Debugger::the().session()->poke(member.location_data.address, new_value.value());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
|
|||
auto variable_address = variable.location_data.address;
|
||||
|
||||
if (variable.is_enum_type()) {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
auto it = variable.type->members.find_if([&enumerator_value = value.value()](const auto& enumerator) {
|
||||
return enumerator->constant_data.as_u32 == enumerator_value;
|
||||
|
@ -74,19 +74,19 @@ static String variable_value_as_string(const Debug::DebugInfo::VariableInfo& var
|
|||
}
|
||||
|
||||
if (variable.type_name == "int") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return String::formatted("{}", static_cast<int>(value.value()));
|
||||
}
|
||||
|
||||
if (variable.type_name == "char") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return String::formatted("'{0:c}'", (char)value.value());
|
||||
}
|
||||
|
||||
if (variable.type_name == "bool") {
|
||||
auto value = Debugger::the().session()->peek((u32*)variable_address);
|
||||
auto value = Debugger::the().session()->peek(variable_address);
|
||||
VERIFY(value.has_value());
|
||||
return (value.value() & 1) ? "true" : "false";
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView
|
|||
auto value = string_to_variable_value(string_value, *variable);
|
||||
|
||||
if (value.has_value()) {
|
||||
auto success = Debugger::the().session()->poke((u32*)variable->location_data.address, value.value());
|
||||
auto success = Debugger::the().session()->poke(variable->location_data.address, value.value());
|
||||
VERIFY(success);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue