OLD | NEW |
1 // Copyright (c) 2010, Google Inc. | 1 // Copyright (c) 2010, 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 if (fd_ == -1) | 161 if (fd_ == -1) |
162 minidump_writer_.Close(); | 162 minidump_writer_.Close(); |
163 dumper_->ThreadsResume(); | 163 dumper_->ThreadsResume(); |
164 } | 164 } |
165 | 165 |
166 bool Dump() { | 166 bool Dump() { |
167 // A minidump file contains a number of tagged streams. This is the number | 167 // A minidump file contains a number of tagged streams. This is the number |
168 // of stream which we write. | 168 // of stream which we write. |
169 unsigned kNumWriters = 13; | 169 unsigned kNumWriters = 13; |
170 | 170 |
171 TypedMDRVA<MDRawHeader> header(&minidump_writer_); | |
172 TypedMDRVA<MDRawDirectory> dir(&minidump_writer_); | 171 TypedMDRVA<MDRawDirectory> dir(&minidump_writer_); |
173 if (!header.Allocate()) | 172 { |
174 return false; | 173 // Ensure the header gets flushed, as that happens in the destructor. |
175 if (!dir.AllocateArray(kNumWriters)) | 174 // If a crash occurs somewhere below, at least the header will be |
176 return false; | 175 // intact. |
177 my_memset(header.get(), 0, sizeof(MDRawHeader)); | 176 TypedMDRVA<MDRawHeader> header(&minidump_writer_); |
| 177 if (!header.Allocate()) |
| 178 return false; |
178 | 179 |
179 header.get()->signature = MD_HEADER_SIGNATURE; | 180 if (!dir.AllocateArray(kNumWriters)) |
180 header.get()->version = MD_HEADER_VERSION; | 181 return false; |
181 header.get()->time_date_stamp = time(NULL); | 182 |
182 header.get()->stream_count = kNumWriters; | 183 my_memset(header.get(), 0, sizeof(MDRawHeader)); |
183 header.get()->stream_directory_rva = dir.position(); | 184 |
| 185 header.get()->signature = MD_HEADER_SIGNATURE; |
| 186 header.get()->version = MD_HEADER_VERSION; |
| 187 header.get()->time_date_stamp = time(NULL); |
| 188 header.get()->stream_count = kNumWriters; |
| 189 header.get()->stream_directory_rva = dir.position(); |
| 190 } |
184 | 191 |
185 unsigned dir_index = 0; | 192 unsigned dir_index = 0; |
186 MDRawDirectory dirent; | 193 MDRawDirectory dirent; |
187 | 194 |
188 if (!WriteThreadListStream(&dirent)) | 195 if (!WriteThreadListStream(&dirent)) |
189 return false; | 196 return false; |
190 dir.CopyIndex(dir_index++, &dirent); | 197 dir.CopyIndex(dir_index++, &dirent); |
191 | 198 |
192 if (!WriteMappings(&dirent)) | 199 if (!WriteMappings(&dirent)) |
193 return false; | 200 return false; |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 const MappingList& mappings, | 1358 const MappingList& mappings, |
1352 const AppMemoryList& appmem, | 1359 const AppMemoryList& appmem, |
1353 LinuxDumper* dumper) { | 1360 LinuxDumper* dumper) { |
1354 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper); | 1361 MinidumpWriter writer(filename, -1, NULL, mappings, appmem, dumper); |
1355 if (!writer.Init()) | 1362 if (!writer.Init()) |
1356 return false; | 1363 return false; |
1357 return writer.Dump(); | 1364 return writer.Dump(); |
1358 } | 1365 } |
1359 | 1366 |
1360 } // namespace google_breakpad | 1367 } // namespace google_breakpad |
OLD | NEW |