Skip to content

Commit 6239958

Browse files
yabincGerrit Code Review
authored andcommitted
Merge "Simpleperf: rewrite unsupported logging style."
2 parents 6b355fe + 42aa127 commit 6239958

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

simpleperf/event_fd.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,23 @@ std::unique_ptr<EventFd> EventFd::OpenEventFile(const perf_event_attr& attr, pid
4848
}
4949
int perf_event_fd = perf_event_open(&perf_attr, tid, cpu, -1, 0);
5050
if (perf_event_fd == -1) {
51-
(report_error ? PLOG(ERROR) : PLOG(DEBUG)) << "open perf_event_file (event " << event_name
52-
<< ", tid " << tid << ", cpu " << cpu << ") failed";
51+
if (report_error) {
52+
PLOG(ERROR) << "open perf_event_file (event " << event_name << ", tid " << tid << ", cpu "
53+
<< cpu << ") failed";
54+
} else {
55+
PLOG(DEBUG) << "open perf_event_file (event " << event_name << ", tid " << tid << ", cpu "
56+
<< cpu << ") failed";
57+
}
5358
return nullptr;
5459
}
5560
if (fcntl(perf_event_fd, F_SETFD, FD_CLOEXEC) == -1) {
56-
(report_error ? PLOG(ERROR) : PLOG(DEBUG)) << "fcntl(FD_CLOEXEC) for perf_event_file (event "
57-
<< event_name << ", tid " << tid << ", cpu " << cpu
58-
<< ") failed";
61+
if (report_error) {
62+
PLOG(ERROR) << "fcntl(FD_CLOEXEC) for perf_event_file (event " << event_name << ", tid "
63+
<< tid << ", cpu " << cpu << ") failed";
64+
} else {
65+
PLOG(DEBUG) << "fcntl(FD_CLOEXEC) for perf_event_file (event " << event_name << ", tid "
66+
<< tid << ", cpu " << cpu << ") failed";
67+
}
5968
return nullptr;
6069
}
6170
return std::unique_ptr<EventFd>(new EventFd(perf_event_fd, event_name, tid, cpu));

simpleperf/event_type.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
#include "event_fd.h"
2929
#include "utils.h"
3030

31-
#define EVENT_TYPE_TABLE_ENTRY(name, type, config) \
32-
{ name, type, config } \
33-
,
31+
#define EVENT_TYPE_TABLE_ENTRY(name, type, config) {name, type, config},
3432

3533
static const std::vector<EventType> static_event_type_array = {
3634
#include "event_type_table.h"

simpleperf/workload.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ static void ChildProcessFn(std::vector<std::string>& args, int start_signal_fd,
108108
TEMP_FAILURE_RETRY(write(exec_child_fd, &exec_child_failed, 1));
109109
close(exec_child_fd);
110110
errno = saved_errno;
111-
PLOG(FATAL) << "execvp(" << argv[0] << ") failed";
111+
PLOG(ERROR) << "child process failed to execvp(" << argv[0] << ")";
112112
} else {
113-
PLOG(FATAL) << "child process failed to receive start_signal, nread = " << nread;
113+
PLOG(ERROR) << "child process failed to receive start_signal, nread = " << nread;
114114
}
115115
}
116116

@@ -125,7 +125,11 @@ bool Workload::Start() {
125125
char exec_child_failed;
126126
ssize_t nread = TEMP_FAILURE_RETRY(read(exec_child_fd_, &exec_child_failed, 1));
127127
if (nread != 0) {
128-
((nread == -1) ? PLOG(ERROR) : LOG(ERROR)) << "exec child failed, nread = " << nread;
128+
if (nread == -1) {
129+
PLOG(ERROR) << "failed to receive error message from child process";
130+
} else {
131+
LOG(ERROR) << "received error message from child process";
132+
}
129133
return false;
130134
}
131135
work_state_ = Started;

0 commit comments

Comments
 (0)