mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2024-11-27 00:51:47 +00:00
hiebpfplugin仅在root下调用
Signed-off-by: ganchuantao <ganchuantao1@huawei.com> Change-Id: I7cdc86ffce97c1b3f64b50d660a6dd4725667b9e
This commit is contained in:
parent
51c25d2b29
commit
5b5a0995c4
@ -41,6 +41,7 @@ ohos_source_set("hiebpfplugin_source") {
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"hilog:libhilog_base",
|
||||
"init:libbegetutil",
|
||||
"openssl:libcrypto_shared",
|
||||
"protobuf:protobuf_lite",
|
||||
]
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <parameters.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "hiebpf_plugin_config.pb.h"
|
||||
@ -36,7 +37,9 @@ std::shared_ptr<TraceFileWriter> g_splitTraceWriter {nullptr};
|
||||
|
||||
void RunCmd(std::string& cmd)
|
||||
{
|
||||
if (getuid() == 0) {
|
||||
std::string debugMode = "0";
|
||||
debugMode = OHOS::system::GetParameter("const.debuggable", debugMode);
|
||||
if (debugMode == "1") {
|
||||
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd.c_str(), "r"), pclose);
|
||||
if (pipe == nullptr) {
|
||||
PROFILER_LOG_ERROR(LOG_CORE, "HiebpfPlugin::RunCmd: create popen FAILED!");
|
||||
@ -125,4 +128,4 @@ EXPORT_API PluginModuleStruct g_pluginModule = {
|
||||
.resultBufferSizeHint = MAX_BUFFER_SIZE,
|
||||
.isStandaloneFileData = true,
|
||||
.outFileName = "/data/local/tmp/hiebpf.data",
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user