$ FIRMDBG="create 123" my_firm_compiler
Command | |
---|---|
|
only dump graphs containing the given name |
|
break after initialization |
|
break if node nr was created |
|
break if node nr is replaced by another node |
|
break before node nr is lowered |
|
break if the irg of nr or entity name is deleted |
|
break if the entity nr or name was created |
|
break if the type nr or name was created |
|
show all breakpoints |
|
enable breakpoint nr |
|
disable breakpoint nr |
|
show content of type nr or name |
|
show content of entity nr or name |
|
sets the debug module to mask msk |
|
sets the debug module name to level lvl |
|
redirects debug output of module name to file |
|
prints address and graph number of a method given by its name |
|
prints address and graph number of a method given by its ldname |
|
list all commands |
libFirm contains a builtin debug extension helping set breakpoints and inspecting data.
When firm starts up the environment variable FIRMDBG is interpreted as debug commands. Examples:
$ FIRMDBG="create 123" my_firm_compiler
$ FIRMDBG="setmask firm.be.prefalloc -1" my_firm_compiler
The debug extension is accessed using the builtin firm_debug
function.
In gdb, issue a call
call firm_debug(".help")
In the Visual Studio Debugger, simply place a call into the watch window.
Further, the following functions/expression might be useful while debugging
Function | |
---|---|
|
dumps graph irg |
|
the current graph, set by most libFirm functions |
|
dumps graph irg |
You can predefine gdb macros for common constructs like displaying an ir_node*
or dumping the current graph for opening it in ycomp.
The following is a good idea:
set unwindonsignal on
# FIRM
# The following is able to print most important firm datastructures:
# ir_node*, tarval*, ir_type*, ir_mode* and maybe others should work
define irn
print gdb_node_helper($arg0)
end
# Hack to display the length of a firm ARR_F or ARR_D
define arrlen
p array_len($arg0)
end
define dumpg
if $argc == 1
if is_ir_graph($arg0)
call dump_ir_graph($arg0, "XXX")
else
if is_ir_node($arg0)
call dump_ir_graph(get_irn_irg($arg0), "XXX")
else
printf "Cannot determine graph of given argument\n"
end
end
else
call dump_ir_graph(current_ir_graph, "XXX")
end
end
define firmd
call firm_debug($arg0)
end
define graph
if $argc == 1
if is_ir_graph($arg0)
print gdb_node_helper($arg0)
else
if is_ir_node($arg0)
print gdb_node_helper(get_irn_irg($arg0))
else
printf "Cannot determine graph of given argument\n"
end
end
else
call dump_ir_graph(current_ir_graph, "XXX")
end
end
define keep
call add_End_keepalive(get_irg_end(get_irn_irg($arg0)), $arg0)
end
# cparser
define cpexpr
call print_expression($arg0), (void)putchar('\n')
end
define cpstmt
call print_statement($arg0)
end
define cptype
call print_type($arg0), (void)putchar('\n')
end