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

Draft: RISC-V support #829

Closed
wants to merge 4 commits into from
Closed

Conversation

TobiasFaller
Copy link
Contributor

@TobiasFaller TobiasFaller commented Sep 17, 2020

This will be my attempt to implement RISC-V support (#735) for Pwndbg.
Capstone has RISC-V support only in the next branch, so this pull request will stay open until the new release version 5.0.0 is released.
Feel free to give feedback.

@TobiasFaller
Copy link
Contributor Author

There are currently some bugs in Capstone / the Python bindings.
This should be fixed soon.

See:
capstone-engine/capstone#1690
capstone-engine/capstone#1691

@TobiasFaller
Copy link
Contributor Author

TobiasFaller commented Sep 18, 2020

This post has been moved to a separate pull request #830.

pwndbg/regs.py Outdated Show resolved Hide resolved
@disconnect3d
Copy link
Member

@TobiasFaller there seem to be a conflict; can u fix it soo we can merge it? :)

@TobiasFaller
Copy link
Contributor Author

TobiasFaller commented Dec 14, 2020

@TobiasFaller there seem to be a conflict; can u fix it soo we can merge it? :)

Yeah, sure. As this is still a WIP I have not rebased it yet.
I will update this MR after Feb. the 18th.

@TobiasFaller
Copy link
Contributor Author

TobiasFaller commented Mar 4, 2021

Updates: capstone-engine/capstone#1690 has now been merged too.

@TobiasFaller TobiasFaller changed the title [WIP] RISC-V support Draft: RISC-V support Jul 19, 2021
@TobiasFaller TobiasFaller changed the title Draft: RISC-V support [WIP] RISC-V support Jul 19, 2021
@TobiasFaller
Copy link
Contributor Author

TobiasFaller commented Jul 19, 2021

Update: There has not been a release of aquynh/capstone with RISC-V support yet. Maybe it is time to move to a more active project / fork?

@disconnect3d
Copy link
Member

Maybe it is time to move to a more active project / fork?

Is there actually a fork that is more active or/and supports RISC-V?

@lyctw
Copy link

lyctw commented Mar 10, 2022

Hi
Does RISC-V support still wait for Capstone 5.0.0 release?

@TobiasFaller
Copy link
Contributor Author

Hi Dose RISC-V support still wait for Capstone 5.0.0 release?

Yes, but the first release candidates seem to have been released ten days ago which means it's probably not long before a stable release will be done.

Please keep in mind that this RISC-V extension's code has not been fully tested yet and can only be considered a prototype.
I'll probably get back to this implementation in the next weeks.

@TobiasFaller TobiasFaller changed the title [WIP] RISC-V support Draft: RISC-V support Mar 10, 2022
@disconnect3d
Copy link
Member

@TobiasFaller ping :)

@TobiasFaller
Copy link
Contributor Author

@TobiasFaller ping :)

Still waiting for a stable capstone 5.0 release.

@lonnywong
Copy link
Contributor

@disconnect3d @TobiasFaller

It's been a long time. Can we support RISC-V without capstone?

How about make a simple disassembler by calling

instr = gdb.execute("x/i %#x" % address, to_string=True)

lonnywong added a commit to lonnywong/pwndbg that referenced this pull request Aug 24, 2022
base on pwndbg#829 by Tobias Faller <faller@endiio.com>
lonnywong added a commit to lonnywong/pwndbg that referenced this pull request Aug 30, 2022
base on pwndbg#829 by Tobias Faller <faller@endiio.com>
lonnywong added a commit to lonnywong/pwndbg that referenced this pull request Aug 30, 2022
base on pwndbg#829 by Tobias Faller <faller@endiio.com>
disconnect3d pushed a commit that referenced this pull request Aug 30, 2022
* add riscv:rv64 registers

base on #829 by Tobias Faller <faller@endiio.com>

* disassemble without capstone to support other architectures

* ignore gdb.error on context_backtrace
@FantasqueX
Copy link

FantasqueX commented Sep 14, 2022

Really want this feature. Encounter some difficulty when debugging on riscv64 hardware without pwndbg. Thanks everyone working on this issue in advance.

Update: I'll try the one in master branch.

@disconnect3d
Copy link
Member

@FantasqueX pls let me know if and how the dev/latest version works for u!

