OLD | NEW |
1 // Copyright (c) 2009, Google Inc. | 1 // Copyright (c) 2009, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 memcpy(maps_path + 6 + pid_len, "/maps", 6); | 119 memcpy(maps_path + 6 + pid_len, "/maps", 6); |
120 | 120 |
121 const int fd = sys_open(maps_path, O_RDONLY, 0); | 121 const int fd = sys_open(maps_path, O_RDONLY, 0); |
122 if (fd < 0) | 122 if (fd < 0) |
123 return false; | 123 return false; |
124 LineReader *const line_reader = new(allocator_) LineReader(fd); | 124 LineReader *const line_reader = new(allocator_) LineReader(fd); |
125 | 125 |
126 const char *line; | 126 const char *line; |
127 unsigned line_len; | 127 unsigned line_len; |
128 while (line_reader->GetNextLine(&line, &line_len)) { | 128 while (line_reader->GetNextLine(&line, &line_len)) { |
129 uintptr_t start_addr; | 129 uintptr_t start_addr, end_addr, offset; |
130 uintptr_t end_addr; | |
131 | 130 |
132 const char* i1 = my_read_hex_ptr(&start_addr, line); | 131 const char* i1 = my_read_hex_ptr(&start_addr, line); |
133 if (*i1 == '-') { | 132 if (*i1 == '-') { |
134 const char *i2 = my_read_hex_ptr(&end_addr, i1 + 1); | 133 const char *i2 = my_read_hex_ptr(&end_addr, i1 + 1); |
135 if (*i2 == ' ') { | 134 if (*i2 == ' ') { |
136 MappingInfo *const module = new(allocator_) MappingInfo; | 135 const char *i3 = my_read_hex_ptr(&offset, i2 + 6 /* skip ' rwxp ' */); |
137 memset(module, 0, sizeof(MappingInfo)); | 136 if (*i3 == ' ') { |
138 module->start_addr = start_addr; | 137 MappingInfo *const module = new(allocator_) MappingInfo; |
139 module->size = end_addr - start_addr; | 138 memset(module, 0, sizeof(MappingInfo)); |
140 const char *name = NULL; | 139 module->start_addr = start_addr; |
141 // Only copy name if the name is a valid path name. | 140 module->size = end_addr - start_addr; |
142 if ((name = my_strchr(line, '/')) != NULL) { | 141 module->offset = offset; |
143 const unsigned l = my_strlen(name); | 142 const char *name = NULL; |
144 if (l < sizeof(module->name)) | 143 // Only copy name if the name is a valid path name. |
145 memcpy(module->name, name, l); | 144 if ((name = my_strchr(line, '/')) != NULL) { |
| 145 const unsigned l = my_strlen(name); |
| 146 if (l < sizeof(module->name)) |
| 147 memcpy(module->name, name, l); |
| 148 } |
| 149 |
| 150 result->push_back(module); |
146 } | 151 } |
147 | |
148 result->push_back(module); | |
149 } | 152 } |
150 } | 153 } |
151 | 154 |
152 line_reader->PopLine(line_len); | 155 line_reader->PopLine(line_len); |
153 } | 156 } |
154 | 157 |
155 sys_close(fd); | 158 sys_close(fd); |
156 return result->size() > 0; | 159 return result->size() > 0; |
157 } | 160 } |
158 | 161 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 for (size_t i = 0; i < mappings_.size(); ++i) { | 326 for (size_t i = 0; i < mappings_.size(); ++i) { |
324 const uintptr_t start = static_cast<uintptr_t>(mappings_[i]->start_addr); | 327 const uintptr_t start = static_cast<uintptr_t>(mappings_[i]->start_addr); |
325 if (addr >= start && addr - start < mappings_[i]->size) | 328 if (addr >= start && addr - start < mappings_[i]->size) |
326 return mappings_[i]; | 329 return mappings_[i]; |
327 } | 330 } |
328 | 331 |
329 return NULL; | 332 return NULL; |
330 } | 333 } |
331 | 334 |
332 } // namespace google_breakpad | 335 } // namespace google_breakpad |
OLD | NEW |