LLDB mainline
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
lldb_private::x86AssemblyInspectionEngine Class Reference

#include <x86AssemblyInspectionEngine.h>

Classes

struct  lldb_reg_info
 One of the two initialize methods that can be called on this object; they must be called before any of the assembly inspection methods are called. More...
 

Public Member Functions

 x86AssemblyInspectionEngine (const lldb_private::ArchSpec &arch)
 default ctor
 
 ~x86AssemblyInspectionEngine ()
 default dtor
 
void Initialize (lldb::RegisterContextSP &reg_ctx)
 One of the two initialize methods that can be called on this object; they must be called before any of the assembly inspection methods are called.
 
void Initialize (std::vector< lldb_reg_info > &reg_info)
 
bool GetNonCallSiteUnwindPlanFromAssembly (uint8_t *data, size_t size, lldb_private::AddressRange &func_range, lldb_private::UnwindPlan &unwind_plan)
 Create an UnwindPlan for a "non-call site" stack frame situation.
 
bool AugmentUnwindPlanFromCallSite (uint8_t *data, size_t size, lldb_private::AddressRange &func_range, lldb_private::UnwindPlan &unwind_plan, lldb::RegisterContextSP &reg_ctx)
 Take an existing UnwindPlan, probably from eh_frame which may be missing description of the epilogue instructions, and add the epilogue description to it based on the instructions in the function.
 
bool FindFirstNonPrologueInstruction (uint8_t *data, size_t size, size_t &offset)
 

Private Types

enum  CPU { k_i386 , k_x86_64 , k_cpu_unspecified }
 
enum  i386_register_numbers {
  k_machine_eax = 0 , k_machine_ecx = 1 , k_machine_edx = 2 , k_machine_ebx = 3 ,
  k_machine_esp = 4 , k_machine_ebp = 5 , k_machine_esi = 6 , k_machine_edi = 7 ,
  k_machine_eip = 8
}
 
enum  x86_64_register_numbers {
  k_machine_rax = 0 , k_machine_rcx = 1 , k_machine_rdx = 2 , k_machine_rbx = 3 ,
  k_machine_rsp = 4 , k_machine_rbp = 5 , k_machine_rsi = 6 , k_machine_rdi = 7 ,
  k_machine_r8 = 8 , k_machine_r9 = 9 , k_machine_r10 = 10 , k_machine_r11 = 11 ,
  k_machine_r12 = 12 , k_machine_r13 = 13 , k_machine_r14 = 14 , k_machine_r15 = 15 ,
  k_machine_rip = 16
}
 
enum  { kMaxInstructionByteSize = 32 }
 
typedef std::map< uint32_t, lldb_reg_infoMachineRegnumToNameAndLLDBRegnum
 

Private Member Functions

bool nonvolatile_reg_p (int machine_regno)
 
bool push_rbp_pattern_p ()
 
bool push_0_pattern_p ()
 
bool push_imm_pattern_p ()
 
bool push_extended_pattern_p ()
 
bool push_misc_reg_p ()
 
bool mov_rsp_rbp_pattern_p ()
 
bool mov_rsp_rbx_pattern_p ()
 
bool mov_rbp_rsp_pattern_p ()
 
bool mov_rbx_rsp_pattern_p ()
 
bool sub_rsp_pattern_p (int &amount)
 
bool add_rsp_pattern_p (int &amount)
 
bool lea_rsp_pattern_p (int &amount)
 
bool lea_rbp_rsp_pattern_p (int &amount)
 
bool lea_rbx_rsp_pattern_p (int &amount)
 
bool and_rsp_pattern_p ()
 
bool push_reg_p (int &regno)
 
bool pop_reg_p (int &regno)
 
bool pop_rbp_pattern_p ()
 
bool pop_misc_reg_p ()
 
bool leave_pattern_p ()
 
bool call_next_insn_pattern_p ()
 
bool mov_reg_to_local_stack_frame_p (int &regno, int &rbp_offset)
 
bool ret_pattern_p ()
 
bool jmp_to_reg_p ()
 
bool pc_rel_branch_or_jump_p (const int instruction_length, int &offset)
 
bool non_local_branch_p (const lldb::addr_t current_func_text_offset, const lldb_private::AddressRange &func_range, const int instruction_length)
 
bool local_branch_p (const lldb::addr_t current_func_text_offset, const lldb_private::AddressRange &func_range, const int instruction_length, lldb::addr_t &target_insn_offset)
 
