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

Debugger: Get target memory in load/store instructions #7675

Merged
merged 1 commit into from Apr 8, 2022

Conversation

Copy link
Contributor

@TryTwo TryTwo commented Jan 4, 2019

Backend:
Updates disassembler instructions. Mostly spaces and commas. PS load/store uses 0x notation. Required for new features.
Adds function to PPCDebugInterface to calculate target memory address for load/store instructions.

Code widget new feature:
-Context menu for copying or showing memory target in load/store instructions. Only works if the PC is near the instruction (register consistency).

/edit removed trace and diff for their own PRs
/edit2 changed breakpoint memory to 'show in memory'.

@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Jan 4, 2019

I could follow the "show in memory" context item to send the target memory address to the memory widget, rather than breakpoint or even copy it. If that's better?

Copy link
Member

@lioncash lioncash left a comment

I've reviewed the first three commits. The tracing and differencing change should be in its own PR (it's 1K+ LoC on its own, not counting other things), the other changes preceding it are fine by themselves in one PR, since they're mostly related.

Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Jan 5, 2019

Thanks for the detailed review, I'll work on it. Removing tracing and differencing. I see they should each have their own PR, though tracing does rely on this PR.

@TryTwo TryTwo changed the title Debugger code features Debugger: Get target memory in load/store instructions Jan 6, 2019
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Jan 10, 2019

I found one major issue with GekkoDisassembler. On load/stores that use a register for the offset (lwzx) if the offset register value is 0, then the offset is 0 and NOT r0. All others cases are normal (offset = 1 -> r1). I don't know how to correctly fix that. I will edit my PPCDebugInterface to deal with the error instead.

This error also applies to things like icbi. icbi r0, r4 should be icbi 0, r4.

Also, I dealt with all listed PR issues, but left a few open for discussion.

@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Jan 10, 2019

Fixed offset = 0 instead of r0.
Removed breakpoint target memory address context item.
Added show target memory in the memory widget context item. -- In practice you often want to BP it on write or on read, not both, so sending it to the memory widget and BPing it there works better..

Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.h Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Jan 22, 2019

Fixed everything I think needs fixing. Any open issues are left open for further comment, but may not need anything done.

Also tweaked:
PPCDebugInfo: I saw after recent changes I could remove one of the offset variables and just use one variable for both.
CodeViewWidget: Slightly reordered my additions in the context men, and "Show in memory" -> "Show instruction in &memory", since we have two show in memory options now I thought it should be more verbose.

@TryTwo TryTwo force-pushed the Debugger_Code_Features branch 3 times, most recently from ff18e68 to 2222c3e Compare Mar 9, 2022
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Mar 9, 2022

Would still be nice to see this old PR get accepted.

This PR has important base changes for the use of regex on PPC instructions. It is shared by my code tracing PR, which I haven't had time to work on. This would be a small, but definitely step in that direction and opening up new useful features to be added. After this PR, my plan is to implement the base tracing logic in another PR with a basic usable feature, then perhaps tackle the full code tracing PR again.

@TryTwo TryTwo requested a review from lioncash Mar 9, 2022
Source/Core/Common/DebugInterface.h Outdated Show resolved Hide resolved
Source/Core/Common/GekkoDisassembler.cpp Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.cpp Outdated Show resolved Hide resolved
Source/Core/Core/Debugger/PPCDebugInterface.h Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Mar 9, 2022

Side note: GekkoDisasm doesn't recognize when 0 needs to be 0 and not r0. I deal with this bug in my regex logic. lfsx f1, r0, r4 should be lfsx f1, 0, r4 for example. Too much work for me to identify every case and fix, I think. I'll check the bug reports to see if it's noted.

@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Mar 14, 2022

I think my commits are all good now, except for squashing. Am I expected to hit the re-request review every time I finish updating it? I don't know.

@TryTwo TryTwo requested a review from sepalani Mar 14, 2022
Copy link
Contributor

@sepalani sepalani left a comment

I think my commits are all good now, except for squashing. Am I expected to hit the re-request review every time I finish updating it? I don't know.

IIRC, it sends a notification to the reviewers. I think it's fine to use it when your PR is ready to be reviewed.

Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@sepalani sepalani left a comment

Other than that, LGTM.

Source/Core/Common/GekkoDisassembler.cpp Show resolved Hide resolved
…opy a load/store target memory address from instructions at or near PC when paused.
@TryTwo
Copy link
Contributor Author

@TryTwo TryTwo commented Mar 25, 2022

Ok, I think we're good.

Copy link
Contributor

@sepalani sepalani left a comment

LGTM

@AdmiralCurtiss
Copy link
Contributor

@AdmiralCurtiss AdmiralCurtiss commented Apr 8, 2022

It's a bit silly that you're reverse-engineering the register from the disassembled instruction string, but eh, seems to work well enough.

@AdmiralCurtiss AdmiralCurtiss merged commit 23508ca into dolphin-emu:master Apr 8, 2022
10 checks passed
@TryTwo TryTwo deleted the Debugger_Code_Features branch Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants