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

lldb RISC-V support #55383

Open
kasperk81 opened this issue May 11, 2022 · 20 comments
Open

lldb RISC-V support #55383

kasperk81 opened this issue May 11, 2022 · 20 comments

Comments

@kasperk81
Copy link

On RISC-V, gdb is not always a suitable option to debug programs, especially for folks who use lldb plugins on other architectures. Without the working lldb, debugging code can be quite challenging.

D62732 is in review for over three years and there is no indication whether it is moving forward or abandoned. I realize that it is a matter of prioritization, but if someone else in the community can help with testing on riscv64/32, please do so. Or better yet, if you are familiar with lldb code-base, resubmit the patch.

@llvmbot
Copy link
Member

llvmbot commented May 11, 2022

@llvm/issue-subscribers-backend-risc-v

@llvmbot
Copy link
Member

llvmbot commented May 11, 2022

@llvm/issue-subscribers-lldb

@DavidSpickett
Copy link
Collaborator

Someone asked about this on Discord, so clearly we need a bit of an update here.

The referenced Phab review did later land as 847de9c.

Recently we got corefile support for RISC-V 64: d3a9043

Before that, Emmer added all the register information and a whole bunch of instructions to the emulation plugin. I think this was needed due to a lack of hardware single step (a standardized one at least).

I've been told the basics work when connecting to qemu at least, but I don't know about a native RISC-V system and there's no publuc build bot for either configuration.

If anyone does try lldb and has problems, please raise issues for them, it helps a lot just to know they exist.

@tedwoodward you seem to have been in this area last year, do you know what the state is?

@tedwoodward
Copy link

Earlier this year, Qualcomm released a toolchain based on LLVM 18.0 that included LLDB. It works with RISC-V 32 and 64, tested with Linux user space QEMU.

Our team is working on getting the LLDB test suite running for RISC-V 32 using QEMU, and plan to upstream support when it's in good shape. I'd like to run a bot in the llvm farm, but we haven't had that discussion internally. If not us, I'd like the tests to be set up so anyone could get RISC-V QEMU and run LLDB tests with it.

I don't think we've got any debug on hardware yet. Maybe when there is more hardware, and RISC-V Linux is more mature we could port lldb-server to it, and run remote tests on hardware (or system QEMU). Or JTAG with OpenOCD.

@kasperk81
Copy link
Author

Debian also just enabled lldb for llvm-18 https://salsa.debian.org/pkg-llvm-team/llvm-toolchain/-/merge_requests/137 (soon to be landed in unstable hopefully soon..)

need to enable it for Alpine, here is MR https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/68640

plugins support is needed to get stuff like https://github.com/dotnet/diagnostics/tree/main/src/SOS/lldbplugin working. i will test it once the package is available in one of these distros.

@DavidSpickett
Copy link
Collaborator

Significant PRs since Ted's update in July:
#99039
#99043
#90075
#93297
#79990
#104547

In summary:

  • A bunch of API tests fixed.
  • Fixed breakpointing an unknown instruction.
  • Core file debugging for rv64, including gpr only and gpr + fpr.
  • Improved connections to non lldb-server remote debug servers on risc-v.

@kasperk81
Copy link
Author

upcoming ubuntu 24.10 has lldb:

$ docker run --platform linux/riscv64 --rm ubuntu:24.10 sh -c \
     'uname -a && apt update && apt search liblldb-18-dev' # or lldb-18

Linux bef2d8730a94 6.10.0-linuxkit #1 SMP Wed Jul 17 10:51:09 UTC 2024 riscv64 riscv64 riscv64 GNU/Linux
...
liblldb-18-dev/oracular 1:18.1.8-9ubuntu1 riscv64
  Next generation, high-performance debugger, header files

so does alpine edge:

$ docker run --platform linux/riscv64 --rm alpine:edge sh -c \
     'uname -a && apk update && apk search lldb-dev' # or lldb

Linux 12b67a23eb80 6.10.0-linuxkit #1 SMP Wed Jul 17 10:51:09 UTC 2024 riscv64 Linux
...
lldb-dev-18.1.8-r0

@kasperk81
Copy link
Author

Significant PRs since Ted's update in July: #99039 #99043 #90075 #93297 #79990 #104547

In summary:

* A bunch of API tests fixed.

* Fixed breakpointing an unknown instruction.

* Core file debugging for rv64, including gpr only and gpr + fpr.

* Improved connections to non lldb-server remote debug servers on risc-v.

@sylvestre, @Ikke if it's not too late, can we apply these patches to lldb-18 (in debian and alpine respectively)?

https://github.com/llvm/llvm-project/pull/99039.patch
https://github.com/llvm/llvm-project/pull/99043.patch
https://github.com/llvm/llvm-project/pull/90075.patch
https://github.com/llvm/llvm-project/pull/93297.patch
https://github.com/llvm/llvm-project/pull/79990.patch
https://github.com/llvm/llvm-project/pull/104547.patch

and the last one on lldb-19 as well?

@DavidSpickett
Copy link
Collaborator

Expressions can now make function calls: #99336

@kasperk81
Copy link
Author

awesome! a few hours ago, ubuntu 24.04 LTS accepted lldb 18 (see bug report). hopefully, these patches will make it into lldb 19, so the product becomes fully usable with all the bells and whistles, including custom plugin commands. waiting for llvm 20 means progress won’t come until the end of next year, when distros start adopting it—possibly not until 2026 for LTS releases. :/

@ncopa
Copy link

ncopa commented Oct 10, 2024

