diff --git a/runners/bench_runner.c b/runners/bench_runner.c index ef90244f..eb6b58f9 100644 --- a/runners/bench_runner.c +++ b/runners/bench_runner.c @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/runners/test_runner.c b/runners/test_runner.c index 8553d697..b4ee92a5 100644 --- a/runners/test_runner.c +++ b/runners/test_runner.c @@ -21,6 +21,7 @@ #include #include #include +#include // some helpers diff --git a/scripts/bench.py b/scripts/bench.py index 32beba31..026f0aee 100755 --- a/scripts/bench.py +++ b/scripts/bench.py @@ -1366,13 +1366,6 @@ def run(runner, bench_ids=[], **args): '-ex', 'break %s:%d' % (path, lineno), '-ex', 'run', '--args'] - elif failure.assert_ is not None: - cmd[:0] = args['gdb_path'] + [ - '-q', - '-ex', 'run', - '-ex', 'frame function raise', - '-ex', 'up 2', - '--args'] else: cmd[:0] = args['gdb_path'] + [ '-q', diff --git a/scripts/prettyasserts.py b/scripts/prettyasserts.py index 8f741f16..b2aa577f 100755 --- a/scripts/prettyasserts.py +++ b/scripts/prettyasserts.py @@ -13,12 +13,6 @@ import re import sys -# NOTE the use of macros here helps keep a consistent stack depth which -# tools may rely on. -# -# If compilation errors are noisy consider using -ftrack-macro-expansion=0. -# - LIMIT = 16 CMP = { @@ -65,28 +59,27 @@ def write_header(f, limit=LIMIT): f.writeln("#include ") f.writeln("#include ") f.writeln("#include ") - f.writeln("#include ") # give source a chance to define feature macros f.writeln("#undef _FEATURES_H") f.writeln() # write print macros f.writeln("__attribute__((unused))") - f.writeln("static void __pretty_assert_print_bool(") + f.writeln("static void __pretty_assert_bool(") f.writeln(" const void *v, size_t size) {") f.writeln(" (void)size;") f.writeln(" printf(\"%s\", *(const bool*)v ? \"true\" : \"false\");") f.writeln("}") f.writeln() f.writeln("__attribute__((unused))") - f.writeln("static void __pretty_assert_print_int(") + f.writeln("static void __pretty_assert_int(") f.writeln(" const void *v, size_t size) {") f.writeln(" (void)size;") f.writeln(" printf(\"%\"PRIiMAX, *(const intmax_t*)v);") f.writeln("}") f.writeln() f.writeln("__attribute__((unused))") - f.writeln("static void __pretty_assert_print_mem(") + f.writeln("static void __pretty_assert_mem(") f.writeln(" const void *v, size_t size) {") f.writeln(" const uint8_t *v_ = v;") f.writeln(" printf(\"\\\"\");") @@ -104,13 +97,13 @@ def write_header(f, limit=LIMIT): f.writeln("}") f.writeln() f.writeln("__attribute__((unused))") - f.writeln("static void __pretty_assert_print_str(") + f.writeln("static void __pretty_assert_str(") f.writeln(" const void *v, size_t size) {") - f.writeln(" __pretty_assert_print_mem(v, size);") + f.writeln(" __pretty_assert_mem(v, size);") f.writeln("}") f.writeln() - f.writeln("__attribute__((unused, noinline))") - f.writeln("static void __pretty_assert_fail(") + f.writeln("__attribute__((unused))") + f.writeln("static void __pretty_assert_print(") f.writeln(" const char *file, int line,") f.writeln(" void (*type_print_cb)(const void*, size_t),") f.writeln(" const char *cmp,") @@ -122,7 +115,6 @@ def write_header(f, limit=LIMIT): f.writeln(" type_print_cb(rh, rsize);") f.writeln(" printf(\"\\n\");") f.writeln(" fflush(NULL);") - f.writeln(" raise(SIGABRT);") f.writeln("}") f.writeln() @@ -133,57 +125,64 @@ def write_header(f, limit=LIMIT): f.writeln(" bool _lh = !!(lh); \\") f.writeln(" bool _rh = !!(rh); \\") f.writeln(" if (!(_lh %s _rh)) { \\" % op) - f.writeln(" __pretty_assert_fail( \\") + f.writeln(" __pretty_assert_print( \\") f.writeln(" __FILE__, __LINE__, \\") - f.writeln(" __pretty_assert_print_bool, \"%s\", \\" + f.writeln(" __pretty_assert_bool, \"%s\", \\" % cmp) f.writeln(" &_lh, 0, \\") f.writeln(" &_rh, 0); \\") + f.writeln(" __builtin_trap(); \\") f.writeln(" } \\") f.writeln("} while (0)") + f.writeln() for op, cmp in sorted(CMP.items()): f.writeln("#define __PRETTY_ASSERT_INT_%s(lh, rh) do { \\" % cmp.upper()) f.writeln(" __typeof__(rh) _lh = lh; \\") f.writeln(" __typeof__(rh) _rh = rh; \\") f.writeln(" if (!(_lh %s _rh)) { \\" % op) - f.writeln(" __pretty_assert_fail( \\") + f.writeln(" __pretty_assert_print( \\") f.writeln(" __FILE__, __LINE__, \\") - f.writeln(" __pretty_assert_print_int, \"%s\", \\" + f.writeln(" __pretty_assert_int, \"%s\", \\" % cmp) f.writeln(" &(intmax_t){(intmax_t)_lh}, 0, \\") f.writeln(" &(intmax_t){(intmax_t)_rh}, 0); \\") + f.writeln(" __builtin_trap(); \\") f.writeln(" } \\") f.writeln("} while (0)") + f.writeln() for op, cmp in sorted(CMP.items()): f.writeln("#define __PRETTY_ASSERT_MEM_%s(lh, rh, size) do { \\" % cmp.upper()) f.writeln(" const void *_lh = lh; \\") f.writeln(" const void *_rh = rh; \\") f.writeln(" if (!(memcmp(_lh, _rh, size) %s 0)) { \\" % op) - f.writeln(" __pretty_assert_fail( \\") + f.writeln(" __pretty_assert_print( \\") f.writeln(" __FILE__, __LINE__, \\") - f.writeln(" __pretty_assert_print_mem, \"%s\", \\" + f.writeln(" __pretty_assert_mem, \"%s\", \\" % cmp) f.writeln(" _lh, size, \\") f.writeln(" _rh, size); \\") + f.writeln(" __builtin_trap(); \\") f.writeln(" } \\") f.writeln("} while (0)") + f.writeln() for op, cmp in sorted(CMP.items()): f.writeln("#define __PRETTY_ASSERT_STR_%s(lh, rh) do { \\" % cmp.upper()) f.writeln(" const char *_lh = lh; \\") f.writeln(" const char *_rh = rh; \\") f.writeln(" if (!(strcmp(_lh, _rh) %s 0)) { \\" % op) - f.writeln(" __pretty_assert_fail( \\") + f.writeln(" __pretty_assert_print( \\") f.writeln(" __FILE__, __LINE__, \\") - f.writeln(" __pretty_assert_print_str, \"%s\", \\" + f.writeln(" __pretty_assert_str, \"%s\", \\" % cmp) f.writeln(" _lh, strlen(_lh), \\") f.writeln(" _rh, strlen(_rh)); \\") + f.writeln(" __builtin_trap(); \\") f.writeln(" } \\") f.writeln("} while (0)") - f.writeln() + f.writeln() f.writeln() def mkassert(type, cmp, lh, rh, size=None): diff --git a/scripts/test.py b/scripts/test.py index 9f8c20b2..ff3e225c 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -1375,13 +1375,6 @@ def run(runner, test_ids=[], **args): '-ex', 'ignore 1 %d' % powerlosses, '-ex', 'run', '--args'] - elif failure.assert_ is not None: - cmd[:0] = args['gdb_path'] + [ - '-q', - '-ex', 'run', - '-ex', 'frame function raise', - '-ex', 'up 2', - '--args'] else: cmd[:0] = args['gdb_path'] + [ '-q',