summaryrefslogtreecommitdiffhomepage
path: root/dev/LibDebugger/src/POSIX.cc
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 11:10:06 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 11:10:46 +0100
commitf4a3ae900294759eb79307137a1efa9e2fbe2a10 (patch)
tree8bba5e42b01ab6f79d2ae849dfc66716d96c602a /dev/LibDebugger/src/POSIX.cc
parent5bc9c1f376051d9fff7b837b4707437e9f756015 (diff)
debugger(posix): Refactor LibDebugger POSIX engine: rename, namespace update, API cleanup
- Renamed `IDebuggerEngine.h` → `POSIX.h` and `DebuggerEnginePOSIX.cc` → `POSIX.cc` - Moved `IDebuggerEngine` class into `LibDebugger::POSIX` namespace and renamed it to `Debugger` - Simplified method names: - `SetBreakpoint` → `Break` - `ContinueExecution` → `Continue` - Replaced generic return codes with `EXIT_SUCCESS` / `EXIT_FAILURE` - Updated includes and symbol usage to reflect changes across the codebase Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibDebugger/src/POSIX.cc')
-rw-r--r--dev/LibDebugger/src/POSIX.cc75
1 files changed, 75 insertions, 0 deletions
diff --git a/dev/LibDebugger/src/POSIX.cc b/dev/LibDebugger/src/POSIX.cc
new file mode 100644
index 0000000..21e122c
--- /dev/null
+++ b/dev/LibDebugger/src/POSIX.cc
@@ -0,0 +1,75 @@
+/***
+ (C) 2025 Amlal El Mahrouss
+ */
+
+#include <LibCompiler/Defines.h>
+#include <LibDebugger/POSIX.h>
+
+#ifndef _WIN32
+
+LIBCOMPILER_MODULE(DebuggerPOSIX)
+{
+ if (argc < 1)
+ {
+ return EXIT_FAILURE;
+ }
+
+ LibDebugger::POSIX::Debugger debugger;
+ pid_t pid = 0L;
+
+ if (argc >= 3 && std::string(argv[1]) == "-p" &&
+ argv[2] != nullptr)
+ {
+ pid = std::stoi(argv[2]);
+ debugger.Attach(pid);
+ }
+
+ while (YES)
+ {
+ std::string cmd;
+ std::getline(std::cin, cmd);
+
+ if (cmd == "c" ||
+ cmd == "cont")
+ debugger.Continue();
+
+ if (cmd == "d" ||
+ cmd == "detach")
+ debugger.Detach();
+
+ if (cmd == "attach")
+ {
+ std::cout << "[?] Enter a PID to attach on: ";
+
+ std::getline(std::cin, cmd);
+ pid = std::stoi(cmd.c_str());
+
+ debugger.Attach(pid);
+ }
+
+ if (cmd == "exit")
+ {
+ if (pid > 0)
+ debugger.Detach();
+
+ break;
+ }
+
+ if (cmd == "break" ||
+ cmd == "b")
+ {
+ std::cout << "[?] Enter an address to add a breakpoint on: ";
+
+ std::getline(std::cin, cmd);
+
+ LibDebugger::POSIX::CAddr breakpoint_addr = reinterpret_cast<LibDebugger::POSIX::CAddr>(std::stoul(cmd.c_str(), nullptr, 16));
+
+ if (breakpoint_addr)
+ debugger.Break(breakpoint_addr);
+ }
+ }
+
+ return EXIT_SUCCESS;
+}
+
+#endif \ No newline at end of file