diff --git a/protos/perfetto/trace_processor/trace_processor.proto b/protos/perfetto/trace_processor/trace_processor.proto index bfb2a1f697..86b49186c0 100644 --- a/protos/perfetto/trace_processor/trace_processor.proto +++ b/protos/perfetto/trace_processor/trace_processor.proto @@ -155,6 +155,8 @@ message TraceProcessorRpc { StatusResult status = 210; // For TPM_REGISTER_SQL_PACKAGE. RegisterSqlPackageResult register_sql_package_result = 211; + // For TPM_FINALIZE_TRACE_DATA. + FinalizeDataResult finalize_data_result = 212; } // Previously: RawQueryArgs for TPM_QUERY_RAW_DEPRECATED @@ -356,4 +358,8 @@ message RegisterSqlPackageArgs { message RegisterSqlPackageResult { optional string error = 1; -} \ No newline at end of file +} + +message FinalizeDataResult { + optional string error = 1; +} diff --git a/python/perfetto/trace_processor/trace_processor.descriptor b/python/perfetto/trace_processor/trace_processor.descriptor index 976fb9b245..40cec3567b 100644 Binary files a/python/perfetto/trace_processor/trace_processor.descriptor and b/python/perfetto/trace_processor/trace_processor.descriptor differ diff --git a/src/trace_processor/rpc/rpc.cc b/src/trace_processor/rpc/rpc.cc index 49feef3568..d26cdc1a7a 100644 --- a/src/trace_processor/rpc/rpc.cc +++ b/src/trace_processor/rpc/rpc.cc @@ -212,7 +212,11 @@ void Rpc::ParseRpcRequest(const uint8_t* data, size_t len) { } case RpcProto::TPM_FINALIZE_TRACE_DATA: { Response resp(tx_seq_id_++, req_type); - NotifyEndOfFile(); + auto* result = resp->set_finalize_data_result(); + base::Status res = NotifyEndOfFile(); + if (!res.ok()) { + result->set_error(res.message()); + } resp.Send(rpc_response_fn_); break; } diff --git a/ui/src/trace_processor/engine.ts b/ui/src/trace_processor/engine.ts index ccb8a036ce..58a3705bbe 100644 --- a/ui/src/trace_processor/engine.ts +++ b/ui/src/trace_processor/engine.ts @@ -208,7 +208,7 @@ export abstract class EngineBase implements Engine, Disposable { let isFinalResponse = true; switch (rpc.response) { - case TPM.TPM_APPEND_TRACE_DATA: + case TPM.TPM_APPEND_TRACE_DATA: { const appendResult = assertExists(rpc.appendResult); const pendingPromise = assertExists(this.pendingParses.shift()); if (exists(appendResult.error) && appendResult.error.length > 0) { @@ -217,9 +217,17 @@ export abstract class EngineBase implements Engine, Disposable { pendingPromise.resolve(); } break; - case TPM.TPM_FINALIZE_TRACE_DATA: - assertExists(this.pendingEOFs.shift()).resolve(); + } + case TPM.TPM_FINALIZE_TRACE_DATA: { + const finalizeResult = assertExists(rpc.finalizeDataResult); + const pendingPromise = assertExists(this.pendingEOFs.shift()); + if (exists(finalizeResult.error) && finalizeResult.error.length > 0) { + pendingPromise.reject(finalizeResult.error); + } else { + pendingPromise.resolve(); + } break; + } case TPM.TPM_RESET_TRACE_PROCESSOR: assertExists(this.pendingResetTraceProcessors.shift()).resolve(); break;