diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-04-22 01:21:49 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-04-22 01:22:46 -0300 |
| commit | bd9b1e2c6b912c7cdab55ec6acc063c88a59cff1 (patch) | |
| tree | 077ab8da47828f9fd23893eeefa54c7d8fb2a314 /ChocolArm64/State | |
| parent | 4906acdde96c09b4e12a3801a4bacd5233a2f8e6 (diff) | |
Stub a few services, add support for generating call stacks on the CPU
Diffstat (limited to 'ChocolArm64/State')
| -rw-r--r-- | ChocolArm64/State/AThreadState.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ChocolArm64/State/AThreadState.cs b/ChocolArm64/State/AThreadState.cs index 6f3f62f6..ce127886 100644 --- a/ChocolArm64/State/AThreadState.cs +++ b/ChocolArm64/State/AThreadState.cs @@ -1,5 +1,6 @@ using ChocolArm64.Events; using System; +using System.Collections.Generic; using System.Diagnostics; namespace ChocolArm64.State @@ -56,10 +57,17 @@ namespace ChocolArm64.State public event EventHandler<AInstExceptionEventArgs> SvcCall; public event EventHandler<AInstUndefinedEventArgs> Undefined; + private Stack<long> CallStack; + private static Stopwatch TickCounter; private static double HostTickFreq; + public AThreadState() + { + CallStack = new Stack<long>(); + } + static AThreadState() { HostTickFreq = 1.0 / Stopwatch.Frequency; @@ -83,5 +91,27 @@ namespace ChocolArm64.State { Undefined?.Invoke(this, new AInstUndefinedEventArgs(Position, RawOpCode)); } + + internal void EnterMethod(long Position) + { + CallStack.Push(Position); + } + + internal void ExitMethod() + { + CallStack.TryPop(out _); + } + + internal void JumpMethod(long Position) + { + CallStack.TryPop(out _); + + CallStack.Push(Position); + } + + public long[] GetCallStack() + { + return CallStack.ToArray(); + } } }
\ No newline at end of file |
