libdwarf
Functions
Macro Access: DWARF5

Functions

int dwarf_get_macro_context (Dwarf_Die dw_die, Dwarf_Unsigned *dw_version_out, Dwarf_Macro_Context *dw_macro_context, Dwarf_Unsigned *dw_macro_unit_offset_out, Dwarf_Unsigned *dw_macro_ops_count_out, Dwarf_Unsigned *dw_macro_ops_data_length_out, Dwarf_Error *dw_error)
 DWARF5 .debug_macro access via Dwarf_Die. More...
 
int dwarf_get_macro_context_by_offset (Dwarf_Die dw_die, Dwarf_Unsigned dw_offset, Dwarf_Unsigned *dw_version_out, Dwarf_Macro_Context *dw_macro_context, Dwarf_Unsigned *dw_macro_ops_count_out, Dwarf_Unsigned *dw_macro_ops_data_length, Dwarf_Error *dw_error)
 DWARF5 .debug_macro access via Dwarf_Die and an offset. More...
 
int dwarf_macro_context_total_length (Dwarf_Macro_Context dw_context, Dwarf_Unsigned *dw_mac_total_len, Dwarf_Error *dw_error)
 Return a macro context total length. More...
 
void dwarf_dealloc_macro_context (Dwarf_Macro_Context dw_mc)
 Dealloc a macro context. More...
 
int dwarf_macro_context_head (Dwarf_Macro_Context dw_mc, Dwarf_Half *dw_version, Dwarf_Unsigned *dw_mac_offset, Dwarf_Unsigned *dw_mac_len, Dwarf_Unsigned *dw_mac_header_len, unsigned int *dw_flags, Dwarf_Bool *dw_has_line_offset, Dwarf_Unsigned *dw_line_offset, Dwarf_Bool *dw_has_offset_size_64, Dwarf_Bool *dw_has_operands_table, Dwarf_Half *dw_opcode_count, Dwarf_Error *dw_error)
 Access the internal details of a Dwarf_Macro_Context. More...
 
int dwarf_macro_operands_table (Dwarf_Macro_Context dw_mc, Dwarf_Half dw_index, Dwarf_Half *dw_opcode_number, Dwarf_Half *dw_operand_count, const Dwarf_Small **dw_operand_array, Dwarf_Error *dw_error)
 Access to the details of the opcode operands table. More...
 
int dwarf_get_macro_op (Dwarf_Macro_Context dw_macro_context, Dwarf_Unsigned dw_op_number, Dwarf_Unsigned *dw_op_start_section_offset, Dwarf_Half *dw_macro_operator, Dwarf_Half *dw_forms_count, const Dwarf_Small **dw_formcode_array, Dwarf_Error *dw_error)
 Access macro operation details of a single operation. More...
 
int dwarf_get_macro_defundef (Dwarf_Macro_Context dw_macro_context, Dwarf_Unsigned dw_op_number, Dwarf_Unsigned *dw_line_number, Dwarf_Unsigned *dw_index, Dwarf_Unsigned *dw_offset, Dwarf_Half *dw_forms_count, const char **dw_macro_string, Dwarf_Error *dw_error)
 Get Macro defundef. More...
 
int dwarf_get_macro_startend_file (Dwarf_Macro_Context dw_macro_context, Dwarf_Unsigned dw_op_number, Dwarf_Unsigned *dw_line_number, Dwarf_Unsigned *dw_name_index_to_line_tab, const char **dw_src_file_name, Dwarf_Error *dw_error)
 Get Macro start end. More...
 
int dwarf_get_macro_import (Dwarf_Macro_Context dw_macro_context, Dwarf_Unsigned dw_op_number, Dwarf_Unsigned *dw_target_offset, Dwarf_Error *dw_error)
 Get Macro import. More...
 

Detailed Description

Reading the .debug_macro section.

See also
Reading .debug_macro data (DWARF5) An example reading .debug_macro

Function Documentation

◆ dwarf_get_macro_context()

