#include "os_thread.hpp"
#include "os_string.hpp"
#include "trace_file.hpp"
-#include "trace_writer.hpp"
+#include "trace_writer_local.hpp"
#include "trace_format.hpp"
#endif
process.trimDirectory();
- os::String prefix = os::getCurrentDir();
+#ifdef ANDROID
+ os::String prefix = "/data";
+#else
+ os::String prefix = os::getCurrentDir();
+#endif
prefix.join(process);
for (;;) {
static os::thread_specific_ptr<unsigned> thread_id_specific_ptr;
unsigned LocalWriter::beginEnter(const FunctionSig *sig) {
- os::acquireMutex();
+ mutex.lock();
++acquired;
if (!m_file->isOpened()) {
void LocalWriter::endEnter(void) {
Writer::endEnter();
--acquired;
- os::releaseMutex();
+ mutex.unlock();
}
void LocalWriter::beginLeave(unsigned call) {
- os::acquireMutex();
+ mutex.lock();
++acquired;
Writer::beginLeave(call);
}
void LocalWriter::endLeave(void) {
Writer::endLeave();
--acquired;
- os::releaseMutex();
+ mutex.unlock();
}
void LocalWriter::flush(void) {
/*
* Do nothing if the mutex is already acquired (e.g., if a segfault happen
- * while writing the file) to prevent dead-lock.
+ * while writing the file) as state could be inconsistent, therefore yield
+ * inconsistent trace files and/or repeated segfaults till infinity.
*/
- os::acquireMutex();
+ mutex.lock();
if (acquired) {
os::log("apitrace: ignoring exception while tracing\n");
} else {
}
--acquired;
}
- os::releaseMutex();
+ mutex.unlock();
}