[lldb][x86_64] Support fs_base/gs_base register in Linux
Summary: [lldb][x86_64] This patch adds fs_base/gs_base support for Linux x86_64. Originally, I plan to split the diff into two parts, one to refactoring lldb_xxx_x86_64 => x86_64::lldb_xxx across code base and the other one for adding fs_base/gs_base, but it turns out to be a non-trivial effort to split and very error prone so I decided to keep a single diff to get feedback. 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 linux files are change to use x86_64::lldb_xxx => x86_64_with_base::lldb_xxx * 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. Reviewers:clayborg,labath,jingham,jdoerfert,JDevlieghere,kusmour,GeorgeHuyubo Subscribers: Tasks: Tags: Differential Revision: https://reviews.llvm.org/D155256
Loading
Please sign in to comment