SWDEV-369548 - Added getProcessId function in Os:: and change log functions to use that.

Change-Id: Ib64ee4d65a5212af7a4a95f80173b7ff8382340f
This commit is contained in:
Ioannis Assiouras
2022-12-02 17:22:04 +00:00
rodzic 8c582a02ef
commit 7631ba8b4d
5 zmienionych plików z 16 dodań i 4 usunięć
+3
Wyświetl plik
@@ -317,6 +317,9 @@ class Os : AllStatic {
//! Uninstall SIGFPE handler for CPU device
static void uninstallSigfpeHandler();
//! Return the current process id
static int getProcessId();
};
/*@}*/
+4
Wyświetl plik
@@ -919,6 +919,10 @@ bool Os::MemoryMapFileTruncated(const char* fname, const void** mmap_ptr, size_t
return true;
}
int Os::getProcessId() {
return ::getpid();
}
} // namespace amd
#endif // !defined(_WIN32) && !defined(__CYGWIN__)
+4
Wyświetl plik
@@ -941,6 +941,10 @@ bool Os::FindFileNameFromAddress(const void* image, std::string* fname_ptr, size
return false;
}
int Os::getProcessId() {
return ::_getpid();
}
} // namespace amd
#endif // _WIN32 || __CYGWIN__
+3 -3
Wyświetl plik
@@ -106,7 +106,7 @@ void log_printf(LogLevel level, const char* file, int line, const char* format,
va_end(ap);
uint64_t timeUs = Os::timeNanos() / 1000ULL;
fprintf(outFile, ":%d:%-25s:%-4d: %010lld us: %-5d: [tid:0x%s] %s\n", level, file, line,
timeUs/1ULL, getpid(), str_thrd_id.str().c_str(), message);
timeUs/1ULL, Os::getProcessId(), str_thrd_id.str().c_str(), message);
fflush(outFile);
}
@@ -123,10 +123,10 @@ void log_printf(LogLevel level, const char* file, int line, uint64_t* start,
uint64_t timeUs = Os::timeNanos() / 1000ULL;
if (start == 0 || *start == 0) {
fprintf(outFile, ":%d:%-25s:%-4d: %010lld us: %-5d: [tid:0x%s] %s\n", level, file, line,
timeUs/1ULL, getpid(), str_thrd_id.str().c_str(), message);
timeUs/1ULL, Os::getProcessId(), str_thrd_id.str().c_str(), message);
} else {
fprintf(outFile, ":%d:%-25s:%-4d: %010lld us: %-5d: [tid:0x%s] %s: duration: %lld us\n",
level, file, line, timeUs/1ULL, getpid(), str_thrd_id.str().c_str(), message,
level, file, line, timeUs/1ULL, Os::getProcessId(), str_thrd_id.str().c_str(), message,
(timeUs - *start)/1ULL);
}
fflush(outFile);
+2 -1
Wyświetl plik
@@ -20,6 +20,7 @@
#include "top.hpp"
#include "utils/flags.hpp"
#include "os/os.hpp"
#include <unordered_map>
#include <string>
@@ -156,7 +157,7 @@ bool Flag::init() {
if (!flagIsDefault(AMD_LOG_LEVEL)) {
if (!flagIsDefault(AMD_LOG_LEVEL_FILE)) {
std::string fileName = AMD_LOG_LEVEL_FILE;
fileName = fileName + "_" + std::to_string(getpid());
fileName = fileName + "_" + std::to_string(Os::getProcessId());
outFile = fopen(fileName.c_str(), "w");
}
}