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

Side by Side Diff: base/process_util_openbsd.cc

Issue 8368009: Replace most LOG statements with DLOG statements in base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/process_util_mac.mm ('k') | base/process_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/process_util.h" 5 #include "base/process_util.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 #include <dirent.h> 8 #include <dirent.h>
9 #include <dlfcn.h> 9 #include <dlfcn.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid(), 57 int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_UID, getuid(),
58 sizeof(struct kinfo_proc), 0 }; 58 sizeof(struct kinfo_proc), 0 };
59 59
60 bool done = false; 60 bool done = false;
61 int try_num = 1; 61 int try_num = 1;
62 const int max_tries = 10; 62 const int max_tries = 10;
63 63
64 do { 64 do {
65 size_t len = 0; 65 size_t len = 0;
66 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) { 66 if (sysctl(mib, arraysize(mib), NULL, &len, NULL, 0) < 0) {
67 LOG(ERROR) << "failed to get the size needed for the process list"; 67 DLOG(ERROR) << "failed to get the size needed for the process list";
68 kinfo_procs_.resize(0); 68 kinfo_procs_.resize(0);
69 done = true; 69 done = true;
70 } else { 70 } else {
71 size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc); 71 size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
72 // Leave some spare room for process table growth (more could show up 72 // Leave some spare room for process table growth (more could show up
73 // between when we check and now) 73 // between when we check and now)
74 num_of_kinfo_proc += 16; 74 num_of_kinfo_proc += 16;
75 kinfo_procs_.resize(num_of_kinfo_proc); 75 kinfo_procs_.resize(num_of_kinfo_proc);
76 len = num_of_kinfo_proc * sizeof(struct kinfo_proc); 76 len = num_of_kinfo_proc * sizeof(struct kinfo_proc);
77 if (sysctl(mib, arraysize(mib), &kinfo_procs_[0], &len, NULL, 0) < 0) { 77 if (sysctl(mib, arraysize(mib), &kinfo_procs_[0], &len, NULL, 0) < 0) {
78 // If we get a mem error, it just means we need a bigger buffer, so 78 // If we get a mem error, it just means we need a bigger buffer, so
79 // loop around again. Anything else is a real error and give up. 79 // loop around again. Anything else is a real error and give up.
80 if (errno != ENOMEM) { 80 if (errno != ENOMEM) {
81 LOG(ERROR) << "failed to get the process list"; 81 DLOG(ERROR) << "failed to get the process list";
82 kinfo_procs_.resize(0); 82 kinfo_procs_.resize(0);
83 done = true; 83 done = true;
84 } 84 }
85 } else { 85 } else {
86 // Got the list, just make sure we're sized exactly right 86 // Got the list, just make sure we're sized exactly right
87 size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc); 87 size_t num_of_kinfo_proc = len / sizeof(struct kinfo_proc);
88 kinfo_procs_.resize(num_of_kinfo_proc); 88 kinfo_procs_.resize(num_of_kinfo_proc);
89 done = true; 89 done = true;
90 } 90 }
91 } 91 }
92 } while (!done && (try_num++ < max_tries)); 92 } while (!done && (try_num++ < max_tries));
93 93
94 if (!done) { 94 if (!done) {
95 LOG(ERROR) << "failed to collect the process list in a few tries"; 95 DDLOG(ERROR) << "failed to collect the process list in a few tries";
96 kinfo_procs_.resize(0); 96 kinfo_procs_.resize(0);
97 } 97 }
98 } 98 }
99 99
100 ProcessIterator::~ProcessIterator() { 100 ProcessIterator::~ProcessIterator() {
101 } 101 }
102 102
103 bool ProcessIterator::CheckForNextProcess() { 103 bool ProcessIterator::CheckForNextProcess() {
104 std::string data; 104 std::string data;
105 for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++index_of_kinfo_proc_) { 105 for (; index_of_kinfo_proc_ < kinfo_procs_.size(); ++index_of_kinfo_proc_) {
(...skipping 24 matching lines...) Expand all
130 // |entry_.cmd_line_args_|. 130 // |entry_.cmd_line_args_|.
131 std::string delimiters; 131 std::string delimiters;
132 delimiters.push_back('\0'); 132 delimiters.push_back('\0');
133 Tokenize(data, delimiters, &entry_.cmd_line_args_); 133 Tokenize(data, delimiters, &entry_.cmd_line_args_);
134 134
135 // |data| starts with the full executable path followed by a null character. 135 // |data| starts with the full executable path followed by a null character.
136 // We search for the first instance of '\0' and extract everything before it 136 // We search for the first instance of '\0' and extract everything before it
137 // to populate |entry_.exe_file_|. 137 // to populate |entry_.exe_file_|.
138 size_t exec_name_end = data.find('\0'); 138 size_t exec_name_end = data.find('\0');
139 if (exec_name_end == std::string::npos) { 139 if (exec_name_end == std::string::npos) {
140 LOG(ERROR) << "command line data didn't match expected format"; 140 DLOG(ERROR) << "command line data didn't match expected format";
141 continue; 141 continue;
142 } 142 }
143 143
144 entry_.pid_ = kinfo.p_pid; 144 entry_.pid_ = kinfo.p_pid;
145 entry_.ppid_ = kinfo.p_ppid; 145 entry_.ppid_ = kinfo.p_ppid;
146 entry_.gid_ = kinfo.p__pgid; 146 entry_.gid_ = kinfo.p__pgid;
147 size_t last_slash = data.rfind('/', exec_name_end); 147 size_t last_slash = data.rfind('/', exec_name_end);
148 if (last_slash == std::string::npos) 148 if (last_slash == std::string::npos)
149 entry_.exe_file_.assign(data, 0, exec_name_end); 149 entry_.exe_file_.assign(data, 0, exec_name_end);
150 else 150 else
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize); 322 return mem_total - (mem_free*pagesize) - (mem_inactive*pagesize);
323 } 323 }
324 324
325 void EnableTerminationOnOutOfMemory() { 325 void EnableTerminationOnOutOfMemory() {
326 } 326 }
327 327
328 void EnableTerminationOnHeapCorruption() { 328 void EnableTerminationOnHeapCorruption() {
329 } 329 }
330 330
331 } // namespace base 331 } // namespace base
OLDNEW
« no previous file with comments | « base/process_util_mac.mm ('k') | base/process_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698