diff options
author | ssid <ssid@google.com> | 2021-03-04 13:06:12 -0800 |
---|---|---|
committer | ssid <ssid@google.com> | 2021-03-04 13:06:12 -0800 |
commit | 9add2ec6ef6b0123a296fda40da025560a28deb4 (patch) | |
tree | 8cf512acff978b0c22d15c087b8c45cdf4184995 | |
parent | f79461a8155c38244cfdd5c2e6778789014515db (diff) | |
download | perfetto-9add2ec6ef6b0123a296fda40da025560a28deb4.tar.gz |
Parse source location interned argument
Bug: 181712926
Change-Id: I5b03b7436fc5cb7c27a6b8895116902b00d1ee0b
8 files changed, 71 insertions, 4 deletions
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto index dbb48b46d..3aea606f7 100644 --- a/protos/perfetto/trace/perfetto_trace.proto +++ b/protos/perfetto/trace/perfetto_trace.proto @@ -6784,8 +6784,6 @@ message TrackEvent { oneof source_location_field { // Non-interned field. SourceLocation source_location = 33; - // TODO(ssid): The interned source locations are not parsed by trace - // processor. // Interned field. uint64 source_location_iid = 34; } diff --git a/protos/perfetto/trace/track_event/track_event.proto b/protos/perfetto/trace/track_event/track_event.proto index 8fccaa132..9c2952fd9 100644 --- a/protos/perfetto/trace/track_event/track_event.proto +++ b/protos/perfetto/trace/track_event/track_event.proto @@ -250,8 +250,6 @@ message TrackEvent { oneof source_location_field { // Non-interned field. SourceLocation source_location = 33; - // TODO(ssid): The interned source locations are not parsed by trace - // processor. // Interned field. uint64 source_location_iid = 34; } diff --git a/src/trace_processor/export_json.cc b/src/trace_processor/export_json.cc index a0af5358d..63a481a7b 100644 --- a/src/trace_processor/export_json.cc +++ b/src/trace_processor/export_json.cc @@ -643,6 +643,14 @@ class JsonExporter { if (args["task"].empty()) args.removeMember("task"); } + if (args.isMember("source")) { + Json::Value source = args["source"]; + if (source.isObject() && source.isMember("function_name")) { + args["function_name"] = source["function_name"]; + args["file_name"] = source["file_name"]; + args.removeMember("source"); + } + } } } diff --git a/src/trace_processor/importers/proto/track_event_parser.cc b/src/trace_processor/importers/proto/track_event_parser.cc index 16f727749..20b86eaff 100644 --- a/src/trace_processor/importers/proto/track_event_parser.cc +++ b/src/trace_processor/importers/proto/track_event_parser.cc @@ -1012,6 +1012,10 @@ class TrackEventParser::EventImporter { log_errors(ParseDebugAnnotationArgs(*it, inserter)); } + if (event_.has_source_location_iid()) { + log_errors(AddSourceLocationArgs(event_.source_location_iid(), inserter)); + } + if (event_.has_task_execution()) { log_errors(ParseTaskExecutionArgs(event_.task_execution(), inserter)); } @@ -1186,6 +1190,33 @@ class TrackEventParser::EventImporter { return util::OkStatus(); } + util::Status AddSourceLocationArgs(uint64_t iid, BoundInserter* inserter) { + if (!iid) + return util::ErrStatus("SourceLocation with invalid iid"); + + auto* decoder = sequence_state_->LookupInternedMessage< + protos::pbzero::InternedData::kSourceLocationsFieldNumber, + protos::pbzero::SourceLocation>(iid); + if (!decoder) + return util::ErrStatus("SourceLocation with invalid iid"); + + StringId file_name_id = kNullStringId; + StringId function_name_id = kNullStringId; + uint32_t line_number = 0; + + file_name_id = storage_->InternString(decoder->file_name()); + function_name_id = storage_->InternString(decoder->function_name()); + line_number = decoder->line_number(); + + inserter->AddArg(parser_->source_location_file_name_key_id_, + Variadic::String(file_name_id)); + inserter->AddArg(parser_->source_location_function_name_key_id_, + Variadic::String(function_name_id)); + inserter->AddArg(parser_->source_location_line_number_key_id_, + Variadic::UnsignedInteger(line_number)); + return util::OkStatus(); + } + util::Status ParseLogMessage(ConstBytes blob, BoundInserter* inserter) { if (!utid_) return util::ErrStatus("LogMessage without thread association"); @@ -1281,6 +1312,12 @@ TrackEventParser::TrackEventParser(TraceProcessorContext* context, context->storage->InternString("task.posted_from.line_number")), log_message_body_key_id_( context->storage->InternString("track_event.log_message")), + source_location_function_name_key_id_( + context->storage->InternString("source.function_name")), + source_location_file_name_key_id_( + context->storage->InternString("source.file_name")), + source_location_line_number_key_id_( + context->storage->InternString("source.line_number")), raw_legacy_event_id_( context->storage->InternString("track_event.legacy_event")), legacy_event_passthrough_utid_id_( diff --git a/src/trace_processor/importers/proto/track_event_parser.h b/src/trace_processor/importers/proto/track_event_parser.h index b13cc625b..5165feac5 100644 --- a/src/trace_processor/importers/proto/track_event_parser.h +++ b/src/trace_processor/importers/proto/track_event_parser.h @@ -76,6 +76,9 @@ class TrackEventParser { const StringId task_function_name_args_key_id_; const StringId task_line_number_args_key_id_; const StringId log_message_body_key_id_; + const StringId source_location_function_name_key_id_; + const StringId source_location_file_name_key_id_; + const StringId source_location_line_number_key_id_; const StringId raw_legacy_event_id_; const StringId legacy_event_passthrough_utid_id_; const StringId legacy_event_category_key_id_; diff --git a/test/trace_processor/track_event/track_event_typed_args.textproto b/test/trace_processor/track_event/track_event_typed_args.textproto index 471f16a83..f248aea3d 100644 --- a/test/trace_processor/track_event/track_event_typed_args.textproto +++ b/test/trace_processor/track_event/track_event_typed_args.textproto @@ -136,3 +136,21 @@ packet { [perfetto.protos.ChromeTrackEvent.chrome_app_state]: APP_STATE_FOREGROUND } } +packet { + trusted_packet_sequence_id: 1 + timestamp: 7000 + track_event { + track_uuid: 1 + categories: "cat" + name: "name6" + type: 3 + source_location_iid: 1 + } + interned_data: { + source_locations: { + iid: 1 + file_name: "source.cc" + function_name: "SourceFunction" + } + } +} diff --git a/test/trace_processor/track_event/track_event_typed_args_args.out b/test/trace_processor/track_event/track_event_typed_args_args.out index 229d3cdbb..4e1697aa9 100644 --- a/test/trace_processor/track_event/track_event_typed_args_args.out +++ b/test/trace_processor/track_event/track_event_typed_args_args.out @@ -16,3 +16,7 @@ "nested_message_extension_for_testing.child_field_for_testing","nested_message_extension_for_testing.child_field_for_testing","[NULL]","nesting test" "string_extension_for_testing","string_extension_for_testing","[NULL]","an extension string!" "chrome_app_state","chrome_app_state","[NULL]","APP_STATE_FOREGROUND" +"source.file_name","source.file_name","[NULL]","source.cc" +"source.function_name","source.function_name","[NULL]","SourceFunction" +"source.line_number","source.line_number",0,"[NULL]" +"source_location_iid","source_location_iid",1,"[NULL]" diff --git a/test/trace_processor/track_event/track_event_typed_args_slices.out b/test/trace_processor/track_event/track_event_typed_args_slices.out index 85b697a94..1c1049768 100644 --- a/test/trace_processor/track_event/track_event_typed_args_slices.out +++ b/test/trace_processor/track_event/track_event_typed_args_slices.out @@ -4,3 +4,4 @@ "[NULL]","[NULL]","t1","[NULL]",3000,0,"cat","name3" "[NULL]","[NULL]","t1","[NULL]",4000,0,"cat","name4" "[NULL]","[NULL]","t1","[NULL]",6000,0,"cat","name5" +"[NULL]","[NULL]","t1","[NULL]",7000,0,"cat","name6" |