int dwarf_get_macro_context ( Dwarf_Die  dw_die,
Dwarf_Unsigned dw_version_out,
Dwarf_Macro_Context dw_macro_context,
Dwarf_Unsigned dw_macro_unit_offset_out,
Dwarf_Unsigned dw_macro_ops_count_out,
Dwarf_Unsigned dw_macro_ops_data_length_out,
Dwarf_Error dw_error 
)
See also
Reading .debug_macro data (DWARF5)
Parameters
dw_dieThe CU DIE of interest.
dw_version_outOn success returns the macro context version (5)
dw_macro_contextOn success returns a pointer to a macro context which allows access to the context content.
dw_macro_unit_offset_outOn success returns the offset of the macro context.
dw_macro_ops_count_outOn success returns the number of macro operations in the context.
dw_macro_ops_data_length_outOn success returns the length in bytes of the operations in the context.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc. If no .debug_macro section exists for the CU it returns DW_DLV_NO_ENTRY.

◆ dwarf_get_macro_context_by_offset()

int dwarf_get_macro_context_by_offset ( Dwarf_Die  dw_die,
Dwarf_Unsigned  dw_offset,
Dwarf_Unsigned dw_version_out,
Dwarf_Macro_Context dw_macro_context,
Dwarf_Unsigned dw_macro_ops_count_out,
Dwarf_Unsigned dw_macro_ops_data_length,
Dwarf_Error dw_error 
)
Parameters
dw_dieThe CU DIE of interest.
dw_offsetThe offset in the section to begin reading.
dw_version_outOn success returns the macro context version (5)
dw_macro_contextOn success returns a pointer to a macro context which allows access to the context content.
dw_macro_ops_count_outOn success returns the number of macro operations in the context.
dw_macro_ops_data_lengthOn success returns the length in bytes of the macro context, starting at the offset of the first byte of the context.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc. If no .debug_macro section exists for the CU it returns DW_DLV_NO_ENTRY. If the dw_offset is outside the section it returns DW_DLV_ERROR.

◆ dwarf_macro_context_total_length()

int dwarf_macro_context_total_length ( Dwarf_Macro_Context  dw_context,
Dwarf_Unsigned dw_mac_total_len,
Dwarf_Error dw_error 
)
Parameters
dw_contextA pointer to the macro context of interest.
dw_mac_total_lenOn success returns the length in bytes of the macro context.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_dealloc_macro_context()

void dwarf_dealloc_macro_context ( Dwarf_Macro_Context  dw_mc)
Parameters
dw_mcA pointer to the macro context of interest. On return the caller should zero the pointer as the pointer is then stale.

◆ dwarf_macro_context_head()

int dwarf_macro_context_head ( Dwarf_Macro_Context  dw_mc,
Dwarf_Half dw_version,
Dwarf_Unsigned dw_mac_offset,
Dwarf_Unsigned dw_mac_len,
Dwarf_Unsigned dw_mac_header_len,
unsigned int *  dw_flags,
Dwarf_Bool dw_has_line_offset,
Dwarf_Unsigned dw_line_offset,
Dwarf_Bool dw_has_offset_size_64,
Dwarf_Bool dw_has_operands_table,
Dwarf_Half dw_opcode_count,
Dwarf_Error dw_error 
)

Not described in detail here. See DWARF5 Standard Section 6.3.1 Macro Information Header page 166.

◆ dwarf_macro_operands_table()

int dwarf_macro_operands_table ( Dwarf_Macro_Context  dw_mc,
Dwarf_Half  dw_index,
Dwarf_Half dw_opcode_number,
Dwarf_Half dw_operand_count,
const Dwarf_Small **  dw_operand_array,
Dwarf_Error dw_error 
)

Not of much interest to most libdwarf users.

Parameters
dw_mcThe macro context of interest.
dw_indexThe opcode operands table index. 0 through dw_opcode_count-1.
dw_opcode_numberOn success returns the opcode number in the table.
dw_operand_countOn success returns the number of forms for that dw_index.
dw_operand_arrayOn success returns the array of op operand forms
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_get_macro_op()