@disconnect3d
Copy link
Member

@TobiasFaller fwiw we could potentially use the release candidate version too. I'm rather okay with it, as long as we give a choice to users to switch between the current solution and capstone based one.

@TobiasFaller
Copy link
Contributor Author

@TobiasFaller fwiw we could potentially use the release candidate version too. I'm rather okay with it, as long as we give a choice to users to switch between the current solution and capstone based one.

@disconnect3d Okay, I'll see what I can do and how to make the release candidate version usable. I'll need to validate and rebase the current implementation though, so it will take time.

@Xeonacid
Copy link
Contributor

@disconnect3d Okay, I'll see what I can do and how to make the release candidate version usable. I'll need to validate and rebase the current implementation though, so it will take time.

Hi. How is it going? Is there anything I can do to help? I'm very interested in this work.

@disconnect3d
Copy link
Member

@Xeonacid Hi! Sure, you can help :)

We added some basic support for riscv:rv64 in #1588.

To work with RISC-V further we need to:

  1. Add other RISC-V architecture variants: mainly, make sure we map registers properly and that we have a corresponding Capstone disassebler. If there is no Capstone disassembler, we have to fallback to the GDB one somehow.
  2. Ideally, add some basic qemu tests for those ("does it launch without crash", "does it provide correct registers, disassembly and stack output", etc)
  3. Extend the support to enhance the disassembly: this is what DisassemblyAssistant can be used for. Note that this feature overall may need some overwork as it was mainly designed for x86/x64 stuff.

Generally, I think we should close this draft since it is conflicted and not worked upon anyway, but one can base upon this and extend Pwndbg further.

@Xeonacid
Copy link
Contributor

@Xeonacid Hi! Sure, you can help :)

We added some basic support for riscv:rv64 in #1588.

To work with RISC-V further we need to:

  1. Add other RISC-V architecture variants: mainly, make sure we map registers properly and that we have a corresponding Capstone disassebler. If there is no Capstone disassembler, we have to fallback to the GDB one somehow.
  2. Ideally, add some basic qemu tests for those ("does it launch without crash", "does it provide correct registers, disassembly and stack output", etc)
  3. Extend the support to enhance the disassembly: this is what DisassemblyAssistant can be used for. Note that this feature overall may need some overwork as it was mainly designed for x86/x64 stuff.

Generally, I think we should close this draft since it is conflicted and not worked upon anyway, but one can base upon this and extend Pwndbg further.

Thanks for the information! I will work on this.

@disconnect3d
Copy link
Member

Thanks for the information! I will work on this.

Great! If you have any questions, you can also ask on our Discord: https://discord.gg/9rrbG3yt

@disconnect3d
Copy link
Member

I am closing this PR for now

peace-maker added a commit to peace-maker/pwndbg that referenced this pull request May 2, 2023
This is a resurrection of pwndbg#829

Co-authored-by: Tobias Faller <faller@endiio.com>
peace-maker added a commit to peace-maker/pwndbg that referenced this pull request May 30, 2023
This is a resurrection of pwndbg#829

Co-authored-by: Tobias Faller <faller@endiio.com>
peace-maker added a commit to peace-maker/pwndbg that referenced this pull request Jun 26, 2023
This is a resurrection of pwndbg#829

Co-authored-by: Tobias Faller <faller@endiio.com>
peace-maker added a commit to peace-maker/pwndbg that referenced this pull request Jun 26, 2023
This is a resurrection of pwndbg#829

Co-authored-by: Tobias Faller <faller@endiio.com>
peace-maker added a commit to peace-maker/pwndbg that referenced this pull request Jun 26, 2023
This is a resurrection of pwndbg#829

Co-authored-by: Tobias Faller <faller@endiio.com>
disconnect3d pushed a commit that referenced this pull request Jul 4, 2023
* Improve RISCV support

This is a resurrection of #829

Co-authored-by: Tobias Faller <faller@endiio.com>

* Silence bogus vermin warning

* Fix relative backwards jump calculations

The target address wouldn't be truncated to the pointer size.

* Add basic qemu-user test

* Run qemu-user tests in CI

* Make shfmt happy

* Fix pwntools < 4.11.0 support

* Support RISCV32 for pwntools < 4.11.0 as well

---------

Co-authored-by: Tobias Faller <faller@endiio.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants