We don't need to get the PID
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sstream>
#include <cstring>
#include <string>
#include <sstream>
#include <cstring>
#include <string>
#define MYBINARYNAME "model"
#define MYLIBRARYNAME "libmodel.so"
#define MYBINARYNAME "model"
#define MYLIBRARYNAME "libmodel.so"
-#define MAPFILE_FORMAT "/proc/%d/maps"
+#define MAPFILE "/proc/self/maps"
SnapshotStack * snapshotObject;
SnapshotStack * snapshotObject;
* library to snapshot them.
*/
static void SnapshotGlobalSegments(){
* library to snapshot them.
*/
static void SnapshotGlobalSegments(){
- int pid = getpid();
- char buf[9000], filename[100];
- sprintf(filename, MAPFILE_FORMAT, pid);
- map = fopen(filename, "r");
+ map = fopen(MAPFILE, "r");
if (!map) {
perror("fopen");
exit(EXIT_FAILURE);
if (!map) {
perror("fopen");
exit(EXIT_FAILURE);
#include <inttypes.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <inttypes.h>
#include <fcntl.h>
#include <sys/mman.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
#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