[PATCH] Implement a bunch of custom glibc wrappers & corresponding tests.
Lorenzo Martignoni
martignlo at google.com
Thu Nov 21 02:56:36 PST 2013
================
Comment at: lib/dfsan/dfsan_custom.cc:15
@@ -14,1 +14,3 @@
+
+#define _GNU_SOURCE
#include "sanitizer_common/sanitizer_internal_defs.h"
----------------
Removed because enabled by default.
================
Comment at: lib/dfsan/dfsan_custom.cc:432
@@ +431,3 @@
+ if (ret) {
+ internal_memcpy(shadow_for(dest), shadow_for(src), strlen(src) + 1);
+ }
----------------
Peter Collingbourne wrote:
> Length needs to be multiplied by sizeof(dfsan_label).
Done.
================
Comment at: lib/dfsan/done_abilist.txt:159
@@ -136,1 +158,3 @@
+fun:sigaction=custom
+fun:gettimeofday=custom
----------------
Peter Collingbourne wrote:
> Do any of these belong here? I don't think any of them take a callback.
Moved in the appropriate group.
================
Comment at: lib/dfsan/lit_tests/custom.c:29
@@ -17,6 +28,3 @@
-void *ptcb(void *p) {
- assert(p == (void *)1);
- assert(dfsan_get_label((uintptr_t)p) == 0);
- return (void *)2;
-}
+dfsan_label I_LABEL = 0;
+dfsan_label J_LABEL = 0;
----------------
Peter Collingbourne wrote:
> Lowercase, please.
Done.
================
Comment at: lib/dfsan/lit_tests/custom.c:35
@@ -31,5 +34,3 @@
-int main(void) {
- int i = 1;
- dfsan_label i_label = dfsan_create_label("i", 0);
- dfsan_set_label(i_label, &i, sizeof(i));
+#define ASSERT_ZERO_LABELS(ptr, size) assert(0 == dfsan_read_label(ptr, size))
+
----------------
Peter Collingbourne wrote:
> How about calling it ASSERT_READ_ZERO_LABEL? That name makes it clear that the test is reading from memory.
Done.
================
Comment at: lib/dfsan/lit_tests/custom.c:39
@@ +38,3 @@
+
+#define ASSERT_LABELS(ptr, size, label) \
+ assert(label == dfsan_read_label(ptr, size))
----------------
Peter Collingbourne wrote:
> ASSERT_READ_LABEL.
Done.
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:1
@@ +1,2 @@
+# RUN: bash %s
+
----------------
Peter Collingbourne wrote:
> I think this should be part of check_lint.sh rather than a test.
I added the checks for DFSan to check_lint.sh. However, to avoid to mess up with that script too much I put these checks in dfsan/scripts/check_custom_wrappers.sh (which is invoked by check_lint.sh).
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:3
@@ +2,3 @@
+
+tests=$(dirname "$0")/custom.c
+abilist=$(dirname "$tests")/../done_abilist.txt
----------------
Peter Collingbourne wrote:
> testdir=$(dirname "$0") ?
>
> Then base the other variables on it.
Done.
================
Comment at: lib/dfsan/lit_tests/check_tests.sh:21
@@ +20,3 @@
+ <(grep "^\\s*test_.*();" "$tests" | sed "s/.*\(test_.*\)();/\1/") \
+ <(grep __dfsw_ "$wrappers" | sed "s/.*__dfsw_\([^(]*\).*/test_\1()/")
+
----------------
Peter Collingbourne wrote:
> Ditto.
Done.
http://llvm-reviews.chandlerc.com/D2234
More information about the llvm-commits
mailing list