[llvm-commits] [poolalloc] r133564 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Jun 21 15:44:02 PDT 2011


Author: aggarwa4
Date: Tue Jun 21 17:44:02 2011
New Revision: 133564

URL: http://llvm.org/viewvc/llvm-project?rev=133564&view=rev
Log:
Add tracking for some more library functions.

Modified:
    poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c

Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=133564&r1=133563&r2=133564&view=diff
==============================================================================
--- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original)
+++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Tue Jun 21 17:44:02 2011
@@ -4,6 +4,10 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <netdb.h>
+#include <poll.h>
+#include <sys/types.h>
+#include <sys/socket.h>
 #include <sys/mman.h>
 
 #define DEBUG (0)
@@ -115,9 +119,7 @@
   uintptr_t p = maskAddress(ptr);
   shadow_begin[p] = typeNumber;
   memset(&shadow_begin[p + 1], 0, size - 1);
-#if DEBUG
   printf("Store(%d): %p, %p = %u | %lu bytes | \n", tag, ptr, (void *)p, typeNumber, size);
-#endif
 
 }
 
@@ -186,22 +188,6 @@
   }
 
 }
-/**
- * Check the loaded type against the type recorded in the shadow memory.
- */
-void trackLoadInst(void *ptr, uint8_t typeNumber, uint64_t size, uint32_t tag) {
-  uint8_t *metadata = malloc(size);
-
-  getTypeTag(ptr, size, metadata);
-
-  checkType(typeNumber, size ,metadata, ptr, tag);
-#if DEBUG
-  printf("Load(%d): %p, %p = actual: %u, expect: %u | %lu  bytes\n", tag, ptr, (void *)p, typeNumber, shadow_begin[p], size);
-#endif
-
-  free(metadata);
-}
-
 
 /**
  *  For memset type instructions, that set values. 
@@ -237,6 +223,10 @@
   printf("Copy(%d): %p, %p = %u | %lu bytes \n", tag, dstptr, srcptr, shadow_begin[s], size);
 #endif
 }
+void setTypeInfo(void *dstptr, void *metadata, uint64_t size, uint32_t tag) {
+  uintptr_t d = maskAddress(dstptr);
+  memcpy(&shadow_begin[d], metadata, size);
+}
 
 /**
  * Initialize metadata for the pointer returned by __ctype_b_loc
@@ -287,3 +277,27 @@
 void trackgethostname(void *ptr, uint32_t tag) {
   trackInitInst(ptr, strlen(ptr) + 1, tag);
 }
+
+void trackgetaddrinfo(void *ptr, uint32_t tag) {
+  struct addrinfo *res;
+  struct addrinfo ** result = (struct addrinfo **)ptr;
+  for(res = *result; res != NULL; res = res->ai_next) {
+    trackInitInst(res->ai_addr, sizeof(struct sockaddr), tag);
+    trackInitInst(res, sizeof(struct addrinfo), tag);
+  }
+
+  trackInitInst(result, sizeof(struct addrinfo*), tag);
+}
+
+void trackaccept(void *ptr, uint32_t tag) {
+  trackInitInst(ptr, sizeof(struct sockaddr), tag);
+}
+
+void trackpoll(void *ptr, uint64_t nfds, uint32_t tag) {
+  struct pollfd *fds = (struct pollfd *)ptr;
+  unsigned i = 0;
+  while (i < nfds) {
+    trackInitInst(&fds[i], sizeof(struct pollfd), tag);
+    i++;
+  }
+}





More information about the llvm-commits mailing list