-bool checkPermissions( MyString permStr ){
- return permStr.find("w") != MyString::npos;
-}
-static void takeSegmentSnapshot( const MyString & lineText ){
- std::vector< MyString, MyAlloc< MyString > > firstSplit = splitString( lineText, ' ' );
- if( checkPermissions( firstSplit[ 1 ] ) ){
- std::vector< MyString, MyAlloc< MyString > > secondSplit = splitString( firstSplit[ 0 ], '-' );
- size_t val1 = 0, val2 = 0;
- sscanf( secondSplit[ 0 ].c_str(), "%zx", &val1 );
- sscanf( secondSplit[ 1 ].c_str(), "%zx", &val2 );
- size_t len = ( val2 - val1 ) / PAGESIZE;
- if( 0 != len ){
- addMemoryRegionToSnapShot( ( void * )val1, len );
+ /* Wait for correct part */
+ while (fgets(buf, sizeof(buf), map)) {
+ if (strstr(buf, "==== regions for process"))
+ break;
+ }
+
+ while (fgets(buf, sizeof(buf), map)) {
+ char regionname[200] = "";
+ char type[23];
+ char smstr[23];
+ char r, w, x;
+ char mr, mw, mx;
+ int size;
+ void *begin, *end;
+
+ //Skip out at the end of the section
+ if (buf[0] == '\n')
+ break;
+
+ sscanf(buf, "%22s %p-%p [%5dK] %c%c%c/%c%c%c SM=%3s %200s\n", type, &begin, &end, &size, &r, &w, &x, &mr, &mw, &mx, smstr, regionname);
+
+ if (w == 'w' && strstr(regionname, MYBINARYNAME)) {
+ size_t len = ((uintptr_t)end - (uintptr_t)begin) / PAGESIZE;
+ if (len != 0)
+ snapshot_add_memory_region(begin, len);