[Lldb-commits] [PATCH] D130985: [lldb] Fix TestDeletedExecutable on linux

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Aug 2 06:42:11 PDT 2022


labath marked an inline comment as done.
labath added a comment.

In D130985#3693453 <https://reviews.llvm.org/D130985#3693453>, @DavidSpickett wrote:

> Tell me if I understand the strategy.
>
> If you're on arm64 but the process is actually arm32 and you ask for the general registers, you'll get back something with size < the size you expect for the 64 bit register set.
> If you're on arm32 then you always assume that the architecture is the host architecture (since there's no backward compatibility mode to worry about).
> (though see my comment about potential cross arch shenanigans)
>
> Ditto for x86_64 and i386.
>
> If the architecture doesn't have a 32/64 split then assume host architecture (as you did for s390x).
>
> And ppc64 we don't support a ppc32 so again use the host (and maybe ppc64 doesn't have a backward compatibility mode in linux anyway).
>
> And you're looking at the size of the register context, not the number of registers or their names or whatever. So even for something like RISCV vs RISCV64 where the number and names of registers is the same, the *size* changes with the bitness (xlen I think they call it) so it would still work.

That is correct. I couldn't have said it better myself. :)

> If so, sounds good to me.





================
Comment at: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:792
     RegisterValue &value) {
   // PTRACE_PEEKUSER don't work in the aarch64 linux kernel used on android
   // devices (always return "Bad address"). To avoid using PTRACE_PEEKUSER we
----------------
This one.


================
Comment at: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp:844
   return NativeRegisterContextLinux::ReadGPR();
 #else  // __aarch64__
   struct iovec ioVec;
----------------
DavidSpickett wrote:
> Is this a problem? First time I'm seeing such code I thought to debug arm32 on arm64 you just had to use an arm32 lldb-server binary.
> 
> Host architecture would be arm64 if `__aarch64__` was defined, right? Same thing if I took an arm32 lldb-server binary and ran it on arm64, host is arm64.
> 
> Or is this not a problem. This architecture detection is a last resort so not getting a corner case right might be fine.
Well.. it's definitely not a problem here. I think this is related to the problem on described on line 792 (they were introduced in the same commit -- e85e6021f040e399203883a78c53b1617053e141), although it may not be relevant anymore.

Generally speaking there can be some differences in the 32-bit codepaths when speaking to 32 or 64-bit kernels. For example, one can use PTRACE_SINGLESTEP for debugging arm(32) binaries on 64-bit kernels, even though that functionality would is not present on real 32-bit kernels.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130985



More information about the lldb-commits mailing list