uint16_t extract_2 (uint8_t *b)
 
int16_t extract_2_signed (uint8_t *b)
 
uint32_t extract_4 (uint8_t *b)
 
int32_t extract_4_signed (uint8_t *b)
 
bool instruction_length (uint8_t *insn, int &length, uint32_t buffer_remaining_bytes)
 
bool machine_regno_to_lldb_regno (int machine_regno, uint32_t &lldb_regno)
 
 x86AssemblyInspectionEngine (const x86AssemblyInspectionEngine &)=delete
 
const x86AssemblyInspectionEngineoperator= (const x86AssemblyInspectionEngine &)=delete
 

Private Attributes

uint8_t * m_cur_insn
 
uint32_t m_machine_ip_regnum
 
uint32_t m_machine_sp_regnum
 
uint32_t m_machine_fp_regnum
 
uint32_t m_machine_alt_fp_regnum
 
uint32_t m_lldb_ip_regnum
 
uint32_t m_lldb_sp_regnum
 
uint32_t m_lldb_fp_regnum
 
uint32_t m_lldb_alt_fp_regnum
 
MachineRegnumToNameAndLLDBRegnum m_reg_map
 
lldb_private::ArchSpec m_arch
 
CPU m_cpu
 
int m_wordsize
 
bool m_register_map_initialized
 
::LLVMDisasmContextRef m_disasm_context
 

Detailed Description

Definition at line 28 of file x86AssemblyInspectionEngine.h.

Member Typedef Documentation

◆ MachineRegnumToNameAndLLDBRegnum

Definition at line 182 of file x86AssemblyInspectionEngine.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
kMaxInstructionByteSize 

Definition at line 169 of file x86AssemblyInspectionEngine.h.

◆ CPU

Enumerator
k_i386 
k_x86_64 
k_cpu_unspecified 

Definition at line 135 of file x86AssemblyInspectionEngine.h.

◆ i386_register_numbers

Enumerator
k_machine_eax 
k_machine_ecx 
k_machine_edx 
k_machine_ebx 
k_machine_esp 
k_machine_ebp 
k_machine_esi 
k_machine_edi 
k_machine_eip 

Definition at line 137 of file x86AssemblyInspectionEngine.h.

◆ x86_64_register_numbers

Enumerator
k_machine_rax 
k_machine_rcx 
k_machine_rdx 
k_machine_rbx 
k_machine_rsp 
k_machine_rbp 
k_machine_rsi 
k_machine_rdi 
k_machine_r8 
k_machine_r9 
k_machine_r10 
k_machine_r11 
k_machine_r12 
k_machine_r13 
k_machine_r14 
k_machine_r15 
k_machine_rip 

Definition at line 149 of file x86AssemblyInspectionEngine.h.

Constructor & Destructor Documentation

◆ x86AssemblyInspectionEngine() [1/2]

x86AssemblyInspectionEngine::x86AssemblyInspectionEngine ( const lldb_private::ArchSpec arch)

default ctor

Definition at line 23 of file x86AssemblyInspectionEngine.cpp.

References lldb_private::ArchSpec::GetTriple(), and m_disasm_context.

◆ ~x86AssemblyInspectionEngine()

x86AssemblyInspectionEngine::~x86AssemblyInspectionEngine ( )

default dtor

Definition at line 39 of file x86AssemblyInspectionEngine.cpp.

References m_disasm_context.

◆ x86AssemblyInspectionEngine() [2/2]

lldb_private::x86AssemblyInspectionEngine::x86AssemblyInspectionEngine ( const x86AssemblyInspectionEngine )
privatedelete

Member Function Documentation

◆ add_rsp_pattern_p()

bool x86AssemblyInspectionEngine::add_rsp_pattern_p ( int &  amount)
private

◆ and_rsp_pattern_p()

bool x86AssemblyInspectionEngine::and_rsp_pattern_p ( )
private

Definition at line 551 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn, and m_wordsize.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ AugmentUnwindPlanFromCallSite()

bool x86AssemblyInspectionEngine::AugmentUnwindPlanFromCallSite ( uint8_t *  data,
size_t  size,
lldb_private::AddressRange func_range,
lldb_private::UnwindPlan unwind_plan,
lldb::RegisterContextSP reg_ctx 
)

Take an existing UnwindPlan, probably from eh_frame which may be missing description of the epilogue instructions, and add the epilogue description to it based on the instructions in the function.

