libdwarf
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_Unsigned count = 0;
int res = 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_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));
&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) {
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. */
}
}
return DW_DLV_OK;
}
int dwarf_get_CFA_name(unsigned int dw_val_in, const char **dw_s_out)
dwarf_get_CFA_name
struct Dwarf_Frame_Instr_Head_s * Dwarf_Frame_Instr_Head
Definition: libdwarf.h:370
struct Dwarf_Error_s * Dwarf_Error
Definition: libdwarf.h:597
struct Dwarf_Cie_s * Dwarf_Cie
Definition: libdwarf.h:676
unsigned char Dwarf_Small
Definition: libdwarf.h:204
signed long long Dwarf_Signed
Definition: libdwarf.h:197
unsigned long long Dwarf_Unsigned
Definition: libdwarf.h:196
void * Dwarf_Ptr
Definition: libdwarf.h:208
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...
void dwarf_dealloc_frame_instr_head(Dwarf_Frame_Instr_Head dw_head)
Deallocates the frame instruction data in dw_head.
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...
Definition: libdwarf.h:330