summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2012-10-27 15:19:22 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2012-10-30 10:39:50 +0100
commit891197cb02f21d5a80de21aa9a94b4557f483f6d (patch)
tree5c337799380539ba0579018b43114ae932473185
parent211aaabd26e2f4eab27d054b1984c66904fb45c2 (diff)
Let panic() print file, line and function.
Adjust some panic messages accordingly.
-rw-r--r--adt/error.h10
-rw-r--r--ast.c2
-rw-r--r--ast2firm.c30
-rw-r--r--attribute.c2
-rw-r--r--entity.c2
-rw-r--r--mangle.c2
-rw-r--r--type.c12
-rw-r--r--walk.c4
-rw-r--r--wrappergen/write_fluffy.c2
-rw-r--r--wrappergen/write_jna.c4
10 files changed, 37 insertions, 33 deletions
diff --git a/adt/error.h b/adt/error.h
index ad6c08d..49a3a8c 100644
--- a/adt/error.h
+++ b/adt/error.h
@@ -24,8 +24,12 @@
#include <stdlib.h>
#include "config.h"
-static inline __attribute__((noreturn))
-void panic(const char *msg)
-{ fprintf(stderr, "Panic: %s\n", msg); abort(); }
+static inline __attribute__((noreturn)) void panic(char const *const file, int const line, char const *const func, char const *const msg)
+{
+ fprintf(stderr, "%s:%d: panic in %s: %s\n", file, line, func, msg);
+ abort();
+}
+
+#define panic(msg) panic(__FILE__, __LINE__, __func__, (msg))
#endif
diff --git a/ast.c b/ast.c
index ac0ac87..712add2 100644
--- a/ast.c
+++ b/ast.c
@@ -1918,7 +1918,7 @@ check_type:
case EXPR_ERROR:
return EXPR_CLASS_ERROR;
}
- panic("invalid expression found (is constant expression)");
+ panic("invalid expression");
}
void init_ast(void)
diff --git a/ast2firm.c b/ast2firm.c
index f6db928..11a4844 100644
--- a/ast2firm.c
+++ b/ast2firm.c
@@ -884,7 +884,7 @@ static bool declaration_is_definition(const entity_t *entity)
case ENTITY_LOCAL_LABEL:
break;
}
- panic("declaration_is_definition called on non-declaration");
+ panic("entity is not a declaration");
}
/**
@@ -1270,7 +1270,7 @@ static ir_node *literal_to_firm(const literal_expression_t *literal)
break;
default:
- panic("Invalid literal kind found");
+ panic("invalid literal kind");
}
dbg_info *dbgi = get_dbg_info(&literal->base.source_position);
@@ -1320,7 +1320,7 @@ static ir_node *char_literal_to_firm(string_literal_expression_t const *literal)
}
default:
- panic("Invalid literal kind found");
+ panic("invalid literal kind");
}
dbg_info *dbgi = get_dbg_info(&literal->base.source_position);
@@ -1554,7 +1554,7 @@ static ir_node *reference_addr(const reference_expression_t *ref)
panic("not implemented reference type");
}
- panic("reference to declaration with unknown type found");
+ panic("reference to declaration with unknown type");
}
static ir_node *reference_expression_to_firm(const reference_expression_t *ref)
@@ -1668,7 +1668,7 @@ static ir_node *process_builtin_call(const call_expression_t *call)
case BUILTIN_LIBC_CHECK:
panic("builtin did not produce an entity");
}
- panic("invalid builtin found");
+ panic("invalid builtin");
}
/**
@@ -2118,7 +2118,7 @@ static ir_node *create_incdec(const unary_expression_t *expression)
store_value = result;
break;
default:
- panic("no incdec expr in create_incdec");
+ panic("no incdec expr");
}
set_value_for_expression_addr(value_expr, store_value, addr);
@@ -2350,7 +2350,7 @@ static ir_node *unary_expression_to_firm(const unary_expression_t *expression)
default:
break;
}
- panic("invalid UNEXPR type found");
+ panic("invalid unary expression type");
}
/**
@@ -3078,7 +3078,7 @@ static ir_node *classify_type_to_firm(const classify_type_expression_t *const ex
tc = real_type_class;
goto make_const;
}
- panic("Unexpected atomic type in classify_type_to_firm().");
+ panic("Unexpected atomic type.");
}
case TYPE_COMPLEX: tc = complex_type_class; goto make_const;
@@ -3101,7 +3101,7 @@ static ir_node *classify_type_to_firm(const classify_type_expression_t *const ex
case TYPE_ERROR:
break;
}
- panic("unexpected TYPE classify_type_to_firm().");
+ panic("unexpected type.");
}
make_const:;
@@ -3319,7 +3319,7 @@ static ir_node *_expression_to_firm(expression_t const *const expr)
case EXPR_ERROR: break;
}
- panic("invalid expression found");
+ panic("invalid expression");
}
/**
@@ -3684,7 +3684,7 @@ static void advance_current_object(type_path_t *path)
{
if (path->invalid) {
/* TODO: handle this... */
- panic("invalid initializer in ast2firm (excessive elements)");
+ panic("invalid initializer (excessive elements)");
}
type_path_entry_t *top = get_type_path_top(path);
@@ -3861,7 +3861,7 @@ static ir_initializer_t *create_ir_initializer(
return create_ir_initializer_value(&initializer->value);
case INITIALIZER_DESIGNATOR:
- panic("unexpected designator initializer found");
+ panic("unexpected designator initializer");
}
panic("unknown initializer");
}
@@ -4010,7 +4010,7 @@ static void create_dynamic_initializer_sub(ir_initializer_t *initializer,
}
}
- panic("invalid IR_INITIALIZER found");
+ panic("invalid ir_initializer");
}
static void create_dynamic_initializer(ir_initializer_t *initializer,
@@ -4390,7 +4390,7 @@ static void create_local_declaration(entity_t *entity)
case STORAGE_CLASS_TYPEDEF:
break;
}
- panic("invalid storage class found");
+ panic("invalid storage class");
}
static void create_local_declarations(entity_t *e)
@@ -4995,7 +4995,7 @@ jump:
return NULL;
}
- case STATEMENT_ERROR: panic("error statement found");
+ case STATEMENT_ERROR: panic("error statement");
}
panic("statement not implemented");
}
diff --git a/attribute.c b/attribute.c
index 71f91d3..ca9ad19 100644
--- a/attribute.c
+++ b/attribute.c
@@ -513,7 +513,7 @@ static bool attribute_argument_equal(const attribute_argument_t *arg1,
/* TODO */
return false;
}
- panic("Unknown argument type found");
+ panic("unknown argument type");
}
static bool attribute_arguments_equal(const attribute_argument_t *args1,
diff --git a/entity.c b/entity.c
index 3a2db26..353c770 100644
--- a/entity.c
+++ b/entity.c
@@ -45,7 +45,7 @@ const char *get_entity_kind_name(entity_kind_t kind)
case ENTITY_NAMESPACE: return "namespace";
}
- panic("Invalid entity kind encountered in get_entity_kind_name");
+ panic("invalid entity kind");
}
/**
diff --git a/mangle.c b/mangle.c
index 2ac2287..da43b1a 100644
--- a/mangle.c
+++ b/mangle.c
@@ -56,7 +56,7 @@ static char get_atomic_type_mangle(atomic_type_kind_t kind)
case ATOMIC_TYPE_FLOAT: return 'f';
case ATOMIC_TYPE_DOUBLE: return 'd';
}
- panic("invalid atomic type in mangler");
+ panic("invalid atomic type");
}
static void mangle_atomic_type(const atomic_type_t *type)
diff --git a/type.c b/type.c
index 0c697ef..f009f36 100644
--- a/type.c
+++ b/type.c
@@ -872,10 +872,10 @@ bool is_type_incomplete(const type_t *type)
case TYPE_TYPEDEF:
case TYPE_TYPEOF:
- panic("is_type_incomplete called without typerefs skipped");
+ panic("typedef not skipped");
}
- panic("invalid type found");
+ panic("invalid type");
}
bool is_type_object(const type_t *type)
@@ -1001,7 +1001,7 @@ bool types_compatible(const type_t *type1, const type_t *type2)
return true;
case TYPE_TYPEDEF:
case TYPE_TYPEOF:
- panic("typerefs not skipped in compatible types?!?");
+ panic("typeref not skipped");
}
}
@@ -1092,7 +1092,7 @@ unsigned get_type_size(type_t *type)
case TYPE_TYPEOF:
return get_type_size(type->typeoft.typeof_type);
}
- panic("invalid type in get_type_size");
+ panic("invalid type");
}
unsigned get_type_alignment(type_t *type)
@@ -1130,7 +1130,7 @@ unsigned get_type_alignment(type_t *type)
case TYPE_TYPEOF:
return get_type_alignment(type->typeoft.typeof_type);
}
- panic("invalid type in get_type_alignment");
+ panic("invalid type");
}
/**
@@ -1172,7 +1172,7 @@ decl_modifiers_t get_type_modifiers(const type_t *type)
case TYPE_TYPEOF:
return get_type_modifiers(type->typeoft.typeof_type);
}
- panic("invalid type found in get_type_modifiers");
+ panic("invalid type");
}
type_qualifiers_t get_type_qualifier(const type_t *type, bool skip_array_type)
diff --git a/walk.c b/walk.c
index c3d13ab..96a722b 100644
--- a/walk.c
+++ b/walk.c
@@ -83,7 +83,7 @@ static void walk_type(type_t *const type, const walk_env_t *const env)
walk_entity((entity_t*)type->enumt.enume, env);
return;
}
- panic("invalid type found");
+ panic("invalid type");
}
static void walk_expression(expression_t *const expr,
@@ -269,7 +269,7 @@ static void walk_entity(entity_t *entity, const walk_env_t *const env)
case ENTITY_LOCAL_LABEL:
return;
}
- panic("invalid entity found");
+ panic("invalid entity");
}
static void walk_declarations(entity_t* entity,
diff --git a/wrappergen/write_fluffy.c b/wrappergen/write_fluffy.c
index 7b66c74..2ff84a3 100644
--- a/wrappergen/write_fluffy.c
+++ b/wrappergen/write_fluffy.c
@@ -214,7 +214,7 @@ static void write_unary_expression(const unary_expression_t *expression)
fputc('!', out);
break;
default:
- panic("unimeplemented unary expression found");
+ panic("unimplemented unary expression");
}
write_expression(expression->value);
}
diff --git a/wrappergen/write_jna.c b/wrappergen/write_jna.c
index a31cf05..3e17794 100644
--- a/wrappergen/write_jna.c
+++ b/wrappergen/write_jna.c
@@ -226,7 +226,7 @@ static void write_type(type_t *type)
case TYPE_ERROR:
case TYPE_TYPEOF:
case TYPE_TYPEDEF:
- panic("invalid type found");
+ panic("invalid type");
case TYPE_ARRAY:
case TYPE_REFERENCE:
case TYPE_FUNCTION:
@@ -275,7 +275,7 @@ static void write_unary_expression(const unary_expression_t *expression)
write_expression(expression->value);
return;
default:
- panic("unimeplemented unary expression found");
+ panic("unimplemented unary expression");
}
write_expression(expression->value);
}