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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include <ucontext.h> | 84 #include <ucontext.h> |
85 | 85 |
86 #include <algorithm> | 86 #include <algorithm> |
87 #include <utility> | 87 #include <utility> |
88 #include <vector> | 88 #include <vector> |
89 | 89 |
90 #include "common/basictypes.h" | 90 #include "common/basictypes.h" |
91 #include "common/linux/linux_libc_support.h" | 91 #include "common/linux/linux_libc_support.h" |
92 #include "common/memory.h" | 92 #include "common/memory.h" |
93 #include "client/linux/log/log.h" | 93 #include "client/linux/log/log.h" |
| 94 #include "client/linux/microdump_writer/microdump_writer.h" |
94 #include "client/linux/minidump_writer/linux_dumper.h" | 95 #include "client/linux/minidump_writer/linux_dumper.h" |
95 #include "client/linux/minidump_writer/minidump_writer.h" | 96 #include "client/linux/minidump_writer/minidump_writer.h" |
96 #include "common/linux/eintr_wrapper.h" | 97 #include "common/linux/eintr_wrapper.h" |
97 #include "third_party/lss/linux_syscall_support.h" | 98 #include "third_party/lss/linux_syscall_support.h" |
98 | 99 |
99 #if defined(__ANDROID__) | 100 #if defined(__ANDROID__) |
100 #include "linux/sched.h" | 101 #include "linux/sched.h" |
101 #endif | 102 #endif |
102 | 103 |
103 #ifndef PR_SET_PTRACER | 104 #ifndef PR_SET_PTRACER |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 bool install_handler, | 204 bool install_handler, |
204 const int server_fd) | 205 const int server_fd) |
205 : filter_(filter), | 206 : filter_(filter), |
206 callback_(callback), | 207 callback_(callback), |
207 callback_context_(callback_context), | 208 callback_context_(callback_context), |
208 minidump_descriptor_(descriptor), | 209 minidump_descriptor_(descriptor), |
209 crash_handler_(NULL) { | 210 crash_handler_(NULL) { |
210 if (server_fd >= 0) | 211 if (server_fd >= 0) |
211 crash_generation_client_.reset(CrashGenerationClient::TryCreate(server_fd)); | 212 crash_generation_client_.reset(CrashGenerationClient::TryCreate(server_fd)); |
212 | 213 |
213 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD()) | 214 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD() && |
| 215 !minidump_descriptor_.IsMicrodumpOnConsole()) |
214 minidump_descriptor_.UpdatePath(); | 216 minidump_descriptor_.UpdatePath(); |
215 | 217 |
216 pthread_mutex_lock(&g_handler_stack_mutex_); | 218 pthread_mutex_lock(&g_handler_stack_mutex_); |
217 if (!g_handler_stack_) | 219 if (!g_handler_stack_) |
218 g_handler_stack_ = new std::vector<ExceptionHandler*>; | 220 g_handler_stack_ = new std::vector<ExceptionHandler*>; |
219 if (install_handler) { | 221 if (install_handler) { |
220 InstallAlternateStackLocked(); | 222 InstallAlternateStackLocked(); |
221 InstallHandlersLocked(); | 223 InstallHandlersLocked(); |
222 } | 224 } |
223 g_handler_stack_->push_back(this); | 225 g_handler_stack_->push_back(this); |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 logger::write(msg, sizeof(msg) - 1); | 543 logger::write(msg, sizeof(msg) - 1); |
542 logger::write(strerror(errno), strlen(strerror(errno))); | 544 logger::write(strerror(errno), strlen(strerror(errno))); |
543 logger::write("\n", 1); | 545 logger::write("\n", 1); |
544 } | 546 } |
545 } | 547 } |
546 | 548 |
547 // This function runs in a compromised context: see the top of the file. | 549 // This function runs in a compromised context: see the top of the file. |
548 // Runs on the cloned process. | 550 // Runs on the cloned process. |
549 bool ExceptionHandler::DoDump(pid_t crashing_process, const void* context, | 551 bool ExceptionHandler::DoDump(pid_t crashing_process, const void* context, |
550 size_t context_size) { | 552 size_t context_size) { |
| 553 if (minidump_descriptor_.IsMicrodumpOnConsole()) { |
| 554 return google_breakpad::WriteMicrodump(crashing_process, |
| 555 context, |
| 556 context_size, |
| 557 mapping_list_); |
| 558 } |
551 if (minidump_descriptor_.IsFD()) { | 559 if (minidump_descriptor_.IsFD()) { |
552 return google_breakpad::WriteMinidump(minidump_descriptor_.fd(), | 560 return google_breakpad::WriteMinidump(minidump_descriptor_.fd(), |
553 minidump_descriptor_.size_limit(), | 561 minidump_descriptor_.size_limit(), |
554 crashing_process, | 562 crashing_process, |
555 context, | 563 context, |
556 context_size, | 564 context_size, |
557 mapping_list_, | 565 mapping_list_, |
558 app_memory_list_); | 566 app_memory_list_); |
559 } | 567 } |
560 return google_breakpad::WriteMinidump(minidump_descriptor_.path(), | 568 return google_breakpad::WriteMinidump(minidump_descriptor_.path(), |
(...skipping 15 matching lines...) Expand all Loading... |
576 } | 584 } |
577 | 585 |
578 // In order to making using EBP to calculate the desired value for ESP | 586 // In order to making using EBP to calculate the desired value for ESP |
579 // a valid operation, ensure that this function is compiled with a | 587 // a valid operation, ensure that this function is compiled with a |
580 // frame pointer using the following attribute. This attribute | 588 // frame pointer using the following attribute. This attribute |
581 // is supported on GCC but not on clang. | 589 // is supported on GCC but not on clang. |
582 #if defined(__i386__) && defined(__GNUC__) && !defined(__clang__) | 590 #if defined(__i386__) && defined(__GNUC__) && !defined(__clang__) |
583 __attribute__((optimize("no-omit-frame-pointer"))) | 591 __attribute__((optimize("no-omit-frame-pointer"))) |
584 #endif | 592 #endif |
585 bool ExceptionHandler::WriteMinidump() { | 593 bool ExceptionHandler::WriteMinidump() { |
586 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD()) { | 594 if (!IsOutOfProcess() && !minidump_descriptor_.IsFD() && |
| 595 !minidump_descriptor_.IsMicrodumpOnConsole()) { |
587 // Update the path of the minidump so that this can be called multiple times | 596 // Update the path of the minidump so that this can be called multiple times |
588 // and new files are created for each minidump. This is done before the | 597 // and new files are created for each minidump. This is done before the |
589 // generation happens, as clients may want to access the MinidumpDescriptor | 598 // generation happens, as clients may want to access the MinidumpDescriptor |
590 // after this call to find the exact path to the minidump file. | 599 // after this call to find the exact path to the minidump file. |
591 minidump_descriptor_.UpdatePath(); | 600 minidump_descriptor_.UpdatePath(); |
592 } else if (minidump_descriptor_.IsFD()) { | 601 } else if (minidump_descriptor_.IsFD()) { |
593 // Reposition the FD to its beginning and resize it to get rid of the | 602 // Reposition the FD to its beginning and resize it to get rid of the |
594 // previous minidump info. | 603 // previous minidump info. |
595 lseek(minidump_descriptor_.fd(), 0, SEEK_SET); | 604 lseek(minidump_descriptor_.fd(), 0, SEEK_SET); |
596 ignore_result(ftruncate(minidump_descriptor_.fd(), 0)); | 605 ignore_result(ftruncate(minidump_descriptor_.fd(), 0)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 descriptor.UpdatePath(); | 718 descriptor.UpdatePath(); |
710 if (!google_breakpad::WriteMinidump(descriptor.path(), | 719 if (!google_breakpad::WriteMinidump(descriptor.path(), |
711 child, | 720 child, |
712 child_blamed_thread)) | 721 child_blamed_thread)) |
713 return false; | 722 return false; |
714 | 723 |
715 return callback ? callback(descriptor, callback_context, true) : true; | 724 return callback ? callback(descriptor, callback_context, true) : true; |
716 } | 725 } |
717 | 726 |
718 } // namespace google_breakpad | 727 } // namespace google_breakpad |
OLD | NEW |