The unwind_plan 's register numbers must be converted into the lldb register numbering scheme OR a RegisterContext must be provided in reg_ctx. If the unwind_plan register numbers are already in lldb register numbering, reg_ctx may be null.

Returns
true if the unwind_plan was updated, false if it was not.

Definition at line 1325 of file x86AssemblyInspectionEngine.cpp.

References add_rsp_pattern_p(), lldb_private::UnwindPlan::AppendRow(), lldb_private::ConstString::AsCString(), call_next_insn_pattern_p(), lldb_private::eLazyBoolNo, lldb_private::eLazyBoolYes, lldb::eRegisterKindLLDB, lldb_private::AddressRange::GetBaseAddress(), lldb_private::UnwindPlan::GetRegisterKind(), lldb_private::UnwindPlan::GetRowAtIndex(), lldb_private::UnwindPlan::GetRowCount(), lldb_private::UnwindPlan::GetRowForFunctionOffset(), lldb_private::UnwindPlan::GetSourceName(), lldb_private::UnwindPlan::InsertRow(), instruction_length(), lldb_private::Address::IsValid(), kMaxInstructionByteSize, lea_rsp_pattern_p(), leave_pattern_p(), m_cur_insn, m_lldb_fp_regnum, m_lldb_sp_regnum, m_wordsize, pop_misc_reg_p(), pop_rbp_pattern_p(), pop_reg_p(), push_extended_pattern_p(), push_imm_pattern_p(), push_misc_reg_p(), push_reg_p(), ret_pattern_p(), lldb_private::UnwindPlan::SetPlanValidAddressRange(), lldb_private::UnwindPlan::SetSourcedFromCompiler(), lldb_private::UnwindPlan::SetSourceName(), lldb_private::UnwindPlan::SetUnwindPlanValidAtAllInstructions(), and sub_rsp_pattern_p().

Referenced by UnwindAssembly_x86::AugmentUnwindPlanFromCallSite().

◆ call_next_insn_pattern_p()

bool x86AssemblyInspectionEngine::call_next_insn_pattern_p ( )
private

◆ extract_2()

uint16_t x86AssemblyInspectionEngine::extract_2 ( uint8_t *  b)
private

Definition at line 845 of file x86AssemblyInspectionEngine.cpp.

◆ extract_2_signed()

int16_t x86AssemblyInspectionEngine::extract_2_signed ( uint8_t *  b)
private

Definition at line 852 of file x86AssemblyInspectionEngine.cpp.

Referenced by pc_rel_branch_or_jump_p().

◆ extract_4()

uint32_t x86AssemblyInspectionEngine::extract_4 ( uint8_t *  b)
private

◆ extract_4_signed()

int32_t x86AssemblyInspectionEngine::extract_4_signed ( uint8_t *  b)
private

Definition at line 866 of file x86AssemblyInspectionEngine.cpp.

Referenced by pc_rel_branch_or_jump_p().

◆ FindFirstNonPrologueInstruction()

bool x86AssemblyInspectionEngine::FindFirstNonPrologueInstruction ( uint8_t *  data,
size_t  size,
size_t &  offset 
)

◆ GetNonCallSiteUnwindPlanFromAssembly()

bool x86AssemblyInspectionEngine::GetNonCallSiteUnwindPlanFromAssembly ( uint8_t *  data,
size_t  size,
lldb_private::AddressRange func_range,
lldb_private::UnwindPlan unwind_plan 
)

Create an UnwindPlan for a "non-call site" stack frame situation.

This is usually when this function/method is currently executing, and may be at a location where exception-handling style unwind information (eh_frame, compact unwind info, arm unwind info) are not valid. data is a pointer to the instructions for the function size is the size of the instruction buffer above func_range is the start Address and size of the function, to be included in the UnwindPlan unwind_plan is the unwind plan that this method creates

Returns
true if it was able to create an UnwindPlan; false if not.

Definition at line 901 of file x86AssemblyInspectionEngine.cpp.

References add_rsp_pattern_p(), and_rsp_pattern_p(), lldb_private::UnwindPlan::AppendRow(), call_next_insn_pattern_p(), lldb_private::UnwindPlan::Clear(), lldb_private::eLazyBoolNo, lldb_private::eLazyBoolYes, lldb::eRegisterKindLLDB, instruction_length(), jmp_to_reg_p(), kMaxInstructionByteSize, lea_rbp_rsp_pattern_p(), lea_rbx_rsp_pattern_p(), lea_rsp_pattern_p(), leave_pattern_p(), m_cur_insn, m_disasm_context, m_lldb_alt_fp_regnum, m_lldb_fp_regnum, m_lldb_ip_regnum, m_lldb_sp_regnum, m_machine_fp_regnum, m_register_map_initialized, m_wordsize, machine_regno_to_lldb_regno(), mov_rbp_rsp_pattern_p(), mov_rbx_rsp_pattern_p(), mov_reg_to_local_stack_frame_p(), mov_rsp_rbp_pattern_p(), mov_rsp_rbx_pattern_p(), non_local_branch_p(), nonvolatile_reg_p(), pc, pop_misc_reg_p(), pop_reg_p(), push_0_pattern_p(), push_extended_pattern_p(), push_imm_pattern_p(), push_misc_reg_p(), push_reg_p(), ret_pattern_p(), lldb_private::UnwindPlan::Row::RegisterLocation::SetAtAFAPlusOffset(), lldb_private::UnwindPlan::Row::RegisterLocation::SetAtCFAPlusOffset(), lldb_private::UnwindPlan::Row::RegisterLocation::SetIsCFAPlusOffset(), lldb_private::UnwindPlan::SetPlanValidAddressRange(), lldb_private::UnwindPlan::SetRegisterKind(), lldb_private::UnwindPlan::SetSourcedFromCompiler(), lldb_private::UnwindPlan::SetSourceName(), lldb_private::UnwindPlan::SetUnwindPlanForSignalTrap(), lldb_private::UnwindPlan::SetUnwindPlanValidAtAllInstructions(), sp, and sub_rsp_pattern_p().

Referenced by UnwindAssembly_x86::GetNonCallSiteUnwindPlanFromAssembly().

◆ Initialize() [1/2]

void x86AssemblyInspectionEngine::Initialize ( lldb::RegisterContextSP reg_ctx)

◆ Initialize() [2/2]

void x86AssemblyInspectionEngine::Initialize ( std::vector< lldb_reg_info > &  reg_info)

◆ instruction_length()

bool x86AssemblyInspectionEngine::instruction_length ( uint8_t *  insn,
int &  length,
uint32_t  buffer_remaining_bytes 
)
private

◆ jmp_to_reg_p()

bool x86AssemblyInspectionEngine::jmp_to_reg_p ( )
private

Definition at line 678 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ lea_rbp_rsp_pattern_p()

bool x86AssemblyInspectionEngine::lea_rbp_rsp_pattern_p ( int &  amount)
private

◆ lea_rbx_rsp_pattern_p()

bool x86AssemblyInspectionEngine::lea_rbx_rsp_pattern_p ( int &  amount)
private

◆ lea_rsp_pattern_p()

bool x86AssemblyInspectionEngine::lea_rsp_pattern_p ( int &  amount)
private

◆ leave_pattern_p()

bool x86AssemblyInspectionEngine::leave_pattern_p ( )
private

◆ local_branch_p()

bool x86AssemblyInspectionEngine::local_branch_p ( const lldb::addr_t  current_func_text_offset,
const lldb_private::AddressRange func_range,
const int  instruction_length,
lldb::addr_t target_insn_offset 
)
private

◆ machine_regno_to_lldb_regno()

bool x86AssemblyInspectionEngine::machine_regno_to_lldb_regno ( int  machine_regno,
uint32_t &  lldb_regno 
)
private

Definition at line 891 of file x86AssemblyInspectionEngine.cpp.

References m_reg_map.

Referenced by GetNonCallSiteUnwindPlanFromAssembly(), and Initialize().

◆ mov_rbp_rsp_pattern_p()

bool x86AssemblyInspectionEngine::mov_rbp_rsp_pattern_p ( )
private

Definition at line 409 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn, and m_wordsize.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ mov_rbx_rsp_pattern_p()

bool x86AssemblyInspectionEngine::mov_rbx_rsp_pattern_p ( )
private

Definition at line 422 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn, and m_wordsize.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ mov_reg_to_local_stack_frame_p()

bool x86AssemblyInspectionEngine::mov_reg_to_local_stack_frame_p ( int &  regno,
int &  rbp_offset 
)
private

◆ mov_rsp_rbp_pattern_p()

bool x86AssemblyInspectionEngine::mov_rsp_rbp_pattern_p ( )
private

◆ mov_rsp_rbx_pattern_p()

bool x86AssemblyInspectionEngine::mov_rsp_rbx_pattern_p ( )
private

Definition at line 396 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn, and m_wordsize.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ non_local_branch_p()

bool x86AssemblyInspectionEngine::non_local_branch_p ( const lldb::addr_t  current_func_text_offset,
const lldb_private::AddressRange func_range,
const int  instruction_length 
)
private

◆ nonvolatile_reg_p()

bool x86AssemblyInspectionEngine::nonvolatile_reg_p ( int  machine_regno)
private

◆ operator=()

const x86AssemblyInspectionEngine & lldb_private::x86AssemblyInspectionEngine::operator= ( const x86AssemblyInspectionEngine )
privatedelete

◆ pc_rel_branch_or_jump_p()

bool x86AssemblyInspectionEngine::pc_rel_branch_or_jump_p ( const int  instruction_length,
int &  offset 
)
private

◆ pop_misc_reg_p()

bool x86AssemblyInspectionEngine::pop_misc_reg_p ( )
private

◆ pop_rbp_pattern_p()

bool x86AssemblyInspectionEngine::pop_rbp_pattern_p ( )
private

Definition at line 581 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn.

Referenced by AugmentUnwindPlanFromCallSite().

◆ pop_reg_p()

bool x86AssemblyInspectionEngine::pop_reg_p ( int &  regno)
private

◆ push_0_pattern_p()

bool x86AssemblyInspectionEngine::push_0_pattern_p ( )
private

Definition at line 313 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn.

Referenced by GetNonCallSiteUnwindPlanFromAssembly().

◆ push_extended_pattern_p()

bool x86AssemblyInspectionEngine::push_extended_pattern_p ( )
private

◆ push_imm_pattern_p()

bool x86AssemblyInspectionEngine::push_imm_pattern_p ( )
private

◆ push_misc_reg_p()

bool x86AssemblyInspectionEngine::push_misc_reg_p ( )
private

◆ push_rbp_pattern_p()

bool x86AssemblyInspectionEngine::push_rbp_pattern_p ( )
private

Definition at line 307 of file x86AssemblyInspectionEngine.cpp.

References m_cur_insn.

Referenced by FindFirstNonPrologueInstruction().

◆ push_reg_p()

bool x86AssemblyInspectionEngine::push_reg_p ( int &  regno)
private

◆ ret_pattern_p()

bool x86AssemblyInspectionEngine::ret_pattern_p ( )
private

◆ sub_rsp_pattern_p()

bool x86AssemblyInspectionEngine::sub_rsp_pattern_p ( int &  amount)
private

Member Data Documentation

◆ m_arch

lldb_private::ArchSpec lldb_private::x86AssemblyInspectionEngine::m_arch
private

Definition at line 186 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize(), and instruction_length().

◆ m_cpu

CPU lldb_private::x86AssemblyInspectionEngine::m_cpu
private

Definition at line 187 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize(), and nonvolatile_reg_p().

◆ m_cur_insn

uint8_t* lldb_private::x86AssemblyInspectionEngine::m_cur_insn
private

◆ m_disasm_context

::LLVMDisasmContextRef lldb_private::x86AssemblyInspectionEngine::m_disasm_context
private

◆ m_lldb_alt_fp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_lldb_alt_fp_regnum
private

◆ m_lldb_fp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_lldb_fp_regnum
private

◆ m_lldb_ip_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_lldb_ip_regnum
private

◆ m_lldb_sp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_lldb_sp_regnum
private

◆ m_machine_alt_fp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_machine_alt_fp_regnum
private

Definition at line 176 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize().

◆ m_machine_fp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_machine_fp_regnum
private

◆ m_machine_ip_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_machine_ip_regnum
private

Definition at line 173 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize().

◆ m_machine_sp_regnum

uint32_t lldb_private::x86AssemblyInspectionEngine::m_machine_sp_regnum
private

Definition at line 174 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize().

◆ m_reg_map

MachineRegnumToNameAndLLDBRegnum lldb_private::x86AssemblyInspectionEngine::m_reg_map
private

Definition at line 184 of file x86AssemblyInspectionEngine.h.

Referenced by Initialize(), and machine_regno_to_lldb_regno().

◆ m_register_map_initialized

bool lldb_private::x86AssemblyInspectionEngine::m_register_map_initialized
private

◆ m_wordsize

int lldb_private::x86AssemblyInspectionEngine::m_wordsize
private

The documentation for this class was generated from the following files: