OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/debug_util.h" |
| 6 |
| 7 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 8 #include <signal.h> // For SigUSR1Handler below. |
| 9 #endif |
| 10 |
| 11 #include "base/logging.h" |
| 12 |
| 13 #if defined(OS_POSIX) && !defined(OS_ANDROID) |
| 14 static void SigUSR1Handler(int signal) { } |
| 15 #endif |
| 16 |
| 17 namespace content { |
| 18 |
| 19 void WaitForDebugger(const std::string& label) { |
| 20 #if defined(OS_WIN) |
| 21 #if defined(GOOGLE_CHROME_BUILD) |
| 22 std::string title = "Google Chrome"; |
| 23 #else // CHROMIUM_BUILD |
| 24 std::string title = "Chromium"; |
| 25 #endif // CHROMIUM_BUILD |
| 26 title += " "; |
| 27 title += label; // makes attaching to process easier |
| 28 std::string message = label; |
| 29 message += " starting with pid: "; |
| 30 message += base::IntToString(base::GetCurrentProcId()); |
| 31 ::MessageBox(NULL, UTF8ToWide(message).c_str(), UTF8ToWide(title).c_str(), |
| 32 MB_OK | MB_SETFOREGROUND); |
| 33 #elif defined(OS_POSIX) |
| 34 #if defined(OS_ANDROID) |
| 35 LOG(ERROR) << label << " waiting for GDB."; |
| 36 // Wait 24 hours for a debugger to be attached to the current process. |
| 37 base::debug::WaitForDebugger(24 * 60 * 60, false); |
| 38 #else |
| 39 // TODO(playmobil): In the long term, overriding this flag doesn't seem |
| 40 // right, either use our own flag or open a dialog we can use. |
| 41 // This is just to ease debugging in the interim. |
| 42 LOG(ERROR) << label |
| 43 << " (" |
| 44 << getpid() |
| 45 << ") paused waiting for debugger to attach. " |
| 46 << "Send SIGUSR1 to unpause."; |
| 47 // Install a signal handler so that pause can be woken. |
| 48 struct sigaction sa; |
| 49 memset(&sa, 0, sizeof(sa)); |
| 50 sa.sa_handler = SigUSR1Handler; |
| 51 sigaction(SIGUSR1, &sa, NULL); |
| 52 |
| 53 pause(); |
| 54 #endif // defined(OS_ANDROID) |
| 55 #endif // defined(OS_POSIX) |
| 56 } |
| 57 |
| 58 } // namespace content |
OLD | NEW |