[Lldb-commits] [PATCH] D128250: [LLDB][RISCV]Add initial support for lldb-server.

Tiancheng Zhang via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jul 25 14:14:01 PDT 2022


tzb99 added a comment.

In D128250#3676635 <https://reviews.llvm.org/D128250#3676635>, @tzb99 wrote:

> In D128250#3640942 <https://reviews.llvm.org/D128250#3640942>, @Emmmer wrote:
>
>> This patch change:
>>
>> - Add the recognition of architecture riscv64 in `HostInfoBase.cpp`
>> - Add the recognition of architecture riscv64 and riscv32 in `ObjectFilePECOFF.cpp`
>> - Add riscv's `ebreak` command to `Platform.cpp`
>>
>> Now lldb can debug with simple executables on `qemu-system-riscv64` and be able to attach to a `gdbserver`.
>>
>> ---
>>
>> TODO: some unittest failed
>>
>>   bash
>>   [ RUN      ] TestBase.LaunchModePreservesEnvironment
>>   /home/emmmer/git/llvm-project/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp:29: Failure
>>   Value of: llvm::detail::TakeExpected(ClientOr)
>>   Expected: succeeded
>>     Actual: failed  (Unable to parse qRegisterInfo: generic)
>>   [  FAILED  ] TestBase.LaunchModePreservesEnvironment (662 ms)
>>   
>>   
>>   [ RUN      ] TestBase.vAttachRichError
>>   Connection established.
>>   Launched '/home/emmmer/git/llvm-project/build-cross/tools/lldb/unittests/tools/lldb-server/./environment_check' as process 1553...
>>   lldb-server-local_build
>>   Connection established.
>>   Launched '/home/emmmer/git/llvm-project/build-cross/tools/lldb/unittests/tools/lldb-server/./environment_check' as process 1556...
>>   lldb-server-local_build
>>   /home/emmmer/git/llvm-project/lldb/unittests/tools/lldb-server/tests/LLGSTest.cpp:60: Failure
>>   Value of: llvm::detail::TakeExpected(ClientOr)
>>   Expected: succeeded
>>     Actual: failed  (Unable to parse qRegisterInfo: generic)
>>   [  FAILED  ] TestBase.vAttachRichError (364 ms)
>>
>> In riscv, the user-mode process cannot directly take the `pc` register but must obtain the pc state through `auipc`, while the `pc` register is required to exist in the test, so it failed.
>>
>> ---
>>
>>   bash
>>   [ RUN      ] DumpDataExtractorTest.Formats
>>   /home/emmmer/git/llvm-project/lldb/unittests/Core/DumpDataExtractorTest.cpp:90: Failure
>>   Expected equality of these values:
>>     expected
>>       Which is: "{-nan -nan nan nan}"
>>     result.GetString()
>>       Which is: "{nan nan nan nan}"
>>   [  FAILED  ] DumpDataExtractorTest.Formats (25 ms)
>>
>> The reason is currently unknown, and further verification is required
>>
>> ---
>>
>> About buildbot: Unfortunately, as an individual developer, I may not have the ability to maintain a 7*24-hour compile server or even a cluster, but I will do my best to provide some test reports.
>
> Hello:
>
> I implemented the diff into my local llvm project and cross-compiled the project using in-tree build with enable projects as:
> -DLLVM_ENABLE_PROJECTS="clang;lld;lldb"
>
> The project can be compiled using the "Release" mode. The lldb-server can be initiated and connected to the host machine from the qemu environment. It can ran the riscv binary using process continue / thread continue, but the compiled lldb-server cannot get any thread information and cannot perform thread step-in functionality. Then I performed the Debug mode to build the project. Error occurred so the build command cannot be finished. The error shows like:
>
> [3759/4081] Linking CXX shared library lib/libclang-cpp.so.15git
> FAILED: lib/libclang-cpp.so.15git 
> : && riscv-gnu-toolchain/bin/riscv64-unknown-linux-gnu-g++ -
>
> Can your lldb-server work properly on the riscv qemu environment? My question might be, what is the proper recipe for cross-building the lldb-server? Or, should the diff be changed to enable getting the thread instruction info of the lldb-server?
>
> Thank you very much!

One more detail about the ThreadInfo: This is the strace of my lldb-server runing on the qemu:

recvfrom(9, "$jThreadsInfo#c1", 8192, 0, NULL, NULL) = 16
gettid()                                = 353
openat(AT_FDCWD, "/proc/354/task/354/comm", O_RDONLY|O_CLOEXEC) = 8
read(8, "riscvv\n", 16384)              = 7
read(8, "", 16384)                      = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [HUP CHLD], 8) = 0
close(8)                                = 0
rt_sigprocmask(SIG_SETMASK, [HUP CHLD], NULL, 8) = 0
sendto(9, "$[{\"name\":\"riscvv\",\"reason\":\"sig"..., 64, 0, NULL, 0) = 64
gettid()                                = 353
pselect6(10, [6 9], NULL, NULL, {tv_sec=0, tv_nsec=0}, NULL) = 1 (in [9], left {tv_sec=0, tv_nsec=0})
recvfrom(9, "$jThreadExtendedInfo:#b9", 8192, 0, NULL, NULL) = 24
gettid()                                = 353


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128250/new/

https://reviews.llvm.org/D128250



More information about the lldb-commits mailing list