Clear RISC-V hart triggers during attach/detach#2194
Open
ALTracer wants to merge 3 commits intoblackmagic-debug:mainfrom
Open
Clear RISC-V hart triggers during attach/detach#2194ALTracer wants to merge 3 commits intoblackmagic-debug:mainfrom
ALTracer wants to merge 3 commits intoblackmagic-debug:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Detailed description
riscv_attach()&riscv_detach().Normally GDB is supposed to set-unset all break/watch points (Z/z-packets) on every halt/resume, and remove them before detach. However, for unrelated reasons, when I used
blackpill-f411ceagainst GD32VF103CB, sometimes it got stuck busy-looping during ordinary step/next/finish commands (automatically using hardware breakpoints). Then I Ctrl+C out twice from GDB to disconnect, do ausbreset 003/012against "BMP",tionotifies me it Disconnected/Connected to ttyBmpTarg, and again I start GDB, scan, attach, continue debugging -- here GDB/BMP don't know that some of 4 triggers are in use, will report SIGTRAP when these hit, but won't let me easily remove them. One workaround is to enqueue 4 different breakpoints and resume+halt once; another is to power-cycle the target (which is not applicable to every board, consider battery-powered devices).This is also reproducible with BMDA. Additionally, if you try to step/continue across any watchpoint that hits, GDB+BMD busyloop each other with "breakpoint hit" (actually watchpoint) -- "vCont" with no way out. I suppose this is a separate issue, but clearing out triggers helps to back out of it.
Cortex-M layer clears out FPB and DWT comparators during attach/detach, Cortex-A/R layer clears out DBG_WCR/WVR (watchpoint control/value) of Debug Unit during attach/detach, too. I'm not sure why, and I also have opinions about DWT being possibly used by firmware for realtime trace. But let's bring RISC-V layer to feature parity with them.
Question for testing. What happens on targets which implement 0 trigger slots? WARL semantics allow both loops to execute once with no side effects? There is another issue where BMD reports 1 trigger discovered (0++ equals 1) even if it's not implemented.
Your checklist for this pull request
Closing issues