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 | 8 |
9 #if defined(OS_LINUX) || defined(OS_ANDROID) | 9 #if defined(OS_LINUX) || defined(OS_ANDROID) |
10 #include <inttypes.h> | 10 #include <inttypes.h> |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 return true; | 89 return true; |
90 } | 90 } |
91 | 91 |
92 bool ParseProcMaps(const std::string& input, | 92 bool ParseProcMaps(const std::string& input, |
93 std::vector<MappedMemoryRegion>* regions_out) { | 93 std::vector<MappedMemoryRegion>* regions_out) { |
94 CHECK(regions_out); | 94 CHECK(regions_out); |
95 std::vector<MappedMemoryRegion> regions; | 95 std::vector<MappedMemoryRegion> regions; |
96 | 96 |
97 // This isn't async safe nor terribly efficient, but it doesn't need to be at | 97 // This isn't async safe nor terribly efficient, but it doesn't need to be at |
98 // this point in time. | 98 // this point in time. |
99 std::vector<std::string> lines = SplitString( | 99 std::vector<std::string> lines; |
100 input, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 100 SplitString(input, '\n', &lines); |
101 | 101 |
102 for (size_t i = 0; i < lines.size(); ++i) { | 102 for (size_t i = 0; i < lines.size(); ++i) { |
103 // Due to splitting on '\n' the last line should be empty. | 103 // Due to splitting on '\n' the last line should be empty. |
104 if (i == lines.size() - 1) { | 104 if (i == lines.size() - 1) { |
105 if (!lines[i].empty()) { | 105 if (!lines[i].empty()) { |
106 DLOG(WARNING) << "Last line not empty"; | 106 DLOG(WARNING) << "Last line not empty"; |
107 return false; | 107 return false; |
108 } | 108 } |
109 break; | 109 break; |
110 } | 110 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 regions.push_back(region); | 158 regions.push_back(region); |
159 regions.back().path.assign(line + path_index); | 159 regions.back().path.assign(line + path_index); |
160 } | 160 } |
161 | 161 |
162 regions_out->swap(regions); | 162 regions_out->swap(regions); |
163 return true; | 163 return true; |
164 } | 164 } |
165 | 165 |
166 } // namespace debug | 166 } // namespace debug |
167 } // namespace base | 167 } // namespace base |
OLD | NEW |