From 56cad49780d5a7a8f433e7b9f968acbf22cf33c6 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 4 Jul 2005 13:55:50 +0000 Subject: [PATCH] added function for convertion debug info into human readable strings [r6177] --- ir/debug/dbginfo.c | 22 +++++++++------------- ir/debug/dbginfo.h | 35 ++++++++++++++++++++++++++++++++++- ir/debug/dbginfo_t.h | 12 +++++++----- 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/ir/debug/dbginfo.c b/ir/debug/dbginfo.c index 83b491d4c..99c88372e 100644 --- a/ir/debug/dbginfo.c +++ b/ir/debug/dbginfo.c @@ -10,7 +10,6 @@ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ - #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -21,30 +20,27 @@ #include "entity_t.h" void -dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) { +default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info) { set_irn_dbg_info(nw, get_irn_dbg_info(old)); } void -dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes, +default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes, ir_node **old_nodes, int n_old_nodes, dbg_action info) { } +merge_pair_func *__dbg_info_merge_pair = default_dbg_info_merge_pair; -void (*__dbg_info_merge_pair)(ir_node *nw, ir_node *old, dbg_action info) - = &dbg_info_merge_pair; - -void (*__dbg_info_merge_sets)(ir_node **new_nodes, int n_new_nodes, - ir_node **old_nodes, int n_old_nodes, - dbg_action info) - = &dbg_info_merge_sets; +merge_sets_func *__dbg_info_merge_sets = default_dbg_info_merge_sets; +snprint_dbg_func *__dbg_info_snprint = (snprint_dbg_func *)0; -void dbg_init( merge_pair_func *mpf, merge_sets_func *msf ) +void dbg_init( merge_pair_func *mpf, merge_sets_func *msf, snprint_dbg_func *snprint_dbg ) { - __dbg_info_merge_pair = mpf; - __dbg_info_merge_sets = msf; + __dbg_info_merge_pair = mpf ? mpf : default_dbg_info_merge_pair; + __dbg_info_merge_sets = msf ? msf : default_dbg_info_merge_sets; + __dbg_info_snprint = snprint_dbg; } diff --git a/ir/debug/dbginfo.h b/ir/debug/dbginfo.h index 5575248dc..e9ad670c8 100644 --- a/ir/debug/dbginfo.h +++ b/ir/debug/dbginfo.h @@ -183,11 +183,25 @@ typedef void merge_pair_func(ir_node *new_node, ir_node *old_node, dbg_action ac */ typedef void merge_sets_func(ir_node **new_node_array, int new_num_entries, ir_node **old_node_array, int old_num_entries, dbg_action action); +/** + * The type of the debug info to human readable string function. + * + * @param buf pointer to a buffer that will hold the info + * @param len length of the buffer + * @param dbg the debug info + * + * @return Number of written characters to the buffer. + * + * @see dbg_init() + */ +typedef unsigned snprint_dbg_func(char *buf, unsigned len, const dbg_info *dbg); + /** * Initializes the debug support. * * @param dbg_info_merge_pair see function description * @param dbg_info_merge_sets see function description + * @param snprint_dbg see function description * * This function takes Pointers to two functions that merge the * debug information when a @@ -208,9 +222,28 @@ typedef void merge_sets_func(ir_node **new_node_array, int new_num_entries, ir_n * * Further both functions pass an enumeration indicating the action * performed by the transformation, e.g. the kind of optimization performed. + * + * print_dbg is called to convert a debug info into a human readable string. + * This string is the dumped in the duper functions. + * + * Note that if NULL is passed for dbg_info_merge_pair or dbg_info_merge_sets, the default + * implementations default_dbg_info_merge_pair() and default_dbg_info_merge_sets() are used. */ -void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets); +void dbg_init(merge_pair_func *dbg_info_merge_pair, merge_sets_func *dbg_info_merge_sets, snprint_dbg_func *snprint_dbg); /** @} */ +/** + * The default merge_pair_func implementation, simply copies the debug info + * from old to new. + */ +void default_dbg_info_merge_pair(ir_node *nw, ir_node *old, dbg_action info); + +/** + * The default merge_sets_func implementation, does nothing + */ +void default_dbg_info_merge_sets(ir_node **new_nodes, int n_new_nodes, + ir_node **old_nodes, int n_old_nodes, + dbg_action info); + #endif /* _DBGINFO_H_ */ diff --git a/ir/debug/dbginfo_t.h b/ir/debug/dbginfo_t.h index c7894d23f..33e24e6dc 100644 --- a/ir/debug/dbginfo_t.h +++ b/ir/debug/dbginfo_t.h @@ -29,14 +29,16 @@ /** * The current merge_pair_func(), access only from inside firm. */ -extern void (*__dbg_info_merge_pair)(ir_node *nw, ir_node *old, - dbg_action info); +extern merge_pair_func *__dbg_info_merge_pair; /** * The current merge_sets_func(), access only from inside firm. */ -extern void (*__dbg_info_merge_sets)(ir_node **new_nodes, int n_new_nodes, - ir_node **old_nodes, int n_old_nodes, - dbg_action info); +extern merge_sets_func *__dbg_info_merge_sets; + +/** + * The current snprint_dbg_func(), access only from inside firm. + */ +extern snprint_dbg_func *__dbg_info_snprint; #endif /* __DBGINFO_T_H__ */ -- 2.20.1