Skip to content

Commit

Permalink
Resolved #429
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Dec 16, 2020
1 parent 3224830 commit f516569
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ILRuntime/Runtime/Enviorment/AppDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public unsafe AppDomain()
loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
var mi = typeof(System.Runtime.CompilerServices.RuntimeHelpers).GetMethod("InitializeArray");
RegisterCLRMethodRedirection(mi, CLRRedirections.InitializeArray);
mi = typeof(AppDomain).GetMethod("GetCurrentStackTrace");
RegisterCLRMethodRedirection(mi, CLRRedirections.GetCurrentStackTrace);
foreach (var i in typeof(System.Activator).GetMethods())
{
if (i.Name == "CreateInstance" && i.IsGenericMethodDefinition)
Expand Down Expand Up @@ -233,6 +235,11 @@ public void LoadAssemblyFile(string path)
}
}

public string GetCurrentStackTrace()
{
throw new NotSupportedException("Cannot call this method from CLR side");
}

#if USE_MDB || USE_PDB
/// <summary>
/// 加载Assembly 文件和PDB文件或MDB文件,从指定的路径(PDB和MDB文件按默认命名方式,并且和Assembly文件处于同一目录中
Expand Down
7 changes: 7 additions & 0 deletions ILRuntime/Runtime/Enviorment/CLRRedirections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ namespace ILRuntime.Runtime.Enviorment
{
unsafe static class CLRRedirections
{
public static StackObject* GetCurrentStackTrace(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj)
{
StackObject* ret = esp - 1 - 1;
intp.Free(esp - 1);

return ILIntepreter.PushObject(ret, mStack, intp.AppDomain.DebugService.GetStackTrace(intp));
}
public static StackObject* CreateInstance(ILIntepreter intp, StackObject* esp, IList<object> mStack, CLRMethod method, bool isNewObj)
{
IType[] genericArguments = method.GenericArguments;
Expand Down
5 changes: 5 additions & 0 deletions TestCases/LightTester1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,11 @@ static void UnitTest_1014Sub(ref int a)
}
}

public static void UnitTest_1015()
{
Console.WriteLine(ILRuntimeTest.TestMainForm._app.GetCurrentStackTrace());
}

public class TestClass<T> where T : class, new()
{
public T tValue;
Expand Down

0 comments on commit f516569

Please sign in to comment.