Merge "profiling: Do not install hook if Client init fails."
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 9a4902f..3c11c8b 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -30,6 +30,7 @@
results += input.canned_checks.CheckGNFormatted(input, output)
results += CheckIncludeGuards(input, output)
results += CheckAndroidBlueprint(input, output)
+ results += CheckBinaryDescriptors(input, output)
results += CheckMergedTraceConfigProto(input, output)
results += CheckWhitelist(input, output)
return results
@@ -85,7 +86,7 @@
tool = 'tools/gen_binary_descriptors'
file_filter = lambda x: input_api.FilterSourceFile(
x,
- white_list=('.*[.]h$', '.*[.]proto$', tool))
+ white_list=('protos/perfetto/.*[.]proto$', '.*[.]h', tool))
if not input_api.AffectedSourceFiles(file_filter):
return []
if subprocess.call([tool, '--check-only']):
diff --git a/src/base/android_task_runner.cc b/src/base/android_task_runner.cc
index 23697c8..f9673dd 100644
--- a/src/base/android_task_runner.cc
+++ b/src/base/android_task_runner.cc
@@ -55,7 +55,7 @@
void AndroidTaskRunner::Run() {
quit_ = false;
- while (true) {
+ for (;;) {
{
std::lock_guard<std::mutex> lock(lock_);
if (quit_)
diff --git a/src/base/unix_task_runner.cc b/src/base/unix_task_runner.cc
index da5c023..be59f9b 100644
--- a/src/base/unix_task_runner.cc
+++ b/src/base/unix_task_runner.cc
@@ -43,7 +43,7 @@
void UnixTaskRunner::Run() {
PERFETTO_DCHECK_THREAD(thread_checker_);
quit_ = false;
- while (true) {
+ for (;;) {
int poll_timeout_ms;
{
std::lock_guard<std::mutex> lock(lock_);
diff --git a/src/base/watchdog_unittest.cc b/src/base/watchdog_unittest.cc
index 6088733..866f19e 100644
--- a/src/base/watchdog_unittest.cc
+++ b/src/base/watchdog_unittest.cc
@@ -96,7 +96,7 @@
watchdog.SetCpuLimit(10, 25);
watchdog.Start();
volatile int x = 0;
- while (true) {
+ for (;;) {
x++;
}
},
diff --git a/src/perfetto_cmd/perfetto_config.descriptor.h b/src/perfetto_cmd/perfetto_config.descriptor.h
index 74bbfac..5f0361b 100644
--- a/src/perfetto_cmd/perfetto_config.descriptor.h
+++ b/src/perfetto_cmd/perfetto_config.descriptor.h
@@ -10,7 +10,7 @@
// This file was autogenerated by tools/gen_binary_descriptors. Do not edit.
// SHA1(tools/gen_binary_descriptors)
-// 39b24672017b75f5e5ac590c4dc03b2c41bf3eea
+// 2aabce73a7c0d2527e9cb33b9c3c05aeca7a9534
// SHA1(protos/perfetto/config/perfetto_config.proto)
// 91af0d676a39daa199e00b09a1b1e13670c0bea1
diff --git a/src/profiling/memory/bookkeeping.cc b/src/profiling/memory/bookkeeping.cc
index 8f78d25..b819222 100644
--- a/src/profiling/memory/bookkeeping.cc
+++ b/src/profiling/memory/bookkeeping.cc
@@ -192,6 +192,7 @@
WriteString(packet, str);
auto mapping = packet->add_mappings();
+ mapping->set_id(map.id());
mapping->set_offset(map->offset);
mapping->set_start(map->start);
mapping->set_end(map->end);
@@ -252,6 +253,7 @@
for (const pid_t pid : dump_rec.pids) {
ProfilePacket::ProcessHeapSamples* sample =
profile_packet->add_process_dumps();
+ sample->set_pid(static_cast<uint64_t>(pid));
auto it = bookkeeping_data_.find(pid);
if (it == bookkeeping_data_.end())
continue;
diff --git a/src/trace_processor/sqlite_utils.h b/src/trace_processor/sqlite_utils.h
index 0d3dc94..53d1e19 100644
--- a/src/trace_processor/sqlite_utils.h
+++ b/src/trace_processor/sqlite_utils.h
@@ -203,7 +203,7 @@
PERFETTO_DCHECK(sqlite3_column_count(*stmt) == 2);
std::vector<Table::Column> columns;
- while (true) {
+ for (;;) {
err = sqlite3_step(raw_stmt);
if (err == SQLITE_DONE)
break;
diff --git a/src/traced/probes/ftrace/cpu_reader.cc b/src/traced/probes/ftrace/cpu_reader.cc
index 5acb2a1..e607cf7 100644
--- a/src/traced/probes/ftrace/cpu_reader.cc
+++ b/src/traced/probes/ftrace/cpu_reader.cc
@@ -206,7 +206,7 @@
snprintf(thread_name, sizeof(thread_name), "traced_probes%zu", cpu);
pthread_setname_np(pthread_self(), thread_name);
- while (true) {
+ for (;;) {
// First do a blocking splice which sleeps until there is at least one
// page of data available and enough space to write it into the staging
// pipe.
@@ -238,7 +238,7 @@
// Then do as many non-blocking splices as we can. This moves any full
// pages from the trace pipe into the staging pipe as long as there is
// data in the former and space in the latter.
- while (true) {
+ for (;;) {
{
PERFETTO_METATRACE("splice_nonblocking", cpu);
splice_res = splice(trace_fd, nullptr, staging_write_fd, nullptr,
@@ -268,7 +268,7 @@
bool CpuReader::Drain(const std::set<FtraceDataSource*>& data_sources) {
PERFETTO_DCHECK_THREAD(thread_checker_);
- while (true) {
+ for (;;) {
uint8_t* buffer = GetBuffer();
long bytes =
PERFETTO_EINTR(read(*staging_read_fd_, buffer, base::kPageSize));
diff --git a/src/traced/probes/ftrace/ftrace_controller_unittest.cc b/src/traced/probes/ftrace/ftrace_controller_unittest.cc
index aa059f8..1f5d28e 100644
--- a/src/traced/probes/ftrace/ftrace_controller_unittest.cc
+++ b/src/traced/probes/ftrace/ftrace_controller_unittest.cc
@@ -215,7 +215,7 @@
}
void WaitForData(size_t cpu) {
- while (true) {
+ for (;;) {
{
std::unique_lock<std::mutex> lock(lock_);
if (cpus_to_drain_[cpu])
diff --git a/src/traced/probes/ftrace/ftrace_procfs.cc b/src/traced/probes/ftrace/ftrace_procfs.cc
index cb84dd7..105b678 100644
--- a/src/traced/probes/ftrace/ftrace_procfs.cc
+++ b/src/traced/probes/ftrace/ftrace_procfs.cc
@@ -185,7 +185,7 @@
size_t start = 0;
size_t end = 0;
- while (true) {
+ for (;;) {
end = s.find(' ', start);
if (end == std::string::npos)
end = s.size();
diff --git a/tools/gen_binary_descriptors b/tools/gen_binary_descriptors
index 513ef95..d608095 100755
--- a/tools/gen_binary_descriptors
+++ b/tools/gen_binary_descriptors
@@ -34,6 +34,7 @@
SCRIPT_PATH = 'tools/gen_binary_descriptors'
+
def hash_path(path):
hash = hashlib.sha1()
with open(os.path.join(ROOT_DIR, path)) as f:
@@ -41,8 +42,19 @@
return hash.hexdigest()
+def find_protoc():
+ for root, dirs, files in os.walk(ROOT_DIR):
+ if 'protoc' in files:
+ return os.path.join(root, 'protoc')
+ for name in ('src', 'buildtools'):
+ if name in dirs:
+ dirs.remove(name)
+ return None
+
+
def check(source, target):
- assert os.path.exists(os.path.join(ROOT_DIR, target))
+ assert os.path.exists(os.path.join(ROOT_DIR, target)), \
+ 'Output file {} does not exist and so cannot be checked'.format(target)
with open(target, 'rb') as f:
s = f.read()
@@ -52,7 +64,7 @@
for path, expected_sha1 in hashes:
actual_sha1 = hash_path(os.path.join(ROOT_DIR, path))
assert actual_sha1 == expected_sha1, \
- 'Hash for path {} did not match'.format(path)
+ 'In {} hash given for {} did not match'.format(target, path)
def generate(source, target, protoc_path):
@@ -123,13 +135,21 @@
parser.add_argument('--protoc')
args = parser.parse_args()
- for source, target in SOURCE_TARGET.iteritems():
- if args.check_only:
- check(source, target)
- else:
- protoc = args.protoc
- assert os.path.exists(protoc)
- generate(source, target, args.protoc)
+ try:
+ for source, target in SOURCE_TARGET.iteritems():
+ if args.check_only:
+ check(source, target)
+ else:
+ protoc = args.protoc or find_protoc()
+ assert protoc, 'protoc not found specific (--protoc PROTOC_PATH)'
+ assert os.path.exists(protoc), '{} does not exist'.format(protoc)
+ if protoc is not args.protoc:
+ print('Using protoc: {}'.format(protoc))
+ generate(source, target, protoc)
+ except AssertionError as e:
+ if not str(e):
+ raise
+ print('Error: {}'.format(e))
if __name__ == '__main__':
exit(main())
diff --git a/tools/pipestats.cc b/tools/pipestats.cc
index 15fbe27..6279efc 100644
--- a/tools/pipestats.cc
+++ b/tools/pipestats.cc
@@ -40,7 +40,7 @@
__attribute__((__noreturn__)) void ReadLoop(int fd) {
char buf[4096];
- while (true) {
+ for (;;) {
base::ignore_result(read(fd, &buf, sizeof(buf)));
}
}
@@ -67,7 +67,7 @@
// SPLICE_F_NONBLOCK flag passed to splice().
SetBlocking(*staging_write_fd, false);
- while (true) {
+ for (;;) {
ssize_t splice_res = splice(*trace_fd, nullptr, *staging_write_fd, nullptr,
base::kPageSize, SPLICE_F_MOVE);
if (splice_res > 0) {