mirror of
https://gitee.com/openharmony/hiviewdfx_hiview
synced 2024-11-23 17:19:57 +00:00
Do not depend on hiperf directly
hiperf is not in the minimal system, separate it during compile time. Signed-off-by: ericlee <liyu1@huawei.com>
This commit is contained in:
parent
7f08e6d0b4
commit
dbb36165c8
@ -53,4 +53,10 @@ declare_args() {
|
||||
}
|
||||
|
||||
enable_hiview_usage_event_report_build = true
|
||||
|
||||
has_hiperf = true
|
||||
if (defined(global_parts_info) &&
|
||||
!defined(global_parts_info.developtools_hiperf)) {
|
||||
has_hiperf = false
|
||||
}
|
||||
}
|
||||
|
@ -43,5 +43,8 @@ ohos_source_set("log_catcher") {
|
||||
"$hiview_interfaces/inner_api/unified_collection/utility:libucollection_utility",
|
||||
]
|
||||
|
||||
external_deps = [ "hiperf:hiperf_client" ]
|
||||
if (has_hiperf) {
|
||||
cflags = [ "-DHAS_HIPERF" ]
|
||||
external_deps = [ "hiperf:hiperf_client" ]
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,9 @@
|
||||
#include "sys_event.h"
|
||||
|
||||
#include "event_log_catcher.h"
|
||||
#ifdef HAS_HIPERF
|
||||
#include "hiperf_client.h"
|
||||
#endif
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
class PeerBinderCatcher : public EventLogCatcher {
|
||||
@ -56,14 +58,18 @@ private:
|
||||
std::string perfCmd_ = "";
|
||||
std::string binderPath_ = LOGGER_BINDER_DEBUG_PROC_PATH;
|
||||
std::shared_ptr<SysEvent> event_ = nullptr;
|
||||
#ifdef HAS_HIPERF
|
||||
std::unique_ptr<Developtools::HiPerf::HiperfClient::Client> perfClient_ = nullptr;
|
||||
#endif
|
||||
std::map<int, std::list<PeerBinderCatcher::BinderInfo>> BinderInfoParser(std::ifstream& fin, int fd) const;
|
||||
void ParseBinderCallChain(std::map<int, std::list<PeerBinderCatcher::BinderInfo>>& manager,
|
||||
std::set<int>& pids, int pid) const;
|
||||
std::set<int> GetBinderPeerPids(int fd) const;
|
||||
void CatcherStacktrace(int fd, int pid) const;
|
||||
#ifdef HAS_HIPERF
|
||||
void ForkToDumpHiperf(const std::set<int>& pids);
|
||||
void DoExecHiperf(const std::string& fileName, const std::set<int>& pids);
|
||||
#endif
|
||||
};
|
||||
} // namespace HiviewDFX
|
||||
} // namespace OHOS
|
||||
|
@ -35,7 +35,9 @@
|
||||
namespace OHOS {
|
||||
namespace HiviewDFX {
|
||||
DEFINE_LOG_LABEL(0xD002D01, "EventLogger-PeerBinderCatcher");
|
||||
#ifdef HAS_HIPERF
|
||||
using namespace Developtools::HiPerf;
|
||||
#endif
|
||||
constexpr char EVENT_LOG_PATH[] = "/data/log/eventlog";
|
||||
PeerBinderCatcher::PeerBinderCatcher() : EventLogCatcher()
|
||||
{
|
||||
@ -83,8 +85,9 @@ int PeerBinderCatcher::Catch(int fd)
|
||||
std::string content = "PeerBinder pids is empty\r\n";
|
||||
FileUtil::SaveStringToFd(fd, content);
|
||||
}
|
||||
|
||||
#ifdef HAS_HIPERF
|
||||
ForkToDumpHiperf(pids);
|
||||
#endif
|
||||
std::string pidStr = "";
|
||||
for (auto pidTemp : pids) {
|
||||
if (pidTemp != pid_) {
|
||||
@ -211,6 +214,7 @@ void PeerBinderCatcher::CatcherStacktrace(int fd, int pid) const
|
||||
LogCatcherUtils::DumpStacktrace(fd, pid);
|
||||
}
|
||||
|
||||
#ifdef HAS_HIPERF
|
||||
void PeerBinderCatcher::DoExecHiperf(const std::string& fileName, const std::set<int>& pids)
|
||||
{
|
||||
HiperfClient::RecordOption opt;
|
||||
@ -286,5 +290,6 @@ void PeerBinderCatcher::ForkToDumpHiperf(const std::set<int>& pids)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
} // namespace HiviewDFX
|
||||
} // namespace OHOS
|
@ -46,8 +46,9 @@ ohos_unittest("EventloggerCatcherTest") {
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"hiperf:hiperf_client",
|
||||
"input:libmmi-client",
|
||||
]
|
||||
external_deps = [ "input:libmmi-client" ]
|
||||
if (has_hiperf) {
|
||||
cflags = [ "-DHAS_HIPERF" ]
|
||||
external_deps += [ "hiperf:hiperf_client" ]
|
||||
}
|
||||
}
|
||||
|
@ -532,10 +532,11 @@ HWTEST_F(EventloggerCatcherTest, EventloggerCatcherTest008, TestSize.Level3)
|
||||
peerBinderCatcher->Initialize("foundation", 1, pid_);
|
||||
peerBinderCatcher->GetBinderPeerPids(fd);
|
||||
peerBinderCatcher->CatcherStacktrace(fd, pid_);
|
||||
|
||||
#ifdef HAS_HIPERF
|
||||
std::set<int> pids;
|
||||
pids.insert(pid_);
|
||||
peerBinderCatcher->DoExecHiperf("peerBinderCatcher", pids);
|
||||
#endif
|
||||
close(fd);
|
||||
printf("PeerBinderCatcher End\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user