185 pagesize = getpagesize();
187 pid_t myselfpid = getpid();
188 char outputfilename[1024];
189 outputfilename[0] = 0;
190 sprintf(outputfilename,
"./memoryhotpot.out.%d.%d", phase, myselfpid);
191 outputFile = open(outputfilename, O_CREAT|O_RDWR, S_IRWXU);
195 #ifdef PROTECTEDMEMORYDEBUG
196 printf(
"Page size: %d\n", pagesize);
200 for (logpagesize = -1, tmp = pagesize; tmp > 0; logpagesize++)
203 #ifdef PROTECTEDMEMORYDEBUG
204 printf(
"log(page size): %d\n", logpagesize);
209 AllocateProtectedHeap(totalHeap, pagesize);
211 memorySegments[numOfSegments].start = getPageNumber(nextPosition);
212 memorySegments[numOfSegments].end = getPageNumber(endPosition);
225 static char filename2[1024];
230 if (-1 == readFile((
char *)
"/proc/self/cmdline", buf1, 1024)) {
231 perror(
"readFile: /proc/self/cmdline");
234 memset(application, 0, 1024);
235 strcpy(application, buf1);
239 if (-1 == readFile((
char *)
"/proc/self/maps", buf2, 51200)) {
240 perror(
"readFile: /proc/self/maps");
243 static char lastfilename[1024];
245 tmp2 = readMapsLine(tmp2, &start, &end, &writable, filename2);
246 if (strlen(filename2) > 0)
249 strcpy(lastfilename, filename2);
253 strcpy(filename2, lastfilename);
263 if (strstr(filename2,
"ld") != 0)
265 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
266 << writable <<
", " << filename2
269 else if (strstr(filename2,
"vdso") != 0)
271 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
272 << writable <<
", " << filename2
275 else if (strstr(filename2,
"stack") != 0)
277 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
278 << writable <<
", " << filename2
281 else if (strstr(filename2,
"libc") != 0)
283 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
284 << writable <<
", " << filename2
287 else if (strstr(filename2,
"libProtectedMemory.so") != 0)
289 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
290 << writable <<
", " << filename2
293 else if (strstr(filename2,
"libParRunManagerMP.so") != 0)
295 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
296 << writable <<
", " << filename2
299 else if (strstr(filename2,
"libmymalloc.so") != 0)
301 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
302 << writable <<
", " << filename2
305 else if (strstr(filename2,
"libtpmallocstub.so") != 0)
307 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
308 << writable <<
", " << filename2
311 else if (strstr(filename2,
"heap") != 0)
313 static int Heapcount = 0;
318 std::cout <<
"Protected: " << numOfSegments <<
", " << start <<
", " << end <<
", "
319 << writable <<
", " << filename2
321 memorySegments[numOfSegments].start = start;
322 memorySegments[numOfSegments].end = end;
327 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
328 << writable <<
", " << filename2
332 else if (strstr(filename2,
"ParA01") != 0)
334 static int Parmaincount = 0;
337 printf(
"Determine: %d\n", Parmaincount);
340 std::cout <<
"Protected: " << numOfSegments <<
", " << start <<
", " << end <<
", "
341 << writable <<
", " << filename2
343 memorySegments[numOfSegments].start = start;
344 memorySegments[numOfSegments].end = end;
348 else if (strstr(filename2,
"geant4") != 0)
350 std::cout <<
"Protected: " << numOfSegments <<
", " << start <<
", " << end <<
", "
351 << writable <<
", " << filename2
353 memorySegments[numOfSegments].start = start;
354 memorySegments[numOfSegments].end = end;
361 std::cout <<
"Not protected: " << start <<
", " << end <<
", "
362 << writable <<
", " << filename2
366 }
while ((*tmp2) !=
'\0' && numOfSegments < 4096);