aboutsummaryrefslogtreecommitdiff
path: root/src/debugger/types.h
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-08-27 14:17:34 +0200
committerhachem <im@hachem.wtf>2026-08-27 14:17:34 +0200
commit705e3914e4e820c3ac92892c32c93479691a09e7 (patch)
treebad8932559620328da060ea45245fcabec2332f2 /src/debugger/types.h
parent90398614bcc9e1c1bde7a0f65a0db66173a1d8b4 (diff)
add: debugger interface
Diffstat (limited to 'src/debugger/types.h')
-rw-r--r--src/debugger/types.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/debugger/types.h b/src/debugger/types.h
new file mode 100644
index 0000000..2f9a698
--- /dev/null
+++ b/src/debugger/types.h
@@ -0,0 +1,120 @@
+#pragma once
+
+#include <cstdint>
+#include <filesystem>
+#include <string>
+#include <string_view>
+#include <vector>
+
+namespace Hsdbg
+{
+ enum class TargetState : uint8_t
+ {
+ NoTarget,
+ Loaded,
+ Launching,
+ Running,
+ Stopped,
+ Exited,
+ Crashed,
+ };
+
+ enum class StopReason : uint8_t
+ {
+ None,
+ Breakpoint,
+ Step,
+ Signal,
+ Exception,
+ Watchpoint,
+ };
+
+ enum class StepMode : uint8_t
+ {
+ Line,
+ Instruction,
+ };
+
+ constexpr auto to_string(TargetState state) -> std::string_view
+ {
+ switch (state)
+ {
+ case TargetState::NoTarget: return "no target";
+ case TargetState::Loaded: return "loaded";
+ case TargetState::Launching: return "launching";
+ case TargetState::Running: return "running";
+ case TargetState::Stopped: return "stopped";
+ case TargetState::Exited: return "exited";
+ case TargetState::Crashed: return "crashed";
+ }
+
+ return "unknown";
+ }
+
+ constexpr auto to_string(StopReason reason) -> std::string_view
+ {
+ switch (reason)
+ {
+ case StopReason::None: return "none";
+ case StopReason::Breakpoint: return "breakpoint";
+ case StopReason::Step: return "step";
+ case StopReason::Signal: return "signal";
+ case StopReason::Exception: return "exception";
+ case StopReason::Watchpoint: return "watchpoint";
+ }
+
+ return "unknown";
+ }
+
+ struct LaunchSpec
+ {
+ std::filesystem::path executable;
+ std::filesystem::path working_directory;
+ std::vector<std::string> arguments;
+ std::vector<std::string> environment;
+ bool stop_at_entry = true;
+ };
+
+ struct Breakpoint
+ {
+ uint32_t id = 0;
+ std::filesystem::path file;
+ uint32_t line = 0;
+ std::string function;
+ uint64_t address = 0;
+ std::string condition;
+ uint32_t hit_count = 0;
+ bool enabled = true;
+ bool resolved = false;
+ };
+
+ struct StackFrame
+ {
+ uint32_t index = 0;
+ uint64_t program_counter = 0;
+ std::string function;
+ std::filesystem::path file;
+ uint32_t line = 0;
+ };
+
+ struct Thread
+ {
+ uint64_t id = 0;
+ std::string name;
+ StopReason stop_reason = StopReason::None;
+ };
+
+ struct Variable
+ {
+ std::string name;
+ std::string type;
+ std::string value;
+ std::vector<Variable> children;
+ };
+
+ struct Register
+ {
+ std::string name;
+ uint64_t value = 0;
+ };
+}