[lldb] Fix TestDeletedExecutable on linux
authorPavel Labath <pavel@labath.sk>
Tue, 2 Aug 2022 11:34:24 +0000 (13:34 +0200)
committerPavel Labath <pavel@labath.sk>
Wed, 3 Aug 2022 13:44:19 +0000 (15:44 +0200)
commit69c39e2abc311aa226d54b82a2cc8fa648902c7d
treedf3beb0905f74410f1b3da8df44248b0b4789abe
parentfb65b17932e1163adeda943a3a36f9b482b97f47
[lldb] Fix TestDeletedExecutable on linux

Currently, lldb-server was opening the executable file to determine the
process architecture (to differentiate between 32 and 64 bit
architecture flavours). This isn't a particularly trustworthy source of
information (the file could have been changed since the process was
started) and it is not always available (file could be deleted or
otherwise inaccessible).

Unfortunately, ptrace does not give us a direct API to access the
process architecture, but we can still infer it via some of its
responses -- given that the general purpose register set of 64-bit
applications is larger [citation needed] than the GPR set of 32-bit
ones, we can just ask for the application GPR set and check its size.

This is what this patch does.

Differential Revision: https://reviews.llvm.org/D130985
15 files changed:
lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_ppc64le.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_s390x.cpp
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.cpp
lldb/source/Plugins/Process/Utility/RegisterContextLinux_i386.h
lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.cpp
lldb/source/Plugins/Process/Utility/RegisterContextLinux_x86_64.h
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.cpp
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h
lldb/test/API/functionalities/deleted-executable/TestDeletedExecutable.py