| 45 | } |
| 46 | |
| 47 | void MemSection::readMap(std::string& line) |
| 48 | { |
| 49 | std::istringstream iss(line); |
| 50 | |
| 51 | char d; |
| 52 | /* Read addresses */ |
| 53 | iss >> std::hex >> addr >> d >> endaddr; |
| 54 | size = endaddr - addr; |
| 55 | |
| 56 | /* Read and parse flags */ |
| 57 | std::string flags; |
| 58 | iss >> flags; |
| 59 | readflag = (flags.find('r') != std::string::npos); |
| 60 | writeflag = (flags.find('w') != std::string::npos); |
| 61 | execflag = (flags.find('x') != std::string::npos); |
| 62 | sharedflag = (flags.find('s') != std::string::npos); |
| 63 | |
| 64 | /* Read the rest */ |
| 65 | iss >> offset >> device >> std::dec >> inode; |
| 66 | |
| 67 | /* Put the rest of the line into filename */ |
| 68 | std::getline(iss, filename); |
| 69 | |
| 70 | /* Trim filename */ |
| 71 | filename.erase(filename.begin(), std::find_if(filename.begin(), filename.end(), [](int ch) { |
| 72 | return !std::isspace(ch); |
| 73 | })); |
| 74 | filename.erase(std::find_if(filename.rbegin(), filename.rend(), [](int ch) { |
| 75 | return !std::isspace(ch); |
| 76 | }).base(), filename.end()); |
| 77 | |
| 78 | /* Determine section type */ |
| 79 | if (!readflag) { |
| 80 | type = MemNoRead; |
| 81 | return; |
| 82 | } |
| 83 | |
| 84 | if (filename.compare("[vsyscall]") == 0 || |
| 85 | filename.compare("[vectors]") == 0 || |
| 86 | filename.compare("[vvar]") == 0 || |
| 87 | filename.compare("[vdso]") == 0) { |
| 88 | type = MemSpecial; |
| 89 | return; |
| 90 | } |
| 91 | |
| 92 | if (filename.find("[stack") == 0) { |
| 93 | type = MemStack; |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | if (filename.compare("[heap]") == 0) { |
| 98 | type = MemHeap; |
| 99 | heap_discovered = true; |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | bool isempty = (filename.find_first_not_of("\t\n ") == std::string::npos); |
| 104 | |