int dwarf_get_macro_op ( Dwarf_Macro_Context  dw_macro_context,
Dwarf_Unsigned  dw_op_number,
Dwarf_Unsigned dw_op_start_section_offset,
Dwarf_Half dw_macro_operator,
Dwarf_Half dw_forms_count,
const Dwarf_Small **  dw_formcode_array,
Dwarf_Error dw_error 
)

Useful for printing basic data about the operation.

Parameters
dw_macro_contextThe macro context of interest.
dw_op_numbervalid values are 0 through dw_macro_ops_count_out-1.
dw_op_start_section_offsetOn success returns the section offset of this operator.
dw_macro_operatorOn success returns the the macro operator itself, for example DW_MACRO_define.
dw_forms_countOn success returns the number of forms in the formcode array.
dw_formcode_arrayOn success returns a pointer to the formcode array of operand forms.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc.

◆ dwarf_get_macro_defundef()

int dwarf_get_macro_defundef ( Dwarf_Macro_Context  dw_macro_context,
Dwarf_Unsigned  dw_op_number,
Dwarf_Unsigned dw_line_number,
Dwarf_Unsigned dw_index,
Dwarf_Unsigned dw_offset,
Dwarf_Half dw_forms_count,
const char **  dw_macro_string,
Dwarf_Error dw_error 
)

To extract the value portion of a macro define:

See also
dwarf_find_macro_value_start
Parameters
dw_macro_contextThe macro context of interest.
dw_op_numbervalid values are 0 through dw_macro_ops_count_out-1. The op number must be for a def/undef.
dw_line_numberThe line number in the user source for this define/undef
dw_indexOn success if the macro is an strx form the value returned is the string index in the record, otherwise zero is returned.
dw_offsetOn success if the macro is an strp or sup form the value returned is the string offset in the appropriate section, otherwise zero is returned.
dw_forms_countOn success the value 2 is returned.
dw_macro_stringOn success a pointer to a null-terminated string is returned. Do not dealloc or free this string.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc. It is an error if operator dw_op_number is not a DW_MACRO_define, DW_MACRO_undef, DW_MACRO_define_strp DW_MACRO_undef_strp, DW_MACRO_undef_sup, DW_MACRO_undef_sup, DW_MACRO_define_strx, or DW_MACRO_undef_strx,

◆ dwarf_get_macro_startend_file()

int dwarf_get_macro_startend_file ( Dwarf_Macro_Context  dw_macro_context,
Dwarf_Unsigned  dw_op_number,
Dwarf_Unsigned dw_line_number,
Dwarf_Unsigned dw_name_index_to_line_tab,
const char **  dw_src_file_name,
Dwarf_Error dw_error 
)
Parameters
dw_macro_contextThe macro context of interest.
dw_op_numberValid values are 0 through dw_macro_ops_count_out-1. The op number must be for a start/end.
dw_line_numberIf end_file nothing is returned here. If start_file on success returns the line number of the source line of the include directive.
dw_name_index_to_line_tabIf end_file nothing is returned here. If start_file on success returns the file name index in the line table file names table.
dw_src_file_nameIf end_file nothing is returned here. If start_file on success returns a pointer to the null-terminated source file name. Do not free or dealloc this string.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc. It is an error if the operator is not DW_MACRO_start_file or DW_MACRO_end_file.

◆ dwarf_get_macro_import()

int dwarf_get_macro_import ( Dwarf_Macro_Context  dw_macro_context,
Dwarf_Unsigned  dw_op_number,
Dwarf_Unsigned dw_target_offset,
Dwarf_Error dw_error 
)
Parameters
dw_macro_contextThe macro context of interest.
dw_op_numberValid values are 0 through dw_macro_ops_count_out-1.
dw_target_offsetReturns the offset in the imported section.
dw_errorThe usual error detail return pointer.
Returns
Returns DW_DLV_OK etc. It is an error if the operator is not DW_MACRO_import or DW_MACRO_import_sup.