Fix lock level violations when dumping low overhead traces
There were two lock level violations in the code that dumps low overhead
traces
1. We should not wait for checkpoints to finish while holding the
trace_lock_. This CL fixes it by waiting for the checkpoints after
releasing the trace_lock_. Since we release trace_lock_ while waiting
we need additional synchronization to make sure trace_data_ isn't
deleted while checkpoints are still running. This is done using a
ConditionVariable and waiting on it if a trace dump is in progress
before deleting the trace_data_.
2. We should not enter a ScopedObjectAccess (that acquires mutator lock)
while holding the bottom level trace_data_lock_. We now take a
snapshot of the traced_methods and traced_threads when holding the
trace_data_lock_ and then dump thread and method information outside
the lock. Dumping methods requires mutator lock to get the
information about the method.
Bug: 352518093
Test: Manual testing with feature enabled and kDebugLocking enabled.
Change-Id: I42a61f4d43eb985a93bc7884c09f771a5fbcd8f2
2 files changed