Merge remote-tracking branch 'origin/master' into pldi13
authorBrian Norris <banorris@uci.edu>
Sat, 3 Nov 2012 22:31:02 +0000 (15:31 -0700)
committerBrian Norris <banorris@uci.edu>
Sat, 3 Nov 2012 22:31:02 +0000 (15:31 -0700)
common.h
config.h
main.cc
snapshot-interface.cc
snapshotimp.h

index 50410ea7e0a1bce920a2bb3ce3b968d602f929de..81b26728d917c0af8c1b26e9d0fa2d28cccb8a5a 100644 (file)
--- a/common.h
+++ b/common.h
@@ -20,6 +20,7 @@
 
 void assert_hook(void);
 
+#ifdef CONFIG_ASSERT
 #define ASSERT(expr) \
 do { \
        if (!(expr)) { \
@@ -30,6 +31,10 @@ do { \
                exit(EXIT_FAILURE); \
        } \
 } while (0)
+#else
+#define ASSERT(expr) \
+       do { } while (0)
+#endif /* CONFIG_ASSERT */
 
 #define error_msg(...) fprintf(stderr, "Error: " __VA_ARGS__)
 
index 109e8d86097ab55c545705f0059c544bb01b9738..227c9a9c7a5df0586b84c254eaab5f431bd58559 100644 (file)
--- a/config.h
+++ b/config.h
@@ -9,6 +9,10 @@
 /*             #ifndef CONFIG_DEBUG
                #define CONFIG_DEBUG
                #endif
+
+               #ifndef CONFIG_ASSERT
+               #define CONFIG_ASSERT
+               #endif
 */
 
 /** Turn on support for dumping cyclegraphs as dot files at each
diff --git a/main.cc b/main.cc
index fc1b2779daa657ae6460293da49d29a5c95ec21d..635b8da70bc213e3db6524c964e78301b1b28ebf 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -72,8 +72,10 @@ static void parse_options(struct model_params *params, int *argc, char ***argv)
                        break;
                }
        }
-       (*argc) -= optind;
-       (*argv) += optind;
+       (*argv)[optind - 1] = (*argv)[0];
+       (*argc) -= (optind - 1);
+       (*argv) += (optind - 1);
+       optind = 1;
 
        if (error)
                print_usage(params);
index 47fafa5b0641f8865cb279c47f08531e9cbfd4f1..c22b8712b32937cbd415fb9f2ab7d1039e8c97a8 100644 (file)
@@ -3,7 +3,6 @@
 #include <iostream>
 #include <fstream>
 #include <unistd.h>
-#include <sys/types.h>
 #include <sstream>
 #include <cstring>
 #include <string>
@@ -16,7 +15,7 @@
 
 #define MYBINARYNAME "model"
 #define MYLIBRARYNAME "libmodel.so"
-#define MAPFILE_FORMAT "/proc/%d/maps"
+#define MAPFILE "/proc/self/maps"
 
 SnapshotStack * snapshotObject;
 
@@ -73,12 +72,10 @@ static void SnapshotGlobalSegments(){
  *     library to snapshot them.
  */
 static void SnapshotGlobalSegments(){
-       int pid = getpid();
-       char buf[9000], filename[100];
+       char buf[9000];
        FILE *map;
 
-       sprintf(filename, MAPFILE_FORMAT, pid);
-       map = fopen(filename, "r");
+       map = fopen(MAPFILE, "r");
        if (!map) {
                perror("fopen");
                exit(EXIT_FAILURE);
index 2e4929d0477e4605cd5363fb86266cd054d1f3fe..b03d28527e3efe69257cbf48ac1311776dbec5ee 100644 (file)
@@ -9,7 +9,6 @@
 #include <inttypes.h>
 #include <fcntl.h>
 #include <sys/mman.h>
-#include <sys/types.h>
 #include <csignal>
 #define SHARED_MEMORY_DEFAULT  (100 * ((size_t)1 << 20)) // 100mb for the shared memory
 #define STACK_SIZE_DEFAULT      (((size_t)1 << 20) * 20)  // 20 mb out of the above 100 mb for my stack