@@ -292,8 +292,9 @@ class MimeWriter {
292
292
iov_index_ = 0 ;
293
293
}
294
294
295
- protected:
296
295
void AddItem (const void * base, size_t size);
296
+
297
+ protected:
297
298
// Minor performance trade-off for easier-to-maintain code.
298
299
void AddString (const char * str) {
299
300
AddItem (str, my_strlen (str));
@@ -684,6 +685,7 @@ void EnableCrashDumping(bool unattended) {
684
685
true , // Install handlers.
685
686
-1 ); // Server file descriptor. -1 for in-process.
686
687
#endif
688
+ LOG (INFO) << " Initialized crash dump in " << dumps_path.value ();
687
689
}
688
690
689
691
#if defined(OS_ANDROID)
@@ -1052,7 +1054,6 @@ void HandleCrashDump(const BreakpadInfo& info) {
1052
1054
exe_buf = GetCrashingProcessName (info, &allocator);
1053
1055
#endif
1054
1056
1055
- VLOG (1 ) << " info.fd: " << info.fd << " info.filename:" << info.filename ;
1056
1057
if (info.fd != -1 ) {
1057
1058
// Dump is provided with an open FD.
1058
1059
keep_fd = true ;
@@ -1240,289 +1241,12 @@ void HandleCrashDump(const BreakpadInfo& info) {
1240
1241
#else
1241
1242
MimeWriter writer (temp_file_fd, mime_boundary);
1242
1243
#endif
1243
- {
1244
- std::string product_name;
1245
- std::string version;
1246
-
1247
- breakpad::GetBreakpadClient ()->GetProductNameAndVersion (&product_name,
1248
- &version);
1249
-
1250
- writer.AddBoundary ();
1251
- writer.AddPairString (" prod" , product_name.c_str ());
1252
- writer.AddBoundary ();
1253
- writer.AddPairString (" ver" , version.c_str ());
1254
- writer.AddBoundary ();
1255
- writer.AddPairString (" guid" , info.guid );
1256
- writer.AddBoundary ();
1257
- if (info.pid > 0 ) {
1258
- char pid_value_buf[kUint64StringSize ];
1259
- uint64_t pid_value_len = my_uint64_len (info.pid );
1260
- my_uint64tos (pid_value_buf, info.pid , pid_value_len);
1261
- static const char pid_key_name[] = " pid" ;
1262
- writer.AddPairData (pid_key_name, sizeof (pid_key_name) - 1 ,
1263
- pid_value_buf, pid_value_len);
1264
- writer.AddBoundary ();
1265
- }
1266
- #if defined(OS_ANDROID)
1267
- // Addtional MIME blocks are added for logging on Android devices.
1268
- static const char android_build_id[] = " android_build_id" ;
1269
- static const char android_build_fp[] = " android_build_fp" ;
1270
- static const char device[] = " device" ;
1271
- static const char model[] = " model" ;
1272
- static const char brand[] = " brand" ;
1273
- static const char exception_info[] = " exception_info" ;
1274
-
1275
- base::android::BuildInfo* android_build_info =
1276
- base::android::BuildInfo::GetInstance ();
1277
- writer.AddPairString (
1278
- android_build_id, android_build_info->android_build_id ());
1279
- writer.AddBoundary ();
1280
- writer.AddPairString (
1281
- android_build_fp, android_build_info->android_build_fp ());
1282
- writer.AddBoundary ();
1283
- writer.AddPairString (device, android_build_info->device ());
1284
- writer.AddBoundary ();
1285
- writer.AddPairString (model, android_build_info->model ());
1286
- writer.AddBoundary ();
1287
- writer.AddPairString (brand, android_build_info->brand ());
1288
- writer.AddBoundary ();
1289
- if (android_build_info->java_exception_info () != NULL ) {
1290
- writer.AddPairString (exception_info,
1291
- android_build_info->java_exception_info ());
1292
- writer.AddBoundary ();
1293
- }
1294
- #endif
1295
- writer.Flush ();
1296
- }
1297
-
1298
- if (info.process_start_time > 0 ) {
1299
- struct kernel_timeval tv;
1300
- if (!sys_gettimeofday (&tv, NULL )) {
1301
- uint64_t time = kernel_timeval_to_ms (&tv);
1302
- if (time > info.process_start_time ) {
1303
- time -= info.process_start_time ;
1304
- char time_str[kUint64StringSize ];
1305
- const unsigned time_len = my_uint64_len (time);
1306
- my_uint64tos (time_str, time, time_len);
1307
-
1308
- static const char process_time_msg[] = " ptime" ;
1309
- writer.AddPairData (process_time_msg, sizeof (process_time_msg) - 1 ,
1310
- time_str, time_len);
1311
- writer.AddBoundary ();
1312
- writer.Flush ();
1313
- }
1314
- }
1315
- }
1316
-
1317
- if (info.process_type_length ) {
1318
- writer.AddPairString (" ptype" , info.process_type );
1319
- writer.AddBoundary ();
1320
- writer.Flush ();
1321
- }
1322
-
1323
- // If GPU info is known, send it.
1324
- if (*child_process_logging::g_gpu_vendor_id) {
1325
- #if !defined(OS_ANDROID)
1326
- static const char vendor_msg[] = " gpu-venid" ;
1327
- static const char device_msg[] = " gpu-devid" ;
1328
- #endif
1329
- static const char gl_vendor_msg[] = " gpu-gl-vendor" ;
1330
- static const char gl_renderer_msg[] = " gpu-gl-renderer" ;
1331
- static const char driver_msg[] = " gpu-driver" ;
1332
- static const char psver_msg[] = " gpu-psver" ;
1333
- static const char vsver_msg[] = " gpu-vsver" ;
1334
-
1335
- #if !defined(OS_ANDROID)
1336
- writer.AddPairString (vendor_msg, child_process_logging::g_gpu_vendor_id);
1337
- writer.AddBoundary ();
1338
- writer.AddPairString (device_msg, child_process_logging::g_gpu_device_id);
1339
- writer.AddBoundary ();
1340
- #endif
1341
- writer.AddPairString (gl_vendor_msg, child_process_logging::g_gpu_gl_vendor);
1342
- writer.AddBoundary ();
1343
- writer.AddPairString (gl_renderer_msg,
1344
- child_process_logging::g_gpu_gl_renderer);
1345
- writer.AddBoundary ();
1346
- writer.AddPairString (driver_msg, child_process_logging::g_gpu_driver_ver);
1347
- writer.AddBoundary ();
1348
- writer.AddPairString (psver_msg, child_process_logging::g_gpu_ps_ver);
1349
- writer.AddBoundary ();
1350
- writer.AddPairString (vsver_msg, child_process_logging::g_gpu_vs_ver);
1351
- writer.AddBoundary ();
1352
- writer.Flush ();
1353
- }
1354
-
1355
- if (info.distro_length ) {
1356
- static const char distro_msg[] = " lsb-release" ;
1357
- writer.AddPairString (distro_msg, info.distro );
1358
- writer.AddBoundary ();
1359
- writer.Flush ();
1360
- }
1361
-
1362
- // For renderers and plugins.
1363
- if (info.crash_url_length ) {
1364
- static const char url_chunk_msg[] = " url-chunk-" ;
1365
- static const unsigned kMaxUrlLength = 8 * MimeWriter::kMaxCrashChunkSize ;
1366
- writer.AddPairDataInChunks (url_chunk_msg, sizeof (url_chunk_msg) - 1 ,
1367
- info.crash_url , std::min (info.crash_url_length , kMaxUrlLength ),
1368
- MimeWriter::kMaxCrashChunkSize , false /* Don't strip whitespaces. */ );
1369
- }
1370
-
1371
- if (*child_process_logging::g_channel) {
1372
- writer.AddPairString (" channel" , child_process_logging::g_channel);
1373
- writer.AddBoundary ();
1374
- writer.Flush ();
1375
- }
1376
-
1377
- if (*child_process_logging::g_num_views) {
1378
- writer.AddPairString (" num-views" , child_process_logging::g_num_views);
1379
- writer.AddBoundary ();
1380
- writer.Flush ();
1381
- }
1382
-
1383
- if (*child_process_logging::g_num_extensions) {
1384
- writer.AddPairString (" num-extensions" ,
1385
- child_process_logging::g_num_extensions);
1386
- writer.AddBoundary ();
1387
- writer.Flush ();
1388
- }
1389
-
1390
- unsigned extension_ids_len =
1391
- my_strlen (child_process_logging::g_extension_ids);
1392
- if (extension_ids_len) {
1393
- static const char extension_msg[] = " extension-" ;
1394
- static const unsigned kMaxExtensionsLen =
1395
- kMaxReportedActiveExtensions * child_process_logging::kExtensionLen ;
1396
- writer.AddPairDataInChunks (extension_msg, sizeof (extension_msg) - 1 ,
1397
- child_process_logging::g_extension_ids,
1398
- std::min (extension_ids_len, kMaxExtensionsLen ),
1399
- child_process_logging::kExtensionLen ,
1400
- false /* Don't strip whitespace. */ );
1401
- }
1402
-
1403
- unsigned printer_info_len =
1404
- my_strlen (child_process_logging::g_printer_info);
1405
- if (printer_info_len) {
1406
- static const char printer_info_msg[] = " prn-info-" ;
1407
- static const unsigned kMaxPrnInfoLen =
1408
- kMaxReportedPrinterRecords * child_process_logging::kPrinterInfoStrLen ;
1409
- writer.AddPairDataInChunks (printer_info_msg, sizeof (printer_info_msg) - 1 ,
1410
- child_process_logging::g_printer_info,
1411
- std::min (printer_info_len, kMaxPrnInfoLen ),
1412
- child_process_logging::kPrinterInfoStrLen ,
1413
- true );
1414
- }
1415
-
1416
- if (*child_process_logging::g_num_switches) {
1417
- writer.AddPairString (" num-switches" ,
1418
- child_process_logging::g_num_switches);
1419
- writer.AddBoundary ();
1420
- writer.Flush ();
1421
- }
1422
-
1423
- unsigned switches_len =
1424
- my_strlen (child_process_logging::g_switches);
1425
- if (switches_len) {
1426
- static const char switch_msg[] = " switch-" ;
1427
- static const unsigned kMaxSwitchLen =
1428
- kMaxSwitches * child_process_logging::kSwitchLen ;
1429
- writer.AddPairDataInChunks (switch_msg, sizeof (switch_msg) - 1 ,
1430
- child_process_logging::g_switches,
1431
- std::min (switches_len, kMaxSwitchLen ),
1432
- child_process_logging::kSwitchLen ,
1433
- true /* Strip whitespace since switches are padded to kSwitchLen. */ );
1434
- }
1435
-
1436
- if (*child_process_logging::g_num_variations) {
1437
- writer.AddPairString (" num-experiments" ,
1438
- child_process_logging::g_num_variations);
1439
- writer.AddBoundary ();
1440
- writer.Flush ();
1441
- }
1442
-
1443
- unsigned variation_chunks_len =
1444
- my_strlen (child_process_logging::g_variation_chunks);
1445
- if (variation_chunks_len) {
1446
- static const char variation_msg[] = " experiment-chunk-" ;
1447
- static const unsigned kMaxVariationsLen =
1448
- kMaxReportedVariationChunks * kMaxVariationChunkSize ;
1449
- writer.AddPairDataInChunks (variation_msg, sizeof (variation_msg) - 1 ,
1450
- child_process_logging::g_variation_chunks,
1451
- std::min (variation_chunks_len, kMaxVariationsLen ),
1452
- kMaxVariationChunkSize ,
1453
- true /* Strip whitespace since variation chunks are padded. */ );
1454
- }
1455
-
1456
- if (info.oom_size ) {
1457
- char oom_size_str[kUint64StringSize ];
1458
- const unsigned oom_size_len = my_uint64_len (info.oom_size );
1459
- my_uint64tos (oom_size_str, info.oom_size , oom_size_len);
1460
- static const char oom_size_msg[] = " oom-size" ;
1461
- writer.AddPairData (oom_size_msg, sizeof (oom_size_msg) - 1 ,
1462
- oom_size_str, oom_size_len);
1463
- writer.AddBoundary ();
1464
- writer.Flush ();
1465
- }
1466
-
1467
- if (info.crash_keys ) {
1468
- CrashKeyStorage::Iterator crash_key_iterator (*info.crash_keys );
1469
- const CrashKeyStorage::Entry* entry;
1470
- while ((entry = crash_key_iterator.Next ())) {
1471
- writer.AddPairString (entry->key , entry->value );
1472
- writer.AddBoundary ();
1473
- writer.Flush ();
1474
- }
1475
- }
1476
-
1477
- writer.AddFileContents (g_dump_msg, dump_data, dump_size);
1478
- #if defined(ADDRESS_SANITIZER)
1479
- // Append a multipart boundary and the contents of the AddressSanitizer log.
1480
- writer.AddBoundary ();
1481
- writer.AddFileContents (g_log_msg, log_data, log_size);
1482
- #endif
1483
- writer.AddEnd ();
1244
+ writer.AddItem (dump_data, dump_size);
1484
1245
writer.Flush ();
1485
1246
1486
1247
IGNORE_RET (sys_close (temp_file_fd));
1487
1248
1488
- #if defined(OS_ANDROID)
1489
- if (info.filename ) {
1490
- int filename_length = my_strlen (info.filename );
1491
-
1492
- // If this was a file, we need to copy it to the right place and use the
1493
- // right file name so it gets uploaded by the browser.
1494
- const char msg[] = " Output crash dump file:" ;
1495
- WriteLog (msg, sizeof (msg) - 1 );
1496
- WriteLog (info.filename , filename_length - 1 );
1497
-
1498
- char pid_buf[kUint64StringSize ];
1499
- uint64_t pid_str_length = my_uint64_len (info.pid );
1500
- my_uint64tos (pid_buf, info.pid , pid_str_length);
1501
-
1502
- // -1 because we won't need the null terminator on the original filename.
1503
- unsigned done_filename_len = filename_length - 1 + pid_str_length;
1504
- char * done_filename = reinterpret_cast <char *>(
1505
- allocator.Alloc (done_filename_len));
1506
- // Rename the file such that the pid is the suffix in order signal to other
1507
- // processes that the minidump is complete. The advantage of using the pid
1508
- // as the suffix is that it is trivial to associate the minidump with the
1509
- // crashed process.
1510
- // Finally, note strncpy prevents null terminators from
1511
- // being copied. Pad the rest with 0's.
1512
- my_strncpy (done_filename, info.filename , done_filename_len);
1513
- // Append the suffix a null terminator should be added.
1514
- my_strncat (done_filename, pid_buf, pid_str_length);
1515
- // Rename the minidump file to signal that it is complete.
1516
- if (rename (info.filename , done_filename)) {
1517
- const char failed_msg[] = " Failed to rename:" ;
1518
- WriteLog (failed_msg, sizeof (failed_msg) - 1 );
1519
- WriteLog (info.filename , filename_length - 1 );
1520
- const char to_msg[] = " to" ;
1521
- WriteLog (to_msg, sizeof (to_msg) - 1 );
1522
- WriteLog (done_filename, done_filename_len - 1 );
1523
- }
1524
- }
1525
- #endif
1249
+ LOG (ERROR) << " crash dump file written to " << info.filename ;
1526
1250
1527
1251
if (!info.upload )
1528
1252
return ;
0 commit comments