#include "config.h"
#endif
-#ifndef NDEBUG
+#ifdef DEBUG_libfirm
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
}
{
bp_ident_t key, *elem;
- entity *ent = get_irg_entity(irg);
+ ir_entity *ent = get_irg_entity(irg);
if (! ent)
return;
* @param ctx the hook context
* @param ent the newly created entity
*/
-static void dbg_new_entity(void *ctx, entity *ent)
+static void dbg_new_entity(void *ctx, ir_entity *ent)
{
{
bp_ident_t key, *elem;
".setmask name msk sets the debug module name to mask msk\n"
".setlvl name lvl sets the debug module name to level lvl\n"
".setoutfile name file redirects debug output of module name to file\n"
+ ".irgname name prints address and graph number of a method given by its name\n"
+ ".irgldname ldname prints address and graph number of a method given by its ldname\n"
".help list all commands\n"
);
} /* show_commands */
long nr; /**< the number that is searched for */
const char *name; /**< the name that is searched for */
} u;
- entity *res; /**< the result */
+ ir_entity *res; /**< the result */
} find_env_t;
/**
* Type-walker: Find an entity with given number.
*/
static void check_ent_nr(type_or_ent *tore, void *ctx) {
- entity *ent = (entity *)tore;
+ ir_entity *ent = (ir_entity *)tore;
find_env_t *env = ctx;
if (is_entity(ent))
* Type-walker: Find an entity with given name.
*/
static void check_ent_name(type_or_ent *tore, void *ctx) {
- entity *ent = (entity *)tore;
+ ir_entity *ent = (ir_entity *)tore;
find_env_t *env = ctx;
if (is_entity(ent))
/**
* Find a firm entity by its number.
*/
-static entity *find_entity_nr(long nr) {
+static ir_entity *find_entity_nr(long nr) {
find_env_t env;
env.u.nr = nr;
/**
* Find a firm entity by its name.
*/
-static entity *find_entity_name(const char *name) {
+static ir_entity *find_entity_name(const char *name) {
find_env_t env;
env.u.name = name;
return env.res;
} /* find_entity_name */
+/**
+ * Search methods for a name.
+ */
+static void show_by_name(type_or_ent *tore, void *env) {
+ ident *id = (ident *)env;
+
+ if (is_entity(tore)) {
+ ir_entity *ent = (ir_entity *)tore;
+
+ if (is_method_entity(ent)) {
+ if (get_entity_ident(ent) == id) {
+ ir_type *owner = get_entity_owner(ent);
+ ir_graph *irg = get_entity_irg(ent);
+
+ if (owner != get_glob_type()) {
+ printf("%s::%s", get_type_name(owner), get_id_str(id));
+ } else {
+ printf("%s", get_id_str(id));
+ }
+ if (irg)
+ printf("[%ld] (%p)\n", get_irg_graph_nr(irg), irg);
+ else
+ printf(" NULL\n");
+ }
+ }
+ }
+} /* show_by_name */
+
+/**
+ * Search methods for a ldname.
+ */
+static void show_by_ldname(type_or_ent *tore, void *env) {
+ ident *id = (ident *)env;
+
+ if (is_entity(tore)) {
+ ir_entity *ent = (ir_entity *)tore;
+
+ if (is_method_entity(ent)) {
+ if (get_entity_ld_ident(ent) == id) {
+ ir_type *owner = get_entity_owner(ent);
+ ir_graph *irg = get_entity_irg(ent);
+
+ if (owner != get_glob_type()) {
+ printf("%s::%s", get_type_name(owner), get_id_str(id));
+ } else {
+ printf("%s", get_id_str(id));
+ }
+ if (irg)
+ printf("[%ld] (%p)\n", get_irg_graph_nr(irg), irg);
+ else
+ printf(" NULL\n");
+ }
+ }
+ }
+} /* show_by_ldname */
+
+/**
+ * prints the address and graph number of all irgs with given name
+ */
+static void irg_name(const char *name) {
+ ident *id = new_id_from_str(name);
+
+ type_walk(show_by_name, NULL, (void *)id);
+} /* irg_name */
+
+/**
+ * prints the address and graph number of all irgs with given ld_name
+ */
+static void irg_ld_name(const char *name) {
+ ident *id = new_id_from_str(name);
+
+ type_walk(show_by_ldname, NULL, (void *)id);
+} /* irg_ld_name */
+
/**
* High level function to use from debugger interface
*
set_dbg_level(name, (1 << lvl) - 1);
else if (sscanf(cmd, ".setoutfile %s %s\n", name, fname) == 2)
set_dbg_outfile(name, fname);
+ else if (sscanf(cmd, ".irgname %s\n", name) == 1)
+ irg_name(name);
+ else if (sscanf(cmd, ".irgldname %s\n", name) == 1)
+ irg_ld_name(name);
else {
show_commands();
}
*
* Redirects debug output of module name to file.
*
+ * @b .irgname name
+ *
+ * Prints address and graph number of a method given by its name.
+ *
+ * @b .irgldname name
+ *
+ * Prints address and graph number of a method given by its linker name.
+ *
* @b .help
*
* List all commands.