summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-11-22 09:59:41 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-11-22 09:59:41 +0100
commitb5adf16a96b9cbb80c74cf30404ed5bcff03ac34 (patch)
treee1be4c79f2c7e878d162c23d5c0518c350b00724 /dev
parentb8e6e1492ed14e270b1061809b0569b8d2f4c0ec (diff)
chore: DebuggerKit cleanup.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev')
-rw-r--r--dev/DebuggerKit/CommonCLI.inl13
-rw-r--r--dev/DebuggerKit/DebuggerContract.h14
-rw-r--r--dev/DebuggerKit/NeKernelContract.h7
-rw-r--r--dev/DebuggerKit/POSIXMachContract.h25
-rw-r--r--dev/DebuggerKit/Platform.h31
-rw-r--r--dev/DebuggerKit/src/NeKernelContract.cc11
-rw-r--r--dev/DebuggerKit/src/NeKernelContractCLI.cc11
-rw-r--r--dev/DebuggerKit/src/POSIXMachContractCLI.cc25
-rw-r--r--dev/LibC++/__abi.h8
-rw-r--r--dev/LibC++/base_math.h17
-rw-r--r--dev/LibC++/base_process.h16
-rw-r--r--dev/LibC++/defines.h10
12 files changed, 104 insertions, 84 deletions
diff --git a/dev/DebuggerKit/CommonCLI.inl b/dev/DebuggerKit/CommonCLI.inl
index a118634..e06a9b9 100644
--- a/dev/DebuggerKit/CommonCLI.inl
+++ b/dev/DebuggerKit/CommonCLI.inl
@@ -1,9 +1,8 @@
-/***
- DebuggerKit
- (C) 2025 Amlal El Mahrouss
- File: CommonCLI.inl
- Purpose: Common Debugger symbols.
-*/
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#define kBlank "\e[0;30m"
#define kRed "\e[0;31m"
@@ -16,7 +15,7 @@ static Bool kKeepRunning = false;
#ifdef DK_NEKERNEL_DEBUGGER
static DebuggerKit::NeKernel::NeKernelContract kKernelDebugger;
#else
-static DebuggerKit::POSIX::POSIXMachContract kDebugger;
+static DebuggerKit::POSIX::POSIXMachContract kUserDebugger;
#endif
static DebuggerKit::ProcessID kPID = 0L;
diff --git a/dev/DebuggerKit/DebuggerContract.h b/dev/DebuggerKit/DebuggerContract.h
index d1c8ed1..2114041 100644
--- a/dev/DebuggerKit/DebuggerContract.h
+++ b/dev/DebuggerKit/DebuggerContract.h
@@ -1,12 +1,12 @@
-/***
- (C) 2025 Amlal El Mahrouss
- */
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#pragma once
-#include <cstdint>
-#include <string>
-#include <unordered_map>
+#include <DebuggerKit/Platform.h>
#define DK_DEBUGGER_CONTRACT : public ::DebuggerKit::DebuggerContract
@@ -46,7 +46,7 @@ class DebuggerContract {
virtual std::unordered_map<uintptr_t, uintptr_t>& Get() { return m_breakpoints; }
protected:
- ProcessID m_pid;
+ ProcessID m_pid{(ProcessID)~0};
std::unordered_map<uintptr_t, uintptr_t> m_breakpoints;
};
} // namespace DebuggerKit
diff --git a/dev/DebuggerKit/NeKernelContract.h b/dev/DebuggerKit/NeKernelContract.h
index 582741a..d048303 100644
--- a/dev/DebuggerKit/NeKernelContract.h
+++ b/dev/DebuggerKit/NeKernelContract.h
@@ -1,7 +1,8 @@
+/* ========================================
-/***
- (C) 2025 Amlal El Mahrouss, licensed under Apache-2.0.
- */
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#ifndef DK_NEKERNEL_CONTRACT_H
#define DK_NEKERNEL_CONTRACT_H
diff --git a/dev/DebuggerKit/POSIXMachContract.h b/dev/DebuggerKit/POSIXMachContract.h
index b1c0e0a..5bd4ba8 100644
--- a/dev/DebuggerKit/POSIXMachContract.h
+++ b/dev/DebuggerKit/POSIXMachContract.h
@@ -1,6 +1,8 @@
-/***
- (C) 2025 Amlal El Mahrouss, licensed under Apache-2.0.
- */
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#pragma once
@@ -9,25 +11,8 @@
/// @file POSIXMachContract.h
/// @brief POSIX Mach debugger.
-#include <CompilerKit/Defines.h>
#include <DebuggerKit/DebuggerContract.h>
-#include <stdint.h>
-#include <sys/ptrace.h>
-#include <sys/types.h>
-#include <sys/user.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <filesystem>
-#include <iostream>
-
-#include <dlfcn.h>
-#include <mach-o/dyld.h>
-#include <mach/mach.h>
-#include <mach/mach_error.h>
-#include <signal.h>
-
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);
diff --git a/dev/DebuggerKit/Platform.h b/dev/DebuggerKit/Platform.h
index 26f47ff..f878845 100644
--- a/dev/DebuggerKit/Platform.h
+++ b/dev/DebuggerKit/Platform.h
@@ -1,9 +1,8 @@
-/***
- DebuggerKit
- (C) 2025 Amlal El Mahrouss, licensed under Apache-2.0.
- File: Platform.h
- Purpose: NeCTI Debugger Platform headers.
-*/
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#pragma once
@@ -11,8 +10,28 @@
/// @author Amlal El Mahrouss
/// =========================================================== ///
+#include <CompilerKit/Defines.h>
+
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
+
+#include <sys/ptrace.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/wait.h>
#include <unistd.h>
+
+#include <filesystem>
+#include <iostream>
+
+#include <dlfcn.h>
+#include <mach-o/dyld.h>
+#include <mach/mach.h>
+#include <mach/mach_error.h>
+#include <signal.h>
+
+#include <cstdint>
+#include <string>
+#include <unordered_map> \ No newline at end of file
diff --git a/dev/DebuggerKit/src/NeKernelContract.cc b/dev/DebuggerKit/src/NeKernelContract.cc
index a062493..38f327d 100644
--- a/dev/DebuggerKit/src/NeKernelContract.cc
+++ b/dev/DebuggerKit/src/NeKernelContract.cc
@@ -1,9 +1,8 @@
-/***
- DebuggerKit
- (C) 2025 Amlal El Mahrouss
- File: NeKernelContract.cc
- Purpose: NeCTI Debugger
-*/
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#ifdef DK_NEKERNEL_DEBUGGER
diff --git a/dev/DebuggerKit/src/NeKernelContractCLI.cc b/dev/DebuggerKit/src/NeKernelContractCLI.cc
index fe8181f..fc13a53 100644
--- a/dev/DebuggerKit/src/NeKernelContractCLI.cc
+++ b/dev/DebuggerKit/src/NeKernelContractCLI.cc
@@ -1,9 +1,8 @@
-/***
- DebuggerKit
- (C) 2025 Amlal El Mahrouss
- File: NeKernelContract.cc
- Purpose: NeCTI Debugger CLI.
-*/
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#ifdef DK_NEKERNEL_DEBUGGER
diff --git a/dev/DebuggerKit/src/POSIXMachContractCLI.cc b/dev/DebuggerKit/src/POSIXMachContractCLI.cc
index 22a626d..77fe844 100644
--- a/dev/DebuggerKit/src/POSIXMachContractCLI.cc
+++ b/dev/DebuggerKit/src/POSIXMachContractCLI.cc
@@ -1,9 +1,8 @@
-/***
- DebuggerKit
- (C) 2025 Amlal El Mahrouss
- File: POSIXMachContract.cc
- Purpose: OS X/Darwin Debugger
-*/
+/* ========================================
+
+ Copyright (C) 2025 Amlal El Mahrouss, Licensed under the Apache 2.0 license.
+
+======================================== */
#ifdef DK_MACH_DEBUGGER
@@ -19,7 +18,7 @@ static void dbgi_ctrlc_handler(std::int32_t _) {
return;
}
- kDebugger.Break();
+ kUserDebugger.Break();
pfd::notify("Debugger Event", "Breakpoint hit!");
@@ -33,7 +32,7 @@ NECTI_MODULE(DebuggerMachPOSIX) {
if (argc >= 3 && std::string(argv[1]) == "-p" && argv[2] != nullptr) {
kPath = argv[2];
- kDebugger.SetPath(kPath);
+ kUserDebugger.SetPath(kPath);
kStdOut << "[+] Image set to: " << kPath << "\n";
} else {
@@ -54,7 +53,7 @@ NECTI_MODULE(DebuggerMachPOSIX) {
if (!std::getline(std::cin, cmd)) break;
if (cmd == "c" || cmd == "cont" || cmd == "continue") {
- if (kDebugger.Continue()) {
+ if (kUserDebugger.Continue()) {
kKeepRunning = true;
kStdOut << "[+] Continuing...\n";
@@ -63,17 +62,17 @@ NECTI_MODULE(DebuggerMachPOSIX) {
}
}
- if (cmd == "d" || cmd == "detach") kDebugger.Detach();
+ if (cmd == "d" || cmd == "detach") kUserDebugger.Detach();
if (cmd == "start") {
kStdOut << "[?] Enter a argument to use: ";
std::getline(std::cin, cmd);
- kDebugger.Attach(kPath, cmd, kPID);
+ kUserDebugger.Attach(kPath, cmd, kPID);
}
if (cmd == "exit") {
- if (kPID > 0) kDebugger.Detach();
+ if (kPID > 0) kUserDebugger.Detach();
break;
}
@@ -83,7 +82,7 @@ NECTI_MODULE(DebuggerMachPOSIX) {
std::getline(std::cin, cmd);
- if (kDebugger.BreakAt(cmd)) {
+ if (kUserDebugger.BreakAt(cmd)) {
pfd::notify("Debugger Event", "Add BreakAt at: " + cmd);
}
}
diff --git a/dev/LibC++/__abi.h b/dev/LibC++/__abi.h
index d46a9ee..70afae5 100644
--- a/dev/LibC++/__abi.h
+++ b/dev/LibC++/__abi.h
@@ -6,4 +6,10 @@
#pragma once
-extern "C" void __compilerkit_unreachable(void);
+#include <LibC++/defines.h>
+
+__init_decl()
+
+extern void __compilerkit_unreachable(void);
+
+__fini_decl() \ No newline at end of file
diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h
index 73cb174..60b260e 100644
--- a/dev/LibC++/base_math.h
+++ b/dev/LibC++/base_math.h
@@ -8,10 +8,14 @@
#include <LibC++/defines.h>
+#ifndef NAN
+#define NAN (__builtin_nanf(""))
+#endif // !NAN
+
/// @file Math.h
/// @brief Math functions.
-#ifdef __NE_USE_DOUBLE__
+#ifdef __LIBCXX_USE_DOUBLE__
typedef double real_type;
#else
typedef float real_type;
@@ -20,7 +24,9 @@ typedef float real_type;
namespace std::base_math {
inline constexpr static auto not_a_number = NAN;
+/// =========================================================== ///
/// @brief Power function, with Repeat argument.
+/// =========================================================== ///
template <size_t Exponent>
inline real_type pow(real_type in) {
if (Exponent == 0) return 1; // Any number to the power of 0 is 1.
@@ -36,6 +42,9 @@ inline real_type pow(real_type in) {
return result;
}
+/// =========================================================== ///
+/// @brief Square root function.
+/// =========================================================== ///
inline real_type sqrt(real_type in) {
if (in == 0) return 0;
if (in == not_a_number) return not_a_number;
@@ -51,8 +60,10 @@ inline real_type sqrt(real_type in) {
return x;
}
+/// =========================================================== ///
/// @brief Square of function, with Base template argument.
-/// @param of Base argument to find sqquare of
+/// @param of Base argument to find the square of.
+/// =========================================================== ///
template <size_t Base>
inline real_type surd(real_type in) {
if (in == 0) return 0;
@@ -64,10 +75,12 @@ inline real_type surd(real_type in) {
return not_a_number;
}
+/// =========================================================== ///
/// @brief Linear interpolation equation solver.
/// @param from where?
/// @param to to?
/// @param Updated diff value according to difference.
+/// =========================================================== ///
inline real_type lerp(real_type to, real_type from, real_type stat) {
real_type diff = (to - from);
return from + (diff * stat);
diff --git a/dev/LibC++/base_process.h b/dev/LibC++/base_process.h
index abcbf08..f9b0596 100644
--- a/dev/LibC++/base_process.h
+++ b/dev/LibC++/base_process.h
@@ -8,14 +8,22 @@
#include <LibC++/defines.h>
+__init_decl()
+
/// @brief CRT exit, with exit code (!!! exits all threads. !!!)
/// @param code the exit code.
/// @return the return > 0 for non successful.
-extern "C" int exit_(int code);
+extern int exit_(int code);
/// @brief CRT signal handler.
/// @param code the signal code.
-extern "C" void signal_(int code);
+extern void signal_(int code);
+
+extern void (*__atexit_cdecl_ptr)(void);
+extern void (**__atexit_lst_ptr)(void);
+extern size_t __atexit_lst_cnt;
+
+__fini_decl()
/// @brief Standard C++ namespace
namespace std::base_process {
@@ -24,10 +32,6 @@ inline int signal(int code) {
return -1;
}
-extern "C" void (*__atexit_cdecl_ptr)(void);
-extern "C" void (**__atexit_lst_ptr)(void);
-extern "C" size_t __atexit_lst_cnt;
-
inline int32_t exit(const int32_t& code) {
for (auto idx = 0UL; idx < __atexit_lst_cnt; ++idx) {
__atexit_lst_ptr[idx]();
diff --git a/dev/LibC++/defines.h b/dev/LibC++/defines.h
index e263d9c..b8ef10c 100644
--- a/dev/LibC++/defines.h
+++ b/dev/LibC++/defines.h
@@ -7,20 +7,16 @@
#ifndef __NECTI_DEFINES_H__
#define __NECTI_DEFINES_H__
-extern "C" {
-#include <stddef.h>
-#include <stdint.h>
-}
-
#define __ATTRIBUTE(X) __attribute__((X))
typedef __SIZE_TYPE__ size_t;
-typedef __SSIZE_TYPE__ ssize_t;
+typedef __INT64_TYPE__ ssize_t;
+typedef __INT32_TYPE__ int32_t;
typedef void* ptr_type;
typedef __SIZE_TYPE__ size_type;
-typedef size_t ptrdiff_t;
+typedef __INT64_TYPE__ ptrdiff_t;
typedef size_t uintptr_t;
typedef void* voidptr_t;
typedef void* any_t;