From 04905eab43fcd4101b10e17ebae04b5918138351 Mon Sep 17 00:00:00 2001 From: nikitalita <69168929+nikitalita@users.noreply.github.com> Date: Thu, 31 Aug 2023 23:39:24 -0700 Subject: [PATCH] debugger cleanup --- .../BreakpointManager.cpp | 18 +----------------- .../StackFrameStateNode.cpp | 6 +----- src/DarkId.Papyrus.DebugServer/pdsPCH.h | 2 ++ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/DarkId.Papyrus.DebugServer/BreakpointManager.cpp b/src/DarkId.Papyrus.DebugServer/BreakpointManager.cpp index 6150c659..26fae558 100644 --- a/src/DarkId.Papyrus.DebugServer/BreakpointManager.cpp +++ b/src/DarkId.Papyrus.DebugServer/BreakpointManager.cpp @@ -17,18 +17,6 @@ namespace DarkId::Papyrus::DebugServer return dap::Error("Could not find PEX data for script %s", scriptName); } auto ref = GetSourceReference(source); - // don't bother setting this - //source.sourceReference = dap::integer(ref); - -#if _DEBUG_DUMP_PEX - std::string dir = logger::log_directory().value_or("").string(); - if (dir.empty()) { - logger::error("Failed to open log directory, PEX will not be dumped"); - } - else if (!LoadAndDumpPexData(scriptName.c_str(), dir)) { - logger::error("Could not save PEX dump for {}"sv, scriptName); - } -#endif bool hasDebugInfo = binary->getDebugInfo().getFunctionInfos().size() > 0; if (!hasDebugInfo) { @@ -96,11 +84,7 @@ namespace DarkId::Papyrus::DebugServer if (!breakpointLines.empty()) { uint32_t currentLine; - #ifdef SKYRIM - bool success = func->TranslateIPToLineNumber(tasklet->topFrame->instructionPointer, currentLine); - #else // FAllOUT - bool success = func->TranslateIPToLineNumber(tasklet->topFrame->ip, currentLine); - #endif + bool success = func->TranslateIPToLineNumber(tasklet->topFrame->STACK_FRAME_IP, currentLine); auto found = breakpointLines.find(currentLine); return success && found != breakpointLines.end(); } diff --git a/src/DarkId.Papyrus.DebugServer/StackFrameStateNode.cpp b/src/DarkId.Papyrus.DebugServer/StackFrameStateNode.cpp index 91082bcb..e857d01b 100644 --- a/src/DarkId.Papyrus.DebugServer/StackFrameStateNode.cpp +++ b/src/DarkId.Papyrus.DebugServer/StackFrameStateNode.cpp @@ -22,11 +22,7 @@ namespace DarkId::Papyrus::DebugServer if (pexCache->GetSourceData(ScriptName.c_str(), source)) { stackFrame.source = source; - #if SKYRIM - uint32_t ip = m_stackFrame->instructionPointer; - #else // FALLOUT - uint32_t ip = m_stackFrame->ip; - #endif + uint32_t ip = m_stackFrame->STACK_FRAME_IP; uint32_t lineNumber; if (m_stackFrame->owningFunction->TranslateIPToLineNumber(ip, lineNumber)) { diff --git a/src/DarkId.Papyrus.DebugServer/pdsPCH.h b/src/DarkId.Papyrus.DebugServer/pdsPCH.h index 050f6c45..d34f1fee 100644 --- a/src/DarkId.Papyrus.DebugServer/pdsPCH.h +++ b/src/DarkId.Papyrus.DebugServer/pdsPCH.h @@ -17,6 +17,7 @@ namespace DarkId::Papyrus::DebugServer namespace XSE = SKSE; namespace logger = SKSE::log; } +#define STACK_FRAME_IP instructionPointer namespace XSE = SKSE; #elif FALLOUT @@ -36,6 +37,7 @@ namespace DarkId::Papyrus::DebugServer namespace XSE = F4SE; namespace logger = F4SE::log; } +#define STACK_FRAME_IP ip namespace XSE = F4SE; #endif