libdwarf: Using dwarf_srclines_b() and linecontext

libdwarf

Loading...
Searching...
No Matches
Using dwarf_srclines_b() and linecontext

Example two using dwarf_srclines_b(), dwarf_linesrc().

Example two using dwarf_srclines_b(), dwarf_linesrc().

See also
  dwarf_srclines_b
  dwarf_srclines_from_linecontext
  dwarf_srclines_dealloc_b

*/
int exampled(Dwarf_Debug dbg,Dwarf_Die somedie,Dwarf_Error *error)
{
Dwarf_Signed count = 0;
Dwarf_Line_Context context = 0;
Dwarf_Line *linebuf = 0;
Dwarf_Signed i = 0;
Dwarf_Line *line;
Dwarf_Small table_count =0;
Dwarf_Unsigned version = 0;
int sres = 0;
sres = dwarf_srclines_b(somedie,
&version, &table_count,&context,error);
if (sres != DW_DLV_OK) {
return sres;
}
sres = dwarf_srclines_from_linecontext(context,
&linebuf,&count,error);
if (sres != DW_DLV_OK) {
dwarf_srclines_dealloc_b(context);
return sres;
}
line = linebuf;
for (i = 0; i < count; ++line,++i) {
char * filename = 0;
int lres = 0;
Dwarf_Line dline = linebuf[i];
lres = dwarf_linesrc(dline,&filename,error);
if (lres != DW_DLV_OK) {
dwarf_srclines_dealloc_b(context);
return lres;
}
/* use filename
Dwarf_Die
struct Dwarf_Die_s * Dwarf_Die
Definition libdwarf.h:627
Dwarf_Line_Context
struct Dwarf_Line_Context_s * Dwarf_Line_Context
Definition libdwarf.h:716
Dwarf_Error
struct Dwarf_Error_s * Dwarf_Error
Definition libdwarf.h:611
Dwarf_Debug
struct Dwarf_Debug_s * Dwarf_Debug
Definition libdwarf.h:617
Dwarf_Line
struct Dwarf_Line_s * Dwarf_Line
Definition libdwarf.h:638
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_srclines_dealloc_b
DW_API void dwarf_srclines_dealloc_b(Dwarf_Line_Context dw_context)
Dealloc the memory allocated by dwarf_srclines_b.
dwarf_linesrc
DW_API int dwarf_linesrc(Dwarf_Line dw_line, char **dw_returned_name, Dwarf_Error *dw_error)
Return the file name applicable to the Dwarf_Line.
dwarf_srclines_b
DW_API int dwarf_srclines_b(Dwarf_Die dw_cudie, Dwarf_Unsigned *dw_version_out, Dwarf_Small *dw_table_count, Dwarf_Line_Context *dw_linecontext, Dwarf_Error *dw_error)
Initialize Dwarf_Line_Context for line table access.
dwarf_srclines_from_linecontext
DW_API int dwarf_srclines_from_linecontext(Dwarf_Line_Context dw_linecontext, Dwarf_Line **dw_linebuf, Dwarf_Signed *dw_linecount, Dwarf_Error *dw_error)
Access source lines from line context.