| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return new PosixMemoryMappedFile(file, memory, size); | 125 return new PosixMemoryMappedFile(file, memory, size); |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 PosixMemoryMappedFile::~PosixMemoryMappedFile() { | 129 PosixMemoryMappedFile::~PosixMemoryMappedFile() { |
| 130 if (memory_) OS::Free(memory_, size_); | 130 if (memory_) OS::Free(memory_, size_); |
| 131 fclose(file_); | 131 fclose(file_); |
| 132 } | 132 } |
| 133 | 133 |
| 134 | 134 |
| 135 void OS::LogSharedLibraryAddresses() { | 135 void OS::LogSharedLibraryAddresses(Isolate* isolate) { |
| 136 // This function assumes that the layout of the file is as follows: | 136 // This function assumes that the layout of the file is as follows: |
| 137 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] | 137 // hex_start_addr-hex_end_addr rwxp <unused data> [binary_file_name] |
| 138 // If we encounter an unexpected situation we abort scanning further entries. | 138 // If we encounter an unexpected situation we abort scanning further entries. |
| 139 FILE* fp = fopen("/proc/self/maps", "r"); | 139 FILE* fp = fopen("/proc/self/maps", "r"); |
| 140 if (fp == NULL) return; | 140 if (fp == NULL) return; |
| 141 | 141 |
| 142 // Allocate enough room to be able to store a full file name. | 142 // Allocate enough room to be able to store a full file name. |
| 143 const int kLibNameLen = FILENAME_MAX + 1; | 143 const int kLibNameLen = FILENAME_MAX + 1; |
| 144 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); | 144 char* lib_name = reinterpret_cast<char*>(malloc(kLibNameLen)); |
| 145 | 145 |
| 146 i::Isolate* isolate = Isolate::Current(); | |
| 147 // This loop will terminate once the scanning hits an EOF. | 146 // This loop will terminate once the scanning hits an EOF. |
| 148 while (true) { | 147 while (true) { |
| 149 uintptr_t start, end; | 148 uintptr_t start, end; |
| 150 char attr_r, attr_w, attr_x, attr_p; | 149 char attr_r, attr_w, attr_x, attr_p; |
| 151 // Parse the addresses and permission bits at the beginning of the line. | 150 // Parse the addresses and permission bits at the beginning of the line. |
| 152 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; | 151 if (fscanf(fp, "%" V8PRIxPTR "-%" V8PRIxPTR, &start, &end) != 2) break; |
| 153 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; | 152 if (fscanf(fp, " %c%c%c%c", &attr_r, &attr_w, &attr_x, &attr_p) != 4) break; |
| 154 | 153 |
| 155 int c; | 154 int c; |
| 156 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { | 155 if (attr_r == 'r' && attr_w != 'w' && attr_x == 'x') { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 // Make sure line termination is in place. | 236 // Make sure line termination is in place. |
| 238 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; | 237 frames[i].text[kStackWalkMaxTextLen - 1] = '\0'; |
| 239 } | 238 } |
| 240 | 239 |
| 241 free(symbols); | 240 free(symbols); |
| 242 | 241 |
| 243 return frames_count; | 242 return frames_count; |
| 244 } | 243 } |
| 245 | 244 |
| 246 } } // namespace v8::internal | 245 } } // namespace v8::internal |
| OLD | NEW |