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 #ifndef __STDC_FORMAT_MACROS | 5 #ifndef __STDC_FORMAT_MACROS |
6 #define __STDC_FORMAT_MACROS | 6 #define __STDC_FORMAT_MACROS |
7 #endif | 7 #endif |
8 | 8 |
9 #include "google_breakpad/processor/proc_maps_linux.h" | 9 #include "google_breakpad/processor/proc_maps_linux.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 bool ParseProcMaps(const std::string& input, | 28 bool ParseProcMaps(const std::string& input, |
29 std::vector<MappedMemoryRegion>* regions_out) { | 29 std::vector<MappedMemoryRegion>* regions_out) { |
30 std::vector<MappedMemoryRegion> regions; | 30 std::vector<MappedMemoryRegion> regions; |
31 | 31 |
32 // This isn't async safe nor terribly efficient, but it doesn't need to be at | 32 // This isn't async safe nor terribly efficient, but it doesn't need to be at |
33 // this point in time. | 33 // this point in time. |
34 | 34 |
35 // Split the string by newlines. | 35 // Split the string by newlines. |
36 std::vector<std::string> lines; | 36 std::vector<std::string> lines; |
37 std::string line = ""; | 37 std::string l = ""; |
38 for (size_t i = 0; i < input.size(); i++) { | 38 for (size_t i = 0; i < input.size(); i++) { |
39 if (input[i] != '\n' && input[i] != '\r') { | 39 if (input[i] != '\n' && input[i] != '\r') { |
40 line.push_back(input[i]); | 40 l.push_back(input[i]); |
41 } else if (line.size() > 0) { | 41 } else if (l.size() > 0) { |
42 lines.push_back(line); | 42 lines.push_back(l); |
43 line.clear(); | 43 l.clear(); |
44 } | 44 } |
45 } | 45 } |
46 if (line.size() > 0) { | 46 if (l.size() > 0) { |
47 BPLOG(ERROR) << "Input doesn't end in newline"; | 47 BPLOG(ERROR) << "Input doesn't end in newline"; |
48 return false; | 48 return false; |
49 } | 49 } |
50 | 50 |
51 for (size_t i = 0; i < lines.size(); ++i) { | 51 for (size_t i = 0; i < lines.size(); ++i) { |
52 MappedMemoryRegion region; | 52 MappedMemoryRegion region; |
53 const char* line = lines[i].c_str(); | 53 const char* line = lines[i].c_str(); |
54 char permissions[5] = {'\0'}; // Ensure NUL-terminated string. | 54 char permissions[5] = {'\0'}; // Ensure NUL-terminated string. |
55 int path_index = 0; | 55 int path_index = 0; |
56 | 56 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 regions.push_back(region); | 96 regions.push_back(region); |
97 regions.back().path.assign(line + path_index); | 97 regions.back().path.assign(line + path_index); |
98 regions.back().line.assign(line); | 98 regions.back().line.assign(line); |
99 } | 99 } |
100 | 100 |
101 regions_out->swap(regions); | 101 regions_out->swap(regions); |
102 return true; | 102 return true; |
103 } | 103 } |
104 | 104 |
105 } // namespace google_breakpad | 105 } // namespace google_breakpad |
OLD | NEW |