Include pid of ANRing process in perfetto traces

Bug: 271415918
Test: Tested locally
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b0a2424f995722f451466b60d6f870b14383b3c2)
Merged-In: I4d666b37fed5a5d0015a39d13695ef7a5046fd59
Change-Id: I4d666b37fed5a5d0015a39d13695ef7a5046fd59
This commit is contained in:
Ben Miles
2023-03-02 14:41:09 +00:00
committed by Cherrypicker Worker
parent 6f965bea4a
commit d0236469aa
3 changed files with 8 additions and 5 deletions

View File

@@ -880,7 +880,8 @@ public class Watchdog implements Dumpable {
CriticalEventLog.getInstance().logLinesForSystemServerTraceFile();
final UUID errorId = mTraceErrorLogger.generateErrorId();
if (mTraceErrorLogger.isAddErrorIdEnabled()) {
mTraceErrorLogger.addErrorIdToTrace("system_server", errorId);
mTraceErrorLogger.addProcessInfoAndErrorIdToTrace("system_server", Process.myPid(),
errorId);
mTraceErrorLogger.addSubjectToTrace(subject, errorId);
}

View File

@@ -348,7 +348,8 @@ class ProcessErrorStateRecord {
if (mService.mTraceErrorLogger != null
&& mService.mTraceErrorLogger.isAddErrorIdEnabled()) {
errorId = mService.mTraceErrorLogger.generateErrorId();
mService.mTraceErrorLogger.addErrorIdToTrace(mApp.processName, errorId);
mService.mTraceErrorLogger.addProcessInfoAndErrorIdToTrace(
mApp.processName, pid, errorId);
mService.mTraceErrorLogger.addSubjectToTrace(annotation, errorId);
} else {
errorId = null;

View File

@@ -45,12 +45,13 @@ public class TraceErrorLogger {
* can be uniquely identified. We also add the same id to the dropbox entry of the error, so
* that we can join the trace and the error server-side.
*
* @param processName The process name to include in the error id.
* @param processName The name of the ANRing process.
* @param pid The pid of the ANRing process.
* @param errorId The unique id with which to tag the trace.
*/
public void addErrorIdToTrace(String processName, UUID errorId) {
public void addProcessInfoAndErrorIdToTrace(String processName, int pid, UUID errorId) {
Trace.traceCounter(Trace.TRACE_TAG_ACTIVITY_MANAGER,
COUNTER_PREFIX + processName + "#" + errorId.toString(),
COUNTER_PREFIX + processName + " " + pid + "#" + errorId.toString(),
PLACEHOLDER_VALUE);
}