GEL  0.99
Generic Debugging Information

Typedefs

typedef struct gel_location_t gel_location_t
 

Functions

void gel_delete_line_map (gel_line_map_t *map)
 
gel_location_t gel_first_line (gel_line_iter_t *iter, gel_line_map_t *map)
 
gel_location_t gel_next_line (gel_line_iter_t *iter)
 
gel_location_t gel_first_addr (gel_addr_iter_t *iter, gel_line_map_t *map)
 
gel_location_t gel_next_addr (gel_addr_iter_t *iter)
 
vaddr_t gel_address_from_line (gel_line_map_t *map, const char *file, int line)
 
int gel_line_from_address (gel_line_map_t *map, vaddr_t addr, const char **file, int *line)
 
gel_line_map_tgel_new_line_map (gel_file_t *file)
 

Detailed Description

This module provide access to the debugging information of an executable. It replaces and complement the old DWARF module allowing transparent access to any supported debugging format. For now, it only provides DWARF access but will soon support STABS debugging information.

To use debugging line information one has first to build a linemap once the executable has been opened:

if(map == NULL)
/ * handle error here * /
gel_line_map_t * gel_new_line_map(gel_file_t *file)
Definition: debug_line.c:476
Definition: debug.h:67

This function will automatically look for the available debugging information and invoke the matching manager. If no debugging information is found or for any error, it returns NULL (and error in gel_errno).

Then, you can retrieve the address matching a source / line pair with:

vaddr_t address = gel_address_from_line(map, "my_source.c", 666);
vaddr_t gel_address_from_line(gel_line_map_t *map, const char *file, int line)
Definition: debug_line.c:355
uint32_t vaddr_t
Definition: types.h:36

Or do the inverse, getting source and line from an address (if any).

const char *source;
int line;
if(gel_line_from_address(map, address, &source, &line) < 0)
/ * there is an error ! * /
int gel_line_from_address(gel_line_map_t *map, vaddr_t addr, const char **file, int *line)
Definition: debug_line.c:387

You can also traverse the list of sorted by source / line information:

for(loc = dwarf_first_line(&iter, map); loc.file; loc = dwarf_next_line(&iter))
printf("low address=%08x, high address=%08x, line=%8d, file=%s\n",
loc.low_addr, loc.high_addr, loc.line, loc.file);
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)

Notice that, in this case, if the debugging information contains aliases (same file name for different instructions blocks), ony one will be visible.

Or the list of available sorted by memory addresses:

for(loc = dwarf_first_addr(&iter, map); loc.file; loc = dwarf_next_addr(&iter))
printf("low address=%08x, high address=%08x, line=%8d, file=%s\n",
loc.low_addr, loc.high_addr, loc.line, loc.file);
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)

Finally, the linemap may be fried with:

void gel_delete_line_map(gel_line_map_t *map)
Definition: debug_line.c:104

Typedef Documentation

◆ gel_location_t

This structure is used to return a debugging line information made of a source file, a line, a starting and an ending address.

Function Documentation

◆ gel_address_from_line()

vaddr_t gel_address_from_line ( gel_line_map_t map,
const char *  file,
int  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.

◆ gel_delete_line_map()

void gel_delete_line_map ( gel_line_map_t map)

Delete a line map.

Parameters
mapLine map to delete.

◆ gel_first_addr()

gel_location_t gel_first_addr ( gel_addr_iter_t iter,
gel_line_map_t 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.

◆ gel_first_line()

gel_location_t gel_first_line ( gel_line_iter_t iter,
gel_line_map_t 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.

◆ gel_line_from_address()

int gel_line_from_address ( gel_line_map_t map,
vaddr_t  addr,
const char **  file,
int *  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.

◆ gel_new_line_map()

gel_line_map_t* gel_new_line_map ( gel_file_t file)

Open the debug source line information.

Parameters
fileFile to work on.
Returns
Created line map for file or NULL (error in gel_errno).

◆ gel_next_addr()

gel_location_t gel_next_addr ( gel_addr_iter_t iter)

Get the next location.

Parameters
iterCurrent address iterator.
Returns
Next address or empty file location.

◆ gel_next_line()

gel_location_t gel_next_line ( gel_line_iter_t iter)

Go to the next line.

Parameters
iterUsed iterator.
Returns
Next location or an empty file location if there is no more line.