| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/thread_watcher_report_hang.h" | 5 #include "chrome/browser/metrics/thread_watcher_report_hang.h" |
| 6 | 6 |
| 7 // We disable optimizations for the whole file so the compiler doesn't merge | 7 // We disable optimizations for the whole file so the compiler doesn't merge |
| 8 // them all together. | 8 // them all together. |
| 9 MSVC_DISABLE_OPTIMIZE() | 9 MSVC_DISABLE_OPTIMIZE() |
| 10 MSVC_PUSH_DISABLE_WARNING(4748) | 10 MSVC_PUSH_DISABLE_WARNING(4748) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if defined(NDEBUG) | 24 #if defined(NDEBUG) |
| 25 base::debug::DumpWithoutCrashing(); | 25 base::debug::DumpWithoutCrashing(); |
| 26 #else | 26 #else |
| 27 base::debug::BreakDebugger(); | 27 base::debug::BreakDebugger(); |
| 28 #endif | 28 #endif |
| 29 } | 29 } |
| 30 | 30 |
| 31 #if !defined(OS_ANDROID) || !defined(NDEBUG) | 31 #if !defined(OS_ANDROID) || !defined(NDEBUG) |
| 32 // TODO(rtenneti): Enabled crashing, after getting data. | 32 // TODO(rtenneti): Enabled crashing, after getting data. |
| 33 NOINLINE void StartupHang() { | 33 NOINLINE void StartupHang() { |
| 34 volatile const char* inhibit_comdat = __FUNCTION__; | 34 volatile int inhibit_comdat = __LINE__; |
| 35 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 35 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 36 ReportThreadHang(); | 36 ReportThreadHang(); |
| 37 } | 37 } |
| 38 #endif // OS_ANDROID | 38 #endif // OS_ANDROID |
| 39 | 39 |
| 40 NOINLINE void ShutdownHang() { | 40 NOINLINE void ShutdownHang() { |
| 41 volatile const char* inhibit_comdat = __FUNCTION__; | 41 volatile int inhibit_comdat = __LINE__; |
| 42 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 42 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 43 ReportThreadHang(); | 43 ReportThreadHang(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 NOINLINE void ThreadUnresponsive_UI() { | 46 NOINLINE void ThreadUnresponsive_UI() { |
| 47 volatile const char* inhibit_comdat = __FUNCTION__; | 47 volatile int inhibit_comdat = __LINE__; |
| 48 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 48 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 49 ReportThreadHang(); | 49 ReportThreadHang(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 NOINLINE void ThreadUnresponsive_DB() { | 52 NOINLINE void ThreadUnresponsive_DB() { |
| 53 volatile const char* inhibit_comdat = __FUNCTION__; | 53 volatile int inhibit_comdat = __LINE__; |
| 54 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 54 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 55 ReportThreadHang(); | 55 ReportThreadHang(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 NOINLINE void ThreadUnresponsive_FILE() { | 58 NOINLINE void ThreadUnresponsive_FILE() { |
| 59 volatile const char* inhibit_comdat = __FUNCTION__; | 59 volatile int inhibit_comdat = __LINE__; |
| 60 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 60 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 61 ReportThreadHang(); | 61 ReportThreadHang(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 NOINLINE void ThreadUnresponsive_FILE_USER_BLOCKING() { | 64 NOINLINE void ThreadUnresponsive_FILE_USER_BLOCKING() { |
| 65 volatile const char* inhibit_comdat = __FUNCTION__; | 65 volatile int inhibit_comdat = __LINE__; |
| 66 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 66 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 67 ReportThreadHang(); | 67 ReportThreadHang(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 NOINLINE void ThreadUnresponsive_PROCESS_LAUNCHER() { | 70 NOINLINE void ThreadUnresponsive_PROCESS_LAUNCHER() { |
| 71 volatile const char* inhibit_comdat = __FUNCTION__; | 71 volatile int inhibit_comdat = __LINE__; |
| 72 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 72 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 73 ReportThreadHang(); | 73 ReportThreadHang(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 NOINLINE void ThreadUnresponsive_CACHE() { | 76 NOINLINE void ThreadUnresponsive_CACHE() { |
| 77 volatile const char* inhibit_comdat = __FUNCTION__; | 77 volatile int inhibit_comdat = __LINE__; |
| 78 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 78 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 79 ReportThreadHang(); | 79 ReportThreadHang(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 NOINLINE void ThreadUnresponsive_IO() { | 82 NOINLINE void ThreadUnresponsive_IO() { |
| 83 volatile const char* inhibit_comdat = __FUNCTION__; | 83 volatile int inhibit_comdat = __LINE__; |
| 84 ALLOW_UNUSED_LOCAL(inhibit_comdat); | 84 ALLOW_UNUSED_LOCAL(inhibit_comdat); |
| 85 ReportThreadHang(); | 85 ReportThreadHang(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 NOINLINE void CrashBecauseThreadWasUnresponsive(int thread_id) { | 88 NOINLINE void CrashBecauseThreadWasUnresponsive(int thread_id) { |
| 89 // TODO(rtenneti): The following is a temporary change to check thread_id | 89 // TODO(rtenneti): The following is a temporary change to check thread_id |
| 90 // numbers explicitly so that we will have minimum code. Will change after the | 90 // numbers explicitly so that we will have minimum code. Will change after the |
| 91 // test run to use content::BrowserThread::ID enum. | 91 // test run to use content::BrowserThread::ID enum. |
| 92 if (thread_id == 0) | 92 if (thread_id == 0) |
| 93 return ThreadUnresponsive_UI(); | 93 return ThreadUnresponsive_UI(); |
| 94 else if (thread_id == 1) | 94 else if (thread_id == 1) |
| 95 return ThreadUnresponsive_DB(); | 95 return ThreadUnresponsive_DB(); |
| 96 else if (thread_id == 2) | 96 else if (thread_id == 2) |
| 97 return ThreadUnresponsive_FILE(); | 97 return ThreadUnresponsive_FILE(); |
| 98 else if (thread_id == 3) | 98 else if (thread_id == 3) |
| 99 return ThreadUnresponsive_FILE_USER_BLOCKING(); | 99 return ThreadUnresponsive_FILE_USER_BLOCKING(); |
| 100 else if (thread_id == 4) | 100 else if (thread_id == 4) |
| 101 return ThreadUnresponsive_PROCESS_LAUNCHER(); | 101 return ThreadUnresponsive_PROCESS_LAUNCHER(); |
| 102 else if (thread_id == 5) | 102 else if (thread_id == 5) |
| 103 return ThreadUnresponsive_CACHE(); | 103 return ThreadUnresponsive_CACHE(); |
| 104 else if (thread_id == 6) | 104 else if (thread_id == 6) |
| 105 return ThreadUnresponsive_IO(); | 105 return ThreadUnresponsive_IO(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace metrics | 108 } // namespace metrics |
| 109 | 109 |
| 110 MSVC_POP_WARNING() | 110 MSVC_POP_WARNING() |
| 111 MSVC_ENABLE_OPTIMIZE(); | 111 MSVC_ENABLE_OPTIMIZE(); |
| OLD | NEW |