enhanced duplicated local label handling (fixes #1067)

This commit is contained in:
thrust26 2025-02-13 19:54:43 +01:00
parent 60e07663d1
commit d67ac42bbc
2 changed files with 21 additions and 4 deletions

View File

@ -619,15 +619,27 @@ bool CartDebug::addLabel(const string& label, uInt16 address)
case AddrType::IO: case AddrType::IO:
return false; return false;
default: default:
removeLabel(label); string newLabel = uniqueLabel(label);
myUserAddresses.emplace(label, address); myUserAddresses.emplace(newLabel, address);
myUserLabels.emplace(address, label); myUserLabels.emplace(address, newLabel);
myLabelLength = std::max(myLabelLength, static_cast<uInt16>(label.size())); myLabelLength = std::max(myLabelLength, static_cast<uInt16>(newLabel.size()));
mySystem.setDirtyPage(address); mySystem.setDirtyPage(address);
return true; return true;
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartDebug::uniqueLabel(const string& label)
{
string uniqueLabel = label;
int count = 0;
while(myUserAddresses.find(uniqueLabel) != myUserAddresses.end())
uniqueLabel = label + "." + std::to_string(++count);
return uniqueLabel;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDebug::removeLabel(const string& label) bool CartDebug::removeLabel(const string& label)
{ {

View File

@ -195,6 +195,11 @@ class CartDebug : public DebuggerSystem
*/ */
bool addLabel(const string& label, uInt16 address); bool addLabel(const string& label, uInt16 address);
/**
Make given (local) label unique by adding .<count> to it
*/
string uniqueLabel(const string& label);
/** /**
Remove the given label and its associated address. Remove the given label and its associated address.
Labels that reference either TIA or RIOT spaces will not be processed. Labels that reference either TIA or RIOT spaces will not be processed.