libdwarf
|
Functions | |
int | dwarf_srcfiles (Dwarf_Die dw_cu_die, char ***dw_srcfiles, Dwarf_Signed *dw_filecount, Dwarf_Error *dw_error) |
The list of source files from the line table header. More... | |
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. More... | |
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. More... | |
int | dwarf_srclines_two_level_from_linecontext (Dwarf_Line_Context dw_context, Dwarf_Line **dw_linebuf, Dwarf_Signed *dw_linecount, Dwarf_Line **dw_linebuf_actuals, Dwarf_Signed *dw_linecount_actuals, Dwarf_Error *dw_error) |
Returns line table counts and data. More... | |
void | dwarf_srclines_dealloc_b (Dwarf_Line_Context dw_context) |
Dealloc the memory allocated by dwarf_srclines_b. More... | |
int | dwarf_srclines_table_offset (Dwarf_Line_Context dw_context, Dwarf_Unsigned *dw_offset, Dwarf_Error *dw_error) |
Return the srclines table offset. More... | |
int | dwarf_srclines_comp_dir (Dwarf_Line_Context dw_context, const char **dw_compilation_directory, Dwarf_Error *dw_error) |
Compilation Directory name for the CU. More... | |
int | dwarf_srclines_subprog_count (Dwarf_Line_Context dw_context, Dwarf_Signed *dw_count, Dwarf_Error *dw_error) |
Subprog count: Part of the two-level line table extension. More... | |
int | dwarf_srclines_subprog_data (Dwarf_Line_Context dw_context, Dwarf_Signed dw_index, const char **dw_name, Dwarf_Unsigned *dw_decl_file, Dwarf_Unsigned *dw_decl_line, Dwarf_Error *dw_error) |
Retrieve data from the line table subprog array. More... | |
int | dwarf_srclines_files_indexes (Dwarf_Line_Context dw_context, Dwarf_Signed *dw_baseindex, Dwarf_Signed *dw_count, Dwarf_Signed *dw_endindex, Dwarf_Error *dw_error) |
Return values easing indexing line table file numbers. Count is the real count of files array entries. Since DWARF 2,3,4 are zero origin indexes and DWARF5 and later are one origin, this function replaces dwarf_srclines_files_count(). More... | |
int | dwarf_srclines_files_data_b (Dwarf_Line_Context dw_context, Dwarf_Signed dw_index_in, const char **dw_name, Dwarf_Unsigned *dw_directory_index, Dwarf_Unsigned *dw_last_mod_time, Dwarf_Unsigned *dw_file_length, Dwarf_Form_Data16 **dw_md5ptr, Dwarf_Error *dw_error) |
Access data for each line table file. More... | |
int | dwarf_srclines_include_dir_count (Dwarf_Line_Context dw_line_context, Dwarf_Signed *dw_count, Dwarf_Error *dw_error) |
Return the number of include directories in the Line Table. More... | |
int | dwarf_srclines_include_dir_data (Dwarf_Line_Context dw_line_context, Dwarf_Signed dw_index, const char **dw_name, Dwarf_Error *dw_error) |
Return the include directories in the Line Table. More... | |
int | dwarf_srclines_version (Dwarf_Line_Context dw_line_context, Dwarf_Unsigned *dw_version, Dwarf_Small *dw_table_count, Dwarf_Error *dw_error) |
The DWARF version number of this compile-unit. More... | |
int | dwarf_linebeginstatement (Dwarf_Line dw_line, Dwarf_Bool *dw_returned_bool, Dwarf_Error *dw_error) |
Read Line beginstatement register. More... | |
int | dwarf_lineendsequence (Dwarf_Line dw_line, Dwarf_Bool *dw_returned_bool, Dwarf_Error *dw_error) |
Read Line endsequence register flag. More... | |
int | dwarf_lineno (Dwarf_Line dw_line, Dwarf_Unsigned *dw_returned_linenum, Dwarf_Error *dw_error) |
Read Line line register. More... | |
int | dwarf_line_srcfileno (Dwarf_Line dw_line, Dwarf_Unsigned *dw_returned_filenum, Dwarf_Error *dw_error) |
Read Line file register. More... | |
int | dwarf_line_is_addr_set (Dwarf_Line dw_line, Dwarf_Bool *dw_is_addr_set, Dwarf_Error *dw_error) |
Is the Dwarf_Line address from DW_LNS_set_address? This is not a line register, but it is a flag set by the library in each Dwarf_Line, and it is derived from reading the line table. More... | |
int | dwarf_lineaddr (Dwarf_Line dw_line, Dwarf_Addr *dw_returned_addr, Dwarf_Error *dw_error) |
Return the address of the Dwarf_Line. More... | |
int | dwarf_lineoff_b (Dwarf_Line dw_line, Dwarf_Unsigned *dw_returned_lineoffset, Dwarf_Error *dw_error) |
Return a column number through the pointer. More... | |
int | dwarf_linesrc (Dwarf_Line dw_line, char **dw_returned_name, Dwarf_Error *dw_error) |
Return the file name applicable to the Dwarf_Line. More... | |
int | dwarf_lineblock (Dwarf_Line dw_line, Dwarf_Bool *dw_returned_bool, Dwarf_Error *dw_error) |
Return the basic_block line register. More... | |
int | dwarf_prologue_end_etc (Dwarf_Line dw_line, Dwarf_Bool *dw_prologue_end, Dwarf_Bool *dw_epilogue_begin, Dwarf_Unsigned *dw_isa, Dwarf_Unsigned *dw_discriminator, Dwarf_Error *dw_error) |
Return various line table registers in one call. More... | |
int | dwarf_linelogical (Dwarf_Line dw_line, Dwarf_Unsigned *dw_returned_logical, Dwarf_Error *dw_error) |
Experimental Two-level logical Row Number Experimental two level line tables. Not explained here. When reading from an actuals table, dwarf_line_logical() returns the logical row number for the line. | |
int | dwarf_linecontext (Dwarf_Line dw_line, Dwarf_Unsigned *dw_returned_context, Dwarf_Error *dw_error) |
Experimental Two-level line tables call contexts Experimental two level line tables. Not explained here. When reading from a logicals table, dwarf_linecontext() returns the logical row number corresponding the the calling context for an inlined call. | |
int | dwarf_line_subprogno (Dwarf_Line, Dwarf_Unsigned *, Dwarf_Error *) |
Two-level line tables get subprogram number Experimental two level line tables. Not explained here. When reading from a logicals table, dwarf_line_subprogno() returns the index in the subprograms table of the inlined subprogram. Currently this always returns zero through the pointer as the relevant field is never updated from the default of zero. | |
int | dwarf_line_subprog (Dwarf_Line, char **, char **, Dwarf_Unsigned *, Dwarf_Error *) |
Two-level line tables get subprog, file, line Experimental two level line tables. Not explained here. When reading from a logicals table, dwarf_line_subprog() returns the name of the inlined subprogram, its declaration filename, and its declaration line number, if available. | |
int | dwarf_check_lineheader_b (Dwarf_Die dw_cu_die, int *dw_errcount_out, Dwarf_Error *dw_error) |
Access to detailed line table header issues. More... | |
int | dwarf_print_lines (Dwarf_Die dw_cu_die, Dwarf_Error *dw_error, int *dw_errorcount_out) |
Print line information in great detail. More... | |
struct Dwarf_Printf_Callback_Info_s | dwarf_register_printf_callback (Dwarf_Debug dw_dbg, struct Dwarf_Printf_Callback_Info_s *dw_callbackinfo) |
For line details this records callback details. More... | |
Access to all the line table details.
int dwarf_srcfiles | ( | Dwarf_Die | dw_cu_die, |
char *** | dw_srcfiles, | ||
Dwarf_Signed * | dw_filecount, | ||
Dwarf_Error * | dw_error | ||
) |
The array returned by this function applies to a single compilation unit (CU).
The returned array is indexed from 0 (zero) to dw_filecount-1 when the function returns DW_DLV_OK.
In referencing the array via a file-number from a DW_AT_decl_file or DW_AT_call_file attribute one needs to know if the CU is DWARF5 or not.
Line Table Version numbers match compilation unit version numbers except that an experimental line table with line table version 0xfe06 has sometimes been used with DWARF4.
For DWARF5:
The file-number from a DW_AT_decl_file or DW_AT_call_file is the proper index into the array of string pointers.
For DWARF2,3,4, including experimental line table version 0xfe06 and a file-number from a DW_AT_decl_file or DW_AT_call_file:
The name strings returned are each assembled in the following way by dwarf_srcfiles():
To retrieve the line table version call dwarf_srclines_b() and dwarf_srclines_version().
dw_cu_die | The CU DIE in this CU. |
dw_srcfiles | On success allocates an array of pointers to strings and for each such, computes the fullest path possible given the CU DIE data for each file name listed in the line table header. |
dw_filecount | On success returns the number of entries in the array of pointers to strings. The number returned is non-negative. |
dw_error | The usual error pointer. |
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 | ||
) |
Returns Dwarf_Line_Context pointer, needed for access to line table data. Returns the line table version number (needed to use dwarf_srcfiles() properly).
dw_cudie | The Compilation Unit (CU) DIE of interest. |
dw_version_out | The DWARF Line Table version number (Standard: 2,3,4, or 5) Version 0xf006 is an experimental (two-level) line table. |
dw_table_count | Zero or one means this is a normal DWARF line table. Two means this is an experimental two-level line table. |
dw_linecontext | On success sets the pointer to point to an opaque structure usable for further queries. |
dw_error | The usual error pointer. |
int dwarf_srclines_from_linecontext | ( | Dwarf_Line_Context | dw_linecontext, |
Dwarf_Line ** | dw_linebuf, | ||
Dwarf_Signed * | dw_linecount, | ||
Dwarf_Error * | dw_error | ||
) |
Provides access to Dwarf_Line data from a Dwarf_Line_Context on a standard line table.
dw_linecontext | The line context of interest. |
dw_linebuf | On success returns an array of pointers to Dwarf_Line. |
dw_linecount | On success returns the count of entries in dw_linebuf. If dw_linecount is returned as zero this is a line table with no lines. |
dw_error | The usual error pointer. |
int dwarf_srclines_two_level_from_linecontext | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Line ** | dw_linebuf, | ||
Dwarf_Signed * | dw_linecount, | ||
Dwarf_Line ** | dw_linebuf_actuals, | ||
Dwarf_Signed * | dw_linecount_actuals, | ||
Dwarf_Error * | dw_error | ||
) |
Works for DWARF2,3,4,5 and for experimental two-level line tables. A single level table will have *linebuf_actuals and *linecount_actuals set to 0.
Two-level line tables are non-standard and not documented further. For standard (one-level) tables, it will return the single table through dw_linebuf, and the value returned through dw_linecount_actuals will be 0.
People not using these two-level tables should dwarf_srclines_from_linecontext instead.
void dwarf_srclines_dealloc_b | ( | Dwarf_Line_Context | dw_context | ) |
The way to deallocate (free) a Dwarf_Line_Context
dw_context | The context to be dealloced (freed). On return the pointer passed in is stale and calling applications should zero the pointer. |
int dwarf_srclines_table_offset | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Unsigned * | dw_offset, | ||
Dwarf_Error * | dw_error | ||
) |
The offset is in the relevant .debug_line or .debug_line.dwo section (and in a split dwarf package file includes the base line table offset).
dw_context | |
dw_offset | On success returns the section offset of the dw_context. |
dw_error | The usual error pointer. |
int dwarf_srclines_comp_dir | ( | Dwarf_Line_Context | dw_context, |
const char ** | dw_compilation_directory, | ||
Dwarf_Error * | dw_error | ||
) |
Do not free() or dealloc the string, it is in a dwarf section.
dw_context | The Line Context of interest. |
dw_compilation_directory | On success returns a pointer to a string identifying the compilation directory of the CU. |
dw_error | The usual error pointer. |
int dwarf_srclines_subprog_count | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Signed * | dw_count, | ||
Dwarf_Error * | dw_error | ||
) |
A non-standard table. The actual meaning of subprog count left undefined here.
dw_context | The Dwarf_Line_Context of interest. |
dw_count | On success returns the two-level line table subprogram array size in this line context. |
dw_error | The usual error pointer. |
int dwarf_srclines_subprog_data | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Signed | dw_index, | ||
const char ** | dw_name, | ||
Dwarf_Unsigned * | dw_decl_file, | ||
Dwarf_Unsigned * | dw_decl_line, | ||
Dwarf_Error * | dw_error | ||
) |
A non-standard table. Not defined here.
dw_context | The Dwarf_Line_Context of interest. |
dw_index | The item to retrieve. Valid indexes are 1 through dw_count. |
dw_name | On success returns a pointer to the subprog name. |
dw_decl_file | On success returns a file number through the pointer. |
dw_decl_line | On success returns a line number through the pointer. |
dw_error | The usual error pointer. |
int dwarf_srclines_files_indexes | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Signed * | dw_baseindex, | ||
Dwarf_Signed * | dw_count, | ||
Dwarf_Signed * | dw_endindex, | ||
Dwarf_Error * | dw_error | ||
) |
dw_context | The line context of interest. |
dw_baseindex | On success returns the base index of valid file indexes. With DWARF2,3,4 the value is 1. With DWARF5 the value is 0. |
dw_count | On success returns the real count of entries. |
dw_endindex | On success returns value such that callers should index as dw_baseindex through dw_endindex-1. |
dw_error | The usual error pointer. |
int dwarf_srclines_files_data_b | ( | Dwarf_Line_Context | dw_context, |
Dwarf_Signed | dw_index_in, | ||
const char ** | dw_name, | ||
Dwarf_Unsigned * | dw_directory_index, | ||
Dwarf_Unsigned * | dw_last_mod_time, | ||
Dwarf_Unsigned * | dw_file_length, | ||
Dwarf_Form_Data16 ** | dw_md5ptr, | ||
Dwarf_Error * | dw_error | ||
) |
Has the md5ptr field so cases where DW_LNCT_MD5 is present can return pointer to the MD5 value. With DWARF 5 index starts with 0. dwarf_srclines_files_indexes() makes indexing through the files easy.
dw_context | The line context of interest. |
dw_index_in | The entry of interest. Callers should index as dw_baseindex through dw_endindex-1. |
dw_name | If dw_name non-null on success returns The file name in the line table header through the pointer. |
dw_directory_index | If dw_directory_index non-null on success returns the directory number in the line table header through the pointer. |
dw_last_mod_time | If dw_last_mod_time non-null on success returns the directory last modification date/time through the pointer. |
dw_file_length | If dw_file_length non-null on success returns the file length recorded in the line table through the pointer. |
dw_md5ptr | If dw_md5ptr non-null on success returns a pointer to the 16byte MD5 hash of the file through the pointer. If there is no md5 value present it returns 0 through the pointer. |
dw_error | The usual error pointer. |
int dwarf_srclines_include_dir_count | ( | Dwarf_Line_Context | dw_line_context, |
Dwarf_Signed * | dw_count, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line_context | The line context of interest. |
dw_count | On success returns the count of directories. How to use this depends on the line table version number. |
dw_error | The usual error pointer. |
int dwarf_srclines_include_dir_data | ( | Dwarf_Line_Context | dw_line_context, |
Dwarf_Signed | dw_index, | ||
const char ** | dw_name, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line_context | The line context of interest. |
dw_index | Pass in an index to the line context list of include directories. If the line table is version 2,3, or 4, the valid indexes are 1 through dw_count. If the line table is version 5 the valid indexes are 0 through dw_count-1. |
dw_name | On success it returns a pointer to a directory name. Do not free/deallocate the string. |
dw_error | The usual error pointer. |
int dwarf_srclines_version | ( | Dwarf_Line_Context | dw_line_context, |
Dwarf_Unsigned * | dw_version, | ||
Dwarf_Small * | dw_table_count, | ||
Dwarf_Error * | dw_error | ||
) |
The .debug_lines[.dwo] table count informs about the line table version and the type of line table involved.
Meaning of the value returned via dw_table_count:
dw_line_context | The Line Context of interest. |
dw_version | On success, returns the line table version through the pointer. |
dw_table_count | On success, returns the tablecount through the pointer. If the table count is zero the line table is a header with no lines. If the table count is 1 this is a standard line table. If the table count is this is an experimental two-level line table. |
dw_error | The usual error pointer. |
int dwarf_linebeginstatement | ( | Dwarf_Line | dw_line, |
Dwarf_Bool * | dw_returned_bool, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_bool | On success it sets the value TRUE (if the dw_line has the is_stmt register set) and FALSE if is_stmt is not set. |
dw_error | The usual error pointer. |
int dwarf_lineendsequence | ( | Dwarf_Line | dw_line, |
Dwarf_Bool * | dw_returned_bool, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_bool | On success it sets the value TRUE (if the dw_line has the end_sequence register set) and FALSE if end_sequence is not set. |
dw_error | The usual error pointer. |
int dwarf_lineno | ( | Dwarf_Line | dw_line, |
Dwarf_Unsigned * | dw_returned_linenum, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_linenum | On success it sets the value to the line number from the Dwarf_Line line register |
dw_error | The usual error pointer. |
int dwarf_line_srcfileno | ( | Dwarf_Line | dw_line, |
Dwarf_Unsigned * | dw_returned_filenum, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_filenum | On success it sets the value to the file number from the Dwarf_Line file register |
dw_error | The usual error pointer. |
int dwarf_line_is_addr_set | ( | Dwarf_Line | dw_line, |
Dwarf_Bool * | dw_is_addr_set, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_is_addr_set | On success it sets the flag to TRUE or FALSE. |
dw_error | The usual error pointer. |
int dwarf_lineaddr | ( | Dwarf_Line | dw_line, |
Dwarf_Addr * | dw_returned_addr, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_addr | On success it sets the value to the value of the address register in the Dwarf_Line. |
dw_error | The usual error pointer. |
int dwarf_lineoff_b | ( | Dwarf_Line | dw_line, |
Dwarf_Unsigned * | dw_returned_lineoffset, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_lineoffset | On success it sets the value to the column register from the Dwarf_Line. |
dw_error | The usual error pointer. |
int dwarf_linesrc | ( | Dwarf_Line | dw_line, |
char ** | dw_returned_name, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_name | On success it reads the file register and finds the source file name from the line table header and returns a pointer to that file name string through the pointer. |
dw_error | The usual error pointer. Do not dealloc or free the string. |
int dwarf_lineblock | ( | Dwarf_Line | dw_line, |
Dwarf_Bool * | dw_returned_bool, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_returned_bool | On success it sets the flag to TRUE or FALSE from the basic_block register in the line table. |
dw_error | The usual error pointer. |
int dwarf_prologue_end_etc | ( | Dwarf_Line | dw_line, |
Dwarf_Bool * | dw_prologue_end, | ||
Dwarf_Bool * | dw_epilogue_begin, | ||
Dwarf_Unsigned * | dw_isa, | ||
Dwarf_Unsigned * | dw_discriminator, | ||
Dwarf_Error * | dw_error | ||
) |
dw_line | The Dwarf_Line of interest. |
dw_prologue_end | On success it sets the flag to TRUE or FALSE from the prologue_end register in the line table. |
dw_epilogue_begin | On success it sets the flag to TRUE or FALSE from the epilogue_begin register in the line table. |
dw_isa | On success it sets the value to the value of from the isa register in the line table. |
dw_discriminator | On success it sets the value to the value of from the discriminator register in the line table. |
dw_error | The usual error pointer. |
int dwarf_check_lineheader_b | ( | Dwarf_Die | dw_cu_die, |
int * | dw_errcount_out, | ||
Dwarf_Error * | dw_error | ||
) |
Lets the caller get detailed messages about some compiler errors we detect. Calls back, the caller should do something with the messages (likely just print them). The lines passed back already have newlines.
dw_cu_die | The CU DIE of interest |
dw_error | If DW_DLV_ERROR this shows one error encountered. |
dw_errcount_out | Returns the count of detected errors through the pointer. |
int dwarf_print_lines | ( | Dwarf_Die | dw_cu_die, |
Dwarf_Error * | dw_error, | ||
int * | dw_errorcount_out | ||
) |
dwarf_print_lines lets the caller prints line information for a CU in great detail. Does not use printf. Instead it calls back to the application using a function pointer once per line-to-print. The lines passed back already have any needed newlines.
dwarfdump uses this function for verbose printing of line table data.
Failing to call the dwarf_register_printf_callback() function will prevent the lines from being passed back but such omission is not an error. The same function, but focused on checking for errors is dwarf_check_lineheader_b().
dw_cu_die | The CU DIE of interest |
dw_error | |
dw_errorcount_out |
struct Dwarf_Printf_Callback_Info_s dwarf_register_printf_callback | ( | Dwarf_Debug | dw_dbg, |
struct Dwarf_Printf_Callback_Info_s * | dw_callbackinfo | ||
) |
Not usually needed. It is a way to check (while using the library) what callback data is in use or to update that callback data.
dw_dbg | The Dwarf_Debug of interest. |
dw_callbackinfo | If non-NULL pass in a pointer to your instance of struct Dwarf_Printf_Callback_Info_s with all the fields filled in. |