This patch adds fs_base/gs_base support for Linux x86_64.
GDB supports fs_base/gs_base registers while LLDB does not. Since both linux coredump note section and ptrace
supports them it is a missing feature.
For context, this is a required feature to support getting pthread pointer on linux from both live and dump debugging.
See thread below for details:
https://discourse.llvm.org/t/how-to-get-pthread-pointer-from-lldb/70542/2?u=jeffreytan81
Implementation wise, we have initially tried #ifdef approach to reuse the code but it is introducing very tricky bugs and proves
hard to maintain. Instead the diff completely separates the registers between x86_64 and x86_64_with_base so that non-linux related
implementations can use x86_64 registers while linux uses x86_64_with_base.
Here are the list of changes done in the patch:
- Registers in lldb-x86-register-enums.h are separated into two: x86_64 and x86_64_with_base
- fs_base/gs_base are added into x86_64_with_base
- All registers are renamed from lldb_xxx_x86_64 => x86_64::lldb_xxx across code base
- All macros are changed to use x86_64::lldb_xxx as well
- All linux files are change to use x86_64::lldb_xxx => x86_64_with_base::lldb_xxx
- NativeRegisterContextDBReg_x86.cpp
- Support linux elf-core:
- A new RegisterContextLinuxCore_x86_64 class is added for ThreadElfCore
- RegisterContextLinuxCore_x86_64 overrides and uses its own register set supports fs_base/gs_base
- RegisterInfos_x86_64_with_base/RegisterInfos_x86_64_with_base_shared ared added to provide g_contained_XXX/g_invalidate_XXX and RegInfo related code sharing.
- RegisterContextPOSIX_x86 ::m_gpr_x86_64 seems to be unused so I removed it.
- NativeRegisterContextDBReg_x86::GetDR() is overridden in NativeRegisterContextLinux_x86_64 to make watchpoint work.
Has this file been put through clang-format? These lines look off.