GEL  0.99
Dwarf Debugging Information

Macros

#define dwarf_address_from_line(map, file, line)   gel_address_from_line(map, file, line)
 
#define dwarf_line_from_address(map, addr, file, line)   gel_line_from_address(map, addr, file, line)
 
#define dwarf_delete_line_map(map)   gel_delete_line_map(map)
 
#define dwarf_first_line(iter, map)   gel_first_line(iter, map)
 
#define dwarf_next_line(iter)   gel_next_line(iter)
 
#define dwarf_first_addr(iter, map)   gel_first_addr(iter, map)
 
#define dwarf_next_addr(iter)   gel_next_addr(iter)
 

Typedefs

typedef struct gel_line_map_t dwarf_line_map_t
 

Functions

dwarf_line_map_tdwarf_new_line_map (gel_file_t *file, gel_sect_t *section)
 

Detailed Description

This module provide access to the DWARF debugging information. Currently, only access to the map between the binary and the sources is provided.

To get such an information, you have first to get the line map :

#include <gel/dwarf_line.h>
dwarf_line_map_t *map = dwarf_new_line_map(GEL_file, containing_section);
...
dwarf_delete_line_map(map);
dwarf_line_map_t * dwarf_new_line_map(gel_file_t *file, gel_sect_t *section)
Definition: dwarf_line.c:1108
Definition: debug.h:67

If no containing section is given, the default section called ".debug_line" is used. dwarf_delete_line_map is used to release memory occupied by the line map.

If you have an address or a source file / line pair, you may get the corresponding information using the following functions :

const char **file, int *line);
vaddr_t dwarf_address_from_line(dwarf_line_map_t *map, const char *file, int line);
#define dwarf_line_from_address(map, addr, file, line)
#define dwarf_address_from_line(map, file, line)
uint32_t vaddr_t
Definition: types.h:36

The first one gives the start address of the code matching the given file name and line. The second one is used to get the line and the source file matching the given address.

You may also traverse all available lines :

for(loc = dwarf_first_line(&iter, map); loc.file;
loc = dwarf_next_line(&iter))
...
struct gel_line_iter_t dwarf_line_iter_t
Definition: dwarf_line.h:41
struct gel_location_t dwarf_location_t
Definition: dwarf_line.h:43
#define dwarf_next_line(iter)
#define dwarf_first_line(iter, map)

Or all available code blocks :

for(loc = dwarf_first_addr(&iter, map); loc.file;
loc = dwarf_next_addr(&iter))
...
struct gel_addr_iter_t dwarf_addr_iter_t
Definition: dwarf_line.h:42
#define dwarf_next_addr(iter)
#define dwarf_first_addr(iter, map)

The dwarf_location_t type provides usual information :

Macro Definition Documentation

◆ dwarf_address_from_line

#define dwarf_address_from_line (   map,
  file,
  line 
)    gel_address_from_line(map, file, line)

Get the actual address of a source line.

Parameters
mapLine map to use.
fileFile name.
lineLine number.
Returns
Matching address or null if no address is found.
Deprecated:
Use gel_address_from_line().

◆ dwarf_delete_line_map

#define dwarf_delete_line_map (   map)    gel_delete_line_map(map)

Delete a line map.

Parameters
mapLine map to delete.
Deprecated:
Use gel_delete_line_map().

◆ dwarf_first_addr

#define dwarf_first_addr (   iter,
  map 
)    gel_first_addr(iter, map)

Initialize the given iterator on the first address.

Parameters
iterIterator to initialize.
mapLine map to use.
Returns
Return the first location or an empty file location if there is no address.
Deprecated:
Use gel_first_addr().

◆ dwarf_first_line

#define dwarf_first_line (   iter,
  map 
)    gel_first_line(iter, map)

Initialize the iterator on the lines.

Parameters
iterIterator to use.
mapMap to iterate on.
Returns
First location or an empty file location if there is no line.
Deprecated:
Use gel_first_line().

◆ dwarf_line_from_address

#define dwarf_line_from_address (   map,
  addr,
  file,
  line 
)    gel_line_from_address(map, addr, file, line)

Get the file and line matching an actual binary address.

Parameters
mapUsed map.
addrLooked address.
fileReturned file.
lineReturned line.
Returns
0 for success, -1 if not found.
Deprecated:
Use gel_line_from_address().

◆ dwarf_next_addr

#define dwarf_next_addr (   iter)    gel_next_addr(iter)

Get the next location.

Parameters
iterCurrent address iterator.
Returns
Next address or empty file location.
Deprecated:
Use gel_next_addr().

◆ dwarf_next_line

#define dwarf_next_line (   iter)    gel_next_line(iter)

Go to the next line.

Parameters
iterUsed iterator.
Returns
Next location or an empty file location if there is no more line.
Deprecated:
Use gel_next_line().

Typedef Documentation

◆ dwarf_line_map_t

Type representing a code / line map.

Function Documentation

◆ dwarf_new_line_map()

dwarf_line_map_t* dwarf_new_line_map ( gel_file_t file,
gel_sect_t section 
)

Build the line information.

Parameters
fileFile containing the section.
sectionSection containing the information (null for default .debug_line).
Returns
Read line map or null for an error. gel_errno errors include: