-
Notifications
You must be signed in to change notification settings - Fork 9
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
Watchpoint support #21
Conversation
…ame base register.
…iggers and unimplemented registers.
This supports triggers that do not have 'type' preset to 2.
Thanks, for your input. I will try to have a look this weekend |
These last tiny commits should make us happy! Do you still have an ESP32-C3 at hand? I'd love to hear a feedback about the break/watchpoint experience on it, especially whether the 'hit' bit is implemented, to test the associated algorithm. I usually start hosted whis DEBUG_INFO and DEBUG_TARGET verbosity:
I am interested in seeing the triggers enumeration on ESP32-C3. On GD32VF103, I get this output:
The
Which means the algorithm has switched to instruction decoding.
In case the watchpoint is not correctly found, the generic SIGTRAP signal is sent forever on
Have a nice weekend. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. Sorry for the pain to find it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: Possible white space change...
uint32_t tselect_saved, tdata1; | ||
uint32_t trigger_idx = 0U; | ||
uint16_t trigger_info = 0U; | ||
uint32_t mcontrol = CSR_TDATA1_TYPE(2) | CSR_MCONTROL_DMODE | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check for whitespace here too or run "git rebase --whitespace=fix origin/ruabmbua"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, CSR_MCONTROL_ACTION_DEBUG is shifted with spaces (not tabs) in order to make it aligned with the upper CSR_TDATA1_TYPE(2) in every editor, whatever the displayed width of the tab indentation by users. This is not an indentation actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git log --check flags this red:
"src/arch/riscv/rvdbg013.c:1596: indent with spaces.
-
CSR_MCONTROL_ACTION_DEBUG | CSR_MCONTROL_ENABLE_MASK;
"
Use as much tabs as possible and only fill the remainder with space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know of --check option, nice. But reading its help, it says a whitespace error is "a space character that is immediately followed by a tab character inside the initial indent of the line". Here, it is the opposite: tabs first for indentation, followed by a few space chars to align with upper line, as shown in this screenshot (tabs and spaces displayed with arrows and dots):
Also, git log --check doesn't report any error on my side:
$ git blame -L1502,+1 -- src/arch/riscv/rvdbg013.c
ffc9982b (Fabrice Prost-Boucle 2022-01-18 22:33:01 +0100 1502) ...
$ git log -n 1 --check ffc9982b
commit ffc9982b577121e91078c74b4f8cf3b38dee7c0e
Author: Fabrice Prost-Boucle <fabalthazar@falbalab.fr>
Date: Tue Jan 18 22:33:01 2022 +0100
Set triggers of type 2 explicitly and which have type 2 available.
This supports triggers that do not have 'type' preset to 2.
git version 2.34.1
False positive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you open the file in doubt in the review aspect on this page, you see solid darker green blocks for spaces where tab could be used. Just for your info, I hope not to annoy you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, my answer referred to line 1502 instead of 1596.
But I still see none "indent with spaces" around 1596.
Can you see this screenshot?
The only spaces you see are before CSR_MCONTROL_ACTION_DEBUG, to align with above CSR_TDATA1_TYPE(2). It will stay aligned whatever editor is used and how width it displays tabs.
These spaces follow one single tab which is a real indentation level.
In other words, there are a lot of spaces here but seem legitimate as long as the indentation level is respected.
I feel I start to bother you about a point I cannot get. grrr :)
The pain is largely rewarded by the working result. And I take it as an opportunity to read and learn a lot about RISC-V! Please explain me more what you mean with whitespace changes and I'll rebase the branch. |
I tried to run on a ESP32-C3, but the jtag_scan() detects the chain wrong. Did you have success? |
I have no ESP32-C3, unfortunately. |
Regarding ESP32-C3: The problem happens one step earlier, in the chain detection. I do not yet fully understand what is wrong and what is a good solution. Circumventing the problem I probably hit the Issue 1 you describe. I will recheck, when spare time allows. DX-Mon as one of the new project leads seem to not like the chain detection scheme and tend to revert, see blackmagic-debug#978 Regarding the idle cycles: The value announced by the device is used as a starting point, but eventually extended if the first read fails. |
Ah, the other ESP-C3 board is revision 3. As the ESP protocol is not (yet?) supported in BMP hosted, I needed to (permantently!) fuse the fuse to allow selection between internal JTAG and external:
|
I really like your test! The perfect example of a chip with tinfo unimplemented. If you enable TARGET debug messages (blackmagic -t -j -v5), I hope you see some "Trigger #x, tinfo unimplemented". Between a lot of DMI_Write/Read lines... We also see that a new line at the end of "RISC-V register 0x7a4 does not exist" is welcome. |
with -t -j -v 5. "Trigger #x, tinfo unimplemented" is seen as you expect. |
I will try to compile some platformio ESP32-C3 example, if there is one and will set breakpoint, debug and report asap. |
Hi Uwe,
Here is a handful of commits that implement watchpoints, both with the usual 'hit' bit method when available, instruction decoding otherwise.
For that, I also revisited the tigger enumeration/discovery to strictly follow the specification and hopefully support forthcoming chips with a variety of possible unavailable triggers or unimplemented registers (like tinfo).
I still get the 32-bit word reading problem time to time. When it occurs, the instruction decoding algorithm gets of course lost. I didn't touch the memory management parts.
This makes me think about what @kdv-temp reported to me about target_mem_read() misbehaviour in his RTT context. Needs more investigation.
Tell me if that is of interest or if it needs rework.
Best,
Fabrice