-
Notifications
You must be signed in to change notification settings - Fork 101
The last field of a register was not printed #908
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
Merged
Tim Newsome (timsifive)
merged 1 commit into
riscv:master
from
en-sc:en-sc/fix-reg-printers
Oct 25, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,11 +61,13 @@ static uint64_t riscv_debug_reg_field_value(riscv_debug_reg_field_info_t field, | |
| } | ||
|
|
||
| static unsigned int riscv_debug_reg_fields_to_s(char *buf, unsigned int offset, | ||
| riscv_debug_reg_field_list_t list, riscv_debug_reg_ctx_t context, uint64_t value) | ||
| struct riscv_debug_reg_field_list_t (*get_next)(riscv_debug_reg_ctx_t contex), | ||
| riscv_debug_reg_ctx_t context, uint64_t value) | ||
| { | ||
| unsigned int curr = offset; | ||
| curr += get_len_or_sprintf(buf, curr, " { "); | ||
| for (; list.get_next; list = list.get_next(context)) { | ||
| for (struct riscv_debug_reg_field_list_t list; get_next; get_next = list.get_next) { | ||
| list = get_next(context); | ||
|
Comment on lines
+69
to
+70
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see how the old code would omit the last field, because when list.get_next is NULL you still need to print out one more field. |
||
| curr += riscv_debug_reg_field_to_s(buf, curr, list.field, context, | ||
| riscv_debug_reg_field_value(list.field, value)); | ||
| curr += get_len_or_sprintf(buf, curr, ", "); | ||
|
|
@@ -85,8 +87,8 @@ unsigned int riscv_debug_reg_to_s(char *buf, enum riscv_debug_reg_ordinal reg_or | |
| length += print_number(buf, length, value); | ||
|
|
||
| if (reg.get_fields_head) | ||
| length += riscv_debug_reg_fields_to_s(buf, length, reg.get_fields_head(context), | ||
| context, value); | ||
| length += riscv_debug_reg_fields_to_s(buf, length, | ||
| reg.get_fields_head, context, value); | ||
|
|
||
| if (buf) | ||
| buf[length] = '\0'; | ||
|
|
||
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.
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.
Why do you need to pass a function get_next instead of the list?
Also, I'm surprised that there are no callers to this function that needed to be updated.
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.
IMHO it makes the loop more concise. If one were to transition to passing a list node, the loop would be required to be a
do ... while ()since there would always be at least one node. I findforloops easier to read. Don't you agree?This is a static function, only called from
riscv_debug_reg_to_s(). The appropriate adjustment (transition from passing a list node to passing a function pointer which generates such node) is made on line 90.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 missed the github info showing me that line 90 was a different function. Thanks for explaining. This is fine.