Fix races in trace_helper.cc

We had an unfortunate race when stopping tracing with the trace_helper
test code. This could lead to calling JNI methods with null or deleted
global references. We fix this by using a JVMTI Raw Monitor and
copying the global into a local ref. This allows us to safely disable
tracing at any time from any thread.

Test: ./test.py --host -j50
Bug: 69657830
Change-Id: I2f5daadddbde0cbd2f8453affb3871774837c47e
1 file changed