aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrimiano Tucci <primiano@google.com>2021-06-23 11:33:01 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-06-23 11:33:01 +0000
commit868b1b728ce1955610f55106f0361741abda404a (patch)
tree4425444e256aab3eb5be269257de9ca7d77ea0c2
parent6065cab9db46736493747f414287007bb14bc92d (diff)
parentf69a7701253a1c934595a31c581465a1acb0af80 (diff)
downloadperfetto-868b1b728ce1955610f55106f0361741abda404a.tar.gz
Add traced & producer version into trace and --query am: f69a770125
Original change: https://googleplex-android-review.googlesource.com/c/platform/external/perfetto/+/15059763 Change-Id: I908b870c5dd780069c5f297f08a9e6193cf8af3b
-rw-r--r--include/perfetto/ext/tracing/core/tracing_service.h3
-rw-r--r--protos/perfetto/common/tracing_service_state.proto12
-rw-r--r--protos/perfetto/config/perfetto_config.proto12
-rw-r--r--protos/perfetto/ipc/producer_port.proto18
-rw-r--r--protos/perfetto/trace/perfetto_trace.proto18
-rw-r--r--protos/perfetto/trace/system_info.proto6
-rw-r--r--src/perfetto_cmd/perfetto_cmd.cc3
-rw-r--r--src/tracing/core/tracing_service_impl.cc14
-rw-r--r--src/tracing/core/tracing_service_impl.h5
-rw-r--r--src/tracing/ipc/producer/producer_ipc_client_impl.cc2
-rw-r--r--src/tracing/ipc/service/producer_ipc_service.cc3
11 files changed, 86 insertions, 10 deletions
diff --git a/include/perfetto/ext/tracing/core/tracing_service.h b/include/perfetto/ext/tracing/core/tracing_service.h
index db54dbb9d..9636cdf7e 100644
--- a/include/perfetto/ext/tracing/core/tracing_service.h
+++ b/include/perfetto/ext/tracing/core/tracing_service.h
@@ -326,7 +326,8 @@ class PERFETTO_EXPORT TracingService {
ProducerSMBScrapingMode smb_scraping_mode =
ProducerSMBScrapingMode::kDefault,
size_t shared_memory_page_size_hint_bytes = 0,
- std::unique_ptr<SharedMemory> shm = nullptr) = 0;
+ std::unique_ptr<SharedMemory> shm = nullptr,
+ const std::string& sdk_version = {}) = 0;
// Connects a Consumer instance and obtains a ConsumerEndpoint, which is
// essentially a 1:1 channel between one Consumer and the Service.
diff --git a/protos/perfetto/common/tracing_service_state.proto b/protos/perfetto/common/tracing_service_state.proto
index 119cea820..1ef4c56c1 100644
--- a/protos/perfetto/common/tracing_service_state.proto
+++ b/protos/perfetto/common/tracing_service_state.proto
@@ -34,6 +34,12 @@ message TracingServiceState {
// Unix uid of the remote process.
optional int32 uid = 3;
+
+ // The version of the client library used by the producer.
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string sdk_version = 4;
}
// Describes a data source registered by a producer. Data sources are listed
@@ -57,4 +63,10 @@ message TracingServiceState {
// Number of tracing sessions in the started state. Always <= num_sessions.
optional int32 num_sessions_started = 4;
+
+ // The version of traced (the same returned by `traced --version`).
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string tracing_service_version = 5;
}
diff --git a/protos/perfetto/config/perfetto_config.proto b/protos/perfetto/config/perfetto_config.proto
index 5b0f2b692..756c8a6c8 100644
--- a/protos/perfetto/config/perfetto_config.proto
+++ b/protos/perfetto/config/perfetto_config.proto
@@ -197,6 +197,12 @@ message TracingServiceState {
// Unix uid of the remote process.
optional int32 uid = 3;
+
+ // The version of the client library used by the producer.
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string sdk_version = 4;
}
// Describes a data source registered by a producer. Data sources are listed
@@ -220,6 +226,12 @@ message TracingServiceState {
// Number of tracing sessions in the started state. Always <= num_sessions.
optional int32 num_sessions_started = 4;
+
+ // The version of traced (the same returned by `traced --version`).
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string tracing_service_version = 5;
}
// End of protos/perfetto/common/tracing_service_state.proto
diff --git a/protos/perfetto/ipc/producer_port.proto b/protos/perfetto/ipc/producer_port.proto
index 1b193ebfc..50b90e7a2 100644
--- a/protos/perfetto/ipc/producer_port.proto
+++ b/protos/perfetto/ipc/producer_port.proto
@@ -152,6 +152,16 @@ message InitializeConnectionRequest {
// SetupTracing response. See TracingService::ConnectProducer() and
// |using_shmem_provided_by_producer| in InitializeConnectionResponse.
optional bool producer_provided_shmem = 6;
+
+ // ---------------------------------------------------
+ // All fields below have been introduced in Android S.
+ // ---------------------------------------------------
+
+ // The version of the client library used by the producer.
+ // This is a human readable string with and its format varies depending on
+ // the build system that is used to build the code and the repo (standalone
+ // vs AOSP). This is intended for human debugging only.
+ optional string sdk_version = 8;
}
message InitializeConnectionResponse {
@@ -262,9 +272,11 @@ message GetAsyncCommandResponse {
message StopDataSource { optional uint64 instance_id = 1; }
- // This message also transports the file descriptor for the shared memory
- // buffer (not a proto field).
- message SetupTracing { optional uint32 shared_buffer_page_size_kb = 1; }
+ // On Android/Linux/Mac this message also transports the file descriptor for
+ // the shared memory buffer (not a proto field).
+ message SetupTracing {
+ optional uint32 shared_buffer_page_size_kb = 1;
+ }
message Flush {
// The instance id (i.e. StartDataSource.new_instance_id) of the data
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index 402fae891..bbb16997a 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -197,6 +197,12 @@ message TracingServiceState {
// Unix uid of the remote process.
optional int32 uid = 3;
+
+ // The version of the client library used by the producer.
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string sdk_version = 4;
}
// Describes a data source registered by a producer. Data sources are listed
@@ -220,6 +226,12 @@ message TracingServiceState {
// Number of tracing sessions in the started state. Always <= num_sessions.
optional int32 num_sessions_started = 4;
+
+ // The version of traced (the same returned by `traced --version`).
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string tracing_service_version = 5;
}
// End of protos/perfetto/common/tracing_service_state.proto
@@ -8326,6 +8338,12 @@ message SystemInfo {
// Ticks per second - sysconf(_SC_CLK_TCK).
optional int64 hz = 3;
+
+ // The version of traced (the same returned by `traced --version`).
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string tracing_service_version = 4;
}
// End of protos/perfetto/trace/system_info.proto
diff --git a/protos/perfetto/trace/system_info.proto b/protos/perfetto/trace/system_info.proto
index 90a7a57b5..ddce4ca7a 100644
--- a/protos/perfetto/trace/system_info.proto
+++ b/protos/perfetto/trace/system_info.proto
@@ -31,4 +31,10 @@ message SystemInfo {
// Ticks per second - sysconf(_SC_CLK_TCK).
optional int64 hz = 3;
+
+ // The version of traced (the same returned by `traced --version`).
+ // This is a human readable string with and its format varies depending on
+ // the build system and the repo (standalone vs AOSP).
+ // This is intended for human debugging only.
+ optional string tracing_service_version = 4;
}
diff --git a/src/perfetto_cmd/perfetto_cmd.cc b/src/perfetto_cmd/perfetto_cmd.cc
index 449f1f570..67ea3ea24 100644
--- a/src/perfetto_cmd/perfetto_cmd.cc
+++ b/src/perfetto_cmd/perfetto_cmd.cc
@@ -1021,6 +1021,7 @@ void PerfettoCmd::PrintServiceState(bool success,
printf(" id: %d\n", producer.id());
printf(" name: \"%s\" \n", producer.name().c_str());
printf(" uid: %d \n", producer.uid());
+ printf(" sdk_version: \"%s\" \n", producer.sdk_version().c_str());
printf("}\n");
}
@@ -1032,6 +1033,8 @@ void PerfettoCmd::PrintServiceState(bool success,
printf(" }\n");
printf("}\n");
}
+ printf("tracing_service_version: \"%s\"\n",
+ svc_state.tracing_service_version().c_str());
printf("num_sessions: %d\n", svc_state.num_sessions());
printf("num_sessions_started: %d\n", svc_state.num_sessions_started());
}
diff --git a/src/tracing/core/tracing_service_impl.cc b/src/tracing/core/tracing_service_impl.cc
index 1764a0ba2..3a4c2a97b 100644
--- a/src/tracing/core/tracing_service_impl.cc
+++ b/src/tracing/core/tracing_service_impl.cc
@@ -58,6 +58,7 @@
#include "perfetto/ext/base/string_utils.h"
#include "perfetto/ext/base/temp_file.h"
#include "perfetto/ext/base/utils.h"
+#include "perfetto/ext/base/version.h"
#include "perfetto/ext/base/watchdog.h"
#include "perfetto/ext/tracing/core/basic_types.h"
#include "perfetto/ext/tracing/core/consumer.h"
@@ -338,7 +339,8 @@ TracingServiceImpl::ConnectProducer(Producer* producer,
bool in_process,
ProducerSMBScrapingMode smb_scraping_mode,
size_t shared_memory_page_size_hint_bytes,
- std::unique_ptr<SharedMemory> shm) {
+ std::unique_ptr<SharedMemory> shm,
+ const std::string& sdk_version) {
PERFETTO_DCHECK_THREAD(thread_checker_);
if (lockdown_mode_ && uid != base::GetCurrentUserId()) {
@@ -367,8 +369,8 @@ TracingServiceImpl::ConnectProducer(Producer* producer,
}
std::unique_ptr<ProducerEndpointImpl> endpoint(new ProducerEndpointImpl(
- id, uid, this, task_runner_, producer, producer_name, in_process,
- smb_scraping_enabled));
+ id, uid, this, task_runner_, producer, producer_name, sdk_version,
+ in_process, smb_scraping_enabled));
auto it_and_inserted = producers_.emplace(id, endpoint.get());
PERFETTO_DCHECK(it_and_inserted.second);
endpoint->shmem_size_hint_bytes_ = shared_memory_size_hint_bytes;
@@ -3047,7 +3049,7 @@ void TracingServiceImpl::MaybeEmitSystemInfo(
tracing_session->did_emit_system_info = true;
protozero::HeapBuffered<protos::pbzero::TracePacket> packet;
auto* info = packet->set_system_info();
- base::ignore_result(info); // For PERFETTO_OS_WIN.
+ info->set_tracing_service_version(base::GetVersionString());
#if !PERFETTO_BUILDFLAG(PERFETTO_OS_WIN) && \
!PERFETTO_BUILDFLAG(PERFETTO_OS_NACL)
struct utsname uname_info;
@@ -3493,6 +3495,7 @@ void TracingServiceImpl::ConsumerEndpointImpl::QueryServiceState(
TracingServiceState svc_state;
const auto& sessions = service_->tracing_sessions_;
+ svc_state.set_tracing_service_version(base::GetVersionString());
svc_state.set_num_sessions(static_cast<int>(sessions.size()));
int num_started = 0;
@@ -3504,6 +3507,7 @@ void TracingServiceImpl::ConsumerEndpointImpl::QueryServiceState(
auto* producer = svc_state.add_producers();
producer->set_id(static_cast<int>(kv.first));
producer->set_name(kv.second->name_);
+ producer->set_sdk_version(kv.second->sdk_version_);
producer->set_uid(static_cast<int32_t>(producer->uid()));
}
@@ -3561,6 +3565,7 @@ TracingServiceImpl::ProducerEndpointImpl::ProducerEndpointImpl(
base::TaskRunner* task_runner,
Producer* producer,
const std::string& producer_name,
+ const std::string& sdk_version,
bool in_process,
bool smb_scraping_enabled)
: id_(id),
@@ -3569,6 +3574,7 @@ TracingServiceImpl::ProducerEndpointImpl::ProducerEndpointImpl(
task_runner_(task_runner),
producer_(producer),
name_(producer_name),
+ sdk_version_(sdk_version),
in_process_(in_process),
smb_scraping_enabled_(smb_scraping_enabled),
weak_ptr_factory_(this) {}
diff --git a/src/tracing/core/tracing_service_impl.h b/src/tracing/core/tracing_service_impl.h
index 27b172cec..401aaa1fe 100644
--- a/src/tracing/core/tracing_service_impl.h
+++ b/src/tracing/core/tracing_service_impl.h
@@ -87,6 +87,7 @@ class TracingServiceImpl : public TracingService {
base::TaskRunner*,
Producer*,
const std::string& producer_name,
+ const std::string& sdk_version,
bool in_process,
bool smb_scraping_enabled);
~ProducerEndpointImpl() override;
@@ -154,6 +155,7 @@ class TracingServiceImpl : public TracingService {
size_t shmem_page_size_hint_bytes_ = 0;
bool is_shmem_provided_by_producer_ = false;
const std::string name_;
+ std::string sdk_version_;
bool in_process_;
bool smb_scraping_enabled_;
@@ -291,7 +293,8 @@ class TracingServiceImpl : public TracingService {
ProducerSMBScrapingMode smb_scraping_mode =
ProducerSMBScrapingMode::kDefault,
size_t shared_memory_page_size_hint_bytes = 0,
- std::unique_ptr<SharedMemory> shm = nullptr) override;
+ std::unique_ptr<SharedMemory> shm = nullptr,
+ const std::string& sdk_version = {}) override;
std::unique_ptr<TracingService::ConsumerEndpoint> ConnectConsumer(
Consumer*,
diff --git a/src/tracing/ipc/producer/producer_ipc_client_impl.cc b/src/tracing/ipc/producer/producer_ipc_client_impl.cc
index 64b10232b..98072cdc0 100644
--- a/src/tracing/ipc/producer/producer_ipc_client_impl.cc
+++ b/src/tracing/ipc/producer/producer_ipc_client_impl.cc
@@ -21,6 +21,7 @@
#include "perfetto/base/logging.h"
#include "perfetto/base/task_runner.h"
+#include "perfetto/ext/base/version.h"
#include "perfetto/ext/ipc/client.h"
#include "perfetto/ext/tracing/core/commit_data_request.h"
#include "perfetto/ext/tracing/core/producer.h"
@@ -169,6 +170,7 @@ void ProducerIPCClientImpl::OnConnect() {
req.set_build_flags(
protos::gen::InitializeConnectionRequest::BUILD_FLAGS_DCHECKS_OFF);
#endif
+ req.set_sdk_version(base::GetVersionString());
producer_port_.InitializeConnection(req, std::move(on_init), shm_fd);
// Create the back channel to receive commands from the Service.
diff --git a/src/tracing/ipc/service/producer_ipc_service.cc b/src/tracing/ipc/service/producer_ipc_service.cc
index cfa79b14b..76ae2e848 100644
--- a/src/tracing/ipc/service/producer_ipc_service.cc
+++ b/src/tracing/ipc/service/producer_ipc_service.cc
@@ -114,7 +114,8 @@ void ProducerIPCService::InitializeConnection(
producer.get(), client_info.uid(), req.producer_name(),
req.shared_memory_size_hint_bytes(),
/*in_process=*/false, smb_scraping_mode,
- req.shared_memory_page_size_hint_bytes(), std::move(shmem));
+ req.shared_memory_page_size_hint_bytes(), std::move(shmem),
+ req.sdk_version());
// Could happen if the service has too many producers connected.
if (!producer->service_endpoint) {