diff --git a/pmu/pfm/pfm.cpp b/pmu/pfm/pfm.cpp index e516dd505933a739496378729db9f5ad5d03eab8..aae863ba2baa027fdec60ec3f816b3e8c7082b83 100644 --- a/pmu/pfm/pfm.cpp +++ b/pmu/pfm/pfm.cpp @@ -173,6 +173,7 @@ struct PmuEvt* PfmGetSpeEvent( evt->collectType = collectType; int type = GetSpeType(); if (type == -1) { + delete evt; return nullptr; } evt->type = static_cast(type); diff --git a/pmu/pfm/uncore.cpp b/pmu/pfm/uncore.cpp index 6ae72cccc080d161f02ca1efda6822a15f2d97aa..e73eb3043069c6a4d3c5fcde53e8b772f415cdd9 100644 --- a/pmu/pfm/uncore.cpp +++ b/pmu/pfm/uncore.cpp @@ -391,6 +391,7 @@ struct PmuEvt* GetUncoreEvent(const char* pmuName, int collectType) // Fill fields for uncore devices. auto err = FillUncoreFields(pmuName, pmuEvtPtr); if (err != SUCCESS) { + delete pmuEvtPtr; return nullptr; } return pmuEvtPtr; @@ -414,6 +415,7 @@ struct PmuEvt* GetUncoreRawEvent(const char* pmuName, int collectType) // Fill fields for uncore devices. auto err = FillUncoreFields(pmuName, pmuEvtPtr); if (err != SUCCESS) { + delete pmuEvtPtr; return nullptr; } return pmuEvtPtr; diff --git a/pmu/pmu_metric.cpp b/pmu/pmu_metric.cpp index 56cf758019246681890aaa4b74727ee41b08e05c..be581c14f0a2201c143d2c623211d2c45762dec6 100644 --- a/pmu/pmu_metric.cpp +++ b/pmu/pmu_metric.cpp @@ -1154,7 +1154,7 @@ namespace KUNPENG_PMU { return ddrcIndex; } - static bool getChannelId(const char *evt, const unsigned ddrNumaId, unsigned &channelId) + static bool getChannelId(const char *evt, unsigned &channelId) { string devName; string evtName; @@ -1196,7 +1196,7 @@ namespace KUNPENG_PMU { unordered_map, PmuDeviceData, channelKeyHash> devDataByChannel; //Key: socketId, channelId, ddrNumaId for (auto &data : rawData) { unsigned channelId; - if (!getChannelId(data.evtName, data.ddrNumaId, channelId)) { + if (!getChannelId(data.evtName, channelId)) { continue; } auto ddrDatakey = make_tuple(data.socketId, channelId, data.ddrNumaId); diff --git a/pmu/spe.cpp b/pmu/spe.cpp index d87587b7bac322cb57669ce45eac5ae384515f62..a8cc7d9570c85c5c9ce719f0c316f2a775582b11 100644 --- a/pmu/spe.cpp +++ b/pmu/spe.cpp @@ -487,7 +487,7 @@ static struct SpeRecord *CoreAuxData(struct SpeCoreContext *ctx, AuxContext *aux return bufEnd; } -static size_t ComputeAuxSize(size_t auxMapLen, size_t headOff, size_t oldOff, int pageSize) +static size_t ComputeAuxSize(size_t auxMapLen, size_t headOff, size_t oldOff) { // Compute current aux buffer size by current offset and previous offset. size_t size = 0; @@ -502,7 +502,7 @@ static size_t ComputeAuxSize(size_t auxMapLen, size_t headOff, size_t oldOff, in } static struct SpeRecord *CoreSpeData(struct SpeCoreContext *ctx, struct ContextSwitchData *dummyData, - struct SpeRecord *buf, int *remainSize, int pageSize, int cpu) + struct SpeRecord *buf, int *remainSize, int cpu) { int dummyIdx = 1; struct perf_event_mmap_page *mpage = (struct perf_event_mmap_page *)ctx->speMpage; @@ -514,7 +514,7 @@ static struct SpeRecord *CoreSpeData(struct SpeCoreContext *ctx, struct ContextS } size_t headOff = head & ctx->mask; size_t oldOff = old & ctx->mask; - size_t size = ComputeAuxSize(mpage->aux_size, headOff, oldOff, pageSize); + size_t size = ComputeAuxSize(mpage->aux_size, headOff, oldOff); size_t auxOffset = 0; struct SpeRecord *bufEnd = nullptr; @@ -554,7 +554,7 @@ int Spe::SpeReadData(struct SpeContext *context, struct SpeRecord *buf, int size int remainSize = size; int dummySize = context->dummyMmapSize; CoreDummyData(context->coreCtxes, dummyData, dummySize, context->pageSize); - CoreSpeData(context->coreCtxes, dummyData, buf, &remainSize, context->pageSize, cpu); + CoreSpeData(context->coreCtxes, dummyData, buf, &remainSize, cpu); return size - remainSize; } diff --git a/symbol/CMakeLists.txt b/symbol/CMakeLists.txt index aaa8988e1e967e5d72bd7c9f6f503bbbc975ab34..33a14d21b3f32b2a990b42475aed5958261bb8d0 100644 --- a/symbol/CMakeLists.txt +++ b/symbol/CMakeLists.txt @@ -8,7 +8,7 @@ set(SYMBOL_FILE_DIR ${PROJECT_TOP_DIR}/symbol) set(INCLUDE_DIR ${PROJECT_TOP_DIR}/include) set(UTIL_FILE_DIR ${PROJECT_TOP_DIR}/util) -file(GLOB SYMBOL_SRC ${SYMBOL_FILE_DIR}/*c ${SYMBOL_FILE_DIR}/*cpp ${UTIL_FILE_DIR}/pcerr.cpp) +file(GLOB SYMBOL_SRC ${SYMBOL_FILE_DIR}/*c ${SYMBOL_FILE_DIR}/*cpp ${UTIL_FILE_DIR}/pcerr.cpp ${UTIL_FILE_DIR}/common.cpp) include_directories(${UTIL_FILE_DIR}) include_directories(${SYMBOL_FILE_DIR}) diff --git a/symbol/symbol_resolve.cpp b/symbol/symbol_resolve.cpp index 2f971f402e24961ef9b1fb126f6ca62621a239d3..cc2d6410bd4d3ecfb94a6dead2d48a53b21c9a88 100644 --- a/symbol/symbol_resolve.cpp +++ b/symbol/symbol_resolve.cpp @@ -25,6 +25,7 @@ #include "name_resolve.h" #include "pcerr.h" #include "symbol_resolve.h" +#include "common.h" using namespace KUNPENG_SYM; constexpr __u64 MAX_LINE_LENGTH = 1024; @@ -1137,6 +1138,12 @@ struct StackAsm* SymbolResolve::MapAsmCodeStack( { char startAddrStr[ADDR_LEN]; char endAddrStr[ADDR_LEN]; + + if (!ExistPath(moduleName)) { + pcerr::New(LIBSYM_ERR_FILE_INVALID, "file does not exist"); + return nullptr; + } + if (startAddr >= endAddr) { pcerr::New(LIBSYM_ERR_START_SMALLER_END, "libysm the end address must be greater than the start address"); return nullptr; @@ -1150,6 +1157,7 @@ struct StackAsm* SymbolResolve::MapAsmCodeStack( pcerr::New(LIBSYM_ERR_SNPRINF_OPERATE_FAILED, "libsym fails to execute snprintf"); return nullptr; } + std::string cmd = "objdump -Fld " + moduleName + " --start-address=" + std::string{startAddrStr} + " --stop-address=" + std::string{endAddrStr}; FILE* pipe = popen(cmd.c_str(), "r");