summaryrefslogtreecommitdiff
path: root/Userland/DevTools/HackStudio/Debugger
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2022-01-27 04:46:27 +0330
committerLinus Groh <mail@linusgroh.de>2022-01-28 22:51:27 +0000
commit6d64b13a1baa8713a28b095ab860699c55fe4e67 (patch)
tree5f8bc67d4a7286128fc27891480973fe8a771c8c /Userland/DevTools/HackStudio/Debugger
parentb27b22a68c095daaa2a7f32a4b6cac3659cbb10e (diff)
downloadserenity-6d64b13a1baa8713a28b095ab860699c55fe4e67.zip
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.
Diffstat (limited to 'Userland/DevTools/HackStudio/Debugger')
-rw-r--r--Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Debugger/Debugger.cpp14
-rw-r--r--Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp8
-rw-r--r--Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp2
-rw-r--r--Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp10
5 files changed, 18 insertions, 18 deletions
diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp
index df2946f6f8..997b8a91b2 100644
--- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp
@@ -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);
diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
index b2464e8e54..9a02d5962a 100644
--- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp
@@ -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);
}
diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp
index aad5c923bf..1da1b2e73a 100644
--- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp
@@ -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);
}
diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp
index 5e5e59e902..afe0abdd1e 100644
--- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp
@@ -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;
}
diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
index 7cbc3d5de8..02f57c81d6 100644
--- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
+++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp
@@ -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;
}