X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fdebug%2Fdebugger.c;h=367972640c295e5b4d0a5974433927d5f2a5c820;hb=f5766f06d94098747aef5c0a0fb1ef75f2d8bb57;hp=9d454fe0248201755c7f9e572aade63ebc3125f3;hpb=760dc5e86197a06bf5c6379813c97c2944163a86;p=libfirm diff --git a/ir/debug/debugger.c b/ir/debug/debugger.c index 9d454fe02..367972640 100644 --- a/ir/debug/debugger.c +++ b/ir/debug/debugger.c @@ -1,18 +1,35 @@ /* - * Project: libFIRM - * File name: ir/debug/debugger.c - * Purpose: Helper function for integerated debug support - * Author: Michael Beck - * Modified by: - * Created: 2005 - * CVS-ID: $Id$ - * Copyright: (c) 2001-2007 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Helper function for integrated debug support + * @author Michael Beck + * @date 2005 + * @version $Id$ */ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "firm_config.h" + #ifdef DEBUG_libfirm #ifdef _WIN32 @@ -32,6 +49,9 @@ #ifdef HAVE_STRING_H #include #endif +#ifdef HAVE_STRINGS_H +#include +#endif #include @@ -41,8 +61,8 @@ #include "irgraph_t.h" #include "entity_t.h" #include "irprintf.h" -#include "typewalk.h" #include "irdump.h" +#include "iredges_t.h" #include "debug.h" #ifdef _WIN32 @@ -172,7 +192,7 @@ do { \ #define FIRM_DBG_MINOR 0 /** for automatic detection of the debug extension */ -static const char *firm_debug_info_string = +static const char firm_debug_info_string[] = API_VERSION(FIRM_DBG_MAJOR, FIRM_DBG_MINOR); /** @@ -240,6 +260,8 @@ static void dbg_printf(const char *fmt, ...) static void dbg_new_node(void *ctx, ir_graph *irg, ir_node *node) { bp_nr_t key, *elem; + (void) ctx; + (void) irg; key.nr = get_irn_node_nr(node); key.bp.reason = BP_ON_NEW_NODE; @@ -261,6 +283,7 @@ static void dbg_new_node(void *ctx, ir_graph *irg, ir_node *node) static void dbg_replace(void *ctx, ir_node *old, ir_node *nw) { bp_nr_t key, *elem; + (void) ctx; key.nr = get_irn_node_nr(old); key.bp.reason = BP_ON_REPLACE; @@ -281,6 +304,7 @@ static void dbg_replace(void *ctx, ir_node *old, ir_node *nw) static void dbg_lower(void *ctx, ir_node *node) { bp_nr_t key, *elem; + (void) ctx; key.nr = get_irn_node_nr(node); key.bp.reason = BP_ON_LOWER; @@ -300,6 +324,7 @@ static void dbg_lower(void *ctx, ir_node *node) */ static void dbg_free_graph(void *ctx, ir_graph *irg) { + (void) ctx; { bp_nr_t key, *elem; key.nr = get_irg_graph_nr(irg); @@ -337,6 +362,7 @@ static void dbg_free_graph(void *ctx, ir_graph *irg) */ static void dbg_new_entity(void *ctx, ir_entity *ent) { + (void) ctx; { bp_ident_t key, *elem; @@ -371,6 +397,7 @@ static void dbg_new_entity(void *ctx, ir_entity *ent) */ static void dbg_new_type(void *ctx, ir_type *tp) { + (void) ctx; { bp_nr_t key, *elem; @@ -421,6 +448,7 @@ static int cmp_nr_bp(const void *elt, const void *key, size_t size) { const bp_nr_t *e1 = elt; const bp_nr_t *e2 = key; + (void) size; return (e1->nr - e2->nr) | (e1->bp.reason - e2->bp.reason); } /* cmp_nr_bp */ @@ -432,6 +460,7 @@ static int cmp_ident_bp(const void *elt, const void *key, size_t size) { const bp_ident_t *e1 = elt; const bp_ident_t *e2 = key; + (void) size; return (e1->id != e2->id) | (e1->bp.reason - e2->bp.reason); } /* cmp_ident_bp */ @@ -1266,10 +1295,46 @@ void firm_init_debugger(void) firm_debug_break(); } /* firm_init_debugger */ +/** + * A gdb helper function to print firm objects. + */ +const char *gdb_node_helper(void *firm_object) { + static char buf[1024]; + ir_snprintf(buf, sizeof(buf), "%+F", firm_object); + return buf; +} + +/** + * A gdb helper function to print tarvals. + */ +const char *gdb_tarval_helper(void *tv_object) { + static char buf[1024]; + ir_snprintf(buf, sizeof(buf), "%+T", tv_object); + return buf; +} + +const char *gdb_out_edge_helper(const ir_node *node) { + static char buf[4*1024]; + char *b = buf; + size_t l; + size_t len = sizeof(buf); + const ir_edge_t *edge; + foreach_out_edge(node, edge) { + ir_node *n = get_edge_src_irn(edge); + + ir_snprintf(b, len, "%+F ", n); + l = strlen(b); + len -= l; + b += l; + } + + return buf; +} + #else /* some picky compiler do not allow empty files */ -static int _firm_only_that_you_can_compile_with_NDEBUG_defined; +static int __attribute__((unused)) _firm_only_that_you_can_compile_with_NDEBUG_defined; #endif /* NDEBUG */