Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] Trace Log Implementation #7389

Closed
Abystus opened this issue Jan 29, 2015 · 4 comments
Closed

[Request] Trace Log Implementation #7389

Abystus opened this issue Jan 29, 2015 · 4 comments

Comments

@Abystus
Copy link

Abystus commented Jan 29, 2015

An option (on/off toggle found on the debugger) to create a text file that will log all assembly execution (w/ optional registers display) up until the option is toggled off. You should be have the ability to alter the file name of the output file from within the gui. Output format per line would be:

[Address] [Instruction Bytes] [Instruction Literal] [Optional Register Display]

Example:

...
0882BA94  00808825  move s1,a0     {Optional Register Display Here}
0882BA98  00408025  move s0,v0     {Optional Register Display Here}
0882BA9C  3C040003  lui  a0,0x3    {Optional Register Display Here}
...

This feature would be very beneficial to hackers as they can manually back trace through the log along the game's execution path in reverse from a breakpoint location with ease. Trace logs can also be compared to show differences in execution path between them, which is very useful for exposing harder to find hacks that are based on random chance.

@unknownbrackets
Copy link
Collaborator

Logging every instruction (when hundreds of millions can be run per second) would generate a /very/ large file and make the emulator /very/ slow.

We do have some options (in the code) to output code being compiled by the jit (so only the first time it's seen), but this will typically be very confusing for people trying to look for a trace - it would basically have missing sections.

We do now have the ability to set breakpoints with custom logging. So for example, you could add a breakpoint to the beginning of a function with "MyFunc({a0},{a1},{a2})" as the log message. Then it would log every call to that function.

Note also that we have other features that can help in this area;

  • Save states. You can save state while trapped.
  • Rewind. The emulator can automatically take save states for you at an interval.
  • Stack unwinding. On a breakpoint, you can see an estimated call stack.
  • Predictability. Every time you load a save state, the game code will operate the same way, generate the same random numbers, etc. (unless it reads/writes to the memstick.)

I think a full assembly trace log is impractical, though, as noted above.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

Quick note - I've started creating a WebSocket API to enable remote debugging. Once done, you could write some code to use stepping and create a log like this. See #10909 for more details.

While I still think a full assembly log is impractical, this would make it a lot easier to do this in your own code.

-[Unknown]

@unknownbrackets
Copy link
Collaborator

I'm going to close this now - as noted, you could theoretically implement a trace log now by setting breakpoints or stepping using the API.

-[Unknown]

@Nemoumbra
Copy link
Contributor

#19457

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants