diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-24 12:26:53 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2026-03-24 12:26:53 +0100 |
| commit | a93ef6a5cd5e75fa24ffd5ba48573a69faf0207b (patch) | |
| tree | e748b74a46a44245d5283c20f817aba82c56c0e2 | |
| parent | e091fdcea9adc6521271c08574915fe617f3dd2d (diff) | |
[FEAT] DebuggerKit: Preppring for first release of Debuggers.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
| -rw-r--r-- | src/CompilerKit/src/Frontends/NectarCompiler+AMD64.cpp | 1 | ||||
| -rw-r--r-- | src/DebuggerKit/src/MachContract.cpp | 3 | ||||
| -rw-r--r-- | src/DebuggerKit/src/MachContractCLI.cpp | 4 | ||||
| -rw-r--r-- | src/DebuggerKit/src/NeKernelContractCLI.cpp | 2 | ||||
| -rw-r--r-- | src/DebuggerKit/src/POSIXContractCLI.cpp | 94 | ||||
| -rw-r--r-- | test/check/missing-syntax-1.nc | 2 | ||||
| -rw-r--r-- | test/check/missing-syntax-2.nc | 2 |
7 files changed, 99 insertions, 9 deletions
diff --git a/src/CompilerKit/src/Frontends/NectarCompiler+AMD64.cpp b/src/CompilerKit/src/Frontends/NectarCompiler+AMD64.cpp index 8146a88..baf7e2f 100644 --- a/src/CompilerKit/src/Frontends/NectarCompiler+AMD64.cpp +++ b/src/CompilerKit/src/Frontends/NectarCompiler+AMD64.cpp @@ -127,7 +127,6 @@ struct CompilerContext { /// @brief This function is for internal uses only, do not call it without a wrapper! CK_IMPORT_C bool NectarCheckLine(CompilerKit::STLString& input); - /// \brief Global compiler context (replaces kState) static CompilerContext kContext; diff --git a/src/DebuggerKit/src/MachContract.cpp b/src/DebuggerKit/src/MachContract.cpp index 8a897be..518f61a 100644 --- a/src/DebuggerKit/src/MachContract.cpp +++ b/src/DebuggerKit/src/MachContract.cpp @@ -9,8 +9,6 @@ #include <DebuggerKit/MachContract.h> #include <ThirdParty/Dialogs/Dialogs.h> -#ifdef DK_MACH_DEBUGGER - /// @brief a terrible way to import globals. #include <DebuggerKit/Common.inl> @@ -95,6 +93,5 @@ NECTAR_MODULE(DebuggerMachPOSIX) { return EXIT_SUCCESS; } -#endif #endif diff --git a/src/DebuggerKit/src/MachContractCLI.cpp b/src/DebuggerKit/src/MachContractCLI.cpp index 0cc9b99..9bdb5b1 100644 --- a/src/DebuggerKit/src/MachContractCLI.cpp +++ b/src/DebuggerKit/src/MachContractCLI.cpp @@ -6,7 +6,7 @@ #ifdef DK_MACH_DEBUGGER -#include <DebuggerKit/POSIXMachContract.h> +#include <DebuggerKit/MachContract.h> #include <ThirdParty/Dialogs/Dialogs.h> #ifdef DK_MACH_DEBUGGER @@ -84,7 +84,7 @@ NECTAR_MODULE(DebuggerMach) { std::getline(std::cin, cmd); if (kUserDebugger.BreakAt(cmd)) { - pfd::notify("Debugger Event", "Add BreakAt at: " + cmd); + pfd::notify("Debugger Event", "Add breakpoint at: " + cmd); } } } diff --git a/src/DebuggerKit/src/NeKernelContractCLI.cpp b/src/DebuggerKit/src/NeKernelContractCLI.cpp index 3680f6a..13144eb 100644 --- a/src/DebuggerKit/src/NeKernelContractCLI.cpp +++ b/src/DebuggerKit/src/NeKernelContractCLI.cpp @@ -82,7 +82,7 @@ NECTAR_MODULE(DebuggerNeKernel) { std::getline(std::cin, cmd); if (kKernelDebugger.BreakAt(cmd)) { - pfd::notify("Debugger Event", "Add BreakAt at: " + cmd); + pfd::notify("Debugger Event", "Add breakpoint at: " + cmd); } } } diff --git a/src/DebuggerKit/src/POSIXContractCLI.cpp b/src/DebuggerKit/src/POSIXContractCLI.cpp new file mode 100644 index 0000000..58aa4a1 --- /dev/null +++ b/src/DebuggerKit/src/POSIXContractCLI.cpp @@ -0,0 +1,94 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org) +// Licensed under the Apache License, Version 2.0 (See accompanying +// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0) +// Official repository: https://github.com/ne-foss-org/nectar + +#ifdef DK_POSIX_DEBUGGER + +#include <DebuggerKit/POSIXContract.h> +#include <ThirdParty/Dialogs/Dialogs.h> + +#include <DebuggerKit/Common.inl> + +/// @internal +/// @brief Handles CTRL-C signal on debugger. +static Void dbgi_ctrlc_handler(std::int32_t _) { + if (!kPID) { + return; + } + + kUserDebugger.Break(); + + pfd::notify("Debugger Event", "Breakpoint hit!"); + + kKeepRunning = false; +} + +NECTAR_MODULE(DebuggerPOSIX) { + pfd::notify( + "Debugger Event", + "Userland Debugger\n(C) 2025 Amlal El Mahrouss, licensed under the Apache 2.0 license."); + + if (argc >= 3 && std::string(argv[1]) == "-p" && argv[2] != nullptr) { + kPath = argv[2]; + kUserDebugger.SetPath(kPath); + + kStdOut << "[+] Image set to: " << kPath << "\n"; + } else { + kStdOut << "usage: " << argv[0] << " -p <path>\n"; + kStdOut << "example: " << argv[0] << " -p </path/to/program>\n"; + + return EXIT_FAILURE; + } + + CompilerKit::install_signal(SIGINT, dbgi_ctrlc_handler); + + while (YES) { + if (kKeepRunning) { + continue; + } + + CompilerKit::STLString cmd{}; + + if (!std::getline(std::cin, cmd)) break; + + if (cmd == "c" || cmd == "cont" || cmd == "continue") { + if (kUserDebugger.Continue()) { + kKeepRunning = true; + + kStdOut << "[+] Continuing...\n"; + pfd::notify("Debugger Event", "Continuing..."); + } + } + + if (cmd == "d" || cmd == "detach") kUserDebugger.Detach(); + + if (cmd == "start") { + kStdOut << "[?] Enter a argument to use: "; + std::getline(std::cin, cmd); + + kUserDebugger.Attach(kPath, cmd, kPID); + } + + if (cmd == "exit") { + if (kPID > 0) kUserDebugger.Detach(); + + break; + } + + if (cmd == "break" || cmd == "b") { + kStdOut << "[?] Enter a symbol to break on: "; + + std::getline(std::cin, cmd); + + if (kUserDebugger.BreakAt(cmd)) { + pfd::notify("Debugger Event", "Add breakpoint at: " + cmd); + } + } + } + + return EXIT_SUCCESS; +} + +#endif diff --git a/test/check/missing-syntax-1.nc b/test/check/missing-syntax-1.nc index 4f2e430..cf094e9 100644 --- a/test/check/missing-syntax-1.nc +++ b/test/check/missing-syntax-1.nc @@ -4,7 +4,7 @@ const main() { let ptr := 0; let sz := 8; - cudaMalloc(ptr, sz); + cudaMalloc(ptr, sz) } diff --git a/test/check/missing-syntax-2.nc b/test/check/missing-syntax-2.nc index 4f2e430..e01171e 100644 --- a/test/check/missing-syntax-2.nc +++ b/test/check/missing-syntax-2.nc @@ -3,7 +3,7 @@ import cudaMalloc; const main() { let ptr := 0; - let sz := 8; + let sz := 8 cudaMalloc(ptr, sz); } |
