SWDEV-369548 - Added getProcessId function in Os:: and change log functions to use that.
Change-Id: Ib64ee4d65a5212af7a4a95f80173b7ff8382340f
This commit is contained in:
@@ -317,6 +317,9 @@ class Os : AllStatic {
|
||||
|
||||
//! Uninstall SIGFPE handler for CPU device
|
||||
static void uninstallSigfpeHandler();
|
||||
|
||||
//! Return the current process id
|
||||
static int getProcessId();
|
||||
};
|
||||
|
||||
/*@}*/
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user