diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 51c63e295e0232f7095a8ee8e03713837e37f419..0000000000000000000000000000000000000000 --- a/.gitattributes +++ /dev/null @@ -1,15 +0,0 @@ -*.tgz filter=lfs diff=lfs merge=lfs -text -*.trp filter=lfs diff=lfs merge=lfs -text -*.apk filter=lfs diff=lfs merge=lfs -text -*.jar filter=lfs diff=lfs merge=lfs -text -*.mp4 filter=lfs diff=lfs merge=lfs -text -*.zip filter=lfs diff=lfs merge=lfs -text -*.asm filter=lfs diff=lfs merge=lfs -text -*.8svn filter=lfs diff=lfs merge=lfs -text -*.9svn filter=lfs diff=lfs merge=lfs -text -*.dylib filter=lfs diff=lfs merge=lfs -text -*.exe filter=lfs diff=lfs merge=lfs -text -*.a filter=lfs diff=lfs merge=lfs -text -*.so filter=lfs diff=lfs merge=lfs -text -*.bin filter=lfs diff=lfs merge=lfs -text -*.dll filter=lfs diff=lfs merge=lfs -text diff --git a/device/etc/hiprofiler_daemon.cfg b/device/etc/hiprofiler_daemon.cfg index 754091cc8402e5d11d7c1c79017a8e0c8b5b3e30..cf9a833db71735e1e2f2188b306bb850f14b20fe 100644 --- a/device/etc/hiprofiler_daemon.cfg +++ b/device/etc/hiprofiler_daemon.cfg @@ -16,17 +16,14 @@ "uid" : "hiprofiler", "gid" : "shell" }], - "permission" : [ - "ohos.permission.GET_BUNDLE_INFO" - ], + "permission" : ["ohos.permission.GET_BUNDLE_INFO"], "secon" : "u:r:native_daemon:s0", "start-mode" : "condition" }, { "name" : "hiprofiler_daemon_sa", "path" : ["/system/bin/native_daemon", "sa"], - "permission" : [ - "ohos.permission.ENABLE_PROFILER", - "ohos.permission.GET_BUNDLE_INFO" + "permission" : ["ohos.permission.ENABLE_PROFILER", + "ohos.permission.GET_BUNDLE_INFO" ], "sandbox" : 0, "caps" : ["CAP_KILL", "CAP_SYS_PTRACE"], diff --git a/device/plugins/cpu_plugin/test/unittest/cpu_data_plugin_unittest.cpp b/device/plugins/cpu_plugin/test/unittest/cpu_data_plugin_unittest.cpp index cf0a3be53774bd3a1c70de5f52d3ce5da64673e0..6130d0d2ccc208a30a39a3d0f137fb0e3c03a053 100644 --- a/device/plugins/cpu_plugin/test/unittest/cpu_data_plugin_unittest.cpp +++ b/device/plugins/cpu_plugin/test/unittest/cpu_data_plugin_unittest.cpp @@ -937,8 +937,9 @@ HWTEST_F(CpuDataPluginTest, TestPid, TestSize.Level1) #endif // COVERAGE_TEST EXPECT_TRUE(PluginCpuinfoStub(plugin1, cpuData1, static_cast(pid1), false, false)); EXPECT_TRUE(PluginCpuinfoStub(plugin2, cpuData2, static_cast(pid2), false, false)); +#ifdef __aarch64__ EXPECT_LT(cpuData1.cpu_usage_info().process_cpu_time_ms(), cpuData2.cpu_usage_info().process_cpu_time_ms()); - +#endif while (waitpid(-1, nullptr, WNOHANG) == 0) { kill(pid1, SIGKILL); kill(pid2, SIGKILL); diff --git a/device/plugins/native_daemon/include/call_stack.h b/device/plugins/native_daemon/include/call_stack.h index 6e7b71dcccf6b1c8c336978bc6e1d0156e9c5ffd..727f89b4e93d39fa58ee104cd67e5fdcfbaec84f 100644 --- a/device/plugins/native_daemon/include/call_stack.h +++ b/device/plugins/native_daemon/include/call_stack.h @@ -43,8 +43,7 @@ public: ~CallStack(); bool UnwindCallStack(const VirtualThread &thread, u64 *regs, u64 regsNum, const u8 *stack, u64 stackSize, std::vector &, - size_t maxStackLevel = MAX_CALL_FRAME_UNWIND_SIZE, int maxjsDepth = 0, - bool jsReport = true); + size_t maxStackLevel = MAX_CALL_FRAME_UNWIND_SIZE, int maxjsDepth = 0, bool jsReport = false); size_t ExpendCallStack(pid_t tid, std::vector &callFrames, size_t expendLimit = 1u); private: @@ -111,7 +110,7 @@ private: static bool CheckAndStepArkFrame(const VirtualThread &thread, uintptr_t& pc, uintptr_t& fp, uintptr_t& sp); #endif bool DoUnwind2(const VirtualThread &thread, std::vector &callStack, size_t maxStackLevel, - int maxjsDepth = 0, bool jsReport = true); + int maxjsDepth = 0, bool jsReport = false); static void DumpTableInfo(UnwindTableInfo &outTableInfo); static int FillUnwindTable(SymbolsFile *symbolsFile, std::shared_ptr map, UnwindInfo *unwindInfoPtr, uintptr_t pc, UnwindTableInfo& outTableInfo); diff --git a/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp b/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp index ff5f00b83dc949090bc312fb93bac45296d9a4ef..ed161c919719eddca596b8f07ea42873fb6ded3d 100644 --- a/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp +++ b/device/plugins/native_daemon/native_memory_profiler_sa/src/native_memory_profiler_sa_stub.cpp @@ -84,7 +84,7 @@ int32_t NativeMemoryProfilerSaStub::StubDumpFile(MessageParcel &data, MessagePar std::string pidPath = "/proc/" + std::to_string(config->pid_) + "/status"; if (stat(pidPath.c_str(), &statBuf) != 0) { PROFILER_LOG_ERROR(LOG_CORE, "StubDumpFile hook process does not exist"); - return false; + return RET_ERR; } } uint32_t fd = static_cast(data.ReadFileDescriptor()); diff --git a/device/plugins/native_daemon/src/hook_manager.cpp b/device/plugins/native_daemon/src/hook_manager.cpp index d68811a3d22e6976e81d7da521d5e1307d58157b..b7e259044f63cdff09cc6f0ebca7a60a327c2c96 100644 --- a/device/plugins/native_daemon/src/hook_manager.cpp +++ b/device/plugins/native_daemon/src/hook_manager.cpp @@ -337,7 +337,7 @@ bool HookManager::CreatePluginSession(const std::vector& c return false; } } - if ((!saMode_) && (!COMMON::IsBetaVersion())) { + if ((!saMode_) && (COMMON::IsUserMode())) { if (!COMMON::CheckApplicationPermission(hookConfig_.pid(), hookConfig_.process_name())) { return false; } @@ -478,6 +478,7 @@ void HookManager::ReadShareMemory(const std::shared_ptr& hookCtx rawStack->baseStackData = nullptr; return true; } + rawStack->freeData = 0; CHECK_TRUE(size >= sizeof(BaseStackRawData), false, "stack data invalid!"); rawStack->baseStackData = std::make_unique(size); @@ -552,7 +553,7 @@ void HookManager::ReadShareMemory(const std::shared_ptr& hookCtx bool HookManager::DestroyPluginSession(const std::vector& pluginIds) { - if ((!saMode_) && (!COMMON::IsBetaVersion())) { + if ((!saMode_) && (COMMON::IsUserMode())) { if (!COMMON::CheckApplicationPermission(hookConfig_.pid(), hookConfig_.process_name())) { return false; } @@ -587,7 +588,7 @@ bool HookManager::StartPluginSession(const std::vector& pluginIds, if (hookCtx_.empty()) { return false; } - if ((!saMode_) && (!COMMON::IsBetaVersion())) { + if ((!saMode_) && (COMMON::IsUserMode())) { if (!COMMON::CheckApplicationPermission(hookConfig_.pid(), hookConfig_.process_name())) { return false; } @@ -601,7 +602,7 @@ bool HookManager::StopPluginSession(const std::vector& pluginIds) if (hookCtx_.empty()) { return false; } - if ((!saMode_) && (!COMMON::IsBetaVersion())) { + if ((!saMode_) && (COMMON::IsUserMode())) { if (!COMMON::CheckApplicationPermission(hookConfig_.pid(), hookConfig_.process_name())) { return false; } diff --git a/device/plugins/native_daemon/src/main.cpp b/device/plugins/native_daemon/src/main.cpp index 01e65311e2a966d97b8e14ace9ec1c1ed711680a..a1095c3c17f2ac441f9930204b05ff57e2386efe 100644 --- a/device/plugins/native_daemon/src/main.cpp +++ b/device/plugins/native_daemon/src/main.cpp @@ -273,6 +273,9 @@ int main(int argc, char* argv[]) std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_ONE_SECOND)); } } else { + if (!COMMON::GetDeveloperMode()) { + return 0; + } if (!COMMON::IsBetaVersion()) { printf("memory profiler only support in beta version\n"); if (lockFileFd > 0) { @@ -319,6 +322,9 @@ int main(int argc, char* argv[]) } } } else { + if (!COMMON::GetDeveloperMode()) { + return 0; + } auto hookManager = std::make_shared(); if (hookManager == nullptr) { if (lockFileFd > 0) { diff --git a/device/plugins/native_daemon/src/virtual_runtime.cpp b/device/plugins/native_daemon/src/virtual_runtime.cpp index 2a6856783cf87507946d190c09525284af6b1d33..8020d31b3f4d74736df0e6b9d953c07580899b4c 100644 --- a/device/plugins/native_daemon/src/virtual_runtime.cpp +++ b/device/plugins/native_daemon/src/virtual_runtime.cpp @@ -565,7 +565,7 @@ void VirtualRuntime::HandleMapInfo(std::vector info, const std::string memMaps->AddMap(mapItem, true); mapsCache_[begin] = memMaps; UpdateSymbols(filePath, mapItem); - if ((!hookConfig_.fp_unwind())) { + if (!hookConfig_.fp_unwind()) { auto &thread = UpdateThread(pid, tid); thread.ParseMap(processMaps_, false); } diff --git a/device/plugins/native_hook/src/hook_client.cpp b/device/plugins/native_hook/src/hook_client.cpp index 249d9a53da1b46a372b86f550000df559f7f23cf..d6cc6eee0ed19a652c29f994cf75edc4742dcdef 100644 --- a/device/plugins/native_hook/src/hook_client.cpp +++ b/device/plugins/native_hook/src/hook_client.cpp @@ -242,8 +242,6 @@ void* MallocHookStart(void* disableHookCallback) { std::lock_guard guard(g_ClientMutex); g_addressChecker = new Bitpool [MAX_BITPOOL_SIZE] {{0}}; - g_miStart = mallinfo2(); - COMMON::PrintMallinfoLog("before hook(byte) => ", g_miStart); g_mallocTimes = 0; g_hookClient.reset(); GetMainThreadRuntimeStackRange(g_filterStaLibRange); @@ -535,8 +533,9 @@ void* hook_aligned_alloc(void* (*fn)(size_t, size_t), size_t align, size_t len) g_timeCost += (end.tv_sec - start.tv_sec) * S_TO_NS + (end.tv_nsec - start.tv_nsec); if (g_mallocTimes % PRINT_INTERVAL == 0) { PROFILER_LOG_ERROR(LOG_CORE, - "g_aligned_allocTimes %" PRIu64" cost time = %" PRIu64" copy data bytes = %" PRIu64" mean cost = %" PRIu64"\n", - g_mallocTimes.load(), g_timeCost.load(), g_dataCounts.load(), g_timeCost.load() / g_mallocTimes.load()); + "g_aligned_allocTimes %" PRIu64" cost time = %" PRIu64" copy data bytes = %" PRIu64" mean cost = %" + PRIu64"\n", g_mallocTimes.load(), g_timeCost.load(), g_dataCounts.load(), + g_timeCost.load() / g_mallocTimes.load()); } #endif return ret; @@ -607,8 +606,9 @@ void* hook_aligned_alloc(void* (*fn)(size_t, size_t), size_t align, size_t len) g_dataCounts += stackSize; if (g_mallocTimes % PRINT_INTERVAL == 0) { PROFILER_LOG_ERROR(LOG_CORE, - "g_aligned_allocTimes %" PRIu64" cost time = %" PRIu64" copy data bytes = %" PRIu64" mean cost = %" PRIu64"\n", - g_mallocTimes.load(), g_timeCost.load(), g_dataCounts.load(), g_timeCost.load() / g_mallocTimes.load()); + "g_aligned_allocTimes %" PRIu64" cost time = %" PRIu64" copy data bytes = %" PRIu64" mean cost = %" + PRIu64"\n", g_mallocTimes.load(), g_timeCost.load(), g_dataCounts.load(), + g_timeCost.load() / g_mallocTimes.load()); } #endif return ret; diff --git a/device/plugins/native_hook/src/hook_socket_client.cpp b/device/plugins/native_hook/src/hook_socket_client.cpp index 53ca539af7ab05023a97b3eb46615c2514567279..880ecc6e44f494fdfc0ff129057cb2dc31e94f69 100644 --- a/device/plugins/native_hook/src/hook_socket_client.cpp +++ b/device/plugins/native_hook/src/hook_socket_client.cpp @@ -126,7 +126,6 @@ bool HookSocketClient::ProtocolProc(SocketContext &context, uint32_t pnum, const std::string smbName = "hooknativesmb_" + std::to_string(pid_); stackWriter_ = std::make_shared(smbName, config_->shareMemorySize, smbFd_, eventFd_, config_->isBlocked); - struct mallinfo2 mi = mallinfo2(); nmdType_ = config_->nmdType; if (nmdType_ == 0 || nmdType_ == ONLY_NMD_TYPE) { SendNmdInfo(); diff --git a/device/plugins/native_hook/src/stack_writer.cpp b/device/plugins/native_hook/src/stack_writer.cpp index d010a60bcaab83bc307b167a4803942cbbbb0492..b915f8a969565b48720ab2a42c1a36b77d82ca54 100644 --- a/device/plugins/native_hook/src/stack_writer.cpp +++ b/device/plugins/native_hook/src/stack_writer.cpp @@ -27,8 +27,6 @@ StackWriter::StackWriter(std::string name, : pluginName_(name), blocked_(blocked) { shareMemoryBlock_ = ShareMemoryAllocator::GetInstance().CreateMemoryBlockRemote(name, size, smbFd); - if (shareMemoryBlock_ == nullptr) { - } eventNotifier_ = EventNotifier::CreateWithFd(eventFd); lastFlushTime_ = std::chrono::steady_clock::now(); } diff --git a/device/plugins/network_profiler/client/src/network_profiler.cpp b/device/plugins/network_profiler/client/src/network_profiler.cpp index 66cd3823421a9302755547c684ec3be8a939a422..feea0e4222e41a59592e3a4498c537b9913cd7d7 100644 --- a/device/plugins/network_profiler/client/src/network_profiler.cpp +++ b/device/plugins/network_profiler/client/src/network_profiler.cpp @@ -150,7 +150,6 @@ void NetworkProfiler::Disable() if (socketClent_) { socketClent_->Reset(); } - socketClent_ = nullptr; enable_ = false; } diff --git a/protos/protos.gni b/protos/protos.gni index 79c14dc66ef4bdf1b0a24a5f56c65946a007e15b..e061622c61f9302abdf86440f66cabda11a64c66 100644 --- a/protos/protos.gni +++ b/protos/protos.gni @@ -15,8 +15,8 @@ import("../build/config.gni") subsys_name = OHOS_PROFILER_SUBSYS_NAME part_name = OHOS_PROFILER_PART_NAME -subsys_x64_out = "clang_${host_cpu}/thirdparty/grpc" -proto_gen_ipc_dir = "clang_${host_cpu}/$subsys_name/$part_name" +subsys_x64_out = "clang_x64/thirdparty/grpc" +proto_gen_ipc_dir = "clang_x64/$subsys_name/$part_name" libc_dir_proto = rebase_path("$asdk_libs_dir", "//") root_output_dir_proto = rebase_path("$root_out_dir", "//")