From f7930b3a1279922cf9e6e75e651fe9b5df247bc6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 2 Dec 2025 01:39:42 -0500 Subject: chore: source level tweaks and breaking API changes. Signed-off-by: Amlal El Mahrouss --- src/DebuggerKit/Config.h | 21 ++++++++++++++------- src/DebuggerKit/DebuggerContract.h | 1 + src/DebuggerKit/POSIXMachContract.h | 8 ++++++++ src/DebuggerKit/Version.h | 15 --------------- src/DebuggerKit/src/POSIXMachContractCLI.cc | 2 ++ 5 files changed, 25 insertions(+), 22 deletions(-) delete mode 100644 src/DebuggerKit/Version.h (limited to 'src/DebuggerKit') 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 #include -#include -#include - #include + +#ifdef __APPLE__ #include #include #include -#include +#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 -#include -#include \ 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 +#include #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 +#include +#include +#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 #include +#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 -- cgit v1.2.3