Debug Extension
From Libfirm
Contents |
[edit] Usage
libFirm contains a builtin debug extension helping set breakpoints and inspecting data. The debug extension is accessed using the builtin firm_debug(command) 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
| current_ir_graph | the current graph, set by most libFirm functions |
| dump_ir_block_graph(current_ir_graph, suffix) | dumps the current graph |
| dump_ir_block_graph_sched(current_ir_graph, suffix) | dumps the current graph with scheduling info |
[edit] Commands
| .init | break after initialization |
| .create nr | break if node nr was created |
| .replace nr | break if node nr is replaced by another node |
| .lower nr | break before node nr is lowered |
| .remirg nr/name | break if the irg of nr or entity name is deleted |
| .newent nr/name | break if the entity nr or name was created |
| .newtype nr/name | break if the type nr or name was created |
| .bp | show all breakpoints |
| .enable nr | enable breakpoint nr |
| .disable nr | disable breakpoint nr |
| .showtype nr/name | show content of type nr or name |
| .showent nr/name | show content of entity nr or name |
| .setmask name msk | sets the debug module to mask msk |
| .setlvl name lvl | sets the debug module name to level lvl |
| .setoutfile name file | redirects debug output of module name to file |
| .irgname name | prints address and graph number of a method given by its name |
| .irgldname name | prints address and graph number of a method given by its ldname |
| .help | list all commands |
[edit] Example .gdbinit file
You can predefine gdb macros for common constructs like displaying an ir_node* or dumping a graph and opening it in ycomp. We use the following:
http://pp.info.uni-karlsruhe.de/~firm/.gdbinit
[edit] Installation for the FirmEvaluator DLL for DevStudio/Visual Studio
The FirmEvaluator shows complex Firm data structures like nodes or bitsets directly in the Visula Studio Debuggers.
Copy the firmEvaluator.dll to an appropriate place.
VC6: <InstallRoot>\Common\MSDev98\Bin\IDE VS2003/VS2005: <Visual Studio folder>\Common7\Packages\Debugger
Open the file AutoExp.dat in
VC6: <Visual Studio folder>\Common\MSDev98\Bin VS2003/VS2005: <Visual Studio folder>\Common7\Packages\Debugger
Add the following to the [AutoExpand] section:
; firm evaluator _arch_register_class_t=name=<name,s> arch_register_class_t=name=<name,s> _arch_register_t=name=<name,s> idx=<index,d> arch_register_t=name=<name,s> idx=<index,d> ir_graph=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_node=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_op=$ADDIN(<path to dll>firmEvaluator.dll,firm_op_Evaluate) entity=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_entity=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_prog=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_mode=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_type=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) tarval=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) ir_loop=$ADDIN(<path to dll>firmEvaluator.dll,firm_Evaluate) _ident=$ADDIN(<path to dll>firmEvaluator.dll,firm_ident_Evaluate) pset=$ADDIN(<path to dll>firmEvaluator.dll,firm_pset_Evaluate) set=$ADDIN(<path to dll>firmEvaluator.dll,firm_set_Evaluate) pmap=$ADDIN(<path to dll>firmEvaluator.dll,firm_set_Evaluate) eset=$ADDIN(<path to dll>firmEvaluator.dll,firm_set_Evaluate) _arr_descr=$ADDIN(<path to dll>firmEvaluator.dll,firm_arr_Evaluate) pdeq=$ADDIN(<path to dll>firmEvaluator.dll,firm_pdeq_Evaluate) _bitset_t=$ADDIN(<path to dll>firmEvaluator.dll,firm_bitset_Evaluate)
<path to dll> can be omitted if the DLL is copied to ts default directory.
The FirmEvaluator decodes the following data structions:
| ir_graph | IRG:{name} [graph number, number of nodes] |
| ir_node | {Node Op}{mode} [node number:node index] |
| ir_entity | ENT:{entity name} [entity number] |
| ir_type | {Type op} {name} [type number] |
| ir_op | operation name |
| ir_mode | mode name |
For the EDG Java frontend the following might be interesting:
; edgjfe a_text_buffer=size=<size,u> text=<buffer,s>


