libdwarf: Macro Access: DWARF5

libdwarf

Loading...
Searching...
No Matches
Functions
Macro Access: DWARF5

## Functions
DW_API 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.
DW_API 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.
DW_API 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.
DW_API void | dwarf_dealloc_macro_context (Dwarf_Macro_Context dw_mc)
| Dealloc a macro context.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.
DW_API 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.

## Detailed Description

Reading the .debug_macro section.

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

## Function Documentation

## ◆ dwarf_dealloc_macro_context()

DW_API void dwarf_dealloc_macro_context | ( | Dwarf_Macro_Context | dw_mc | ) |

Dealloc a macro context.

Parameters

  dw_mc | A pointer to the macro context of interest. On return the caller should zero the pointer as the pointer is then stale.

## ◆ dwarf_get_macro_context()

DW_API 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.

See also
  Reading .debug_macro data (DWARF5)

Parameters

  dw_die | The CU DIE of interest.
  dw_version_out | On success returns the macro context version (5)
  dw_macro_context | On success returns a pointer to a macro context which allows access to the context content.
  dw_macro_unit_offset_out | On success returns the offset of the macro context.
  dw_macro_ops_count_out | On success returns the number of macro operations in the context.
  dw_macro_ops_data_length_out | On success returns the length in bytes of the operations in the context.
  dw_error | The 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()

DW_API 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.

Parameters

  dw_die | The CU DIE of interest.
  dw_offset | The offset in the section to begin reading.
  dw_version_out | On success returns the macro context version (5)
  dw_macro_context | On success returns a pointer to a macro context which allows access to the context content.
  dw_macro_ops_count_out | On success returns the number of macro operations in the context.
  dw_macro_ops_data_length | On success returns the length in bytes of the macro context, starting at the offset of the first byte of the context.
  dw_error | The 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_get_macro_defundef()

DW_API 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.

To extract the value portion of a macro define:

See also
  dwarf_find_macro_value_start

Parameters

  dw_macro_context | The macro context of interest.
  dw_op_number | valid values are 0 through dw_macro_ops_count_out-1. The op number must be for a def/undef.
  dw_line_number | The line number in the user source for this define/undef
  dw_index | On success if the macro is an strx form the value returned is the string index in the record, otherwise zero is returned.
  dw_offset | On 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_count | On success the value 2 is returned.
  dw_macro_string | On success a pointer to a null-terminated string is returned. Do not dealloc or free this string.
  dw_error | The 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_import()

DW_API 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.

Parameters

  dw_macro_context | The macro context of interest.
  dw_op_number | Valid values are 0 through dw_macro_ops_count_out-1.
  dw_target_offset | Returns the offset in the imported section.
  dw_error | The 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.

## ◆ dwarf_get_macro_op()

DW_API 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.

Useful for printing basic data about the operation.

Parameters

  dw_macro_context | The macro context of interest.
  dw_op_number | valid values are 0 through dw_macro_ops_count_out-1.
  dw_op_start_section_offset | On success returns the section offset of this operator.
  dw_macro_operator | On success returns the the macro operator itself, for example DW_MACRO_define.
  dw_forms_count | On success returns the number of forms in the formcode array.
  dw_formcode_array | On success returns a pointer to the formcode array of operand forms.
  dw_error | The usual error detail return pointer.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_get_macro_startend_file()

DW_API 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.

Parameters

  dw_macro_context | The macro context of interest.
  dw_op_number | Valid values are 0 through dw_macro_ops_count_out-1. The op number must be for a start/end.
  dw_line_number | If 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_tab | If 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_name | If 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_error | The 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_macro_context_head()

DW_API 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.

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

## ◆ dwarf_macro_context_total_length()

DW_API 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.

Parameters

  dw_context | A pointer to the macro context of interest.
  dw_mac_total_len | On success returns the length in bytes of the macro context.
  dw_error | The usual error detail return pointer.

Returns
  Returns DW_DLV_OK etc.

## ◆ dwarf_macro_operands_table()

DW_API 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.

Not of much interest to most libdwarf users.

Parameters

  dw_mc | The macro context of interest.
  dw_index | The opcode operands table index. 0 through dw_opcode_count-1.
  dw_opcode_number | On success returns the opcode number in the table.
  dw_operand_count | On success returns the number of forms for that dw_index.
  dw_operand_array | On success returns the array of op operand forms
  dw_error | The usual error detail return pointer.

Returns
  Returns DW_DLV_OK etc.