Call exit instead of _exit when compiled with clang coverage
A function is registered with atexit when compiling with clang coverage. https://cs.android.com/android/platform/superproject/+/main:external/compiler-rt/lib/profile/InstrProfilingFile.c;l=508;drc=c58a43648cd6121c51a2e795a28e2ef90d7813e6 This function dumps coverage when the process exits. However when calling System.exit from java this leads to a call to _exit(2) which doesn't run exit hooks. Instead when compiled with coverage call exit(3) to run the exit hooks. This behavior is the same as what the default "exit" option of ART is doing. https://cs.android.com/android/platform/superproject/+/master:art/libartbase/base/fast_exit.h;l=44;drc=bdf1737bd17132525bcfdc778663123b61e97fa3 Another way to fix this might be to call __llvm_profile_write_file before _exit(2). Test: run avatar and see if coverage increase Bug: 304849228 Change-Id: Iec40612526f34472320be5ba5980cd1eea361ebc
This commit is contained in:
parent
d3a0d02b7f
commit
8adb04718e
@ -1314,7 +1314,16 @@ void AndroidRuntime::exit(int code)
|
||||
ALOGI("VM exiting with result code %d.", code);
|
||||
onExit(code);
|
||||
}
|
||||
|
||||
#ifdef __ANDROID_CLANG_COVERAGE__
|
||||
// When compiled with coverage, a function is registered with atexit to call
|
||||
// `__llvm_profile_write_file` when the process exit.
|
||||
// For Clang code coverage to work, call exit instead of _exit to run hooks
|
||||
// registered with atexit.
|
||||
::exit(code);
|
||||
#else
|
||||
::_exit(code);
|
||||
#endif
|
||||
}
|
||||
|
||||
void AndroidRuntime::onVmCreated(JNIEnv* env)
|
||||
|
Loading…
x
Reference in New Issue
Block a user