snapshot: read from /proc/self/maps
authorBrian Norris <banorris@uci.edu>
Sat, 3 Nov 2012 21:55:56 +0000 (14:55 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 14 Nov 2012 22:26:40 +0000 (14:26 -0800)
We don't need to get the PID

snapshot-interface.cc
snapshotimp.h

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