summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/Debugger/main.cpp18
-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
-rw-r--r--Userland/Libraries/LibCoredump/Inspector.cpp6
-rw-r--r--Userland/Libraries/LibCoredump/Inspector.h4
-rw-r--r--Userland/Libraries/LibDebug/DebugSession.cpp58
-rw-r--r--Userland/Libraries/LibDebug/DebugSession.h49
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp2
-rw-r--r--Userland/Libraries/LibDebug/Dwarf/Expression.cpp4
-rw-r--r--Userland/Libraries/LibDebug/ProcessInspector.h4
-rw-r--r--Userland/Libraries/LibDebug/StackFrameUtils.cpp4
-rw-r--r--Userland/Utilities/functrace.cpp8
15 files changed, 97 insertions, 96 deletions
diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp
index 66da4b426e..89214b5fa3 100644
--- a/Userland/Applications/Debugger/main.cpp
+++ b/Userland/Applications/Debugger/main.cpp
@@ -48,7 +48,7 @@ static void handle_print_registers(const PtraceRegisters& regs)
#endif
}
-static bool handle_disassemble_command(const String& command, void* first_instruction)
+static bool handle_disassemble_command(const String& command, FlatPtr first_instruction)
{
auto parts = command.split(' ');
size_t number_of_instructions_to_disassemble = 5;
@@ -64,7 +64,7 @@ static bool handle_disassemble_command(const String& command, void* first_instru
constexpr size_t dump_size = 0x100;
ByteBuffer code;
for (size_t i = 0; i < dump_size / sizeof(u32); ++i) {
- auto value = g_debug_session->peek(reinterpret_cast<u32*>(first_instruction) + i);
+ auto value = g_debug_session->peek(first_instruction + i * sizeof(u32));
if (!value.has_value())
break;
if (code.try_append(&value, sizeof(u32)).is_error())
@@ -80,7 +80,7 @@ static bool handle_disassemble_command(const String& command, void* first_instru
if (!insn.has_value())
break;
- outln(" {:p} <+{}>:\t{}", offset + reinterpret_cast<size_t>(first_instruction), offset, insn.value().to_string(offset));
+ outln(" {:p} <+{}>:\t{}", offset + first_instruction, offset, insn.value().to_string(offset));
}
return true;
@@ -92,7 +92,7 @@ static bool handle_backtrace_command(const PtraceRegisters& regs)
auto ebp_val = regs.ebp;
auto eip_val = regs.eip;
outln("Backtrace:");
- while (g_debug_session->peek((u32*)eip_val).has_value() && g_debug_session->peek((u32*)ebp_val).has_value()) {
+ while (g_debug_session->peek(eip_val).has_value() && g_debug_session->peek(ebp_val).has_value()) {
auto eip_symbol = g_debug_session->symbolicate(eip_val);
auto source_position = g_debug_session->get_source_position(eip_val);
String symbol_location = (eip_symbol.has_value() && eip_symbol->symbol != "") ? eip_symbol->symbol : "???";
@@ -101,8 +101,8 @@ static bool handle_backtrace_command(const PtraceRegisters& regs)
} else {
outln("{:p} in {}", eip_val, symbol_location);
}
- auto next_eip = g_debug_session->peek((u32*)(ebp_val + 4));
- auto next_ebp = g_debug_session->peek((u32*)ebp_val);
+ auto next_eip = g_debug_session->peek(ebp_val + 4);
+ auto next_ebp = g_debug_session->peek(ebp_val);
eip_val = (u32)next_eip.value();
ebp_val = (u32)next_ebp.value();
}
@@ -115,7 +115,7 @@ static bool handle_backtrace_command(const PtraceRegisters& regs)
static bool insert_breakpoint_at_address(FlatPtr address)
{
- return g_debug_session->insert_breakpoint((void*)address);
+ return g_debug_session->insert_breakpoint(address);
}
static bool insert_breakpoint_at_source_position(const String& file, size_t line)
@@ -181,7 +181,7 @@ static bool handle_examine_command(const String& command)
return false;
}
FlatPtr address = strtoul(argument.characters() + 2, nullptr, 16);
- auto res = g_debug_session->peek((u32*)address);
+ auto res = g_debug_session->peek(address);
if (!res.has_value()) {
outln("Could not examine memory at address {:p}", address);
return true;
@@ -309,7 +309,7 @@ int main(int argc, char** argv)
success = true;
} else if (command.starts_with("dis")) {
- success = handle_disassemble_command(command, reinterpret_cast<void*>(ip));
+ success = handle_disassemble_command(command, ip);
} else if (command.starts_with("bp")) {
success = handle_breakpoint_command(command);
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;
}
diff --git a/Userland/Libraries/LibCoredump/Inspector.cpp b/Userland/Libraries/LibCoredump/Inspector.cpp
index 4eb3614332..52dd645882 100644
--- a/Userland/Libraries/LibCoredump/Inspector.cpp
+++ b/Userland/Libraries/LibCoredump/Inspector.cpp
@@ -51,11 +51,11 @@ void Inspector::parse_loaded_libraries(Function<void(float)> on_progress)
});
}
-bool Inspector::poke(void*, FlatPtr) { return false; }
+bool Inspector::poke(FlatPtr, FlatPtr) { return false; }
-Optional<FlatPtr> Inspector::peek(void* address) const
+Optional<FlatPtr> Inspector::peek(FlatPtr address) const
{
- return m_reader->peek_memory((FlatPtr)address);
+ return m_reader->peek_memory(address);
}
PtraceRegisters Inspector::get_registers() const
diff --git a/Userland/Libraries/LibCoredump/Inspector.h b/Userland/Libraries/LibCoredump/Inspector.h
index af92235707..77a21a910b 100644
--- a/Userland/Libraries/LibCoredump/Inspector.h
+++ b/Userland/Libraries/LibCoredump/Inspector.h
@@ -21,8 +21,8 @@ public:
virtual ~Inspector() override = default;
// ^Debug::ProcessInspector
- virtual bool poke(void* address, FlatPtr data) override;
- virtual Optional<FlatPtr> peek(void* address) const override;
+ virtual bool poke(FlatPtr address, FlatPtr data) override;
+ virtual Optional<FlatPtr> peek(FlatPtr address) const override;
virtual PtraceRegisters get_registers() const override;
virtual void set_registers(PtraceRegisters const&) override;
virtual void for_each_loaded_library(Function<IterationDecision(Debug::LoadedLibrary const&)>) const override;
diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp
index 7e19c8e1b7..fb93771b18 100644
--- a/Userland/Libraries/LibDebug/DebugSession.cpp
+++ b/Userland/Libraries/LibDebug/DebugSession.cpp
@@ -129,27 +129,27 @@ OwnPtr<DebugSession> DebugSession::exec_and_attach(String const& command,
return debug_session;
}
-bool DebugSession::poke(void* address, FlatPtr data)
+bool DebugSession::poke(FlatPtr address, FlatPtr data)
{
- if (ptrace(PT_POKE, m_debuggee_pid, (void*)address, (void*)data) < 0) {
+ if (ptrace(PT_POKE, m_debuggee_pid, bit_cast<void*>(address), bit_cast<void*>(data)) < 0) {
perror("PT_POKE");
return false;
}
return true;
}
-Optional<FlatPtr> DebugSession::peek(void* address) const
+Optional<FlatPtr> DebugSession::peek(FlatPtr address) const
{
Optional<FlatPtr> result;
- auto rc = ptrace(PT_PEEK, m_debuggee_pid, address, nullptr);
+ auto rc = ptrace(PT_PEEK, m_debuggee_pid, bit_cast<void*>(address), nullptr);
if (errno == 0)
result = static_cast<FlatPtr>(rc);
return result;
}
-bool DebugSession::poke_debug(u32 register_index, FlatPtr data)
+bool DebugSession::poke_debug(u32 register_index, FlatPtr data) const
{
- if (ptrace(PT_POKEDEBUG, m_debuggee_pid, reinterpret_cast<void*>(register_index), (void*)data) < 0) {
+ if (ptrace(PT_POKEDEBUG, m_debuggee_pid, bit_cast<void*>(static_cast<FlatPtr>(register_index)), bit_cast<void*>(data)) < 0) {
perror("PT_POKEDEBUG");
return false;
}
@@ -158,14 +158,14 @@ bool DebugSession::poke_debug(u32 register_index, FlatPtr data)
Optional<FlatPtr> DebugSession::peek_debug(u32 register_index) const
{
- Optional<FlatPtr> result;
- int rc = ptrace(PT_PEEKDEBUG, m_debuggee_pid, reinterpret_cast<FlatPtr*>(register_index), nullptr);
+ auto rc = ptrace(PT_PEEKDEBUG, m_debuggee_pid, bit_cast<void*>(static_cast<FlatPtr>(register_index)), nullptr);
if (errno == 0)
- result = static_cast<FlatPtr>(rc);
- return result;
+ return static_cast<FlatPtr>(rc);
+
+ return {};
}
-bool DebugSession::insert_breakpoint(void* address)
+bool DebugSession::insert_breakpoint(FlatPtr address)
{
// We insert a software breakpoint by
// patching the first byte of the instruction at 'address'
@@ -174,7 +174,7 @@ bool DebugSession::insert_breakpoint(void* address)
if (m_breakpoints.contains(address))
return false;
- auto original_bytes = peek(reinterpret_cast<FlatPtr*>(address));
+ auto original_bytes = peek(address);
if (!original_bytes.has_value())
return false;
@@ -190,11 +190,11 @@ bool DebugSession::insert_breakpoint(void* address)
return true;
}
-bool DebugSession::disable_breakpoint(void* address)
+bool DebugSession::disable_breakpoint(FlatPtr address)
{
auto breakpoint = m_breakpoints.get(address);
VERIFY(breakpoint.has_value());
- if (!poke(reinterpret_cast<FlatPtr*>(reinterpret_cast<char*>(breakpoint.value().address)), breakpoint.value().original_first_word))
+ if (!poke(breakpoint.value().address, breakpoint.value().original_first_word))
return false;
auto bp = m_breakpoints.get(breakpoint.value().address).value();
@@ -203,14 +203,14 @@ bool DebugSession::disable_breakpoint(void* address)
return true;
}
-bool DebugSession::enable_breakpoint(void* address)
+bool DebugSession::enable_breakpoint(FlatPtr address)
{
auto breakpoint = m_breakpoints.get(address);
VERIFY(breakpoint.has_value());
VERIFY(breakpoint.value().state == BreakPointState::Disabled);
- if (!poke(reinterpret_cast<FlatPtr*>(breakpoint.value().address), (breakpoint.value().original_first_word & ~(FlatPtr)0xff) | BREAKPOINT_INSTRUCTION))
+ if (!poke(breakpoint.value().address, (breakpoint.value().original_first_word & ~static_cast<FlatPtr>(0xff)) | BREAKPOINT_INSTRUCTION))
return false;
auto bp = m_breakpoints.get(breakpoint.value().address).value();
@@ -219,7 +219,7 @@ bool DebugSession::enable_breakpoint(void* address)
return true;
}
-bool DebugSession::remove_breakpoint(void* address)
+bool DebugSession::remove_breakpoint(FlatPtr address)
{
if (!disable_breakpoint(address))
return false;
@@ -228,12 +228,12 @@ bool DebugSession::remove_breakpoint(void* address)
return true;
}
-bool DebugSession::breakpoint_exists(void* address) const
+bool DebugSession::breakpoint_exists(FlatPtr address) const
{
return m_breakpoints.contains(address);
}
-bool DebugSession::insert_watchpoint(void* address, u32 ebp)
+bool DebugSession::insert_watchpoint(FlatPtr address, u32 ebp)
{
auto current_register_status = peek_debug(DEBUG_CONTROL_REGISTER);
if (!current_register_status.has_value())
@@ -250,7 +250,7 @@ bool DebugSession::insert_watchpoint(void* address, u32 ebp)
return false;
WatchPoint watchpoint { address, next_available_index, ebp };
- if (!poke_debug(next_available_index, reinterpret_cast<uintptr_t>(address)))
+ if (!poke_debug(next_available_index, bit_cast<FlatPtr>(address)))
return false;
dr7_value |= (1u << (next_available_index * 2)); // Enable local breakpoint for our index
@@ -268,14 +268,14 @@ bool DebugSession::insert_watchpoint(void* address, u32 ebp)
return true;
}
-bool DebugSession::remove_watchpoint(void* address)
+bool DebugSession::remove_watchpoint(FlatPtr address)
{
if (!disable_watchpoint(address))
return false;
return m_watchpoints.remove(address);
}
-bool DebugSession::disable_watchpoint(void* address)
+bool DebugSession::disable_watchpoint(FlatPtr address)
{
VERIFY(watchpoint_exists(address));
auto watchpoint = m_watchpoints.get(address).value();
@@ -291,7 +291,7 @@ bool DebugSession::disable_watchpoint(void* address)
return true;
}
-bool DebugSession::watchpoint_exists(void* address) const
+bool DebugSession::watchpoint_exists(FlatPtr address) const
{
return m_watchpoints.contains(address);
}
@@ -308,7 +308,7 @@ PtraceRegisters DebugSession::get_registers() const
void DebugSession::set_registers(PtraceRegisters const& regs)
{
- if (ptrace(PT_SETREGS, m_debuggee_pid, reinterpret_cast<void*>(&const_cast<PtraceRegisters&>(regs)), 0) < 0) {
+ if (ptrace(PT_SETREGS, m_debuggee_pid, bit_cast<void*>(&regs), 0) < 0) {
perror("PT_SETREGS");
VERIFY_NOT_REACHED();
}
@@ -334,7 +334,7 @@ int DebugSession::continue_debuggee_and_wait(ContinueType type)
return wstatus;
}
-void* DebugSession::single_step()
+FlatPtr DebugSession::single_step()
{
// Single stepping works by setting the x86 TRAP flag bit in the eflags register.
// This flag causes the cpu to enter single-stepping mode, which causes
@@ -365,7 +365,7 @@ void* DebugSession::single_step()
regs.rflags &= ~(TRAP_FLAG);
#endif
set_registers(regs);
- return (void*)regs.ip();
+ return regs.ip();
}
void DebugSession::detach()
@@ -390,8 +390,8 @@ Optional<DebugSession::InsertBreakpointAtSymbolResult> DebugSession::insert_brea
if (!symbol.has_value())
return IterationDecision::Continue;
- auto breakpoint_address = symbol.value().value() + lib.base_address;
- bool rc = this->insert_breakpoint(reinterpret_cast<void*>(breakpoint_address));
+ FlatPtr breakpoint_address = symbol->value() + lib.base_address;
+ bool rc = this->insert_breakpoint(breakpoint_address);
if (!rc)
return IterationDecision::Break;
@@ -408,7 +408,7 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
return {};
auto address = address_and_source_position.value().address;
- bool rc = this->insert_breakpoint(reinterpret_cast<void*>(address));
+ bool rc = this->insert_breakpoint(address);
if (!rc)
return {};
diff --git a/Userland/Libraries/LibDebug/DebugSession.h b/Userland/Libraries/LibDebug/DebugSession.h
index 6b8d5850b5..7bdf673169 100644
--- a/Userland/Libraries/LibDebug/DebugSession.h
+++ b/Userland/Libraries/LibDebug/DebugSession.h
@@ -32,15 +32,15 @@ public:
virtual ~DebugSession() override;
// ^Debug::ProcessInspector
- virtual bool poke(void* address, FlatPtr data) override;
- virtual Optional<FlatPtr> peek(void* address) const override;
+ virtual bool poke(FlatPtr address, FlatPtr data) override;
+ virtual Optional<FlatPtr> peek(FlatPtr address) const override;
virtual PtraceRegisters get_registers() const override;
virtual void set_registers(PtraceRegisters const&) override;
virtual void for_each_loaded_library(Function<IterationDecision(LoadedLibrary const&)>) const override;
int pid() const { return m_debuggee_pid; }
- bool poke_debug(u32 register_index, FlatPtr data);
+ bool poke_debug(u32 register_index, FlatPtr data) const;
Optional<FlatPtr> peek_debug(u32 register_index) const;
enum class BreakPointState {
@@ -49,7 +49,7 @@ public:
};
struct BreakPoint {
- void* address { nullptr };
+ FlatPtr address { 0 };
FlatPtr original_first_word { 0 };
BreakPointState state { BreakPointState::Disabled };
};
@@ -70,22 +70,22 @@ public:
Optional<InsertBreakpointAtSourcePositionResult> insert_breakpoint(String const& filename, size_t line_number);
- bool insert_breakpoint(void* address);
- bool disable_breakpoint(void* address);
- bool enable_breakpoint(void* address);
- bool remove_breakpoint(void* address);
- bool breakpoint_exists(void* address) const;
+ bool insert_breakpoint(FlatPtr address);
+ bool disable_breakpoint(FlatPtr address);
+ bool enable_breakpoint(FlatPtr address);
+ bool remove_breakpoint(FlatPtr address);
+ bool breakpoint_exists(FlatPtr address) const;
struct WatchPoint {
- void* address { nullptr };
+ FlatPtr address { 0 };
u32 debug_register_index { 0 };
u32 ebp { 0 };
};
- bool insert_watchpoint(void* address, u32 ebp);
- bool remove_watchpoint(void* address);
- bool disable_watchpoint(void* address);
- bool watchpoint_exists(void* address) const;
+ bool insert_watchpoint(FlatPtr address, u32 ebp);
+ bool remove_watchpoint(FlatPtr address);
+ bool disable_watchpoint(FlatPtr address);
+ bool watchpoint_exists(FlatPtr address) const;
void dump_breakpoints()
{
@@ -104,7 +104,7 @@ public:
int continue_debuggee_and_wait(ContinueType type = ContinueType::FreeRun);
// Returns the new eip
- void* single_step();
+ FlatPtr single_step();
void detach();
@@ -141,8 +141,8 @@ private:
String m_source_root;
bool m_is_debuggee_dead { false };
- HashMap<void*, BreakPoint> m_breakpoints;
- HashMap<void*, WatchPoint> m_watchpoints;
+ HashMap<FlatPtr, BreakPoint> m_breakpoints;
+ HashMap<FlatPtr, WatchPoint> m_watchpoints;
// Maps from library name to LoadedLibrary object
HashMap<String, NonnullOwnPtr<LoadedLibrary>> m_loaded_libraries;
@@ -216,8 +216,8 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
found_ebp = true;
break;
}
- auto return_address = peek(reinterpret_cast<u32*>(current_ebp + sizeof(FlatPtr)));
- auto next_ebp = peek(reinterpret_cast<u32*>(current_ebp));
+ auto return_address = peek(current_ebp + sizeof(FlatPtr));
+ auto next_ebp = peek(current_ebp);
VERIFY(return_address.has_value());
VERIFY(next_ebp.has_value());
current_instruction = return_address.value();
@@ -235,11 +235,11 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
Optional<BreakPoint> current_breakpoint;
if (state == State::FreeRun || state == State::Syscall) {
- current_breakpoint = m_breakpoints.get((void*)((uintptr_t)current_instruction - 1));
+ current_breakpoint = m_breakpoints.get(current_instruction - 1);
if (current_breakpoint.has_value())
state = State::FreeRun;
} else {
- current_breakpoint = m_breakpoints.get((void*)current_instruction);
+ current_breakpoint = m_breakpoints.get(current_instruction);
}
if (current_breakpoint.has_value()) {
@@ -250,7 +250,7 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
// because the cpu has just executed the INT3 we patched into the instruction.
// 2. We restore the original first byte of the instruction,
// because it was patched with INT3.
- auto breakpoint_addr = reinterpret_cast<uintptr_t>(current_breakpoint.value().address);
+ auto breakpoint_addr = bit_cast<FlatPtr>(current_breakpoint.value().address);
#if ARCH(I386)
regs.eip = breakpoint_addr;
#else
@@ -278,8 +278,9 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
bool did_single_step = false;
+ auto current_breakpoint_address = bit_cast<FlatPtr>(current_breakpoint.value().address);
// Re-enable the breakpoint if it wasn't removed by the user
- if (current_breakpoint.has_value() && m_breakpoints.contains(current_breakpoint.value().address)) {
+ if (current_breakpoint.has_value() && m_breakpoints.contains(current_breakpoint_address)) {
// The current breakpoint was removed to make it transparent to the user.
// We now want to re-enable it - the code execution flow could hit it again.
// To re-enable the breakpoint, we first perform a single step and execute the
@@ -288,7 +289,7 @@ void DebugSession::run(DesiredInitialDebugeeState initial_debugee_state, Callbac
// If the user manually inserted a breakpoint at the current instruction,
// we need to disable that breakpoint because we want to singlestep over that
// instruction (we re-enable it again later anyways).
- if (m_breakpoints.contains(current_breakpoint.value().address) && m_breakpoints.get(current_breakpoint.value().address).value().state == BreakPointState::Enabled) {
+ if (m_breakpoints.contains(current_breakpoint_address) && m_breakpoints.get(current_breakpoint_address).value().state == BreakPointState::Enabled) {
disable_breakpoint(current_breakpoint.value().address);
}
auto stopped_address = single_step();
diff --git a/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp b/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
index 983d5f5b27..01c3505d0d 100644
--- a/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/AbbreviationsMap.cpp
@@ -62,7 +62,7 @@ void AbbreviationsMap::populate_map()
}
} while (current_attribute_specification.attribute != Attribute::None || current_attribute_specification.form != AttributeDataForm::None);
- m_entries.set((u32)abbreviation_code, move(abbreviation_entry));
+ m_entries.set(static_cast<u32>(abbreviation_code), move(abbreviation_entry));
}
}
diff --git a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
index 14b8bfb8fa..6d6a5af72c 100644
--- a/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
+++ b/Userland/Libraries/LibDebug/Dwarf/Expression.cpp
@@ -36,8 +36,8 @@ Value evaluate(ReadonlyBytes bytes, [[maybe_unused]] PtraceRegisters const& regs
#endif
default:
- dbgln("DWARF expr addr: {}", (const void*)bytes.data());
- dbgln("unsupported opcode: {}", (u8)opcode);
+ dbgln("DWARF expr addr: {:p}", bytes.data());
+ dbgln("unsupported opcode: {}", opcode);
VERIFY_NOT_REACHED();
}
}
diff --git a/Userland/Libraries/LibDebug/ProcessInspector.h b/Userland/Libraries/LibDebug/ProcessInspector.h
index fd7731e9d8..c1404a1afe 100644
--- a/Userland/Libraries/LibDebug/ProcessInspector.h
+++ b/Userland/Libraries/LibDebug/ProcessInspector.h
@@ -15,8 +15,8 @@ namespace Debug {
class ProcessInspector {
public:
virtual ~ProcessInspector() { }
- virtual bool poke(void* address, FlatPtr data) = 0;
- virtual Optional<FlatPtr> peek(void* address) const = 0;
+ virtual bool poke(FlatPtr address, FlatPtr data) = 0;
+ virtual Optional<FlatPtr> peek(FlatPtr address) const = 0;
virtual PtraceRegisters get_registers() const = 0;
virtual void set_registers(PtraceRegisters const&) = 0;
virtual void for_each_loaded_library(Function<IterationDecision(LoadedLibrary const&)>) const = 0;
diff --git a/Userland/Libraries/LibDebug/StackFrameUtils.cpp b/Userland/Libraries/LibDebug/StackFrameUtils.cpp
index e5cccff5ab..8f5ccf4c26 100644
--- a/Userland/Libraries/LibDebug/StackFrameUtils.cpp
+++ b/Userland/Libraries/LibDebug/StackFrameUtils.cpp
@@ -10,8 +10,8 @@ namespace Debug::StackFrameUtils {
Optional<StackFrameInfo> get_info(ProcessInspector const& inspector, FlatPtr current_ebp)
{
- auto return_address = inspector.peek(reinterpret_cast<u32*>(current_ebp + sizeof(FlatPtr)));
- auto next_ebp = inspector.peek(reinterpret_cast<u32*>(current_ebp));
+ auto return_address = inspector.peek(current_ebp + sizeof(FlatPtr));
+ auto next_ebp = inspector.peek(current_ebp);
if (!return_address.has_value() || !next_ebp.has_value())
return {};
diff --git a/Userland/Utilities/functrace.cpp b/Userland/Utilities/functrace.cpp
index 25e02a7ddc..f082b866ad 100644
--- a/Userland/Utilities/functrace.cpp
+++ b/Userland/Utilities/functrace.cpp
@@ -68,9 +68,9 @@ static void print_syscall(PtraceRegisters& regs, size_t depth)
#endif
}
-static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
+static NonnullOwnPtr<HashMap<FlatPtr, X86::Instruction>> instrument_code()
{
- auto instrumented = make<HashMap<void*, X86::Instruction>>();
+ auto instrumented = make<HashMap<FlatPtr, X86::Instruction>>();
g_debug_session->for_each_loaded_library([&](const Debug::LoadedLibrary& lib) {
lib.debug_info->elf().for_each_section_of_type(SHT_PROGBITS, [&](const ELF::Image::Section& section) {
if (section.name() != ".text")
@@ -80,7 +80,7 @@ static NonnullOwnPtr<HashMap<void*, X86::Instruction>> instrument_code()
X86::Disassembler disassembler(stream);
for (;;) {
auto offset = stream.offset();
- void* instruction_address = (void*)(section.address() + offset + lib.base_address);
+ auto instruction_address = section.address() + offset + lib.base_address;
auto insn = disassembler.next();
if (!insn.has_value())
break;
@@ -150,7 +150,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
new_function = false;
return Debug::DebugSession::ContinueBreakAtSyscall;
}
- auto instruction = instrumented->get((void*)ip).value();
+ auto instruction = instrumented->get(ip).value();
if (instruction.mnemonic() == "RET") {
if (depth != 0)