Skip to content

Commit

Permalink
Debugger: GBA - Import missing ELF symbol objects, improve demangling…
Browse files Browse the repository at this point in the history
… logic
  • Loading branch information
SourMesen committed Sep 24, 2024
1 parent caf0835 commit 2d63259
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions UI/Debugger/Integration/ElfImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ private void PrivateImport(string path, bool showResult, CpuType cpuType)
continue;
}


//Demangle and replace any invalid characters with underscores
name = LabelManager.InvalidLabelRegex.Replace(Demangle(name), "_");

Expand Down Expand Up @@ -106,11 +105,11 @@ private static string Demangle(string name)
List<string> parts = new();
int i = 0;

while(i < name.Length && (name[i] < '0' || name[i] > '9')) {
i++;
}

while(true) {
while(i < name.Length && (name[i] < '0' || name[i] > '9')) {
i++;
}

bool hasLen = false;
int start = i;
while(i < name.Length && name[i] >= '0' && name[i] <= '9') {
Expand All @@ -121,7 +120,7 @@ private static string Demangle(string name)
if(hasLen) {
int val = int.Parse(name.AsSpan(start, i - start));

if(start + val <= name.Length) {
if(i + val <= name.Length) {
string part = name.Substring(i, val);
if(!string.IsNullOrWhiteSpace(part) && part != "_GLOBAL__N_1") {
parts.Add(part);
Expand Down Expand Up @@ -188,10 +187,6 @@ protected override bool TryGetSymbolInfo(SymbolEntry<uint> symbol, int romSize,
{
symbolInfo = null;

if(symbol.Type == SymbolType.Object) {
return false;
}

uint value = symbol.Value & ~(uint)0x01;
AddressInfo relAddr = new AddressInfo() { Address = (int)value, Type = MemoryType.GbaMemory };
AddressInfo absAddr = DebugApi.GetAbsoluteAddress(relAddr);
Expand Down

0 comments on commit 2d63259

Please sign in to comment.