From 2a6e44dcb0ff041b984edd2d9c7dd8e57e72058a Mon Sep 17 00:00:00 2001 From: SingleCopy Date: Tue, 16 Jun 2026 14:05:15 +0100 Subject: [PATCH] Support which segment is selected via the segment/seg args --- src/DebugInterface/Symbols/CDebugSymbols.cpp | 5 +++++ src/DebugInterface/Symbols/CDebugSymbols.h | 1 + src/Tools/C64CommandLine.cpp | 19 +++++++++++++++++++ src/Tools/C64CommandLine.h | 3 ++- src/Tools/C64SettingsStorage.cpp | 1 + src/Tools/C64SettingsStorage.h | 1 + 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/DebugInterface/Symbols/CDebugSymbols.cpp b/src/DebugInterface/Symbols/CDebugSymbols.cpp index 293eab98..1bd7d93d 100644 --- a/src/DebugInterface/Symbols/CDebugSymbols.cpp +++ b/src/DebugInterface/Symbols/CDebugSymbols.cpp @@ -1518,6 +1518,11 @@ void CDebugSymbols::DeactivateSegment() guiMain->UnlockMutex(); } +void CDebugSymbols::SetPreviousSegment(CSlrString* segmentName) +{ + this->previousSegmentName = segmentName; +} + // void CDebugSymbols::SelectNextSegment() { diff --git a/src/DebugInterface/Symbols/CDebugSymbols.h b/src/DebugInterface/Symbols/CDebugSymbols.h index d02c7bb9..afe801bf 100644 --- a/src/DebugInterface/Symbols/CDebugSymbols.h +++ b/src/DebugInterface/Symbols/CDebugSymbols.h @@ -48,6 +48,7 @@ class CDebugSymbols void ActivateSelectedSegment(); void ActivateSegment(CDebugSymbolsSegment *segment); void DeactivateSegment(); + void SetPreviousSegment(CSlrString* segmentName); // void SelectNextSegment(); diff --git a/src/Tools/C64CommandLine.cpp b/src/Tools/C64CommandLine.cpp index 030eb8b6..1e2d5f4c 100644 --- a/src/Tools/C64CommandLine.cpp +++ b/src/Tools/C64CommandLine.cpp @@ -635,6 +635,11 @@ void c64PerformStartupTasksThreaded() debugInterface->symbols->DeleteAllSymbols(); debugInterface->symbols->ParseSourceDebugInfo(c64SettingsPathToDebugInfo); } + + if (c64SettingsDefaultSegment != NULL) + { + debugInterface->symbols->SetPreviousSegment(c64SettingsDefaultSegment); + } } // skip any automatic loading if jukebox is active @@ -891,6 +896,12 @@ void C64DebuggerParseCommandLine2() char *arg = c64ParseCommandLineGetArgument(); c64SettingsPathToDebugInfo = new CSlrString(arg); } + else if (!strcmp(cmd, "segment") || !strcmp(cmd, "seg")) + { + char *arg = c64ParseCommandLineGetArgument(); + LOGD("default segment='%s'", arg); + c64SettingsDefaultSegment = new CSlrString(arg); + } else if (!strcmp(cmd, "autojmp") || !strcmp(cmd, "autojump")) { cmdLineOptionDoAutoJmp = true; @@ -1102,6 +1113,14 @@ void C64DebuggerPassConfigToRunningInstance() byteBuffer->PutSlrString(c64SettingsPathToDebugInfo); } + if (c64SettingsDefaultSegment) + { + LOGD("c64SettingsDefaultSegment"); + c64SettingsPathToWatches->DebugPrint("c64SettingsDefaultSegment="); + byteBuffer->PutU8(C64D_PASS_CONFIG_DATA_DEFAULT_SEGMENT); + byteBuffer->PutSlrString(c64SettingsDefaultSegment); + } + if (c64CommandLineHardReset) { byteBuffer->PutU8(C64D_PASS_CONFIG_DATA_HARD_RESET); diff --git a/src/Tools/C64CommandLine.h b/src/Tools/C64CommandLine.h index d92f58a8..3bd785f7 100644 --- a/src/Tools/C64CommandLine.h +++ b/src/Tools/C64CommandLine.h @@ -40,7 +40,8 @@ typedef enum c64d_pass_config_data_e { C64D_PASS_CONFIG_DATA_HARD_RESET, C64D_PASS_CONFIG_DATA_FULL_SCREEN, C64D_PASS_CONFIG_DATA_SELECT_EMULATOR, - C64D_PASS_CONFIG_DATA_DETACH_EVERYTHING + C64D_PASS_CONFIG_DATA_DETACH_EVERYTHING, + C64D_PASS_CONFIG_DATA_DEFAULT_SEGMENT } c64d_pass_config_data_t; diff --git a/src/Tools/C64SettingsStorage.cpp b/src/Tools/C64SettingsStorage.cpp index 371d638f..905db7d8 100644 --- a/src/Tools/C64SettingsStorage.cpp +++ b/src/Tools/C64SettingsStorage.cpp @@ -209,6 +209,7 @@ CSlrString *c64SettingsPathToSymbols = NULL; CSlrString *c64SettingsPathToBreakpoints = NULL; CSlrString *c64SettingsPathToWatches = NULL; CSlrString *c64SettingsPathToDebugInfo = NULL; +CSlrString *c64SettingsDefaultSegment = NULL; bool c64SettingsUseNativeEmulatorMonitor = false; diff --git a/src/Tools/C64SettingsStorage.h b/src/Tools/C64SettingsStorage.h index eab4c2bd..90f4e6b7 100644 --- a/src/Tools/C64SettingsStorage.h +++ b/src/Tools/C64SettingsStorage.h @@ -202,6 +202,7 @@ extern CSlrString *c64SettingsPathToSymbols; extern CSlrString *c64SettingsPathToWatches; extern CSlrString *c64SettingsPathToBreakpoints; extern CSlrString *c64SettingsPathToDebugInfo; +extern CSlrString *c64SettingsDefaultSegment; extern bool c64SettingsUseNativeEmulatorMonitor;