summaryrefslogtreecommitdiff
path: root/libhwc2.1/ExynosHWCDebug.cpp
diff options
context:
space:
mode:
authorWiwit Rifa'i <wiwitrifai@google.com>2022-11-08 16:20:06 +0800
committerWiwit Rifa'i <wiwitrifai@google.com>2022-12-09 20:12:07 +0800
commite29a42bc92f0e180145233b4fd58229b9d485b10 (patch)
treed4f166ca455658de1efa4eeeded8cabc9cef3212 /libhwc2.1/ExynosHWCDebug.cpp
parent81e2e51b1351d4df010dd7303adba3b0eb6d491d (diff)
libhwc2.1: always update log files with the latest info
Previously, the log files would not be updated anymore if the size is already more than 1 MB. But now, the log files should always be updated but the total size and the file count are still guaranteed to be limited. This will also change the log files to be per display (to avoid race condition for multi-display). Bug: 245511651 Test: make many errors and check HWC log files Test: vndservice call Exynos.HWCService 11 i32 0 i32 308 i32 1 Change-Id: I3f3f0ead7bb5b513d51388a13fcb67762031d93e
Diffstat (limited to 'libhwc2.1/ExynosHWCDebug.cpp')
-rw-r--r--libhwc2.1/ExynosHWCDebug.cpp77
1 files changed, 12 insertions, 65 deletions
diff --git a/libhwc2.1/ExynosHWCDebug.cpp b/libhwc2.1/ExynosHWCDebug.cpp
index bbf676c..dc42369 100644
--- a/libhwc2.1/ExynosHWCDebug.cpp
+++ b/libhwc2.1/ExynosHWCDebug.cpp
@@ -18,33 +18,13 @@
#include <sync/sync.h>
#include "exynos_sync.h"
-uint32_t mErrLogSize = 0;
-uint32_t mFenceLogSize = 0;
-
-int32_t saveErrorLog(const String8 &errString, ExynosDisplay *display)
-{
+int32_t saveErrorLog(const String8 &errString, ExynosDisplay *display) {
+ if (display == nullptr) return -1;
int32_t ret = NO_ERROR;
- if (mErrLogSize >= ERR_LOG_SIZE)
- return -1;
- FILE *pFile = NULL;
- char filePath[128];
- sprintf(filePath, "%s/hwc_error_log.txt", ERROR_LOG_PATH0);
- pFile = fopen(filePath, "a");
- if (pFile == NULL) {
- ALOGE("Fail to open file %s/hwc_error_log.txt, error: %s", ERROR_LOG_PATH0, strerror(errno));
- sprintf(filePath, "%s/hwc_error_log.txt", ERROR_LOG_PATH1);
- pFile = fopen(filePath, "a");
- }
- if (pFile == NULL) {
- ALOGE("Fail to open file %s/hwc_error_log.txt, error: %s", ERROR_LOG_PATH1, strerror(errno));
- return -errno;
- }
+ auto &fileWriter = display->mErrLogFileWriter;
- mErrLogSize = ftell(pFile);
- if (mErrLogSize >= ERR_LOG_SIZE) {
- if (pFile != NULL)
- fclose(pFile);
+ if (!fileWriter.chooseOpenedFile()) {
return -1;
}
@@ -52,47 +32,19 @@ int32_t saveErrorLog(const String8 &errString, ExynosDisplay *display)
struct timeval tv;
gettimeofday(&tv, NULL);
- if (display != NULL) {
- saveString.appendFormat("%s %s %" PRIu64 ": %s\n", getLocalTimeStr(tv).string(),
- display->mDisplayName.string(), display->mErrorFrameCount,
- errString.string());
- } else {
- saveString.appendFormat("%s : %s\n", getLocalTimeStr(tv).string(), errString.string());
- }
+ saveString.appendFormat("%s errFrameNumber %" PRIu64 ": %s\n", getLocalTimeStr(tv).string(),
+ display->mErrorFrameCount, errString.string());
- if (pFile != NULL) {
- fwrite(saveString.string(), 1, saveString.size(), pFile);
- mErrLogSize = (uint32_t)ftell(pFile);
- ret = mErrLogSize;
- fclose(pFile);
- }
+ fileWriter.write(saveString);
+ fileWriter.flush();
return ret;
}
int32_t saveFenceTrace(ExynosDisplay *display) {
int32_t ret = NO_ERROR;
+ auto &fileWriter = display->mFenceFileWriter;
- if (mFenceLogSize >= FENCE_ERR_LOG_SIZE)
- return -1;
-
- FILE *pFile = NULL;
- char filePath[128];
- sprintf(filePath, "%s/hwc_fence_state.txt", ERROR_LOG_PATH0);
- pFile = fopen(filePath, "a");
- if (pFile == NULL) {
- ALOGE("Fail to open file %s/hwc_fence_state.txt, error: %s", ERROR_LOG_PATH0, strerror(errno));
- sprintf(filePath, "%s/hwc_fence_state.txt", ERROR_LOG_PATH1);
- pFile = fopen(filePath, "a");
- }
- if (pFile == NULL) {
- ALOGE("Fail to open file %s, error: %s", ERROR_LOG_PATH1, strerror(errno));
- return -errno;
- }
-
- mFenceLogSize = ftell(pFile);
- if (mFenceLogSize >= FENCE_ERR_LOG_SIZE) {
- if (pFile != NULL)
- fclose(pFile);
+ if (!fileWriter.chooseOpenedFile()) {
return -1;
}
@@ -117,12 +69,7 @@ int32_t saveFenceTrace(ExynosDisplay *display) {
}
}
- if (pFile != NULL) {
- fwrite(saveString.string(), 1, saveString.size(), pFile);
- mFenceLogSize = (uint32_t)ftell(pFile);
- ret = mFenceLogSize;
- fclose(pFile);
- }
-
+ fileWriter.write(saveString);
+ fileWriter.flush();
return ret;
}