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

target/riscv: report helpfull location during register decode #972

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

en-sc
Copy link
Collaborator

@en-sc en-sc commented Dec 1, 2023

LOG_TARGET_DEBUG() reports file, line and function name at the call
site. This information is not helpfull if it always points to the same
location inside log_debug_reg().

Additionally, avoid using VLA in log_debug_reg(), since OpenOCD style guide(doc/manual/style.txt) prohibits it:

  • use malloc() to create dynamic arrays. Do @b not use @c alloca
    or variable length arrays on the stack. non-MMU hosts(uClinux) and
    pthreads require modest and predictable stack usage.

en-sc added 2 commits December 1, 2023 16:45
`LOG_TARGET_DEBUG()` reports file, line and function name at the call
site. This information is not helpfull if it always points to the same
location inside `log_debug_reg()`.

Change-Id: Ib73be0344fb5c80c9ac8e5fdee1084d405522eb7
Signed-off-by: Evgeniy Naydanov <[email protected]>
OpenOCD style guide(`doc/manual/style.txt`) prohibits use of VLA:

> - use malloc() to create dynamic arrays. Do @b not use @c alloca
> or variable length arrays on the stack. non-MMU hosts(uClinux) and
> pthreads require modest and predictable stack usage.

Change-Id: I12e4a5087fd056d69866137237af6deca27f5d33
Signed-off-by: Evgeniy Naydanov <[email protected]>
Copy link
Collaborator

@timsifive timsifive left a comment

Choose a reason for hiding this comment

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

Looks good. Can you share a sample output line emitted by the new code?

@en-sc
Copy link
Collaborator Author

en-sc commented Dec 6, 2023

Prior to the change:

Debug: 82 2 riscv-013.c:307 log_debug_reg(): [riscv.cpu] dtmcs=0x61 { version=1.0, dmistat=0, idle=0, dmireset=0, dtmhardreset=0, errinfo=not implemented, abits=6, }

After:

Debug: 82 3 riscv-013.c:1870 examine(): [riscv.cpu] dtmcs=0x61 { version=1.0, dmistat=0, idle=0, dmireset=0, dtmhardreset=0, errinfo=not implemented, abits=6, }

This PR does not update debug_reg_printer.[ch], so the actual decoding string is flawed. Please, see this comment.

@timsifive timsifive merged commit 7c94814 into riscv-collab:riscv Dec 6, 2023
4 checks passed
@en-sc en-sc deleted the en-sc/decode-location branch August 14, 2024 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants