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 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // static | 450 // static |
451 bool ExceptionHandler::WriteMinidump(const string& dump_path, | 451 bool ExceptionHandler::WriteMinidump(const string& dump_path, |
452 MinidumpCallback callback, | 452 MinidumpCallback callback, |
453 void* callback_context) { | 453 void* callback_context) { |
454 MinidumpDescriptor descriptor(dump_path); | 454 MinidumpDescriptor descriptor(dump_path); |
455 ExceptionHandler eh(descriptor, NULL, callback, callback_context, false, -1); | 455 ExceptionHandler eh(descriptor, NULL, callback, callback_context, false, -1); |
456 return eh.WriteMinidump(); | 456 return eh.WriteMinidump(); |
457 } | 457 } |
458 | 458 |
459 bool ExceptionHandler::WriteMinidump() { | 459 bool ExceptionHandler::WriteMinidump() { |
460 #if !defined(__ARM_EABI__) | 460 #if !defined(__ARM_EABI__) && !defined(__ANDROID__) |
461 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD()) { | 461 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD()) { |
462 // Update the path of the minidump so that this can be called multiple times | 462 // Update the path of the minidump so that this can be called multiple times |
463 // and new files are created for each minidump. This is done before the | 463 // and new files are created for each minidump. This is done before the |
464 // generation happens, as clients may want to access the MinidumpDescriptor | 464 // generation happens, as clients may want to access the MinidumpDescriptor |
465 // after this call to find the exact path to the minidump file. | 465 // after this call to find the exact path to the minidump file. |
466 minidump_descriptor_.UpdatePath(); | 466 minidump_descriptor_.UpdatePath(); |
467 } else if (minidump_descriptor_.IsFD()) { | 467 } else if (minidump_descriptor_.IsFD()) { |
468 // Reposition the FD to its beginning and resize it to get rid of the | 468 // Reposition the FD to its beginning and resize it to get rid of the |
469 // previous minidump info. | 469 // previous minidump info. |
470 lseek(minidump_descriptor_.fd(), 0, SEEK_SET); | 470 lseek(minidump_descriptor_.fd(), 0, SEEK_SET); |
471 ftruncate(minidump_descriptor_.fd(), 0); | 471 ftruncate(minidump_descriptor_.fd(), 0); |
472 } | 472 } |
473 | 473 |
474 // Allow ourselves to be dumped. | 474 // Allow ourselves to be dumped. |
475 sys_prctl(PR_SET_DUMPABLE, 1); | 475 sys_prctl(PR_SET_DUMPABLE, 1); |
476 | 476 |
477 CrashContext context; | 477 CrashContext context; |
478 int getcontext_result = getcontext(&context.context); | 478 int getcontext_result = getcontext(&context.context); |
479 if (getcontext_result) | 479 if (getcontext_result) |
480 return false; | 480 return false; |
481 memcpy(&context.float_state, context.context.uc_mcontext.fpregs, | 481 memcpy(&context.float_state, context.context.uc_mcontext.fpregs, |
482 sizeof(context.float_state)); | 482 sizeof(context.float_state)); |
483 context.tid = sys_gettid(); | 483 context.tid = sys_gettid(); |
484 | 484 |
485 return GenerateDump(&context); | 485 return GenerateDump(&context); |
486 #else | 486 #else |
487 return false; | 487 return false; |
488 #endif // !defined(__ARM_EABI__) | 488 #endif // !defined(__ARM_EABI__) && !defined(__ANDROID__) |
489 } | 489 } |
490 | 490 |
491 void ExceptionHandler::AddMappingInfo(const string& name, | 491 void ExceptionHandler::AddMappingInfo(const string& name, |
492 const u_int8_t identifier[sizeof(MDGUID)], | 492 const u_int8_t identifier[sizeof(MDGUID)], |
493 uintptr_t start_address, | 493 uintptr_t start_address, |
494 size_t mapping_size, | 494 size_t mapping_size, |
495 size_t file_offset) { | 495 size_t file_offset) { |
496 MappingInfo info; | 496 MappingInfo info; |
497 info.start_addr = start_address; | 497 info.start_addr = start_address; |
498 info.size = mapping_size; | 498 info.size = mapping_size; |
499 info.offset = file_offset; | 499 info.offset = file_offset; |
500 strncpy(info.name, name.c_str(), sizeof(info.name) - 1); | 500 strncpy(info.name, name.c_str(), sizeof(info.name) - 1); |
501 info.name[sizeof(info.name) - 1] = '\0'; | 501 info.name[sizeof(info.name) - 1] = '\0'; |
502 | 502 |
503 MappingEntry mapping; | 503 MappingEntry mapping; |
504 mapping.first = info; | 504 mapping.first = info; |
505 memcpy(mapping.second, identifier, sizeof(MDGUID)); | 505 memcpy(mapping.second, identifier, sizeof(MDGUID)); |
506 mapping_list_.push_back(mapping); | 506 mapping_list_.push_back(mapping); |
507 } | 507 } |
508 | 508 |
509 } // namespace google_breakpad | 509 } // namespace google_breakpad |
OLD | NEW |