summaryrefslogtreecommitdiffhomepage
path: root/src/DebuggerKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-02 01:39:42 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-02 01:40:12 -0500
commitf7930b3a1279922cf9e6e75e651fe9b5df247bc6 (patch)
tree984d92f85d89aaf355a51af13d45a358da6473b7 /src/DebuggerKit
parentc895f469119903b3874d74604e582aed0da989ae (diff)
chore: source level tweaks and breaking API changes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/DebuggerKit')
-rw-r--r--src/DebuggerKit/Config.h21
-rw-r--r--src/DebuggerKit/DebuggerContract.h1
-rw-r--r--src/DebuggerKit/POSIXMachContract.h8
-rw-r--r--src/DebuggerKit/Version.h15
-rw-r--r--src/DebuggerKit/src/POSIXMachContractCLI.cc2
5 files changed, 25 insertions, 22 deletions
diff --git a/src/DebuggerKit/Config.h b/src/DebuggerKit/Config.h
index 2697832..7e589d2 100644
--- a/src/DebuggerKit/Config.h
+++ b/src/DebuggerKit/Config.h
@@ -23,15 +23,22 @@
#include <sys/wait.h>
#include <unistd.h>
-#include <filesystem>
-#include <iostream>
-
#include <dlfcn.h>
+
+#ifdef __APPLE__
#include <mach-o/dyld.h>
#include <mach/mach.h>
#include <mach/mach_error.h>
-#include <signal.h>
+#endif
+
+#ifndef kDistRelease
+
+#define kDistVersion "v0.0.7-debuggerkit"
+#define kDistVersionBCD 0x0001
+
+#define ToString(X) Stringify(X)
+#define Stringify(X) #X
+
+#define kDistRelease ToString(kDistReleaseBranch)
-#include <cstdint>
-#include <string>
-#include <unordered_map> \ No newline at end of file
+#endif // !kDistRelease \ No newline at end of file
diff --git a/src/DebuggerKit/DebuggerContract.h b/src/DebuggerKit/DebuggerContract.h
index 2db0526..424bd80 100644
--- a/src/DebuggerKit/DebuggerContract.h
+++ b/src/DebuggerKit/DebuggerContract.h
@@ -7,6 +7,7 @@
#pragma once
#include <DebuggerKit/Config.h>
+#include <unordered_map>
#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::DebuggerContract
diff --git a/src/DebuggerKit/POSIXMachContract.h b/src/DebuggerKit/POSIXMachContract.h
index 5bd4ba8..76aa238 100644
--- a/src/DebuggerKit/POSIXMachContract.h
+++ b/src/DebuggerKit/POSIXMachContract.h
@@ -12,13 +12,17 @@
/// @brief POSIX Mach debugger.
#include <DebuggerKit/DebuggerContract.h>
+#include <filesystem>
+#include <vector>
+#ifdef __APPLE__
CK_IMPORT_C kern_return_t mach_vm_write(vm_map_t target_task, mach_vm_address_t address,
vm_offset_t data, mach_msg_type_number_t dataCnt);
CK_IMPORT_C kern_return_t mach_vm_protect(vm_map_t target_task, mach_vm_address_t address,
mach_vm_size_t size, boolean_t set_maximum,
vm_prot_t new_protection);
+#endif
#define PTRACE_ATTACH PT_ATTACHEXC
#define PTRACE_DETACH PT_DETACH
@@ -93,6 +97,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT {
return false;
}
+#ifdef __APPLE__
task_read_t task;
task_for_pid(mach_task_self(), m_pid, &task);
@@ -102,6 +107,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT {
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
mach_vm_write(task, (mach_vm_address_t) addr, (vm_offset_t) &brk_inst, sizeof(addr));
+#endif
return true;
}
@@ -109,6 +115,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT {
return false;
}
+#ifdef __APPLE__
Bool Break() noexcept override {
task_read_t task;
task_for_pid(mach_task_self(), m_pid, &task);
@@ -137,6 +144,7 @@ class POSIXMachContract final DK_DEBUGGER_CONTRACT {
return kr = KERN_SUCCESS;
}
+#endif
private:
ProcessID m_pid{0};
diff --git a/src/DebuggerKit/Version.h b/src/DebuggerKit/Version.h
deleted file mode 100644
index 8f3168a..0000000
--- a/src/DebuggerKit/Version.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* ========================================
-
- Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
-
-======================================== */
-
-#pragma once
-
-#define kDistVersion "v0.0.7-debuggerkit"
-#define kDistVersionBCD 0x0001
-
-#define ToString(X) Stringify(X)
-#define Stringify(X) #X
-
-#define kDistRelease ToString(kDistReleaseBranch)
diff --git a/src/DebuggerKit/src/POSIXMachContractCLI.cc b/src/DebuggerKit/src/POSIXMachContractCLI.cc
index 9e77a1b..2beaa9a 100644
--- a/src/DebuggerKit/src/POSIXMachContractCLI.cc
+++ b/src/DebuggerKit/src/POSIXMachContractCLI.cc
@@ -11,6 +11,7 @@
#include <ThirdParty/Dialogs.h>
#include <DebuggerKit/CommonCLI.inl>
+#ifdef __APPLE__
/// @internal
/// @brief Handles CTRL-C signal on debugger.
static void dbgi_ctrlc_handler(std::int32_t _) {
@@ -90,5 +91,6 @@ NECTI_MODULE(DebuggerMachPOSIX) {
return EXIT_SUCCESS;
}
+#endif
#endif \ No newline at end of file