-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][RISC-V] Extended if conditions to support alias names for registers #124475
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
Conversation
@llvm/pr-subscribers-testing-tools @llvm/pr-subscribers-lldb Author: None (kper) ChangesExtending the conditionals in Fixes #124023 Full diff: https://github.com/llvm/llvm-project/pull/124475.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
index 8412991933d277..c463bd006b3db4 100644
--- a/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
+++ b/lldb/source/Plugins/ABI/RISCV/ABISysV_riscv.cpp
@@ -850,8 +850,62 @@ void ABISysV_riscv::AugmentRegisterInfo(
it.value().alt_name.SetCString("x3");
else if (it.value().name == "fp")
it.value().alt_name.SetCString("s0");
+ else if (it.value().name == "tp")
+ it.value().alt_name.SetCString("x4");
else if (it.value().name == "s0")
it.value().alt_name.SetCString("x8");
+ else if (it.value().name == "s1")
+ it.value().alt_name.SetCString("x9");
+ else if (it.value().name == "t0")
+ it.value().alt_name.SetCString("x5");
+ else if (it.value().name == "t1")
+ it.value().alt_name.SetCString("x6");
+ else if (it.value().name == "t2")
+ it.value().alt_name.SetCString("x7");
+ else if (it.value().name == "a0")
+ it.value().alt_name.SetCString("x10");
+ else if (it.value().name == "a1")
+ it.value().alt_name.SetCString("x11");
+ else if (it.value().name == "a2")
+ it.value().alt_name.SetCString("x12");
+ else if (it.value().name == "a3")
+ it.value().alt_name.SetCString("x13");
+ else if (it.value().name == "a4")
+ it.value().alt_name.SetCString("x14");
+ else if (it.value().name == "a5")
+ it.value().alt_name.SetCString("x15");
+ else if (it.value().name == "a6")
+ it.value().alt_name.SetCString("x16");
+ else if (it.value().name == "a7")
+ it.value().alt_name.SetCString("x17");
+ else if (it.value().name == "s2")
+ it.value().alt_name.SetCString("x18");
+ else if (it.value().name == "s3")
+ it.value().alt_name.SetCString("x19");
+ else if (it.value().name == "s4")
+ it.value().alt_name.SetCString("x20");
+ else if (it.value().name == "s5")
+ it.value().alt_name.SetCString("x21");
+ else if (it.value().name == "s6")
+ it.value().alt_name.SetCString("x22");
+ else if (it.value().name == "s7")
+ it.value().alt_name.SetCString("x23");
+ else if (it.value().name == "s8")
+ it.value().alt_name.SetCString("x24");
+ else if (it.value().name == "s9")
+ it.value().alt_name.SetCString("x25");
+ else if (it.value().name == "s10")
+ it.value().alt_name.SetCString("x26");
+ else if (it.value().name == "s11")
+ it.value().alt_name.SetCString("x27");
+ else if (it.value().name == "t3")
+ it.value().alt_name.SetCString("x28");
+ else if (it.value().name == "t4")
+ it.value().alt_name.SetCString("x29");
+ else if (it.value().name == "t5")
+ it.value().alt_name.SetCString("x30");
+ else if (it.value().name == "t6")
+ it.value().alt_name.SetCString("x31");
// Set generic regnum so lldb knows what the PC, etc is
it.value().regnum_generic = GetGenericNum(it.value().name.GetStringRef());
|
Please add a test for this. |
A test for this would be finding the tests that check basic reads of registers, and adding reads with the new names. There should be one for core files and one for live processes. |
I haven't checked, but it's possible that this already works for core files. The original bug was specifically about talking to qemu, which doesn't send the alternate name information (and maybe not information about subregisters as well). If that's the case then a more suitable test to emulate would be test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py (in particular, there a test there to check that we know what the aarch64 |
I don't think we do either. Unless it's in the register info structs maybe it is. The way to find out is to write the tests and if they pass without any changes to LLDB - somehow it does work.
This is sort of an alias but we implement it by adding another register. But yes, same energy for sure. |
Basic support was added in 847de9c and I dont see any tests added there. We may have to write a new one for live process at the very least.
Yeah this should work for core files.
|
If it doesn't exist already, we should definitely have a test to cover the core-file case. |
I have created two tests. However, it turned out that |
✅ With the latest revision this PR passed the Python code formatter. |
Which is great, but we need live processes too and I found those, they are in It's probably simpler to set each register to The logic of that test is set all the registers in inline asm, then manually break before the inline asm block finishes, so that compiler generated code doesn't restore the values.
It's very possible that we have never had a register with 3 names before, or we have support for it but the code that checks them doesn't know that.
I would investigate why this error happens and if you can fix it, see what the changes look like. It can probably be a PR after this one, that updates the tests now that they work. But we'll keep this one open while you do that in case it makes more sense to bundle them. If it seems like it's going to be a massive job to fix it, just let us know what you found and I'll take a look too. I don't want to drown you in unexpected work. |
lldb/test/API/functionalities/postmortem/elf-core/TestLinuxCore.py
Outdated
Show resolved
Hide resolved
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
Show resolved
Hide resolved
✅ With the latest revision this PR passed the C/C++ code formatter. |
04424a3
to
5317759
Compare
I have added a live process test. But I struggle to test it (it is currently wrong on purpose - so ignore a eventually green pipeline). First off, I struggle to build libc with RISCV (I am cross compiling from x86-64). Additionally, I will probably have problems running the (riscv) test from my host system. Is there any documentation how to build and test it? Is it possible to schedule like a CI job? |
Not sure why you need the libc. You can use a pre-compiled gcc based toolchain for RISC-V (wherever one gets those, Arm provides such things for Arm I know that).
There are - and I merged more of them just today in fact. For that you will need host tools, and lldb-server for the remote RISC-V machine. The way I do this for Arm is I have a totally vanilla host build, then https://lldb.llvm.org/resources/build.html#example-1-cross-compiling-for-linux-arm64-on-ubuntu-host for the cross build. That build only needs lldb-server ( scp that lldb-server to the RISC-V board, then follow https://lldb.llvm.org/resources/test.html#running-the-test-suite-remotely I suggest at first you stick to using You'll be running those For some more inspiration we do have a few remote debug bots - https://lab.llvm.org/buildbot/#/builders/195/builds/4388/steps/6/logs/stdio - this one does Linux something (x86?) to Linux AArch64. Also, you can use clang as the LLDB_TEST_COMPILER, but if you've got a cross toolchain for RSIC-V anyway, I'd just point it to that. In my case that's usually
Generally, no. There's no way to request an existing buildbot run a pre-commit branch. One day maybe. It's quite a popular request. Specifically, no, because there's no RISC-V LLDB testing in the buildbot system. One can only hope RISC-V enthusiasts address this eventually (folks are putting up qmu-system powered bots, so in theory it's not that far off). |
Thank you for detailed explanations and sorry for the delay. I think, I've got the setup now. But I am still struggling to test this particular test. How far I have got: (RISCV lldb-server)
(X86 lldb)
(Qemu) You would need a debian image setup for that.
In the Qemu guest, I run the following command. I also receive "Connection established" so networking seems to work.
(On the host X86)
The last piece of the puzzle is not working for me because it tells me that there are no matching tests. Could you tell me how to do this? |
This is known, from the cross building doc:
But...
That should have been the workaround for you. =OFF should stop CMake looking for it at all. It might be solved by completely cleaning the build directory, but equally we could be caching the variable incorrectly. If you are on Ubuntu/Debian, you can install the multiarch packages for these things. I did this to test s390x in the past.
Sorry, I forgot that this is a shell test not an API test. I'm not sure if you can run those using dotest, normally on host you'd use llvm-lit for them like:
That might work, but if not, they will be run from Either way you'll need to set the variables shown in the note at the bottom of https://lldb.llvm.org/resources/test.html#running-the-test-suite-remotely. The bot I linked to does this:
-DLLDB_TEST_SYSROOT=/mnt/fs/jetson-agx-ubuntu Sysroots are typically the parent folder of the compiler binaries, if it's a separate download, not sure what it will be if it's an apt installed version. Perhaps ...also side note if you do manage to get If you don't give up after slogging through all these steps that is :) Thanks for sticking with us. |
540b045
to
7d97df1
Compare
@DavidSpickett unfortunately, I did not manage to test it with the test suite. Both However, why the pipeline is now failing for Bolt and lld is a mystery to me. I have updated the branch and maybe the flaky tests go away. EDIT: ok, merging master helped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat professionally restricted from getting too involved in RISC-V, though I would like to see it actually work normally, just to save others hassle.
But I can see this pretty obviously fixes the bug, so I don't have a problem letting this land once my comments have been addressed.
Someone else can get the ninja check-lldb
experience into shape.
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
Show resolved
Hide resolved
a25f6a4
to
d44dd60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address the two new comments and this'll be good to go.
lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
Show resolved
Hide resolved
f614b1e
to
4feaf72
Compare
4feaf72
to
b40c68f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for fixing this and doing all the leg work to verify it.
I will merge once the CI passes, or anyone else can if they have the rights to.
Well, those BOLT failures are unrelated. So if Windows shows the same ones, this can be merged. |
@DavidSpickett thank you for your patience with me :) |
Np. Strangely no BOLT failures on Windows perhaps it doesn't run there, one other lld test but unrelated to this. |
Extending the conditionals in
AugmentRegisterInfo
to support alternative names for lldb.Fixes #124023
There is an exception with register
X8
which is not covered here but more details can be found in the issue #127900.