im currently working on llvm19 for alpine.
We only need https://github.com/llvm/llvm-project/pull/104547.patch for 19 right?

@kasperk81
Copy link
Author

@ncopa, some of these aren't in 19 branch

https://github.com/llvm/llvm-project/pull/99039.patch
https://github.com/llvm/llvm-project/pull/99043.patch
https://github.com/llvm/llvm-project/pull/90075.patch
https://github.com/llvm/llvm-project/pull/93297.patch
https://github.com/llvm/llvm-project/pull/79990.patch
https://github.com/llvm/llvm-project/pull/104547.patch
https://github.com/llvm/llvm-project/pull/99336.patch

basically all of these patches are for feature parity with other archs, so there is no fear of regression of any kind. (lldb is in alpine's community repo)

@sylvestre
Copy link
Collaborator

They are in the correct order?

@kasperk81
Copy link
Author

ops, those patch urls are not good, we should be using .patch to the merge commit of each PR. let me provide it.

@kasperk81
Copy link
Author

kasperk81 commented Oct 10, 2024

PR #99039...
https://github.com/llvm/llvm-project/commit/cbd255942b52c3576aa0dca444811512fff43714.patch
PR #99043...
https://github.com/llvm/llvm-project/commit/a751f653b40f2021f091a2f1ebcc2d91bc4cc89d.patch
PR #90075...
https://github.com/llvm/llvm-project/commit/a1ffabc403d4ce55ab2e665511b0b68a16d4850b.patch
PR #93297...
https://github.com/llvm/llvm-project/commit/d3a9043ec2ee7ea278be4f3c86823512e44d01bf.patch
PR #79990...
https://github.com/llvm/llvm-project/commit/8774d2936dd1cf0ee8d74ff600359d465179d009.patch
PR #104547...
https://github.com/llvm/llvm-project/commit/660e34fd38c3fb39fba1871bbf5b2eb3a48bf277.patch
PR #99336...
https://github.com/llvm/llvm-project/commit/87121403e251828ed0fee8a9c2a2993ce8f57861.patch

@sylvestre, @ncopa these are the merge commits

@kasperk81
Copy link
Author

@sylvestre in ascending order of their merge date

PR # Date Merged (UTC) Patch URL
#79990 2024-01-30T14:02:50Z https://github.com/llvm/llvm-project/commit/8774d2936dd1cf0ee8d74ff600359d465179d009.patch
#93297 2024-06-05T09:14:49Z https://github.com/llvm/llvm-project/commit/d3a9043ec2ee7ea278be4f3c86823512e44d01bf.patch
#90075 2024-07-16T09:03:42Z https://github.com/llvm/llvm-project/commit/a1ffabc403d4ce55ab2e665511b0b68a16d4850b.patch
#99043 2024-07-17T08:36:19Z https://github.com/llvm/llvm-project/commit/a751f653b40f2021f091a2f1ebcc2d91bc4cc89d.patch
#99039 2024-07-18T08:09:52Z https://github.com/llvm/llvm-project/commit/cbd255942b52c3576aa0dca444811512fff43714.patch
#104547 2024-09-04T14:31:59Z https://github.com/llvm/llvm-project/commit/660e34fd38c3fb39fba1871bbf5b2eb3a48bf277.patch
#99336 2024-10-02T09:08:22Z https://github.com/llvm/llvm-project/commit/87121403e251828ed0fee8a9c2a2993ce8f57861.patch

@sylvestre
Copy link
Collaborator

ok, could you please get these patches in the next 19 dot releases?
once it is done, i will see how to apply it to 18 deb packages
thanks

@kasperk81
Copy link
Author

@tru @DavidSpickett,

Would it be feasible to backport the following LLDB patches for RISC-V to v19 branch, or do they not meet the criteria for backporting?

Justification: RISC-V is an emerging architecture, and LLDB's support for it is still maturing. These patches help bring RISC-V closer to feature parity with other architectures currently supported by LLVM.

Risk: The risk is low, as LLDB’s RISC-V support is relatively new, and the associated functionality has not been previously operational.

for chronological cherry-picking, this is the order: #55383 (comment) (+/- potential conflicts 🙂)

@tru
Copy link
Collaborator

tru commented Oct 11, 2024

@tru @DavidSpickett,

Would it be feasible to backport the following LLDB patches for RISC-V to v19 branch, or do they not meet the criteria for backporting?

Justification: RISC-V is an emerging architecture, and LLDB's support for it is still maturing. These patches help bring RISC-V closer to feature parity with other architectures currently supported by LLVM.

Risk: The risk is low, as LLDB’s RISC-V support is relatively new, and the associated functionality has not been previously operational.

for chronological cherry-picking, this is the order: #55383 (comment) (+/- potential conflicts 🙂)

It would definitely be way outside what we normally consider for back-porting. Adding new features post the first release doesn't seem sensible to me, even if the risk for other platforms are low in theory, it is a risk at this point.

@DavidSpickett
Copy link
Collaborator

DavidSpickett commented Oct 11, 2024

I agree. If these patches were fixing issues in features already supported on RISC-V, might be a different story.

Which means anyone interested in RISC-V support has a few months to make LLDB 20 as good as possible. Please raise issues for any test failures and missing features you or other users find. Use builds from the main branch if possible, so problems can be fixed before they make it into a release branch.

Also there is a talk at the upcoming dev meeting on RISC-V support "Hey, do you want a RISC-V debugger?”, so you might get some good news before the next release.

Edit: Which is now on YouTube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants