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

Side by Side Diff: base/debug_util_posix.cc

Issue 100225: POSIX: Add a macro for handling EINTR. (Closed)
Patch Set: ... Created 11 years, 7 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/directory_watcher_inotify.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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 "build/build_config.h" 5 #include "build/build_config.h"
6 #include "base/debug_util.h" 6 #include "base/debug_util.h"
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <execinfo.h> 9 #include <execinfo.h>
10 #include <fcntl.h> 10 #include <fcntl.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <sys/stat.h> 12 #include <sys/stat.h>
13 #include <sys/sysctl.h> 13 #include <sys/sysctl.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 #include <unistd.h> 15 #include <unistd.h>
16 16
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "base/eintr_wrappers.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/scoped_ptr.h" 20 #include "base/scoped_ptr.h"
20 #include "base/string_piece.h" 21 #include "base/string_piece.h"
21 22
22 // static 23 // static
23 bool DebugUtil::SpawnDebuggerOnProcess(unsigned /* process_id */) { 24 bool DebugUtil::SpawnDebuggerOnProcess(unsigned /* process_id */) {
24 NOTIMPLEMENTED(); 25 NOTIMPLEMENTED();
25 return false; 26 return false;
26 } 27 }
27 28
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 bool DebugUtil::BeingDebugged() { 79 bool DebugUtil::BeingDebugged() {
79 int status_fd = open("/proc/self/status", O_RDONLY); 80 int status_fd = open("/proc/self/status", O_RDONLY);
80 if (status_fd == -1) 81 if (status_fd == -1)
81 return false; 82 return false;
82 83
83 // We assume our line will be in the first 1024 characters and that we can 84 // We assume our line will be in the first 1024 characters and that we can
84 // read this much all at once. In practice this will generally be true. 85 // read this much all at once. In practice this will generally be true.
85 // This simplifies and speeds up things considerably. 86 // This simplifies and speeds up things considerably.
86 char buf[1024]; 87 char buf[1024];
87 88
88 ssize_t num_read = read(status_fd, buf, sizeof(buf)); 89 ssize_t num_read = HANDLE_EINTR(read(status_fd, buf, sizeof(buf)));
89 close(status_fd); 90 HANDLE_EINTR(close(status_fd));
90 91
91 if (num_read <= 0) 92 if (num_read <= 0)
92 return false; 93 return false;
93 94
94 StringPiece status(buf, num_read); 95 StringPiece status(buf, num_read);
95 StringPiece tracer("TracerPid:\t"); 96 StringPiece tracer("TracerPid:\t");
96 97
97 StringPiece::size_type pid_index = status.find(tracer); 98 StringPiece::size_type pid_index = status.find(tracer);
98 if (pid_index == StringPiece::npos) 99 if (pid_index == StringPiece::npos)
99 return false; 100 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 for (size_t i = 0; i < trace_.size(); ++i) { 145 for (size_t i = 0; i < trace_.size(); ++i) {
145 (*os) << "\t" << trace_[i] << "\n"; 146 (*os) << "\t" << trace_[i] << "\n";
146 } 147 }
147 } else { 148 } else {
148 (*os) << "Backtrace:\n"; 149 (*os) << "Backtrace:\n";
149 for (size_t i = 0; i < trace_.size(); ++i) { 150 for (size_t i = 0; i < trace_.size(); ++i) {
150 (*os) << "\t" << trace_symbols.get()[i] << "\n"; 151 (*os) << "\t" << trace_symbols.get()[i] << "\n";
151 } 152 }
152 } 153 }
153 } 154 }
OLDNEW
« no previous file with comments | « no previous file | base/directory_watcher_inotify.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698