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

Partially fix info frame for purecap RISC-V #41

Open
wants to merge 2 commits into
base: mips_cheri-8.3
Choose a base branch
from

Conversation

arichardson
Copy link
Member

Previously it would print:

(gdb) info fram
Stack level 5, frame at 0x3fffdfb770:
 pcc = 0x42294b32 in QV4::Scoped<QV4::Object>::Scoped(QV4::Scope const&, QV4::Value const*); saved pcc = 0x4229b4c4
 called by frame at 0x3fffdfb990, caller of frame at 0x3fffdfb6f0
 Arglist at 0x3fffdfb770, args:
 Locals at 0x3fffdfb770,That operation is not available on integers of more than 8 bytes.

by using extract_typed_address, I get the following:

(gdb) info frame
Stack level 5, frame at 0x3fffdfb770:
 pcc = 0x42294b32 in QV4::Scoped<QV4::Object>::Scoped(QV4::Scope const&, QV4::Value const*); saved pcc = 0x4229b4c4
 called by frame at 0x3fffdfb990, caller of frame at 0x3fffdfb6f0
 Arglist at 0x3fffdfb770, args:
 Locals at 0x3fffdfb770, Previous frame's sp is 0x3fffdfb770
 Saved registers:
  cra at 0x3fffdfb760, cfp at 0x3fffdfb750, pcc at 0x3fffdfb760

@arichardson arichardson requested a review from bsdjhb June 25, 2021 10:59
Copy link
Collaborator

@bsdjhb bsdjhb left a comment

Choose a reason for hiding this comment

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

I would probably split these into separate commits? What cares about the reggroup for cap registers I wonder?

gdb/stack.c Outdated Show resolved Hide resolved
@arichardson
Copy link
Member Author

I would probably split these into separate commits? What cares about the reggroup for cap registers I wonder?

I don't remember exactly why the first diff is needed, but after fixing the frame bits info frame ended up calling the regroup stuff and the asserted inside riscv_is_regnum_a_named_csr.

      if (riscv_is_regnum_a_named_csr (regnum))
        return 1;

Previously it would print:
```
(gdb) info fram
Stack level 5, frame at 0x3fffdfb770:
 pcc = 0x42294b32 in QV4::Scoped<QV4::Object>::Scoped(QV4::Scope const&, QV4::Value const*); saved pcc = 0x4229b4c4
 called by frame at 0x3fffdfb990, caller of frame at 0x3fffdfb6f0
 Arglist at 0x3fffdfb770, args:
 Locals at 0x3fffdfb770,That operation is not available on integers of more than 8 bytes.
```
by using `extract_typed_address`, I get the following:
```
(gdb) info frame
Stack level 5, frame at 0x3fffdfb770:
 pcc = 0x42294b32 in QV4::Scoped<QV4::Object>::Scoped(QV4::Scope const&, QV4::Value const*); saved pcc = 0x4229b4c4
 called by frame at 0x3fffdfb990, caller of frame at 0x3fffdfb6f0
 Arglist at 0x3fffdfb770, args:
 Locals at 0x3fffdfb770, Previous frame's sp is 0x3fffdfb770
 Saved registers:
  cra at 0x3fffdfb760, cfp at 0x3fffdfb750, pcc at 0x3fffdfb760
```
This ends up being called by `info frame` after the last commit and
triggers an assertion inside riscv_is_regnum_a_named_csr().
@@ -985,6 +985,8 @@ riscv_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
{
if (regnum < RISCV_FIRST_CSR_REGNUM || regnum == RISCV_PRIV_REGNUM)
return 1;
if (regnum >= RISCV_FIRST_CHERI_REGNUM && regnum <= RISCV_LAST_CHERI_REGNUM)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do wonder if the better fix is actually for the first 'if' here to be:

if (regnum < RISCV_FIRST_CSR_REGNUM || regnum > RISCV_LAST_CSR_REGNUM)
   return 1;

That is something I could upstream, or perhaps even:

if (regnum >= RISCV_FIRST_CSR_REGNUM && regnum <= RISCV_LAST_CSR_REGNUM)
    return riscv_is_regnum_a_named_csr (regnum);
return 1;

Copy link
Collaborator

Choose a reason for hiding this comment

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

This function is quite different upstream, so you can fix this however for now. Your existing patch is fine.

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.

2 participants