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

Conditional breakpoints #11015

Merged
merged 7 commits into from Nov 13, 2022

Conversation

TryTwo
Copy link
Contributor

@TryTwo TryTwo commented Aug 28, 2022

A rebase of abandoned #9334 and fixed the one issue posted in that PR.

To Do in future PRs:

  • Add callstack-based conditionals.
  • Add string support for symbol conditional.
  • Expand to memory breakpoints.
  • Improve writing to registers/memory. Does not seem to work conditionally.
  • Make a help window.

If anyone thinks I should add any of those points to this PR let me know.

Jit and JitAsm have " ABI_CallFunction(PowerPC::CheckBreakPoints); ", which I think causes the breakpoint check to happen twice and two breakpoint log messages are made for one hit. Is that intentional?

/edit Check my private branch here for a branch with callstack and memory breakpoints.

@TryTwo
Copy link
Contributor Author

TryTwo commented Aug 31, 2022

Can I run a format on the external expr.h? I need to edit it and it's annoying with the format style mismatches.

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I run a format on the external expr.h? I need to edit it and it's annoying with the format style mismatches.

I'm fine with it as long as it's on a separated commit.

I don't have the expertise to review expr, however.

Source/Core/Core/PowerPC/BreakPoints.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/BreakPoints.cpp Outdated Show resolved Hide resolved
Source/Core/DolphinLib.props Outdated Show resolved Hide resolved
Source/Core/DolphinLib.props Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.h Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 3, 2022

Thanks for the review. Since the original commits aren't mine should I add the fixes in a new commit or is normal to just edit the old ones?

@sepalani
Copy link
Contributor

sepalani commented Sep 3, 2022

Thanks for the review. Since the original commits aren't mine should I add the fixes in a new commit or is normal to just edit the old ones?

I think editing the original commit is fine as long as it retains authorship.

@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 3, 2022

Ok great. Also, trying to add fixes to the correct commit is a pain. Is it okay if I squash it? Some newer commits are overwriting changes in older commits anyway.

@sepalani
Copy link
Contributor

sepalani commented Sep 3, 2022

Sure feel free to as long as it doesn't make them too big or hard to review I guess.

@TryTwo TryTwo force-pushed the Conditional_Breakpoints branch 2 times, most recently from afefdae to 634ff62 Compare September 3, 2022 23:05
@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 3, 2022

Hopefully my commit squash/re-arrange is acceptable. I finally forced VS to fix the props files with an Untabify option.

Not 100% sure what includes are needed in Expression.cpp there might have been leftovers that aren't needed.

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's working as intended with some caveats. I don't know when an expression I've written is valid. For instance, foo == bar is evaluated to true, ditto for 1 / 0. I also think there should be a help button to explain what kind of condition is intended and what is allowed/set (especially for variables) and what isn't.

If you lack of inspiration for the help message, I've written one in one of my draft.

Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 5, 2022

When I add conditionals for memory break points, it will use the same conditional box, so I will have to move things around in the UI along with the help button.

Should we have multiple help buttons at the bottom or just have the conditional one inline with the condition box?

@Pokechu22
Copy link
Contributor

Thanks for the review. Since the original commits aren't mine should I add the fixes in a new commit or is normal to just edit the old ones?

You may also want to look into Co-authored-by.

@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 7, 2022

Thanks, but adding co-author seems like a big hassle for my setup. Only using windows command line + visual studio, neither of which supports adding it. I think it's okay as-is.

@AdmiralCurtiss
Copy link
Contributor

?? What do you mean 'neither supports'? It's just part of the commit message, and you clearly can write commit messages.

@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 8, 2022

I don't believe it's just adding a footnote to the commit. It's a special formatting to update the embedded author stuff.

@sepalani
Copy link
Contributor

sepalani commented Sep 8, 2022

Thanks, but adding co-author seems like a big hassle for my setup. Only using windows command line + visual studio, neither of which supports adding it. I think it's okay as-is.

My current setup is similar and I don't think I had this issue. Which specific steps did you have trouble with? You can use git rebase -i or git commit --amend to edit the commit message using an interactive way. As Pokechu22 and AdmiralCurtiss said it's just part of the commit message:

@JosJuice
Copy link
Member

JosJuice commented Sep 8, 2022

I don't believe it's just adding a footnote to the commit. It's a special formatting to update the embedded author stuff.

Author and committer yes, co-author no.

@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 8, 2022

Ohhh. Thanks for clearing that up. It seemed like it would change the author/committer stuff, but I guess not!

@TryTwo
Copy link
Contributor Author

TryTwo commented Sep 10, 2022

What's next for this? Does expr.h need a full review? And are the templates returning double acceptable as-is?

I didn't find any bugs when testing the various methods I put in the help commit.

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's next for this? Does expr.h need a full review?

Ideally, yes. Though, it's only used in the debugger, in a single entry-point being the BP's condition so I'm not strongly opposed to the inclusion of this external library.

And are the templates returning double acceptable as-is?

I'm fine with the current state as its documented.

Source/Core/DolphinQt/Debugger/NewBreakpointDialog.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Show resolved Hide resolved
smurf3tte and others added 5 commits October 6, 2022 21:34
Expression class to store compiled expressions and associated variable list.

Co-authored-by:  TryTwo <taolas@gmail.com>
- Support hex prefix 0x or OX
- Support scientific notation

Also, reconcile the bitwise complement operator with C (use ~ instead of ^).
This is necessary to retain precision above 32 bits, but more importantly to prevent an expression like (0x80000000 | 1) from flipping the sign of the result.
This allows for easy reinterpretation of GPRs in an expression.

Co-authored-by:  TryTwo <taolas@gmail.com>
Co-authored-by:  TryTwo <taolas@gmail.com>
@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 7, 2022

Rebase no changes

Source/Core/Core/PowerPC/Expression.cpp Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 8, 2022

Applying the standard formatting to expr.h without any other changes first. Then I will add the changes, so it is easy to see in Compare.

@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 8, 2022

Ok I hit a problem from lack of experience. static double expr_eval(struct expr* e) is recursive. It keeps calling itself to chunk through each part of the expression until it's done. We want to see if any individual calculation comes back NaN. That's easy, but then we want to return a flag if it's NaN. If I send bool* hit_a_nan into the function, so I can flag it, then would I have to edit it into every recursive function call as well?

I feel like that's not the proper way to do it.

@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 8, 2022

Alright, removing the changes to expr.h and going to create a new logging/error checking commit for expression.

@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 8, 2022

Still needs a little work. Couldn't decide on the best way to continually append the string. stringstream? sprintf? fmt?

Also, I was thinking any variable that starts with an "r" could be changed into a 32 bit hexadecimal string. It would give more meaningful output to registers and some user control over the output format. Or does that seem like too much?

@TryTwo
Copy link
Contributor Author

TryTwo commented Oct 10, 2022

The only real issue I see is how spammy it will be if you encounter a NaN. Especially the OSD spam. Not sure if it can be told to only make an OSD if one doesn't exist or something.

I still need to update the help button.

Copy link
Contributor

@sepalani sepalani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside that and the lint error, this seems to work as expected.

Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
Source/Core/Core/PowerPC/Expression.cpp Outdated Show resolved Hide resolved
@TryTwo
Copy link
Contributor Author

TryTwo commented Nov 4, 2022

@AdmiralCurtiss What do you think, ready to go?

I've got two/three more PRs ready to add more features to this.

Copy link
Contributor

@AdmiralCurtiss AdmiralCurtiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this looks good to me.

@AdmiralCurtiss AdmiralCurtiss merged commit 2a81fa6 into dolphin-emu:master Nov 13, 2022
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants