DWARFCallFrameInfo.h [plain text]
#ifndef liblldb_DWARFCallFrameInfo_h_
#define liblldb_DWARFCallFrameInfo_h_
#include <map>
#include "lldb/lldb-private.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Flags.h"
#include "lldb/Core/AddressRange.h"
#include "lldb/Core/VMRange.h"
#include "lldb/Core/dwarf.h"
#include "lldb/Host/Mutex.h"
#include "lldb/Symbol/UnwindPlan.h"
#include "lldb/Symbol/ObjectFile.h"
namespace lldb_private {
class DWARFCallFrameInfo
{
public:
DWARFCallFrameInfo (ObjectFile& objfile,
lldb::SectionSP& section,
lldb::RegisterKind reg_kind,
bool is_eh_frame);
~DWARFCallFrameInfo();
bool
GetAddressRange (Address addr, AddressRange &range);
bool
GetUnwindPlan (Address addr, UnwindPlan& unwind_plan);
private:
enum
{
CFI_AUG_MAX_SIZE = 8,
CFI_HEADER_SIZE = 8
};
struct CIE
{
dw_offset_t cie_offset;
uint8_t version;
char augmentation[CFI_AUG_MAX_SIZE]; uint32_t code_align;
int32_t data_align;
uint32_t return_addr_reg_num;
dw_offset_t inst_offset; uint32_t inst_length; uint8_t ptr_encoding;
lldb_private::UnwindPlan::Row initial_row;
CIE(dw_offset_t offset) : cie_offset(offset), version (-1), code_align (0),
data_align (0), return_addr_reg_num (LLDB_INVALID_REGNUM), inst_offset (0),
inst_length (0), ptr_encoding (0), initial_row() {}
};
typedef STD_SHARED_PTR(CIE) CIESP;
struct FDEEntry
{
AddressRange bounds; dw_offset_t offset;
FDEEntry () : bounds (), offset (0) { }
inline bool
operator<(const DWARFCallFrameInfo::FDEEntry& b) const
{
if (bounds.GetBaseAddress().GetOffset() < b.bounds.GetBaseAddress().GetOffset())
return true;
else
return false;
}
};
typedef std::map<off_t, CIESP> cie_map_t;
bool
IsEHFrame() const;
bool
GetFDEEntryByAddress (Address addr, FDEEntry& fde_entry);
void
GetFDEIndex ();
bool
FDEToUnwindPlan (uint32_t offset, Address startaddr, UnwindPlan& unwind_plan);
const CIE*
GetCIE(dw_offset_t cie_offset);
void
GetCFIData();
ObjectFile& m_objfile;
lldb::SectionSP m_section_sp;
lldb::RegisterKind m_reg_kind;
Flags m_flags;
cie_map_t m_cie_map;
DataExtractor m_cfi_data;
bool m_cfi_data_initialized;
std::vector<FDEEntry> m_fde_index;
bool m_fde_index_initialized; Mutex m_fde_index_mutex;
bool m_is_eh_frame;
CIESP
ParseCIE (const uint32_t cie_offset);
};
}
#endif // liblldb_DWARFCallFrameInfo_h_