aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-12-04 22:52:39 -0200
committerGitHub <noreply@github.com>2018-12-04 22:52:39 -0200
commit3615a70cae3f89197fe185dfc5d0a47fa42151d9 (patch)
tree8e4737422fba15199c1a6ce7c6345996c0e907b5 /Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs
parent85dbb9559ad317a657dafd24da27fec4b3f5250f (diff)
Revert "Adjust naming conventions and general refactoring in HLE Project (#490)" (#526)
This reverts commit 85dbb9559ad317a657dafd24da27fec4b3f5250f.
Diffstat (limited to 'Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs')
-rw-r--r--Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs226
1 files changed, 113 insertions, 113 deletions
diff --git a/Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs b/Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs
index 9ef4ca8f..a6053b1b 100644
--- a/Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs
+++ b/Ryujinx.HLE/HOS/Kernel/HleProcessDebugger.cs
@@ -14,138 +14,138 @@ namespace Ryujinx.HLE.HOS.Kernel
{
private const int Mod0 = 'M' << 0 | 'O' << 8 | 'D' << 16 | '0' << 24;
- private KProcess _owner;
+ private KProcess Owner;
private class Image
{
- public long BaseAddress { get; }
+ public long BaseAddress { get; private set; }
- public ElfSymbol[] Symbols { get; }
+ public ElfSymbol[] Symbols { get; private set; }
- public Image(long baseAddress, ElfSymbol[] symbols)
+ public Image(long BaseAddress, ElfSymbol[] Symbols)
{
- BaseAddress = baseAddress;
- Symbols = symbols;
+ this.BaseAddress = BaseAddress;
+ this.Symbols = Symbols;
}
}
- private List<Image> _images;
+ private List<Image> Images;
- private int _loaded;
+ private int Loaded;
- public HleProcessDebugger(KProcess owner)
+ public HleProcessDebugger(KProcess Owner)
{
- _owner = owner;
+ this.Owner = Owner;
- _images = new List<Image>();
+ Images = new List<Image>();
}
- public void PrintGuestStackTrace(CpuThreadState threadState)
+ public void PrintGuestStackTrace(CpuThreadState ThreadState)
{
EnsureLoaded();
- StringBuilder trace = new StringBuilder();
+ StringBuilder Trace = new StringBuilder();
- trace.AppendLine("Guest stack trace:");
+ Trace.AppendLine("Guest stack trace:");
- void AppendTrace(long address)
+ void AppendTrace(long Address)
{
- Image image = GetImage(address, out int imageIndex);
+ Image Image = GetImage(Address, out int ImageIndex);
- if (image == null || !TryGetSubName(image, address, out string subName))
+ if (Image == null || !TryGetSubName(Image, Address, out string SubName))
{
- subName = $"Sub{address:x16}";
+ SubName = $"Sub{Address:x16}";
}
- else if (subName.StartsWith("_Z"))
+ else if (SubName.StartsWith("_Z"))
{
- subName = Demangler.Parse(subName);
+ SubName = Demangler.Parse(SubName);
}
- if (image != null)
+ if (Image != null)
{
- long offset = address - image.BaseAddress;
+ long Offset = Address - Image.BaseAddress;
- string imageName = GetGuessedNsoNameFromIndex(imageIndex);
+ string ImageName = GetGuessedNsoNameFromIndex(ImageIndex);
- string imageNameAndOffset = $"[{_owner.Name}] {imageName}:0x{offset:x8}";
+ string ImageNameAndOffset = $"[{Owner.Name}] {ImageName}:0x{Offset:x8}";
- trace.AppendLine($" {imageNameAndOffset} {subName}");
+ Trace.AppendLine($" {ImageNameAndOffset} {SubName}");
}
else
{
- trace.AppendLine($" [{_owner.Name}] ??? {subName}");
+ Trace.AppendLine($" [{Owner.Name}] ??? {SubName}");
}
}
- long framePointer = (long)threadState.X29;
+ long FramePointer = (long)ThreadState.X29;
- while (framePointer != 0)
+ while (FramePointer != 0)
{
- if ((framePointer & 7) != 0 ||
- !_owner.CpuMemory.IsMapped(framePointer) ||
- !_owner.CpuMemory.IsMapped(framePointer + 8))
+ if ((FramePointer & 7) != 0 ||
+ !Owner.CpuMemory.IsMapped(FramePointer) ||
+ !Owner.CpuMemory.IsMapped(FramePointer + 8))
{
break;
}
//Note: This is the return address, we need to subtract one instruction
//worth of bytes to get the branch instruction address.
- AppendTrace(_owner.CpuMemory.ReadInt64(framePointer + 8) - 4);
+ AppendTrace(Owner.CpuMemory.ReadInt64(FramePointer + 8) - 4);
- framePointer = _owner.CpuMemory.ReadInt64(framePointer);
+ FramePointer = Owner.CpuMemory.ReadInt64(FramePointer);
}
- Logger.PrintInfo(LogClass.Cpu, trace.ToString());
+ Logger.PrintInfo(LogClass.Cpu, Trace.ToString());
}
- private bool TryGetSubName(Image image, long address, out string name)
+ private bool TryGetSubName(Image Image, long Address, out string Name)
{
- address -= image.BaseAddress;
+ Address -= Image.BaseAddress;
- int left = 0;
- int right = image.Symbols.Length - 1;
+ int Left = 0;
+ int Right = Image.Symbols.Length - 1;
- while (left <= right)
+ while (Left <= Right)
{
- int size = right - left;
+ int Size = Right - Left;
- int middle = left + (size >> 1);
+ int Middle = Left + (Size >> 1);
- ElfSymbol symbol = image.Symbols[middle];
+ ElfSymbol Symbol = Image.Symbols[Middle];
- long endAddr = symbol.Value + symbol.Size;
+ long EndAddr = Symbol.Value + Symbol.Size;
- if ((ulong)address >= (ulong)symbol.Value && (ulong)address < (ulong)endAddr)
+ if ((ulong)Address >= (ulong)Symbol.Value && (ulong)Address < (ulong)EndAddr)
{
- name = symbol.Name;
+ Name = Symbol.Name;
return true;
}
- if ((ulong)address < (ulong)symbol.Value)
+ if ((ulong)Address < (ulong)Symbol.Value)
{
- right = middle - 1;
+ Right = Middle - 1;
}
else
{
- left = middle + 1;
+ Left = Middle + 1;
}
}
- name = null;
+ Name = null;
return false;
}
- private Image GetImage(long address, out int index)
+ private Image GetImage(long Address, out int Index)
{
- lock (_images)
+ lock (Images)
{
- for (index = _images.Count - 1; index >= 0; index--)
+ for (Index = Images.Count - 1; Index >= 0; Index--)
{
- if ((ulong)address >= (ulong)_images[index].BaseAddress)
+ if ((ulong)Address >= (ulong)Images[Index].BaseAddress)
{
- return _images[index];
+ return Images[Index];
}
}
}
@@ -153,42 +153,42 @@ namespace Ryujinx.HLE.HOS.Kernel
return null;
}
- private string GetGuessedNsoNameFromIndex(int index)
+ private string GetGuessedNsoNameFromIndex(int Index)
{
- if ((uint)index > 11)
+ if ((uint)Index > 11)
{
return "???";
}
- if (index == 0)
+ if (Index == 0)
{
return "rtld";
}
- else if (index == 1)
+ else if (Index == 1)
{
return "main";
}
- else if (index == GetImagesCount() - 1)
+ else if (Index == GetImagesCount() - 1)
{
return "sdk";
}
else
{
- return "subsdk" + (index - 2);
+ return "subsdk" + (Index - 2);
}
}
private int GetImagesCount()
{
- lock (_images)
+ lock (Images)
{
- return _images.Count;
+ return Images.Count;
}
}
private void EnsureLoaded()
{
- if (Interlocked.CompareExchange(ref _loaded, 1, 0) == 0)
+ if (Interlocked.CompareExchange(ref Loaded, 1, 0) == 0)
{
ScanMemoryForTextSegments();
}
@@ -196,115 +196,115 @@ namespace Ryujinx.HLE.HOS.Kernel
private void ScanMemoryForTextSegments()
{
- ulong oldAddress = 0;
- ulong address = 0;
+ ulong OldAddress = 0;
+ ulong Address = 0;
- while (address >= oldAddress)
+ while (Address >= OldAddress)
{
- KMemoryInfo info = _owner.MemoryManager.QueryMemory(address);
+ KMemoryInfo Info = Owner.MemoryManager.QueryMemory(Address);
- if (info.State == MemoryState.Reserved)
+ if (Info.State == MemoryState.Reserved)
{
break;
}
- if (info.State == MemoryState.CodeStatic && info.Permission == MemoryPermission.ReadAndExecute)
+ if (Info.State == MemoryState.CodeStatic && Info.Permission == MemoryPermission.ReadAndExecute)
{
- LoadMod0Symbols(_owner.CpuMemory, (long)info.Address);
+ LoadMod0Symbols(Owner.CpuMemory, (long)Info.Address);
}
- oldAddress = address;
+ OldAddress = Address;
- address = info.Address + info.Size;
+ Address = Info.Address + Info.Size;
}
}
- private void LoadMod0Symbols(MemoryManager memory, long textOffset)
+ private void LoadMod0Symbols(MemoryManager Memory, long TextOffset)
{
- long mod0Offset = textOffset + memory.ReadUInt32(textOffset + 4);
+ long Mod0Offset = TextOffset + Memory.ReadUInt32(TextOffset + 4);
- if (mod0Offset < textOffset || !memory.IsMapped(mod0Offset) || (mod0Offset & 3) != 0)
+ if (Mod0Offset < TextOffset || !Memory.IsMapped(Mod0Offset) || (Mod0Offset & 3) != 0)
{
return;
}
- Dictionary<ElfDynamicTag, long> dynamic = new Dictionary<ElfDynamicTag, long>();
+ Dictionary<ElfDynamicTag, long> Dynamic = new Dictionary<ElfDynamicTag, long>();
- int mod0Magic = memory.ReadInt32(mod0Offset + 0x0);
+ int Mod0Magic = Memory.ReadInt32(Mod0Offset + 0x0);
- if (mod0Magic != Mod0)
+ if (Mod0Magic != Mod0)
{
return;
}
- long dynamicOffset = memory.ReadInt32(mod0Offset + 0x4) + mod0Offset;
- long bssStartOffset = memory.ReadInt32(mod0Offset + 0x8) + mod0Offset;
- long bssEndOffset = memory.ReadInt32(mod0Offset + 0xc) + mod0Offset;
- long ehHdrStartOffset = memory.ReadInt32(mod0Offset + 0x10) + mod0Offset;
- long ehHdrEndOffset = memory.ReadInt32(mod0Offset + 0x14) + mod0Offset;
- long modObjOffset = memory.ReadInt32(mod0Offset + 0x18) + mod0Offset;
+ long DynamicOffset = Memory.ReadInt32(Mod0Offset + 0x4) + Mod0Offset;
+ long BssStartOffset = Memory.ReadInt32(Mod0Offset + 0x8) + Mod0Offset;
+ long BssEndOffset = Memory.ReadInt32(Mod0Offset + 0xc) + Mod0Offset;
+ long EhHdrStartOffset = Memory.ReadInt32(Mod0Offset + 0x10) + Mod0Offset;
+ long EhHdrEndOffset = Memory.ReadInt32(Mod0Offset + 0x14) + Mod0Offset;
+ long ModObjOffset = Memory.ReadInt32(Mod0Offset + 0x18) + Mod0Offset;
while (true)
{
- long tagVal = memory.ReadInt64(dynamicOffset + 0);
- long value = memory.ReadInt64(dynamicOffset + 8);
+ long TagVal = Memory.ReadInt64(DynamicOffset + 0);
+ long Value = Memory.ReadInt64(DynamicOffset + 8);
- dynamicOffset += 0x10;
+ DynamicOffset += 0x10;
- ElfDynamicTag tag = (ElfDynamicTag)tagVal;
+ ElfDynamicTag Tag = (ElfDynamicTag)TagVal;
- if (tag == ElfDynamicTag.DT_NULL)
+ if (Tag == ElfDynamicTag.DT_NULL)
{
break;
}
- dynamic[tag] = value;
+ Dynamic[Tag] = Value;
}
- if (!dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out long strTab) ||
- !dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out long symTab) ||
- !dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out long symEntSize))
+ if (!Dynamic.TryGetValue(ElfDynamicTag.DT_STRTAB, out long StrTab) ||
+ !Dynamic.TryGetValue(ElfDynamicTag.DT_SYMTAB, out long SymTab) ||
+ !Dynamic.TryGetValue(ElfDynamicTag.DT_SYMENT, out long SymEntSize))
{
return;
}
- long strTblAddr = textOffset + strTab;
- long symTblAddr = textOffset + symTab;
+ long StrTblAddr = TextOffset + StrTab;
+ long SymTblAddr = TextOffset + SymTab;
- List<ElfSymbol> symbols = new List<ElfSymbol>();
+ List<ElfSymbol> Symbols = new List<ElfSymbol>();
- while ((ulong)symTblAddr < (ulong)strTblAddr)
+ while ((ulong)SymTblAddr < (ulong)StrTblAddr)
{
- ElfSymbol sym = GetSymbol(memory, symTblAddr, strTblAddr);
+ ElfSymbol Sym = GetSymbol(Memory, SymTblAddr, StrTblAddr);
- symbols.Add(sym);
+ Symbols.Add(Sym);
- symTblAddr += symEntSize;
+ SymTblAddr += SymEntSize;
}
- lock (_images)
+ lock (Images)
{
- _images.Add(new Image(textOffset, symbols.OrderBy(x => x.Value).ToArray()));
+ Images.Add(new Image(TextOffset, Symbols.OrderBy(x => x.Value).ToArray()));
}
}
- private ElfSymbol GetSymbol(MemoryManager memory, long address, long strTblAddr)
+ private ElfSymbol GetSymbol(MemoryManager Memory, long Address, long StrTblAddr)
{
- int nameIndex = memory.ReadInt32(address + 0);
- int info = memory.ReadByte (address + 4);
- int other = memory.ReadByte (address + 5);
- int shIdx = memory.ReadInt16(address + 6);
- long value = memory.ReadInt64(address + 8);
- long size = memory.ReadInt64(address + 16);
+ int NameIndex = Memory.ReadInt32(Address + 0);
+ int Info = Memory.ReadByte (Address + 4);
+ int Other = Memory.ReadByte (Address + 5);
+ int SHIdx = Memory.ReadInt16(Address + 6);
+ long Value = Memory.ReadInt64(Address + 8);
+ long Size = Memory.ReadInt64(Address + 16);
- string name = string.Empty;
+ string Name = string.Empty;
- for (int chr; (chr = memory.ReadByte(strTblAddr + nameIndex++)) != 0;)
+ for (int Chr; (Chr = Memory.ReadByte(StrTblAddr + NameIndex++)) != 0;)
{
- name += (char)chr;
+ Name += (char)Chr;
}
- return new ElfSymbol(name, info, other, shIdx, value, size);
+ return new ElfSymbol(Name, Info, Other, SHIdx, Value, Size);
}
}
} \ No newline at end of file