Skip to content

Commit

Permalink
Fixed a bug with relocating valuetype
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed May 26, 2022
1 parent 9c767bc commit d803e3e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
36 changes: 27 additions & 9 deletions ILRuntime/Runtime/Debugger/DebugService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,17 +1681,35 @@ internal unsafe void DumpStack(StackObject* esp, RuntimeStack stack)

for (var i = stack.ValueTypeStackBase; i > stack.ValueTypeStackPointer;)
{
var vt = domain.GetTypeByIndex(i->Value);
var cnt = i->ValueLow;
bool leak = leakVObj.Contains((long)i);
final.AppendLine("----------------------------------------------");
final.AppendLine(string.Format("{2}(0x{0:X8}){1}", (long)i, vt, leak ? "*" : ""));
for (int j = 0; j < cnt; j++)
try
{
var vt = domain.GetTypeByIndex(i->Value);
var cnt = i->ValueLow;
bool leak = leakVObj.Contains((long)i);
final.AppendLine("----------------------------------------------");
final.AppendLine(string.Format("{2}(0x{0:X8}){1}", (long)i, vt, leak ? "*" : ""));
for (int j = 0; j < cnt; j++)
{
StringBuilder sb = new StringBuilder();
var ptr = Minus(i, j + 1);
sb.Append(string.Format("(0x{0:X8}) Type:{1} ", (long)ptr, ptr->ObjectType));
GetStackObjectText(sb, ptr, mStack, valuePointerEnd);
final.AppendLine(sb.ToString());
}
}
catch
{
StringBuilder sb = new StringBuilder();
var ptr = Minus(i, j + 1);
sb.Append(string.Format("(0x{0:X8}) Type:{1} ", (long)ptr, ptr->ObjectType));
GetStackObjectText(sb, ptr, mStack, valuePointerEnd);
final.AppendLine("----------------------------------------------");
sb.Append(string.Format("*(0x{0:X8}) Type:{1} ", (long)i, i->ObjectType));
try
{
GetStackObjectText(sb, i, mStack, valuePointerEnd);
}
catch
{
sb.Append(" Cannot Fetch Object Info");
}
final.AppendLine(sb.ToString());
}
i = Minus(i, i->ValueLow + 1);
Expand Down
5 changes: 2 additions & 3 deletions ILRuntime/Runtime/Stack/RuntimeStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,12 @@ void RelocateValueType(StackObject* src, ref StackObject* dst, ref int mStackBas
StackObject* descriptor = ILIntepreter.ResolveReference(src);
if (descriptor > dst)
throw new StackOverflowException();
*dst = *descriptor;
IType type = intepreter.AppDomain.GetTypeByIndex(descriptor->Value);
int cnt, mCnt;
type.GetValueTypeSize(out cnt, out mCnt);
StackObject* startAddr = descriptor - 1;
StackObject* startAddr = descriptor;
StackObject* endAddr = descriptor - cnt;
StackObject* tarStartAddr = dst - 1;
StackObject* tarStartAddr = dst ;
StackObject* tarEndAddr = dst - cnt;
for(int i = 0; i < cnt; i++)
{
Expand Down

0 comments on commit d803e3e

Please sign in to comment.