llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.61k stars 11.35k forks source link

lldb RISC-V support #55383

Open kasperk81 opened 2 years ago

kasperk81 commented 2 years ago

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 commented 2 years ago

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

llvmbot commented 2 years ago

@llvm/issue-subscribers-lldb

DavidSpickett commented 1 month ago

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

The referenced Phab review did later land as https://github.com/llvm/llvm-project/commit/847de9c332775d1841fec9fea5cb5c41592a4c8f.

Recently we got corefile support for RISC-V 64: https://github.com/llvm/llvm-project/commit/d3a9043ec2ee7ea278be4f3c86823512e44d01bf

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 commented 1 month ago

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 commented 1 month ago

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.