| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/debug/proc_maps_linux.h" | 5 #include "base/debug/proc_maps_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <stddef.h> |
| 9 |
| 10 #include "base/files/file_util.h" |
| 11 #include "base/files/scoped_file.h" |
| 12 #include "base/strings/string_split.h" |
| 13 #include "build/build_config.h" |
| 8 | 14 |
| 9 #if defined(OS_LINUX) || defined(OS_ANDROID) | 15 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 10 #include <inttypes.h> | 16 #include <inttypes.h> |
| 11 #endif | 17 #endif |
| 12 | 18 |
| 13 #include "base/files/file_util.h" | |
| 14 #include "base/files/scoped_file.h" | |
| 15 #include "base/strings/string_split.h" | |
| 16 | |
| 17 #if defined(OS_ANDROID) && !defined(__LP64__) | 19 #if defined(OS_ANDROID) && !defined(__LP64__) |
| 18 // In 32-bit mode, Bionic's inttypes.h defines PRI/SCNxPTR as an | 20 // In 32-bit mode, Bionic's inttypes.h defines PRI/SCNxPTR as an |
| 19 // unsigned long int, which is incompatible with Bionic's stdint.h | 21 // unsigned long int, which is incompatible with Bionic's stdint.h |
| 20 // defining uintptr_t as an unsigned int: | 22 // defining uintptr_t as an unsigned int: |
| 21 // https://code.google.com/p/android/issues/detail?id=57218 | 23 // https://code.google.com/p/android/issues/detail?id=57218 |
| 22 #undef SCNxPTR | 24 #undef SCNxPTR |
| 23 #define SCNxPTR "x" | 25 #define SCNxPTR "x" |
| 24 #endif | 26 #endif |
| 25 | 27 |
| 26 namespace base { | 28 namespace base { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (!lines[i].empty()) { | 107 if (!lines[i].empty()) { |
| 106 DLOG(WARNING) << "Last line not empty"; | 108 DLOG(WARNING) << "Last line not empty"; |
| 107 return false; | 109 return false; |
| 108 } | 110 } |
| 109 break; | 111 break; |
| 110 } | 112 } |
| 111 | 113 |
| 112 MappedMemoryRegion region; | 114 MappedMemoryRegion region; |
| 113 const char* line = lines[i].c_str(); | 115 const char* line = lines[i].c_str(); |
| 114 char permissions[5] = {'\0'}; // Ensure NUL-terminated string. | 116 char permissions[5] = {'\0'}; // Ensure NUL-terminated string. |
| 115 uint8 dev_major = 0; | 117 uint8_t dev_major = 0; |
| 116 uint8 dev_minor = 0; | 118 uint8_t dev_minor = 0; |
| 117 long inode = 0; | 119 long inode = 0; |
| 118 int path_index = 0; | 120 int path_index = 0; |
| 119 | 121 |
| 120 // Sample format from man 5 proc: | 122 // Sample format from man 5 proc: |
| 121 // | 123 // |
| 122 // address perms offset dev inode pathname | 124 // address perms offset dev inode pathname |
| 123 // 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm | 125 // 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm |
| 124 // | 126 // |
| 125 // The final %n term captures the offset in the input string, which is used | 127 // The final %n term captures the offset in the input string, which is used |
| 126 // to determine the path name. It *does not* increment the return value. | 128 // to determine the path name. It *does not* increment the return value. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 regions.push_back(region); | 160 regions.push_back(region); |
| 159 regions.back().path.assign(line + path_index); | 161 regions.back().path.assign(line + path_index); |
| 160 } | 162 } |
| 161 | 163 |
| 162 regions_out->swap(regions); | 164 regions_out->swap(regions); |
| 163 return true; | 165 return true; |
| 164 } | 166 } |
| 165 | 167 |
| 166 } // namespace debug | 168 } // namespace debug |
| 167 } // namespace base | 169 } // namespace base |
| OLD | NEW |