From: Brian Norris Date: Sat, 3 Nov 2012 21:55:56 +0000 (-0700) Subject: snapshot: read from /proc/self/maps X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ff6281947505d1b5bf6491dbfeaa27d5d41ab964;p=cdsspec-compiler.git snapshot: read from /proc/self/maps We don't need to get the PID --- diff --git a/snapshot-interface.cc b/snapshot-interface.cc index 47fafa5..c22b871 100644 --- a/snapshot-interface.cc +++ b/snapshot-interface.cc @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -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); diff --git a/snapshotimp.h b/snapshotimp.h index 2e4929d..b03d285 100644 --- a/snapshotimp.h +++ b/snapshotimp.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #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