-
Notifications
You must be signed in to change notification settings - Fork 328
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
target/riscv:Perform single step before resume if necessary #1144
base: riscv
Are you sure you want to change the base?
target/riscv:Perform single step before resume if necessary #1144
Conversation
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.
@sunnyzhu-learning, thank you for the patch.
Please note that hit
bits are optional and therefore the behavior of targets that don't support them should also be considered.
83a97ca
to
c2e204d
Compare
Q: Please note that |
c2e204d
to
8fad273
Compare
|
8fad273
to
0097f6b
Compare
I don't have a best solution to solve this question, above patch is a optimize solution, Please help with code review,thanks~ |
0097f6b
to
ec2818a
Compare
5f65be9
to
1062402
Compare
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 don't like this change in it's current state. The reason is:
- There are too many operations to derive
hit
field support that are performed in the most common case -- a trigger is not hit. - Handling
mcontrol
type does not consider the fact thatmcontrol.hit
field can be set for a matched trigger that did not fire. Therefore there can be a matchedmcontrol
trigger and another trigger that fired with a different timing that lackshit
field support.
My suggestion is:
When looking into which trigger was hit (riscv_trigger_detect_hit_bits()
):
r->need_single_step
is initializes tofalse
.- In case there is a
mcontrol
trigger (regardless if it has fired or not):r->need_single_step = true
due to the fact that there can be anothermcontrol
ormcontrol6
trigger that lackshit
field support and was hitbefore
. - In case there is a
mcontrol6
trigger: ifhit == after || hit == immed_after
r->need_single_step |= false
. This condition can be detected without any additional reads from the target. - In case of
itrigger
,etrigger
ortmexttrigger
triggerr->need_single_step = true
for the same reason asmcontrol
. - In case there is a trigger of some other type (if I'm correct only
icount
is unaccounted for at this point) that has it'shit
field set,r->need_single_step = false
.
IMHO this will cover the most common cases without the need for excessive investigation of hit
field support.
Please note: analyzing timings for |
When
Yeah,you are right,
your suggestion:
The solution is too crude, but I agree your suggestion, example: riscv-openocd/src/target/riscv/riscv.c Line 1649 in f9a1292
next patch changes to:
Internal discussion a lot, Disagree your suggestion,
I don't agree your suggestion, reference Debug spec 5.7.14 Description:
this can ensure
I agree, use default is ok.
this case first considering
I agree this change, next patch addressed it.
I agree this change, next patch addressed it. Last, Thanks a lot your suggestions, Helped me a lot~ |
The thing is, even when
See the comment in the discussion: #1144 (comment)
Yes, you are right. My mistake. |
e44b56d
to
c8332c6
Compare
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.
Overall I like the idea and thank you for this contribution.
Care needs to be taken that the feature is implemented correctly and that the code remains clear and understandable after the change.
Please, take a look at my comments.
cb0fa3f
to
aa8f517
Compare
aa8f517
to
d57f355
Compare
d57f355
to
1501150
Compare
addressed,move |
1501150
to
1095887
Compare
Two cases where single step is needed before resume: 1. ebreak used in software breakpoint; 2. a trigger that is taken just before the instruction that triggered it is retired. Signed-off-by: Songhe Zhu <[email protected]> Co-developed-by: Fei Gao <[email protected]> Co-developed-by: xiatianyi <[email protected]>
1095887
to
215ecda
Compare
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.
LGTM.
@sunnyzhu-learning Thank you for the contribution and for keeping up with the review suggestions.
Reason for modification:
wfi
in starting, this scene does not require single step behavior;@en-sc @JanMatCodasip please code review~