summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-08 10:14:05 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-02-08 10:14:05 +0100
commit0350589847a0a5bbce5556a62ea5f5df7de29641 (patch)
tree5bedc372d3f71beaca30e57ef931420c8fae3de4 /dev/LibCompiler
parent75b1a419fc13d9c3e1c35665ce24434d4c1ab004 (diff)
ADD: Moved Debugger into LibCompiler.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/LibCompiler')
-rw-r--r--dev/LibCompiler/src/DebuggerPOSIX.cc66
1 files changed, 66 insertions, 0 deletions
diff --git a/dev/LibCompiler/src/DebuggerPOSIX.cc b/dev/LibCompiler/src/DebuggerPOSIX.cc
new file mode 100644
index 0000000..a5e663e
--- /dev/null
+++ b/dev/LibCompiler/src/DebuggerPOSIX.cc
@@ -0,0 +1,66 @@
+/***
+ (C) 2025 Amlal El Mahrouss
+ */
+
+#include <LibCompiler/Defines.h>
+#include <LibDebugger/IDebugger.h>
+
+LIBCOMPILER_MODULE(DebuggerPOSIX)
+{
+ LibDebugger::IDebugger 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.ContinueExecution();
+
+ 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 == "bp")
+ {
+ std::cout << "[?] Enter an address to add a breakpoint on: ";
+
+ std::getline(std::cin, cmd);
+
+ LibDebugger::VmAddress breakpoint_addr = reinterpret_cast<LibDebugger::VmAddress>(std::stoul(cmd.c_str(), nullptr, 16));
+
+ if (breakpoint_addr)
+ debugger.SetBreakpoint(breakpoint_addr);
+ }
+ }
+
+ return 0;
+}