summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 20:58:15 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2025-03-23 20:58:15 +0100
commitd8cf1ef181caa49bb44ed521ed063cfed3eca775 (patch)
treec6b17ffb5d122ef0d5f00beabde92fe4e0450c32 /dev
parent4b0de97035d2a750c4a2073a1992e2eff68926d0 (diff)
feat(dbg): Avoid breakpoint when kPID is not set (kPID = 0)
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev')
-rw-r--r--dev/LibCompiler/src/DynamicLinkerELF.cc82
-rw-r--r--dev/LibDebugger/POSIX.h12
-rw-r--r--dev/LibDebugger/src/POSIX.cc24
3 files changed, 20 insertions, 98 deletions
diff --git a/dev/LibCompiler/src/DynamicLinkerELF.cc b/dev/LibCompiler/src/DynamicLinkerELF.cc
deleted file mode 100644
index 6645219..0000000
--- a/dev/LibCompiler/src/DynamicLinkerELF.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/* -------------------------------------------
-
- Copyright (C) 2024 Amlal EL Mahrouss, all rights reserved
-
- @file DynamicLinker64PEF.cc
- @brief: C++ 64-Bit PEF Linker.
-
-------------------------------------------- */
-
-/// @author EL Mahrouss Amlal (amlel)
-/// @brief NeOS 64-bit PEF Linker.
-/// Last Rev: Sat Feb 24 CET 2024
-/// @note Do not look up for anything with .code64/.data64/.zero64!
-/// It will be loaded when the program loader will start the image.
-
-//! Toolchain Kit.
-#include <LibCompiler/Defines.h>
-
-#include <LibCompiler/NFC/ErrorID.h>
-
-//! Assembler Kit
-#include <LibCompiler/AAL/AssemblyInterface.h>
-
-//! Preferred Executable Format
-#include <LibCompiler/NFC/XCOFF.h>
-#include <LibCompiler/UUID.h>
-
-//! Release macros.
-#include <LibCompiler/Version.h>
-
-//! Advanced Executable Object Format.
-#include <LibCompiler/NFC/AE.h>
-#include <cstdint>
-
-#define kLinkerVersionStr "NeOS 64-Bit Linker (ELF) %s, (c) Amlal EL Mahrouss 2024, all rights reserved.\n"
-
-#define kPrintF printf
-#define kLinkerSplash() kPrintF(kWhite kLinkerVersionStr, kDistVersion)
-
-#define MemoryCopy(DST, SRC, SZ) memcpy(DST, SRC, SZ)
-#define StringCompare(DST, SRC) strcmp(DST, SRC)
-
-#define kPefNoCpu 0U
-#define kPefNoSubCpu 0U
-
-#define kWhite "\e[0;97m"
-
-#define kStdOut (std::cout << kWhite << "ld64 (ELF): ")
-
-#define kLinkerDefaultOrigin kPefBaseOrigin
-#define kLinkerId (0x5046FF)
-#define kLinkerAbiContainer "Container:ABI:"
-
-namespace Detail
-{
- struct DynamicLinkerBlob final
- {
- std::vector<CharType> mBlob{}; // ELF code/bss/data blob.
- UIntPtr mOffset{0UL}; // the offset of the ELF container header...
- };
-} // namespace Detail
-
-static Bool kFatBinaryEnable = false;
-static Bool kStartFound = false;
-static Bool kDuplicateSymbols = false;
-static Bool kVerbose = false;
-
-/* object code and list. */
-static std::vector<LibCompiler::String> kObjectList;
-static std::vector<Detail::DynamicLinkerBlob> kObjectBytes;
-
-static uintptr_t kMIBCount = 8;
-static uintptr_t kByteCount = 1024;
-
-/// @brief NE 64-bit Linker.
-/// @note This linker is made for XCOFF executable, thus NE based OSes.
-LIBCOMPILER_MODULE(DynamicLinker64XCOFF)
-{
- return EXIT_SUCCESS;
-}
-
-// Last rev 13-1-24
diff --git a/dev/LibDebugger/POSIX.h b/dev/LibDebugger/POSIX.h
index 52af66e..b863f58 100644
--- a/dev/LibDebugger/POSIX.h
+++ b/dev/LibDebugger/POSIX.h
@@ -34,17 +34,17 @@ namespace LibDebugger::POSIX
typedef char* CAddr;
#endif
- /// \brief Debugger engine interface class in C++
+ /// \brief LocalDebuggerPOSIX engine interface class in C++
/// \author Amlal El Mahrouss
- class Debugger final
+ class LocalDebuggerPOSIX final
{
public:
- explicit Debugger() = default;
- ~Debugger() = default;
+ explicit LocalDebuggerPOSIX() = default;
+ ~LocalDebuggerPOSIX() = default;
public:
- Debugger& operator=(const Debugger&) = default;
- Debugger(const Debugger&) = default;
+ LocalDebuggerPOSIX& operator=(const LocalDebuggerPOSIX&) = default;
+ LocalDebuggerPOSIX(const LocalDebuggerPOSIX&) = default;
public:
bool Attach(pid_t pid)
diff --git a/dev/LibDebugger/src/POSIX.cc b/dev/LibDebugger/src/POSIX.cc
index 02db4ea..b8c92ae 100644
--- a/dev/LibDebugger/src/POSIX.cc
+++ b/dev/LibDebugger/src/POSIX.cc
@@ -10,11 +10,17 @@
#ifndef _WIN32
-static bool kKeepRunning = false;
-LibDebugger::POSIX::Debugger kDebugger;
+static bool kKeepRunning = false;
+static LibDebugger::POSIX::LocalDebuggerPOSIX kDebugger;
+static pid_t kPID = 0L;
static void DebuggerCtrlCHandler(std::int32_t _)
{
+ if (!kPID)
+ {
+ return;
+ }
+
auto list = kDebugger.Get();
LibDebugger::POSIX::CAddr addr = (LibDebugger::POSIX::CAddr)list[list.size() - 1];
@@ -39,13 +45,11 @@ LIBCOMPILER_MODULE(DebuggerPOSIX)
return EXIT_FAILURE;
}
- pid_t pid = 0L;
-
if (argc >= 3 && std::string(argv[1]) == "-p" &&
argv[2] != nullptr)
{
- pid = std::stoi(argv[2]);
- kDebugger.Attach(pid);
+ kPID = std::stoi(argv[2]);
+ kDebugger.Attach(kPID);
}
::signal(SIGINT, DebuggerCtrlCHandler);
@@ -76,16 +80,16 @@ LIBCOMPILER_MODULE(DebuggerPOSIX)
std::cout << "[?] Enter a PID to attach on: ";
std::getline(std::cin, cmd);
- pid = std::stoi(cmd.c_str());
+ kPID = std::stoi(cmd.c_str());
- pfd::notify("Debugger Event", "Attach process: " + std::to_string(pid));
+ pfd::notify("Debugger Event", "Attach process: " + std::to_string(kPID));
- kDebugger.Attach(pid);
+ kDebugger.Attach(kPID);
}
if (cmd == "exit")
{
- if (pid > 0)
+ if (kPID > 0)
kDebugger.Detach();
break;