summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAchim Kriso <achim.kriso@student.kit.edu>2020-03-10 15:09:41 +0100
committerAndreas Fried <andreas.fried@kit.edu>2020-03-26 14:08:14 +0100
commitcb6be5550724172e75eb92a2950abf467707e1b0 (patch)
treeafbb2b1e06709527510172f7fbbbb1d86fc61e81
parentd7071663f9c61b88d31c0023ac321e729450da0d (diff)
Added option whether to abort on error
-rw-r--r--Makefile2
-rw-r--r--ir/opt/lfasan.c9
-rw-r--r--runtime/lfmalloc/src/lfinternal.c7
-rwxr-xr-xscripts/gen_lf_sizes.py2
4 files changed, 15 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 72d442c..f550ea2 100644
--- a/Makefile
+++ b/Makefile
@@ -165,7 +165,7 @@ $(lf_gen_include_header): scripts/gen_lf_sizes.py
$(Q)$< > $@
.PHONY: $(builddir)/$(lfname).a
-$(builddir)/$(lfname).a: $(lf_gen_include_header)
+$(builddir)/$(lfname).a:
$(Q)mkdir -p $(builddir)/lfmalloc
$(Q)$(MAKE) sizes_include=../../$(lf_gen_include) builddir=../../$(lf_builddir) -C $(lfpath)
$(Q)cp $(builddir)/lfmalloc/$(lfname).a $(builddir) #Always copy, not sure how to fix
diff --git a/ir/opt/lfasan.c b/ir/opt/lfasan.c
index 28705c0..58f18f0 100644
--- a/ir/opt/lfasan.c
+++ b/ir/opt/lfasan.c
@@ -699,11 +699,16 @@ static void insert_bound_check_between(ir_node *irn, ir_node *ptr,
ir_node* abort_call = error_call(ptr, bb_err, lf_map, reason, dbgi);
mark_irn_visited(abort_call);
-
keep_alive(abort_call);
- keep_alive(bb_err);
+#ifdef ABORT_ON_ERROR
+ keep_alive(bb_err);
ir_node* bb_true_in[1] = { proj_true };
+#else
+ ir_node *continue_jmp = new_rd_Jmp(dbgi, bb_err);
+ ir_node* bb_true_in[2] = { proj_true, continue_jmp };
+#endif
+
set_irn_in(old_block, ARRAY_SIZE(bb_true_in), bb_true_in);
//dump_ir_graph(irg, "lf-asan-boundcheck");
diff --git a/runtime/lfmalloc/src/lfinternal.c b/runtime/lfmalloc/src/lfinternal.c
index 972e00f..51d90cd 100644
--- a/runtime/lfmalloc/src/lfinternal.c
+++ b/runtime/lfmalloc/src/lfinternal.c
@@ -377,11 +377,14 @@ void __lf_error(void *ptr, void* base, unsigned long size, unsigned int reason,
}
if (filename != NULL && line != 0) {
- fprintf(stderr, "%s at %p out of bounds (base: %p, size: 0x%lx) in %s:%i.\n",
+ fprintf(stderr, "LFASAN: %s at %p out of bounds (base: %p, size: 0x%lx) in %s:%i.\n",
s_reason, ptr, base, size, filename, line);
} else {
- fprintf(stderr, "%s at %p out of bounds (base: %p, size: 0x%lx).\n",
+ fprintf(stderr, "LFASAN: %s at %p out of bounds (base: %p, size: 0x%lx).\n",
s_reason, ptr, base, size);
}
+
+#ifdef ABORT_ON_ERROR
abort();
+#endif
}
diff --git a/scripts/gen_lf_sizes.py b/scripts/gen_lf_sizes.py
index b1f699e..281ee83 100755
--- a/scripts/gen_lf_sizes.py
+++ b/scripts/gen_lf_sizes.py
@@ -44,6 +44,8 @@ print('#define MAX_SIZE ' + hex(MAX_SIZE))
print('#define REGION_COUNT ' + hex(region_count));
print('const uint64_t SIZES[' + hex(len(sizes)) + '] = {\n' + ',\n'.join(sizes) + '};')
+print('//#define ABORT_ON_ERROR')
+
print('#define MEMORY_WRITE 0')
print('#define MEMORY_READ 1')
print('#define FUNCTION_ESCAPE 2')