mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2025-02-25 21:30:49 +00:00
commit
1524a8dc50
@ -128,7 +128,7 @@ inline void StringReplace(std::string& str, const std::string& oldStr, const std
|
||||
}
|
||||
}
|
||||
|
||||
// let compiler check format string and variable arugments
|
||||
// let compiler check format string and variable arguments
|
||||
static inline std::string StringFormat(const char* fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
|
||||
static inline std::string StringFormat(const char* fmt, ...)
|
||||
|
@ -284,7 +284,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
if (configFile.empty()) { // normal case
|
||||
printf("FAIL\nconfig file argument must sepcified!");
|
||||
printf("FAIL\nconfig file argument must specified!");
|
||||
return 1;
|
||||
}
|
||||
// do capture work
|
||||
|
@ -154,7 +154,7 @@ public:
|
||||
// 根据构建的config写文件
|
||||
FILE* writeFp = fopen(configFile.c_str(), "w");
|
||||
if (writeFp == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateConfigFile: fopen() error = %s", buf);
|
||||
@ -163,26 +163,32 @@ public:
|
||||
|
||||
size_t len = fwrite(const_cast<char*>(configStr.c_str()), 1, configStr.length(), writeFp);
|
||||
if (len < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateConfigFile: fwrite() error = %s", buf);
|
||||
if (fclose(writeFp) != 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fclose() error");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = fflush(writeFp);
|
||||
if (ret == EOF) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateConfigFile: fflush() error = %s", buf);
|
||||
if (fclose(writeFp) != 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fclose() error");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fsync(fileno(writeFp));
|
||||
ret = fclose(writeFp);
|
||||
if (ret == 0) {
|
||||
const int bufSize = 1024;
|
||||
if (ret != 0) {
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateConfigFile: fclose() error = %s", buf);
|
||||
|
@ -40,7 +40,7 @@ int InitShareMemory1()
|
||||
int check = ftruncate(fd, SMB1_SIZE);
|
||||
if (check < 0) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock ftruncate ERR : %s", buf);
|
||||
@ -50,7 +50,7 @@ int InitShareMemory1()
|
||||
g_smbAddr1 = mmap(nullptr, SMB1_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (g_smbAddr1 == static_cast<void*>(MAP_FAILED)) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock g_smbAddr1 mmap ERR : %s", buf);
|
||||
@ -77,7 +77,7 @@ int InitShareMemory2()
|
||||
int check = ftruncate(fd, SMB2_SIZE);
|
||||
if (check < 0) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock ftruncate ERR : %s", buf);
|
||||
@ -87,7 +87,7 @@ int InitShareMemory2()
|
||||
g_smbAddr2 = mmap(nullptr, SMB2_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (g_smbAddr2 == static_cast<void*>(MAP_FAILED)) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock g_smbAddr2 mmap ERR : %s", buf);
|
||||
|
@ -94,7 +94,7 @@ bool BeginTrace()
|
||||
}
|
||||
// real-time: time is set 0.
|
||||
if (g_bytraceInfo->time == 0) {
|
||||
// if time is not set 1s(must >= 1), bytrace tool will use 5s by dafault.
|
||||
// if time is not set 1s(must >= 1), bytrace tool will use 5s by default.
|
||||
beginCmd += " -t 1 ";
|
||||
beginCmd += " --trace_begin ";
|
||||
} else {
|
||||
@ -142,7 +142,7 @@ int BytracePluginSessionStart(const uint8_t* configData, const uint32_t configSi
|
||||
int BytracePluginSessionStop()
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(g_taskMutex);
|
||||
// real-time type nead finish trace.
|
||||
// real-time type need finish trace.
|
||||
if (g_bytraceInfo->time == 0) {
|
||||
int res = StopTrace();
|
||||
CHECK_TRUE(res, 0, "BytracePluginSessionStop, bytrace finish FAILED!");
|
||||
|
@ -131,14 +131,14 @@ int32_t CpuDataPlugin::ReadFile(std::string& fileName)
|
||||
char realPath[PATH_MAX + 1] = {0};
|
||||
|
||||
if (snprintf_s(filePath, sizeof(filePath), sizeof(filePath) - 1, "%s", fileName.c_str()) < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "snprintf_s(%s) error, errno(%d:%s)", fileName.c_str(), errno, buf);
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (realpath(filePath, realPath) == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "realpath(%s) failed, errno(%d:%s)", fileName.c_str(), errno, buf);
|
||||
@ -147,7 +147,7 @@ int32_t CpuDataPlugin::ReadFile(std::string& fileName)
|
||||
|
||||
fd = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to open(%s), errno(%d:%s)", __func__, realPath, errno, buf);
|
||||
|
@ -82,7 +82,7 @@ int main(int agrc, char* agrv[])
|
||||
CpuConfig protoConfig;
|
||||
void* handle = dlopen(SO_PATH.c_str(), RTLD_LAZY);
|
||||
if (handle == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "test:dlopen err, errno(%d:%s)", errno, buf);
|
||||
|
@ -55,7 +55,7 @@ std::string FileUtils::ReadFile(const std::string& path)
|
||||
}
|
||||
int fd = open(realPath, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_WARN(LOG_CORE, "open file %s FAILED: %s!", path.c_str(), buf);
|
||||
|
@ -36,7 +36,10 @@ protected:
|
||||
{
|
||||
size_t offset = buffer_.size();
|
||||
buffer_.resize(buffer_.size() + sizeof(value));
|
||||
memcpy_s(&buffer_[offset], buffer_.capacity() - offset, &value, sizeof(value));
|
||||
if (memcpy_s(&buffer_[offset], buffer_.capacity() - offset, &value, sizeof(value))) {
|
||||
EXPECT_TRUE(false);
|
||||
return;
|
||||
}
|
||||
FieldFormat format = {};
|
||||
format.offset = offset;
|
||||
format.size = sizeof(value);
|
||||
@ -49,7 +52,10 @@ protected:
|
||||
{
|
||||
size_t offset = buffer_.size();
|
||||
buffer_.resize(buffer_.size() + str.size());
|
||||
memcpy_s(&buffer_[offset], buffer_.capacity() - offset, &str[0], str.size());
|
||||
if (memcpy_s(&buffer_[offset], buffer_.capacity() - offset, &str[0], str.size())) {
|
||||
EXPECT_TRUE(false);
|
||||
return;
|
||||
}
|
||||
FieldFormat format = {};
|
||||
format.offset = offset;
|
||||
format.size = str.size();
|
||||
|
@ -319,7 +319,7 @@ bool HilogPlugin::SetHilogLineDetails(const char* data, HilogLine* info)
|
||||
end = pTmp;
|
||||
}
|
||||
int index = 1;
|
||||
while (end != NULL && *pTmp != ':') { // 结束符 ':'
|
||||
while (end != nullptr && *pTmp != ':') { // 结束符 ':'
|
||||
if (*pTmp == '\0' || *pTmp == '\n') {
|
||||
return false;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ uint64_t GetSec(HilogPlugin& plugin, const char* data)
|
||||
{
|
||||
time_t nSeconds = time(nullptr);
|
||||
if (nSeconds == 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "GetSec: get time failed!, errno(%d:%s)", errno, buf);
|
||||
@ -134,7 +134,7 @@ uint64_t GetSec(HilogPlugin& plugin, const char* data)
|
||||
|
||||
struct tm* pTM = localtime(&nSeconds);
|
||||
if (pTM == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "GetSec: get localtime failed!, errno(%d:%s)", errno, buf);
|
||||
|
@ -92,7 +92,7 @@ int MemoryDataPlugin::InitMemVmemFd()
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (realpath(fileName, realPath) == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:realpath failed, errno(%d:%s)", __func__, errno, buf);
|
||||
@ -100,7 +100,7 @@ int MemoryDataPlugin::InitMemVmemFd()
|
||||
}
|
||||
meminfoFd_ = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (meminfoFd_ == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:open failed, fileName, errno(%d:%s)", __func__, errno, buf);
|
||||
@ -116,7 +116,7 @@ int MemoryDataPlugin::InitMemVmemFd()
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (realpath(fileName, realPath) == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:realpath failed, errno(%d:%s)", __func__, errno, buf);
|
||||
@ -124,7 +124,7 @@ int MemoryDataPlugin::InitMemVmemFd()
|
||||
}
|
||||
vmstatFd_ = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (vmstatFd_ == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to open(/proc/vmstat), errno(%d:%s)", __func__, errno, buf);
|
||||
@ -328,7 +328,10 @@ bool MemoryDataPlugin::GetMemInfoByMemoryService(uint32_t pid, ProcessMemoryInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
fread(buffer.get(), 1, BUF_MAX_LEN, fp.get());
|
||||
size_t ret = fread(buffer.get(), 1, BUF_MAX_LEN, fp.get());
|
||||
if (ret == 0) {
|
||||
HILOG_ERROR(LOG_CORE, "%s:fread failed", __func__);
|
||||
}
|
||||
buffer.get()[BUF_MAX_LEN - 1] = '\0';
|
||||
|
||||
return ParseMemInfo(reinterpret_cast<char*>(buffer.get()), memoryInfo);
|
||||
@ -425,7 +428,7 @@ int32_t MemoryDataPlugin::ReadFile(int fd)
|
||||
}
|
||||
int readsize = pread(fd, buffer_.get(), READ_BUFFER_SIZE - 1, 0);
|
||||
if (readsize <= 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to read(%d), errno(%d:%s)", __func__, fd, errno, buf);
|
||||
@ -448,14 +451,14 @@ std::vector<int> MemoryDataPlugin::OpenProcPidFiles(int32_t pid)
|
||||
HILOG_ERROR(LOG_CORE, "%s:snprintf_s error", __func__);
|
||||
}
|
||||
if (realpath(fileName, realPath) == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:realpath failed, errno(%d:%s)", __func__, errno, buf);
|
||||
}
|
||||
int fd = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to open(%s), errno(%d:%s)", __func__, fileName, errno, buf);
|
||||
@ -471,7 +474,7 @@ DIR* MemoryDataPlugin::OpenDestDir(const char* dirPath)
|
||||
|
||||
destDir = opendir(dirPath);
|
||||
if (destDir == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to opendir(%s), errno(%d:%s)", __func__, dirPath, errno, buf);
|
||||
@ -508,7 +511,7 @@ int32_t MemoryDataPlugin::ReadProcPidFile(int32_t pid, const char* pFileName)
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (realpath(fileName, realPath) == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:realpath failed, errno(%d:%s)", __func__, errno, buf);
|
||||
@ -516,7 +519,7 @@ int32_t MemoryDataPlugin::ReadProcPidFile(int32_t pid, const char* pFileName)
|
||||
}
|
||||
fd = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_INFO(LOG_CORE, "%s:failed to open(%s), errno(%d:%s)", __func__, fileName, errno, buf);
|
||||
@ -532,7 +535,7 @@ int32_t MemoryDataPlugin::ReadProcPidFile(int32_t pid, const char* pFileName)
|
||||
bytesRead = read(fd, buffer_.get(), READ_BUFFER_SIZE - 1);
|
||||
if (bytesRead < 0) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_INFO(LOG_CORE, "%s:failed to read(%s), errno(%d:%s)", __func__, fileName, errno, buf);
|
||||
|
@ -40,7 +40,7 @@ int main(int agrc, char* agrv[])
|
||||
}
|
||||
buf = (char *)malloc(size * MB_PER_BYTE);
|
||||
if (buf == nullptr) {
|
||||
const int bufferSize = 1024;
|
||||
const int bufferSize = 256;
|
||||
char buffer[bufferSize] = { 0 };
|
||||
strerror_r(errno, buffer, bufferSize);
|
||||
HILOG_ERROR(LOG_CORE, "malloc %zu fail, err(%s:%d)", size, buffer, errno);
|
||||
|
@ -235,7 +235,7 @@ bool DebugLogger::OpenLog()
|
||||
file_ = fopen(logPath_.c_str(), "w");
|
||||
}
|
||||
if (file_ == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
fprintf(stdout, "unable save log file to '%s' because '%d:%s'\n", logPath_.c_str(), errno, buf);
|
||||
|
@ -462,7 +462,7 @@ private:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HLOGD("elf file open failed with %s by %s", loadElfPath.c_str(), buf);
|
||||
|
@ -507,14 +507,14 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, size_t offset
|
||||
HLOGV("fd is %d", fd);
|
||||
|
||||
HANDLE FileMappingHandle = ::CreateFileMappingW(FileHandle, 0, PAGE_READONLY, 0, 0, 0);
|
||||
if (FileMappingHandle == NULL) {
|
||||
if (FileMappingHandle == nullptr) {
|
||||
HLOGE("CreateFileMappingW %zu Failed with %ld:%s", length, GetLastError(),
|
||||
GetLastErrorString().c_str());
|
||||
return MMAP_FAILED;
|
||||
}
|
||||
|
||||
void *mapAddr = ::MapViewOfFile(FileMappingHandle, FILE_MAP_READ, 0, 0, 0);
|
||||
if (mapAddr == NULL) {
|
||||
if (mapAddr == nullptr) {
|
||||
HLOGE("MapViewOfFile %zu Failed with %ld:%s", length, GetLastError(),
|
||||
GetLastErrorString().c_str());
|
||||
return MMAP_FAILED;
|
||||
|
@ -20,8 +20,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define INIT_LINE_SIZE 1000
|
||||
#define INC_LINE_SIZE 100
|
||||
constexpr int INIT_LINE_SIZE = 1000;
|
||||
constexpr int INC_LINE_SIZE = 100;
|
||||
|
||||
void GetRuntimeStackEnd(const char* stackptr, char** end);
|
||||
|
||||
|
@ -148,6 +148,9 @@ static void GetMainThreadRuntimeStackRange(char** start, char** end)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fclose(fp) != 0) {
|
||||
printf("fclose failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
static bool IfContained(const char* start, const char* end, const char* ptr)
|
||||
|
@ -21,16 +21,16 @@
|
||||
#include <time.h>
|
||||
#pragma clang optimize off
|
||||
|
||||
#define DEFAULT_THREAD_NUM 1
|
||||
#define DEFAULT_MALLOC_SIZE 100
|
||||
#define DEFAULT_REALLOC_SIZE 100
|
||||
#define SLEEP_TIME_SEC 1
|
||||
#define TEST_BRANCH_NUM 3
|
||||
#define ARG_CASE_NUM_THREADNUM 3
|
||||
#define ARG_CASE_MALLOCSIZE 2
|
||||
#define ARG_THREADNUM 2
|
||||
#define STATIC_DEPTH 5
|
||||
#define DATA_SIZE 50
|
||||
const int DEFAULT_THREAD_NUM = 1;
|
||||
const int DEFAULT_MALLOC_SIZE = 100;
|
||||
const int DEFAULT_REALLOC_SIZE = 100;
|
||||
const int SLEEP_TIME_SEC = 1;
|
||||
const int TEST_BRANCH_NUM = 3;
|
||||
const int ARG_CASE_NUM_THREADNUM = 3;
|
||||
const int ARG_CASE_MALLOCSIZE = 2;
|
||||
const int ARG_THREADNUM = 2;
|
||||
const int STATIC_DEPTH = 5;
|
||||
const int DATA_SIZE = 50;
|
||||
|
||||
typedef struct {
|
||||
int data[DATA_SIZE];
|
||||
|
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
||||
++idx;
|
||||
out_fp = fopen(argv[idx], "w");
|
||||
if (out_fp == nullptr) {
|
||||
printf("File '%s' can't be opened.\n", argv[argc]);
|
||||
printf("File '%s' can't be opened.\n", argv[idx]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -197,6 +197,9 @@ int main(int argc, char *argv[])
|
||||
long long total_times = times.load(std::memory_order_relaxed);
|
||||
PRINTF_DATA(out_fp, "The total times(malloc/free): %lld\n", total_times);
|
||||
}
|
||||
if (fclose(out_fp) != 0) {
|
||||
printf("fclose failed.\n");
|
||||
}
|
||||
free(thr_array);
|
||||
printf("Exit\n");
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
char filePath[PATH_MAX + 1] = {0};
|
||||
|
||||
if (snprintf_s(filePath, sizeof(filePath), sizeof(filePath) - 1, "%s", file.c_str()) < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "snprintf_s(%s) error, errno(%d:%s)", file.c_str(), errno, buf);
|
||||
@ -104,7 +104,7 @@ public:
|
||||
|
||||
char* realPath = realpath(filePath, nullptr);
|
||||
if (realPath == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "realpath(%s) failed, errno(%d:%s)", file.c_str(), errno, buf);
|
||||
@ -113,7 +113,7 @@ public:
|
||||
|
||||
fd = open(realPath, O_RDONLY | O_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:failed to open(%s), errno(%d:%s)", __func__, realPath, errno, buf);
|
||||
@ -161,7 +161,7 @@ public:
|
||||
{
|
||||
char *p = DepthMalloc(depth);
|
||||
if (!p) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "ApplyForMalloc: malloc failure, errno(%d:%s)", errno, buf);
|
||||
@ -198,7 +198,7 @@ public:
|
||||
int callocSize = DEFAULT_CALLOC_SIZE / sizeof(char);
|
||||
char *p = DepthCalloc(depth, callocSize);
|
||||
if (!p) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "ApplyForCalloc: calloc failure, errno(%d:%s)", errno, buf);
|
||||
@ -235,7 +235,7 @@ public:
|
||||
int reallocSize = DEFAULT_REALLOC_SIZE;
|
||||
char *p = (char *)malloc(DEFAULT_MALLOC_SIZE);
|
||||
if (!p) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "ApplyForRealloc: malloc failure, errno(%d:%s)", errno, buf);
|
||||
@ -244,7 +244,7 @@ public:
|
||||
char *np = DepthRealloc(depth, p, reallocSize);
|
||||
if (!np) {
|
||||
free(p);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "ApplyForRealloc: realloc failure, errno(%d:%s)", errno, buf);
|
||||
|
@ -39,7 +39,7 @@ int InitShareMemory()
|
||||
int check = ftruncate(fd, SMB_SIZE);
|
||||
if (check < 0) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock ftruncate ERR : %s", buf);
|
||||
@ -49,7 +49,7 @@ int InitShareMemory()
|
||||
g_smbAddr = mmap(nullptr, SMB_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (g_smbAddr == (reinterpret_cast<void *>(-1))) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock g_smbAddr mmap ERR : %s", buf);
|
||||
|
@ -123,7 +123,7 @@ int32_t NetworkPlugin::GetUid(int32_t pid)
|
||||
}
|
||||
std::ifstream input(path, std::ios::in);
|
||||
if (input.fail()) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "%s:NetworkPlugin, open %s failed, errno(%s)", __func__, path.c_str(), buf);
|
||||
|
@ -46,14 +46,14 @@ SocketContext::~SocketContext()
|
||||
|
||||
int ret = shutdown(socketHandle_, SHUT_RDWR);
|
||||
if (ret < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "shutdown socket err = %d %s", errno, buf);
|
||||
}
|
||||
ret = close(socketHandle_);
|
||||
if (ret < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "close socket err = %d %s", errno, buf);
|
||||
|
@ -127,7 +127,7 @@ bool UnixSocketServer::StartServer(const std::string& addrname, ServiceEntry& p)
|
||||
if (acceptThread_.get_id() == std::thread::id()) {
|
||||
close(socketHandle_);
|
||||
unlink(addrname.c_str());
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "StartServer FAIL pthread_create ERR : %s", buf);
|
||||
|
@ -27,10 +27,10 @@
|
||||
|
||||
using namespace ::grpc;
|
||||
|
||||
#define CHECK_REQUEST_RESPONSE(context, requst, response) \
|
||||
#define CHECK_REQUEST_RESPONSE(context, request, response) \
|
||||
do { \
|
||||
CHECK_POINTER_NOTNULL(context, "context ptr invalid!"); \
|
||||
CHECK_POINTER_NOTNULL(requst, "request ptr invalid!"); \
|
||||
CHECK_POINTER_NOTNULL(request, "request ptr invalid!"); \
|
||||
CHECK_POINTER_NOTNULL(response, "response ptr invalid!"); \
|
||||
} while (0)
|
||||
|
||||
|
@ -111,9 +111,9 @@ bool PluginServiceStub::GetRemoveResult()
|
||||
PluginService::PluginService()
|
||||
{
|
||||
pluginIdCounter_ = 0;
|
||||
serviceEntry_ = NULL;
|
||||
pluginServiceImpl_ = NULL;
|
||||
pluginCommandBuilder_ = NULL;
|
||||
serviceEntry_ = nullptr;
|
||||
pluginServiceImpl_ = nullptr;
|
||||
pluginCommandBuilder_ = nullptr;
|
||||
}
|
||||
|
||||
PluginService::~PluginService() {}
|
||||
|
@ -372,7 +372,7 @@ protected:
|
||||
CpuConfig protoConfig;
|
||||
void* handle = dlopen("/system/lib/libcpudataplugin.z.so", RTLD_LAZY);
|
||||
if (handle == nullptr) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "test:dlopen err, errno(%d:%s)", errno, buf);
|
||||
@ -431,8 +431,8 @@ protected:
|
||||
int processNum = fork();
|
||||
if (processNum == 0) {
|
||||
auto requestBuff = std::make_unique<char[]>(MB_PER_BYTE);
|
||||
if (requestBuff == NULL) {
|
||||
const int bufSize = 1024;
|
||||
if (requestBuff == nullptr) {
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "StartRequestMemoryProcess: malloc %zu fail, errno(%d:%s)",
|
||||
@ -463,16 +463,22 @@ protected:
|
||||
size_t len = fwrite(const_cast<char*>(str.c_str()), 1, BLOCK_LEN, writeFp);
|
||||
if (len < 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fwrite() error");
|
||||
if (fclose(writeFp) != 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fclose() error");
|
||||
}
|
||||
return;
|
||||
}
|
||||
int ret = fflush(writeFp);
|
||||
if (ret == EOF) {
|
||||
HILOG_ERROR(LOG_CORE, "fflush() error");
|
||||
if (fclose(writeFp) != 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fclose() error");
|
||||
}
|
||||
return;
|
||||
}
|
||||
fsync(fileno(writeFp));
|
||||
ret = fclose(writeFp);
|
||||
if (ret == 0) {
|
||||
if (ret != 0) {
|
||||
HILOG_ERROR(LOG_CORE, "fclose() error");
|
||||
return;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ bool ShareMemoryBlock::CreateBlockWithFd(std::string name, uint32_t size, int fd
|
||||
|
||||
auto ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlockWithFd mmap ERR : %s", buf);
|
||||
@ -92,7 +92,7 @@ bool ShareMemoryBlock::CreateBlock(std::string name, uint32_t size)
|
||||
int check = ftruncate(fd, size);
|
||||
if (check < 0) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock ftruncate ERR : %s", buf);
|
||||
@ -102,7 +102,7 @@ bool ShareMemoryBlock::CreateBlock(std::string name, uint32_t size)
|
||||
auto ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (ptr == MAP_FAILED) {
|
||||
close(fd);
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
HILOG_ERROR(LOG_CORE, "CreateBlock mmap ERR : %s", buf);
|
||||
|
@ -70,7 +70,7 @@ public class TaskPanel extends JBLayeredPane implements MouseListener {
|
||||
private static final String APPLICATION_TIP_STR = "<html>Application Tuning<br/><br/>"
|
||||
+ "Use the performance profiler to check the CPU,memory,network and energy status of the application</html>";
|
||||
private static final String SYSTEM_TIP_STR = "<html>System Tuning<br/><br/>"
|
||||
+ "Collect system-wide performance traces from Harmony devices from a variety of data sources</html>";
|
||||
+ "Collect system-wide performance traces from openHarmony devices from a variety of data sources</html>";
|
||||
private static final String DISTRIBUTED_TIP_STR =
|
||||
"<html>Distributed Scenario<br/><br/>" + "Collect performance data for distributed scenarios</html>";
|
||||
private static final String GPU_TIP_STR =
|
||||
|
@ -17,12 +17,12 @@ echo "begin to check input"
|
||||
target_os='linux'
|
||||
is_debug='false'
|
||||
if [ "$#" -eq "2" ];then
|
||||
if [ "$1" != 'windows' ] && [ $1 != "linux" ];then
|
||||
if [ "$1" != 'windows' ] && [ "$1" != "linux" ];then
|
||||
echo "failed"
|
||||
echo "Usage: `basename $0` windows/linux debug/release"
|
||||
exit
|
||||
fi
|
||||
if [ $2 != "debug" -a $2 != "release" ];then
|
||||
if [ "$2" != "debug" -a "$2" != "release" ];then
|
||||
echo "failed"
|
||||
echo "Usage: `basename $0` windows/linux debug/release"
|
||||
exit
|
||||
|
@ -131,15 +131,10 @@ size_t SliceFilter::BeginAsyncBinder(uint64_t timestamp, uint32_t pid, DataIndex
|
||||
sliceData.cat, sliceData.name, depth, std::nullopt);
|
||||
|
||||
uint32_t argSetId = INVALID_INT32;
|
||||
if (args.valuesMap_.size()) {
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
} else {
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
}
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
|
||||
argsToSliceQueue_[argSetId] = static_cast<uint32_t>(index);
|
||||
return index;
|
||||
}
|
||||
@ -161,15 +156,10 @@ size_t SliceFilter::BeginBinder(uint64_t timestamp, uint32_t pid, DataIndex cat,
|
||||
sliceStack->push_back(index);
|
||||
|
||||
uint32_t argSetId = INVALID_INT32;
|
||||
if (args.valuesMap_.size()) {
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
} else {
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
}
|
||||
argSetId = streamFilters_->argsFilter_->NewArgs(args);
|
||||
slices->AppendArgSet(argSetId);
|
||||
binderQueue_[pid] = argSetId;
|
||||
|
||||
argsToSliceQueue_[argSetId] = static_cast<uint32_t>(index);
|
||||
return index;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ bool ReadAndParser(SysTuning::TraceStreamer::TraceStreamerSelector& ta, int fd)
|
||||
}
|
||||
|
||||
if (rsize < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
TS_LOGE("Reading trace file failed (errno: %d, %s)", errno, buf);
|
||||
|
@ -60,7 +60,7 @@ HWTEST_F(ParserTest, BytraceParserTest, TestSize.Level1)
|
||||
break;
|
||||
}
|
||||
if (rsize < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
TS_LOGD("Reading trace file failed (errno: %d, %s)", errno, buf);
|
||||
@ -131,7 +131,7 @@ HWTEST_F(ParserTest, HtraceParserTest, TestSize.Level1)
|
||||
break;
|
||||
}
|
||||
if (rsize < 0) {
|
||||
const int bufSize = 1024;
|
||||
const int bufSize = 256;
|
||||
char buf[bufSize] = { 0 };
|
||||
strerror_r(errno, buf, bufSize);
|
||||
TS_LOGD("Reading trace file over (errno: %d, %s)", errno, buf);
|
||||
|
Loading…
x
Reference in New Issue
Block a user