mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-23 06:50:12 +00:00
commit
ab0d16bf0b
@ -25,7 +25,7 @@
|
||||
#include "unwinder.h"
|
||||
#include "virtual_thread.h"
|
||||
#include "hook_common.h"
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
using ADDR_TYPE = unw_word_t;
|
||||
#else
|
||||
using ADDR_TYPE = uintptr_t;
|
||||
@ -66,7 +66,7 @@ private:
|
||||
std::unordered_map<pid_t, unwMemoryCache> porcessMemoryMap_;
|
||||
static bool ReadVirtualThreadMemory(UnwindInfo &unwindInfoPtr, ADDR_TYPE addr,
|
||||
ADDR_TYPE *data);
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
static const std::string GetUnwErrorName(int error);
|
||||
static void dumpUDI(unw_dyn_info_t &di);
|
||||
static bool fillUDI(unw_dyn_info_t &di, SymbolsFile &symbolsFile, std::shared_ptr<DfxMap> mapmmap,
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "dfx_ark.h"
|
||||
|
||||
#include <string>
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
#include <libunwind.h>
|
||||
extern "C" {
|
||||
#include <libunwind_i.h>
|
||||
@ -56,7 +56,7 @@ bool CallStack::ReadVirtualThreadMemory(UnwindInfo &unwindInfoPtr, ADDR_TYPE add
|
||||
}
|
||||
}
|
||||
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
const std::map<unw_error_t, const std::string> UNW_ERROR_MAP = {
|
||||
{UNW_ESUCCESS, std::to_string(UNW_ESUCCESS)},
|
||||
{UNW_EUNSPEC, std::to_string(UNW_EUNSPEC)},
|
||||
@ -406,7 +406,7 @@ bool CallStack::GetIpSP(uint64_t &ip, uint64_t &sp, const u64 *regs, size_t regN
|
||||
return false;
|
||||
}
|
||||
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
bool CallStack::DoUnwind(const VirtualThread &thread, std::vector<CallFrame> &callStack,
|
||||
size_t maxStackLevel)
|
||||
{
|
||||
@ -472,7 +472,7 @@ bool CallStack::UnwindCallStack(const VirtualThread &thread, u64 *regs, u64 regs
|
||||
* unwind itself.
|
||||
*/
|
||||
if (maxStackLevel - 1 > 0) {
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
return DoUnwind(thread, callStack, maxStackLevel);
|
||||
#else
|
||||
return DoUnwind2(thread, callStack, maxStackLevel);
|
||||
@ -654,7 +654,7 @@ CallStack::CallStack()
|
||||
|
||||
CallStack::~CallStack()
|
||||
{
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
for (auto &pair : unwindAddrSpaceMap_) {
|
||||
unw_destroy_addr_space(pair.second);
|
||||
}
|
||||
|
@ -60,7 +60,6 @@ bool HookManager::CheckProcess()
|
||||
struct stat statBuf;
|
||||
std::string pidPath = "/proc/" + std::to_string(pid) + "/status";
|
||||
if (stat(pidPath.c_str(), &statBuf) != 0) {
|
||||
// pid = 0;
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "%s: hook process does not exist", __func__);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
#include <libunwind.h>
|
||||
#endif
|
||||
|
||||
@ -90,7 +90,7 @@ uint64_t GetSupportedRegMask(ArchType arch)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if HAVE_LIBUNWIND
|
||||
#if defined(HAVE_LIBUNWIND) && HAVE_LIBUNWIND
|
||||
const std::map<int, int> LibUnwindRegMap = {
|
||||
#if defined(target_cpu_x86_64)
|
||||
{UNW_X86_64_RAX, PERF_REG_X86_AX}, {UNW_X86_64_RDX, PERF_REG_X86_DX},
|
||||
|
@ -98,13 +98,13 @@ inline static uint32_t AddrHash(uint32_t h)
|
||||
|
||||
inline void Addr2Bitpool(void* addr)
|
||||
{
|
||||
uint32_t val = AddrHash((uint32_t)(uint64_t)addr) % (MAX_BITPOOL_SIZE * DIVIDE_VAL);
|
||||
uint32_t val = AddrHash(static_cast<uint32_t>(reinterpret_cast<uint64_t>(addr))) % (MAX_BITPOOL_SIZE * DIVIDE_VAL);
|
||||
g_addressChecker[val / DIVIDE_VAL].slot |= (0x1 << (val % DIVIDE_VAL));
|
||||
}
|
||||
|
||||
inline bool IsAddrExist(void* addr)
|
||||
{
|
||||
uint32_t val = AddrHash((uint32_t)(uint64_t)addr) % (MAX_BITPOOL_SIZE * DIVIDE_VAL);
|
||||
uint32_t val = AddrHash(static_cast<uint32_t>(reinterpret_cast<uint64_t>(addr))) % (MAX_BITPOOL_SIZE * DIVIDE_VAL);
|
||||
if (g_addressChecker[val / DIVIDE_VAL].slot.load() & (0x1 << (val % DIVIDE_VAL))) {
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user