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 "google_breakpad/processor/proc_maps_linux.h" | 5 #include "google_breakpad/processor/proc_maps_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 | 9 |
10 #if defined(OS_LINUX) || defined(OS_ANDROID) | 10 #if defined(OS_LINUX) || defined(OS_ANDROID) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 int path_index = 0; | 54 int path_index = 0; |
55 | 55 |
56 // Sample format from man 5 proc: | 56 // Sample format from man 5 proc: |
57 // | 57 // |
58 // address perms offset dev inode pathname | 58 // address perms offset dev inode pathname |
59 // 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm | 59 // 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm |
60 // | 60 // |
61 // The final %n term captures the offset in the input string, which is used | 61 // The final %n term captures the offset in the input string, which is used |
62 // to determine the path name. It *does not* increment the return value. | 62 // to determine the path name. It *does not* increment the return value. |
63 // Refer to man 3 sscanf for details. | 63 // Refer to man 3 sscanf for details. |
64 if (sscanf(line, "%lx-%lx %4c %lx %hhx:%hhx %ld %n", | 64 if (sscanf(line, "%" SCNx64 "-%" SCNx64 " %4c %" SCNx64" %hhx:%hhx %" |
65 ®ion.start, ®ion.end, permissions, ®ion.offset, | 65 SCNd64 " %n", ®ion.start, ®ion.end, permissions, |
66 ®ion.major_device, ®ion.minor_device, ®ion.inode, | 66 ®ion.offset, ®ion.major_device, ®ion.minor_device, |
67 &path_index) < 7) { | 67 ®ion.inode, &path_index) < 7) { |
68 BPLOG(ERROR) << "sscanf failed for line: " << line; | 68 BPLOG(ERROR) << "sscanf failed for line: " << line; |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 region.permissions = 0; | 72 region.permissions = 0; |
73 | 73 |
74 if (permissions[0] == 'r') | 74 if (permissions[0] == 'r') |
75 region.permissions |= MappedMemoryRegion::READ; | 75 region.permissions |= MappedMemoryRegion::READ; |
76 else if (permissions[0] != '-') | 76 else if (permissions[0] != '-') |
77 return false; | 77 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
95 regions.push_back(region); | 95 regions.push_back(region); |
96 regions.back().path.assign(line + path_index); | 96 regions.back().path.assign(line + path_index); |
97 regions.back().line.assign(line); | 97 regions.back().line.assign(line); |
98 } | 98 } |
99 | 99 |
100 regions_out->swap(regions); | 100 regions_out->swap(regions); |
101 return true; | 101 return true; |
102 } | 102 } |
103 | 103 |
104 } // namespace google_breakpad | 104 } // namespace google_breakpad |
OLD | NEW |