libdwarf: Using dwarf_expand_frame_instructions

libdwarf

Loading...
Searching...
No Matches
Using dwarf_expand_frame_instructions

Example using dwarf_expand_frame_instructions.

Example using dwarf_expand_frame_instructions.

*/
int examples(Dwarf_Cie cie,
Dwarf_Ptr instruction,Dwarf_Unsigned len,
Dwarf_Error *error)
{
Dwarf_Frame_Instr_Head head = 0;
Dwarf_Unsigned count = 0;
int res = 0;
Dwarf_Unsigned i = 0;
res = dwarf_expand_frame_instructions(cie,instruction,len,
&head,&count, error);
if (res != DW_DLV_OK) {
return res;
}
for (i = 0; i < count; ++i) {
Dwarf_Unsigned instr_offset_in_instrs = 0;
Dwarf_Small cfa_operation = 0;
const char *fields_description = 0;
Dwarf_Unsigned u0 = 0;
Dwarf_Unsigned u1 = 0;
Dwarf_Signed s0 = 0;
Dwarf_Signed s1 = 0;
Dwarf_Unsigned code_alignment_factor = 0;
Dwarf_Signed data_alignment_factor = 0;
Dwarf_Block expression_block;
const char * op_name = 0;
memset(&expression_block,0,sizeof(expression_block));
res = dwarf_get_frame_instruction(head,i,
&instr_offset_in_instrs,&cfa_operation,
&fields_description,&u0,&u1,
&s0,&s1,
&code_alignment_factor,
&data_alignment_factor,
&expression_block,error);
if (res == DW_DLV_ERROR) {
dwarf_dealloc_frame_instr_head(head);
return res;
}
if (res == DW_DLV_OK) {
res = dwarf_get_CFA_name(cfa_operation,
&op_name);
if (res != DW_DLV_OK) {
op_name = "unknown op";
}
printf("Instr %2lu %-22s %s\n",
(unsigned long)i,
op_name,
fields_description);
/* Do something with the various data
as guided by the fields_description.
dwarf_get_CFA_name
DW_API int dwarf_get_CFA_name(unsigned int dw_val_in, const char **dw_s_out)
dwarf_get_CFA_name
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:611
Dwarf_Frame_Instr_Head
struct Dwarf_Frame_Instr_Head_s * Dwarf_Frame_Instr_Head
Definition libdwarf.h:370
Dwarf_Cie
struct Dwarf_Cie_s * Dwarf_Cie
Definition libdwarf.h:695
Dwarf_Block
struct Dwarf_Block_s Dwarf_Block
Dwarf_Ptr
void * Dwarf_Ptr
Definition libdwarf.h:208
Dwarf_Small
unsigned char Dwarf_Small
Definition libdwarf.h:204
Dwarf_Unsigned
unsigned long long Dwarf_Unsigned
Definition libdwarf.h:196
Dwarf_Signed
signed long long Dwarf_Signed
Definition libdwarf.h:197
dwarf_dealloc_frame_instr_head
DW_API void dwarf_dealloc_frame_instr_head(Dwarf_Frame_Instr_Head dw_head)
Deallocates the frame instruction data in dw_head.
dwarf_expand_frame_instructions
DW_API int dwarf_expand_frame_instructions(Dwarf_Cie dw_cie, Dwarf_Small *dw_instructionspointer, Dwarf_Unsigned dw_length_in_bytes, Dwarf_Frame_Instr_Head *dw_head, Dwarf_Unsigned *dw_instr_count, Dwarf_Error *dw_error)
Expands CIE or FDE instructions for detailed examination. Called for CIE initial instructions and FDE...
dwarf_get_frame_instruction
DW_API int dwarf_get_frame_instruction(Dwarf_Frame_Instr_Head dw_head, Dwarf_Unsigned dw_instr_index, Dwarf_Unsigned *dw_instr_offset_in_instrs, Dwarf_Small *dw_cfa_operation, const char **dw_fields_description, Dwarf_Unsigned *dw_u0, Dwarf_Unsigned *dw_u1, Dwarf_Signed *dw_s0, Dwarf_Signed *dw_s1, Dwarf_Unsigned *dw_code_alignment_factor, Dwarf_Signed *dw_data_alignment_factor, Dwarf_Block *dw_expression_block, Dwarf_Error *dw_error)
Return information about a single instruction Fields_description means a sequence of up to three lett...