libdwarf
Loading...
Searching...
No Matches
Reading the .eh_frame section

Example access to .eh_frame.

*/
int exampler(Dwarf_Debug dbg,Dwarf_Addr mypcval,Dwarf_Error *error)
{
/* Given a pc value
for a function find the FDE and CIE data for
the function.
Example shows basic access to FDE/CIE plus
one way to access details given a PC value.
dwarf_get_fde_n() allows accessing all FDE/CIE
data so one could build up an application-specific
table of information if that is more useful. */
Dwarf_Cie *cie_data = 0;
Dwarf_Signed cie_count = 0;
Dwarf_Fde *fde_data = 0;
Dwarf_Signed fde_count = 0;
int fres = 0;
fres = dwarf_get_fde_list_eh(dbg,&cie_data,&cie_count,
&fde_data,&fde_count,error);
if (fres == DW_DLV_OK) {
Dwarf_Fde myfde = 0;
Dwarf_Addr low_pc = 0;
Dwarf_Addr high_pc = 0;
fres = dwarf_get_fde_at_pc(fde_data,mypcval,
&myfde,&low_pc,&high_pc,
error);
if (fres == DW_DLV_OK) {
Dwarf_Cie mycie = 0;
fres = dwarf_get_cie_of_fde(myfde,&mycie,error);
if (fres == DW_DLV_ERROR) {
return fres;
}
if (fres == DW_DLV_OK) {
/* Now we can access a range of information
about the fde and cie applicable. */
}
}
dwarf_dealloc_fde_cie_list(dbg, cie_data, cie_count,
fde_data,fde_count);
return fres;
}
return fres;
}
struct Dwarf_Fde_s * Dwarf_Fde
Definition libdwarf.h:671
struct Dwarf_Debug_s * Dwarf_Debug
Definition libdwarf.h:603
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:597
struct Dwarf_Cie_s * Dwarf_Cie
Definition libdwarf.h:676
signed long long Dwarf_Signed
Definition libdwarf.h:197
unsigned long long Dwarf_Addr
Definition libdwarf.h:199
void dwarf_dealloc_fde_cie_list(Dwarf_Debug dw_dbg, Dwarf_Cie *dw_cie_data, Dwarf_Signed dw_cie_element_count, Dwarf_Fde *dw_fde_data, Dwarf_Signed dw_fde_element_count)
Release storage associated with FDE and CIE arrays.
int dwarf_get_fde_at_pc(Dwarf_Fde *dw_fde_data, Dwarf_Addr dw_pc_of_interest, Dwarf_Fde *dw_returned_fde, Dwarf_Addr *dw_lopc, Dwarf_Addr *dw_hipc, Dwarf_Error *dw_error)
Retrieve an FDE given a pc.
int dwarf_get_cie_of_fde(Dwarf_Fde dw_fde, Dwarf_Cie *dw_cie_returned, Dwarf_Error *dw_error)
Given FDE get CIE.
int dwarf_get_fde_list_eh(Dwarf_Debug dw_dbg, Dwarf_Cie **dw_cie_data, Dwarf_Signed *dw_cie_element_count, Dwarf_Fde **dw_fde_data, Dwarf_Signed *dw_fde_element_count, Dwarf_Error *dw_error)
Get lists of .eh_frame FDEs and CIEs.