OLD | NEW |
1 // Copyright 2013 Google Inc. All rights reserved. | 1 // Copyright 2013 Google Inc. All rights reserved. |
2 // | 2 // |
3 // Redistribution and use in source and binary forms, with or without | 3 // Redistribution and use in source and binary forms, with or without |
4 // modification, are permitted provided that the following conditions are | 4 // modification, are permitted provided that the following conditions are |
5 // met: | 5 // met: |
6 // | 6 // |
7 // * Redistributions of source code must retain the above copyright | 7 // * Redistributions of source code must retain the above copyright |
8 // notice, this list of conditions and the following disclaimer. | 8 // notice, this list of conditions and the following disclaimer. |
9 // * Redistributions in binary form must reproduce the above | 9 // * Redistributions in binary form must reproduce the above |
10 // copyright notice, this list of conditions and the following disclaimer | 10 // copyright notice, this list of conditions and the following disclaimer |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 bool EndpointIndexLess(const EndpointIndex& ei1, const EndpointIndex& ei2) { | 163 bool EndpointIndexLess(const EndpointIndex& ei1, const EndpointIndex& ei2) { |
164 return ei1.endpoint < ei2.endpoint; | 164 return ei1.endpoint < ei2.endpoint; |
165 } | 165 } |
166 | 166 |
167 // Finds the debug stream with the given |name| in the given |session|, and | 167 // Finds the debug stream with the given |name| in the given |session|, and |
168 // populates |table| with its contents. Casts the data directly into OMAP | 168 // populates |table| with its contents. Casts the data directly into OMAP |
169 // structs. | 169 // structs. |
170 bool FindAndLoadOmapTable(const wchar_t* name, | 170 bool FindAndLoadOmapTable(const wchar_t* name, |
171 IDiaSession* session, | 171 IDiaSession* session, |
172 OmapTable* table) { | 172 OmapTable* table) { |
173 assert(name != NULL); | 173 DWORD rva; |
174 assert(session != NULL); | 174 return FindAndLoadDebugStream(name, session, table, &rva); |
175 assert(table != NULL); | |
176 | |
177 CComPtr<IDiaEnumDebugStreamData> stream; | |
178 if (!FindDebugStream(name, session, &stream)) | |
179 return false; | |
180 assert(stream.p != NULL); | |
181 | |
182 LONG count = 0; | |
183 if (FAILED(stream->get_Count(&count))) { | |
184 fprintf(stderr, "IDiaEnumDebugStreamData::get_Count failed for stream " | |
185 "\"%ws\"\n", name); | |
186 return false; | |
187 } | |
188 | |
189 // Get the length of the stream in bytes. | |
190 DWORD bytes_read = 0; | |
191 ULONG count_read = 0; | |
192 if (FAILED(stream->Next(count, 0, &bytes_read, NULL, &count_read))) { | |
193 fprintf(stderr, "IDiaEnumDebugStreamData::Next failed while reading " | |
194 "length of stream \"%ws\"\n", name); | |
195 return false; | |
196 } | |
197 | |
198 // Ensure it's consistent with the OMAP data type. | |
199 DWORD bytes_expected = count * sizeof(OmapTable::value_type); | |
200 if (count * sizeof(OmapTable::value_type) != bytes_read) { | |
201 fprintf(stderr, "DIA debug stream \"%ws\" has an unexpected length", name); | |
202 return false; | |
203 } | |
204 | |
205 // Read the table. | |
206 table->resize(count); | |
207 bytes_read = 0; | |
208 count_read = 0; | |
209 if (FAILED(stream->Next(count, bytes_expected, &bytes_read, | |
210 reinterpret_cast<BYTE*>(&table->at(0)), | |
211 &count_read))) { | |
212 fprintf(stderr, "IDiaEnumDebugStreamData::Next failed while reading " | |
213 "data from stream \"%ws\"\n", name); | |
214 return false; | |
215 } | |
216 | |
217 return true; | |
218 } | 175 } |
219 | 176 |
220 // This determines the original image length by looking through the segment | 177 // This determines the original image length by looking through the segment |
221 // table. | 178 // table. |
222 bool GetOriginalImageLength(IDiaSession* session, DWORD* image_length) { | 179 bool GetOriginalImageLength(IDiaSession* session, DWORD* image_length) { |
223 assert(session != NULL); | 180 assert(session != NULL); |
224 assert(image_length != NULL); | 181 assert(image_length != NULL); |
225 | 182 |
226 CComPtr<IDiaEnumSegments> enum_segments; | 183 CComPtr<IDiaEnumSegments> enum_segments; |
227 if (!FindTable(session, &enum_segments)) | 184 if (!FindTable(session, &enum_segments)) |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 // Output the range in progress. | 642 // Output the range in progress. |
686 if (rva_begin < rva_cur_content) { | 643 if (rva_begin < rva_cur_content) { |
687 mapped_ranges->push_back( | 644 mapped_ranges->push_back( |
688 AddressRange(rva_begin, rva_cur_content - rva_begin)); | 645 AddressRange(rva_begin, rva_cur_content - rva_begin)); |
689 } | 646 } |
690 | 647 |
691 return; | 648 return; |
692 } | 649 } |
693 | 650 |
694 } // namespace google_breakpad | 651 } // namespace google_breakpad |
OLD | NEW |