Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(277)

Side by Side Diff: base/debug/debugger_posix.cc

Issue 2315403002: Force crash on Mac10.9- in BreakDebugger() (Closed)
Patch Set: - Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/debug/debugger.h" 5 #include "base/debug/debugger.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #include <stdlib.h> 11 #include <stdlib.h>
12 #include <sys/param.h> 12 #include <sys/param.h>
13 #include <sys/stat.h> 13 #include <sys/stat.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 16
17 #include <memory> 17 #include <memory>
18 #include <vector> 18 #include <vector>
19 19
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "build/build_config.h" 21 #include "build/build_config.h"
22 22
23 #if defined(__GLIBCXX__) 23 #if defined(__GLIBCXX__)
24 #include <cxxabi.h> 24 #include <cxxabi.h>
25 #endif 25 #endif
26 26
27 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
28 #include <AvailabilityMacros.h> 28 #include <AvailabilityMacros.h>
29 #if !defined(OS_IOS)
30 #include "base/mac/mac_util.h"
31 #endif
29 #endif 32 #endif
30 33
31 #if defined(OS_MACOSX) || defined(OS_BSD) 34 #if defined(OS_MACOSX) || defined(OS_BSD)
32 #include <sys/sysctl.h> 35 #include <sys/sysctl.h>
33 #endif 36 #endif
34 37
35 #if defined(OS_FREEBSD) 38 #if defined(OS_FREEBSD)
36 #include <sys/user.h> 39 #include <sys/user.h>
37 #endif 40 #endif
38 41
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 volatile int go = 0; 227 volatile int go = 0;
225 while (!go) { 228 while (!go) {
226 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100)); 229 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(100));
227 } 230 }
228 #endif 231 #endif
229 } 232 }
230 } 233 }
231 } // namespace 234 } // namespace
232 #define DEBUG_BREAK() DebugBreak() 235 #define DEBUG_BREAK() DebugBreak()
233 #elif defined(DEBUG_BREAK_ASM) 236 #elif defined(DEBUG_BREAK_ASM)
234 #define DEBUG_BREAK() DEBUG_BREAK_ASM() 237 #define DEBUG_BREAK() \
238 do { \
239 if (base::mac::IsAtMostOS10_9()) \
240 *static_cast<volatile int*>(0) = 0; \
241 else \
242 DEBUG_BREAK_ASM(); \
243 } while (false)
235 #else 244 #else
236 #error "Don't know how to debug break on this architecture/OS" 245 #error "Don't know how to debug break on this architecture/OS"
237 #endif 246 #endif
238 247
239 void BreakDebugger() { 248 void BreakDebugger() {
240 // NOTE: This code MUST be async-signal safe (it's used by in-process 249 // NOTE: This code MUST be async-signal safe (it's used by in-process
241 // stack dumping signal handler). NO malloc or stdio is allowed here. 250 // stack dumping signal handler). NO malloc or stdio is allowed here.
242 251
243 // Linker's ICF feature may merge this function with other functions with the 252 // Linker's ICF feature may merge this function with other functions with the
244 // same definition (e.g. any function whose sole job is to call abort()) and 253 // same definition (e.g. any function whose sole job is to call abort()) and
245 // it may confuse the crash report processing system. http://crbug.com/508489 254 // it may confuse the crash report processing system. http://crbug.com/508489
246 static int static_variable_to_make_this_function_unique = 0; 255 static int static_variable_to_make_this_function_unique = 0;
247 base::debug::Alias(&static_variable_to_make_this_function_unique); 256 base::debug::Alias(&static_variable_to_make_this_function_unique);
248 257
249 DEBUG_BREAK(); 258 DEBUG_BREAK();
250 #if defined(OS_ANDROID) && !defined(OFFICIAL_BUILD) 259 #if defined(OS_ANDROID) && !defined(OFFICIAL_BUILD)
251 // For Android development we always build release (debug builds are 260 // For Android development we always build release (debug builds are
252 // unmanageably large), so the unofficial build is used for debugging. It is 261 // unmanageably large), so the unofficial build is used for debugging. It is
253 // helpful to be able to insert BreakDebugger() statements in the source, 262 // helpful to be able to insert BreakDebugger() statements in the source,
254 // attach the debugger, inspect the state of the program and then resume it by 263 // attach the debugger, inspect the state of the program and then resume it by
255 // setting the 'go' variable above. 264 // setting the 'go' variable above.
256 #elif defined(NDEBUG) 265 #elif defined(NDEBUG)
257 // Terminate the program after signaling the debug break. 266 // Terminate the program after signaling the debug break.
258 _exit(1); 267 _exit(1);
259 #endif 268 #endif
260 } 269 }
261 270
262 } // namespace debug 271 } // namespace debug
263 } // namespace base 272 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/debug/stack_trace_posix.cc » ('j') | base/debug/stack_trace_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698