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

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

Issue 8564020: define OS_BSD on *BSD and replace the ifdefs to use that (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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/file_util_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "build/build_config.h" 6 #include "build/build_config.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 11 matching lines...) Expand all
22 #endif 22 #endif
23 23
24 #if defined(__GLIBCXX__) 24 #if defined(__GLIBCXX__)
25 #include <cxxabi.h> 25 #include <cxxabi.h>
26 #endif 26 #endif
27 27
28 #if defined(OS_MACOSX) 28 #if defined(OS_MACOSX)
29 #include <AvailabilityMacros.h> 29 #include <AvailabilityMacros.h>
30 #endif 30 #endif
31 31
32 #if defined(OS_MACOSX) || defined(OS_OPENBSD) || defined(OS_FREEBSD) 32 #if defined(OS_MACOSX) || defined(OS_BSD)
33 #include <sys/sysctl.h> 33 #include <sys/sysctl.h>
34 #endif 34 #endif
35 35
36 #include <ostream> 36 #include <ostream>
37 37
38 #include "base/basictypes.h" 38 #include "base/basictypes.h"
39 #include "base/eintr_wrapper.h" 39 #include "base/eintr_wrapper.h"
40 #include "base/logging.h" 40 #include "base/logging.h"
41 #include "base/memory/scoped_ptr.h" 41 #include "base/memory/scoped_ptr.h"
42 #include "base/safe_strerror_posix.h" 42 #include "base/safe_strerror_posix.h"
43 #include "base/string_piece.h" 43 #include "base/string_piece.h"
44 #include "base/stringprintf.h" 44 #include "base/stringprintf.h"
45 45
46 #if defined(USE_SYMBOLIZE) 46 #if defined(USE_SYMBOLIZE)
47 #include "base/third_party/symbolize/symbolize.h" 47 #include "base/third_party/symbolize/symbolize.h"
48 #endif 48 #endif
49 49
50 #if defined(OS_ANDROID) 50 #if defined(OS_ANDROID)
51 #include "base/threading/platform_thread.h" 51 #include "base/threading/platform_thread.h"
52 #endif 52 #endif
53 53
54 namespace base { 54 namespace base {
55 namespace debug { 55 namespace debug {
56 56
57 bool SpawnDebuggerOnProcess(unsigned /* process_id */) { 57 bool SpawnDebuggerOnProcess(unsigned /* process_id */) {
58 NOTIMPLEMENTED(); 58 NOTIMPLEMENTED();
59 return false; 59 return false;
60 } 60 }
61 61
62 #if defined(OS_MACOSX) || defined(OS_OPENBSD) 62 #if defined(OS_MACOSX) || defined(OS_BSD)
63 63
64 // Based on Apple's recommended method as described in 64 // Based on Apple's recommended method as described in
65 // http://developer.apple.com/qa/qa2004/qa1361.html 65 // http://developer.apple.com/qa/qa2004/qa1361.html
66 bool BeingDebugged() { 66 bool BeingDebugged() {
67 // If the process is sandboxed then we can't use the sysctl, so cache the 67 // If the process is sandboxed then we can't use the sysctl, so cache the
68 // value. 68 // value.
69 static bool is_set = false; 69 static bool is_set = false;
70 static bool being_debugged = false; 70 static bool being_debugged = false;
71 71
72 if (is_set) { 72 if (is_set) {
(...skipping 28 matching lines...) Expand all
101 int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0); 101 int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
102 DCHECK_EQ(sysctl_result, 0); 102 DCHECK_EQ(sysctl_result, 0);
103 if (sysctl_result != 0) { 103 if (sysctl_result != 0) {
104 is_set = true; 104 is_set = true;
105 being_debugged = false; 105 being_debugged = false;
106 return being_debugged; 106 return being_debugged;
107 } 107 }
108 108
109 // This process is being debugged if the P_TRACED flag is set. 109 // This process is being debugged if the P_TRACED flag is set.
110 is_set = true; 110 is_set = true;
111 #if defined(OS_OPENBSD) 111 #if defined(OS_BSD)
112 being_debugged = (info.p_flag & P_TRACED) != 0; 112 being_debugged = (info.p_flag & P_TRACED) != 0;
113 #else 113 #else
114 being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0; 114 being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0;
115 #endif 115 #endif
116 return being_debugged; 116 return being_debugged;
117 } 117 }
118 118
119 #elif defined(OS_LINUX) || defined(OS_ANDROID) 119 #elif defined(OS_LINUX) || defined(OS_ANDROID)
120 120
121 // We can look in /proc/self/status for TracerPid. We are likely used in crash 121 // We can look in /proc/self/status for TracerPid. We are likely used in crash
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 212
213 void BreakDebugger() { 213 void BreakDebugger() {
214 DEBUG_BREAK(); 214 DEBUG_BREAK();
215 #if defined(NDEBUG) 215 #if defined(NDEBUG)
216 _exit(1); 216 _exit(1);
217 #endif 217 #endif
218 } 218 }
219 219
220 } // namespace debug 220 } // namespace debug
221 } // namespace base 221 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698