add hidebug

Signed-off-by: yanmengzhao <yanmengzhao1@huawei.com>
This commit is contained in:
yanmengzhao 2022-02-10 19:47:04 +08:00
parent c2cb076cf6
commit 59e9465a63
12 changed files with 820 additions and 3 deletions

View File

@ -22,7 +22,9 @@
"hilog",
"hiprofiler",
"hiprofiler_cmd",
"hiprofiler_plugins"
"hiprofiler_plugins",
"ace_napi",
"syspara"
],
"third_party": [
"googletest",
@ -32,9 +34,21 @@
},
"build": {
"sub_component": [
"//developtools/profiler/device:hiprofiler_targets"
"//developtools/profiler/device:hiprofiler_targets",
"//developtools/profiler/hidebug/interfaces/js/kits/napi:napi_hidebug"
],
"inner_kits": [
{
"header": {
"header_base": "//developtools/profiler/hidebug/interfaces/native/innerkits/include",
"header_files": [
"hidebug.h",
"hidebug_base.h"
]
},
"name": "//developtools/profiler/hidebug/interfaces/native/innerkits:libhidebug"
}
],
"inner_kits": [],
"test": [
"//developtools/profiler/device:unittest",
"//developtools/profiler/interfaces/kits/test:unittest"

View File

@ -0,0 +1,34 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//developtools/profiler/hidebug/hidebug.gni")
import("//build/ohos.gni")
ohos_source_set("libhidebug_source") {
include_dirs = [
"//utils/native/base/include",
"//developtools/profiler/hidebug/interfaces/native/innerkits/include",
]
sources = [
"hidebug.cpp",
"hidebug_base.cpp",
]
deps = [ "//utils/native/base:utils" ]
external_deps = [
"hilog_native:libhilog",
"startup_l2:syspara",
]
}

View File

@ -0,0 +1,95 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hidebug.h"
#include <stdlib.h>
#include <vector>
#include <hilog/log.h>
#include <parameter.h>
#include <sysparam_errno.h>
namespace OHOS {
namespace HiviewDFX{
static constexpr HiLogLabel LABEL = { LOG_CORE, 0xD002D0B, "HiDebug_Native" };
static constexpr char SPACE_CHR = ' ';
static constexpr char EQUAL_CHR = '=';
bool HiDebug::InitEnvironmentParam(std::string serviceName)
{
const int PARAM_SIZE = 64;
char paramOutBuf[PARAM_SIZE] = { 0 };
std::string defStrValue;
std::string paramValue(defStrValue);
int retLen = GetParameter(serviceName.c_str(), defStrValue.c_str(), paramOutBuf, PARAM_SIZE);
if (retLen > 0) {
paramOutBuf[retLen] = '\0';
paramValue.assign(paramOutBuf, retLen);
HiLog::Debug(LABEL, "GetParameter successfully, param is %{public}s.", paramValue.c_str());
std::map<std::string, std::string> params = this->ParseParam(paramValue);
std::map<std::string, std::string>::iterator iter;
for (iter = params.begin(); iter != params.end(); ++iter) {
setenv(iter->first.c_str(), iter->second.c_str(), 1);
}
return true;
}
return false;
}
std::map<std::string, std::string> HiDebug::ParseParam(std::string paramStr)
{
bool hasKey = false;
bool hasValue = false;
bool hasEql = false;
std::string keyStr;
std::string valueStr;
std::map<std::string, std::string> params;
int startIdx = 0;
int cnt = 0;
for (int i = 0; i < paramStr.size(); ++i) {
if (paramStr[i] == SPACE_CHR) {
if (hasKey) {
keyStr = paramStr.substr(startIdx, cnt);
hasKey = false;
}
if (hasValue) {
valueStr = paramStr.substr(startIdx, cnt);
params[keyStr] = valueStr;
hasValue = false;
hasEql = false;
}
cnt = 0;
startIdx = i + 1;
} else if (paramStr[i] == EQUAL_CHR) {
if (hasKey) {
keyStr = paramStr.substr(startIdx, cnt);
hasKey = false;
}
hasEql = true;
cnt = 0;
startIdx = i + 1;
} else {
cnt++;
hasEql ? hasValue = true : hasKey = true;
}
}
if (hasValue) {
params[keyStr] = paramStr.substr(startIdx, cnt);
}
return params;
}
} // HiviewDFX
} // OHOS

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hidebug_base.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <parameter.h>
#include <sysparam_errno.h>
#include <errno.h>
#include "hilog/log.h"
#undef LOG_DOMAIN
#undef LOG_TAG
#define LOG_DOMAIN 0xD002D0A
#define LOG_TAG "HiDebug_Native"
const char SPACE_CHR = ' ';
const char COLON_CHR = ':';
const int PARAM_BUF_LEN = 128;
int ParseParams(const char *input)
{
bool hasKey = false;
bool hasValue = false;
bool hasEql = false;
char key[MAX_PARA_LEN];
char value[MAX_PARA_LEN];
int startIdx = 0;
int cnt = 0;
int paramCnt = 0;
for (size_t i = 0; i < strlen(input); ++i) {
if (input[i] == SPACE_CHR) {
if (hasKey) {
strncpy(key, input + startIdx, cnt);
key[cnt] = '\0';
hasKey = false;
}
if (hasValue) {
strncpy(value, input + startIdx, cnt);
value[cnt] = '\0';
strcpy(params[paramCnt].key, key);
strcpy(params[paramCnt].value, value);
paramCnt++;
hasValue = false;
hasEql = false;
}
cnt = 0;
startIdx = i + 1;
} else if (input[i] == COLON_CHR) {
if (hasKey) {
strncpy(key, input + startIdx, cnt);
key[cnt] = '\0';
hasKey = false;
}
hasEql = true;
cnt = 0;
startIdx = i + 1;
} else {
cnt++;
hasEql ? hasValue = true : hasKey = true;
}
}
if (hasValue) {
strncpy(value, input + startIdx, cnt);
value[cnt] = '\0';
strcpy(params[paramCnt].key, key);
strcpy(params[paramCnt].value, value);
paramCnt++;
}
return paramCnt;
}
bool InitEnvironmentParam(const char *serviceName)
{
HILOG_INFO(LOG_CORE, "enter InitEnvironmentParam Func.");
char paramOutBuf[PARAM_BUF_LEN];
char defStrValue[PARAM_BUF_LEN];
char queryName[] = "hiviewdfx.debugenv.";
strcat(queryName, serviceName);
int retLen = GetParameter(queryName, defStrValue, paramOutBuf, PARAM_BUF_LEN);
paramOutBuf[retLen] = '\0';
int cnt = ParseParams(paramOutBuf);
printf("once query: queryName = %s, paramStr = %s, retLen = %d, cnt = %d.\n", queryName, paramOutBuf, retLen, cnt);
if (cnt < 1) {
char persistName[] = "persist.hiviewdfx.debugenv.";
strcat(persistName, serviceName);
retLen = GetParameter(persistName, defStrValue, paramOutBuf, PARAM_BUF_LEN);
paramOutBuf[retLen] = '\0';
cnt = ParseParams(paramOutBuf);
printf("persist query: persistName = %s, paramStr = %s, retLen = %d, cnt = %d.\n", persistName, paramOutBuf, retLen, cnt);
}
if (cnt > 0) {
HILOG_ERROR(LOG_CORE, "GET parameter successfully.");
for (int i = 0; i < cnt; ++i) {
errno = 0;
setenv(params[i].key, params[i].value, 1);
HILOG_INFO(LOG_CORE, "setenv errno = %{public}d.", errno);
printf("setenv: key = %s, value = %s, errno = %d.\n", params[i].key, params[i].value, errno);
}
return true;
}
HILOG_ERROR(LOG_CORE, "failed to capture environment params.");
printf("query failed.\n");
return false;
}

15
hidebug/hidebug.gni Normal file
View File

@ -0,0 +1,15 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# hiview path definitions
hidebug_path = "//developtools/profiler/hidebug"

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Provide interfaces related to debugger access and obtaining CPU,
* memory and other virtual machine information during runtime for JS programs
*
* @syscap SystemCapability.HiviewDFX.HiProfiler.HiDebug
* @import import napi_hidebug from '@ohos.napi_hidebug'
* @since 8
*/
declare namespace hidebug {
/**
* Get total native heap memory size
* @since 8
*/
function getNativeHeapSize() : bigint;
/**
* Get Native heap memory allocation size
* @since 8
*/
function getNativeHeapAllocatedSize() : bigint;
/**
* Get Native heap memory free size
* @since 8
*/
function getNativeHeapFreeSize() : bigint;
/**
* Get application process proportional set size memory information
* @since 8
*/
function getPss() : bigint;
/**
* Get process private dirty memory size
* @since 8
*/
function getSharedDirty() : bigint;
/**
* Start CPU Profiling
* @since 8
*/
function startProfiling(fileName : string) : void;
/**
* Stop CPU Profiling
* @since 8
*/
function stopProfiling() : void;
/**
* Dump JS Virtual Machine Heap Snapshot
* @since 8
*/
function dumpHeapData(fileName : string) : void;
}
export default hidebug;

View File

@ -0,0 +1,59 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//developtools/profiler/hidebug/hidebug.gni")
import("//build/ohos.gni")
import("//build/ohos/ace/ace.gni")
config("napi_hidebug_config") {
visibility = [ ":*" ]
include_dirs = [
".",
"include/",
"//utils/native/base/include",
"//third_party/node/src",
"//foundation/ace/napi",
"//foundation/ace/napi/native_engine",
"//foundation/ace/napi/interfaces/kits",
"//third_party/musl/include/malloc.h",
]
}
ohos_shared_library("napi_hidebug") {
sources = [ "napi_hidebug.cpp" ]
configs = [ ":napi_hidebug_config" ]
deps = [
"//base/hiviewdfx/hiview/adapter/utility:hiview_adapter_utility",
"//utils/native/base:utils",
"//foundation/ace/napi:ace_napi",
"//foundation/distributedschedule/safwk/interfaces/innerkits/safwk:system_ability_fwk",
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
]
external_deps = [
"ability_runtime:base",
"ability_runtime:want",
"hilog_native:libhilog",
"ipc:ipc_core",
"bundle_framework:appexecfwk_core",
"ces_standard:cesfwk_services",
]
relative_install_dir = "module"
part_name = "profiler"
subsystem_name = "developtools"
}

View File

@ -0,0 +1,43 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NAPI_HIDEBUG_H
#define NAPI_HIDEBUG_H
#include <string>
#include "napi/native_api.h"
#include "napi/native_node_api.h"
namespace OHOS {
namespace HiviewDFX{
static napi_value StartProfiling(napi_env env, napi_callback_info info);
static napi_value StopProfiling(napi_env env, napi_callback_info info);
static napi_value DumpHeapData(napi_env env, napi_callback_info info);
static napi_value GetPss(napi_env env, napi_callback_info info);
static napi_value GetShareDirty(napi_env env, napi_callback_info info);
static napi_value GetNativeHeapSize(napi_env env, napi_callback_info info);
static napi_value GetNativeHeapAllocatedSize(napi_env env, napi_callback_info info);
static napi_value GetNativeHeapFreeSize(napi_env env, napi_callback_info info);
static napi_value CreateUndefined(napi_env env);
static napi_value CreateErrorMessage(napi_env env, std::string msg);
static bool MatchValueType(napi_env env, napi_value value, napi_valuetype targetType);
static std::string GetFileNameParam(napi_env env, napi_callback_info info);
static uint64_t GetProcessMeminfo(const std::string& matchingItem);
static bool GetBundleNameByUid(std::int32_t uid, std::string& bname);
} // HiviewDFX
} // OHOS
#endif // NAPI_HIDEBUG_H

View File

@ -0,0 +1,254 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "napi_hidebug.h"
#include <fstream>
#include "directory_ex.h"
#include "file_ex.h"
#include "file_util.h"
#include "unistd.h"
#include <errno.h>
#include <securec.h>
#include <malloc.h>
#include <string>
#include "ipc_skeleton.h"
#include "bundle_manager_helper.h"
#include "hilog/log.h"
#include "native_engine/native_engine.h"
namespace OHOS {
namespace HiviewDFX {
namespace {
constexpr HiLogLabel LABEL = { LOG_CORE, 0xD002D0A, "HiDebug_NAPI" };
constexpr int ONE_VALUE_LIMIT = 1;
constexpr int ARRAY_INDEX_FIRST = 0;
constexpr int MODE_FULL = 00777;
const std::string BASE_PATH = "/data/accounts/account_0/appdata/";
const std::string SUB_DIR = "/files/";
}
napi_value StartProfiling(napi_env env, napi_callback_info info)
{
std::string fileName = GetFileNameParam(env, info);
int callingUid = IPCSkeleton::GetCallingUid();
std::string bundleName = "";
if (!GetBundleNameByUid(callingUid, bundleName)) {
return CreateErrorMessage(env, "search bundle name failed.");
}
std::string filePath = BASE_PATH + bundleName + SUB_DIR + fileName;
if (!FileUtil::IsLegalPath(filePath)) {
return CreateErrorMessage(env, "input fileName is illegal.");
}
if (!FileUtil::CreateFile(filePath, MODE_FULL)) {
return CreateErrorMessage(env, "file created failed");
}
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env);
engine->StartCpuProfiler(filePath);
return CreateUndefined(env);
}
napi_value StopProfiling(napi_env env, napi_callback_info info)
{
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env);
engine->StopCpuProfiler();
return CreateUndefined(env);
}
napi_value DumpHeapData(napi_env env, napi_callback_info info)
{
std::string fileName = GetFileNameParam(env, info);
int callingUid = IPCSkeleton::GetCallingUid();
std::string bundleName = "";
if (!GetBundleNameByUid(callingUid, bundleName)) {
return CreateErrorMessage(env, "search bundle name failed.");
}
std::string filePath = BASE_PATH + bundleName + SUB_DIR + fileName;
HiLog::Debug(LABEL, "filePath is %{public}s.", filePath.c_str());
if (!FileUtil::IsLegalPath(filePath)) {
return CreateErrorMessage(env, "input fileName is illegal.");
}
if (!FileUtil::CreateFile(filePath, MODE_FULL)) {
return CreateErrorMessage(env, "file created failed");
}
NativeEngine *engine = reinterpret_cast<NativeEngine*>(env);
engine->DumpHeapSnapShot(filePath);
return CreateUndefined(env);
}
napi_value CreateUndefined(napi_env env)
{
napi_value res = nullptr;
napi_get_undefined(env, &res);
return res;
}
napi_value CreateErrorMessage(napi_env env, std::string msg)
{
napi_value result = nullptr;
napi_value message = nullptr;
napi_create_string_utf8(env, (char *)msg.data(), msg.size(), &message);
napi_create_error(env, nullptr, message, &result);
return result;
}
static napi_value GetPss(napi_env env, napi_callback_info info)
{
napi_value pss;
std::string item = "pss";
uint64_t pssInfo = GetProcessMeminfo(item);
napi_create_int64(env, pssInfo, &pss);
return pss;
}
static napi_value GetShareDirty(napi_env env, napi_callback_info info)
{
napi_value share_dirty;
std::string item = "Shared_Dirty";
uint64_t shareDirtyInfo = GetProcessMeminfo(item);
napi_create_int64(env, shareDirtyInfo, &share_dirty);
return share_dirty;
}
static napi_value GetNativeHeapSize(napi_env env, napi_callback_info info)
{
struct mallinfo mi;
napi_value native_heap_size;
napi_create_int64(env, mi.usmblks, &native_heap_size);
return native_heap_size;
}
static napi_value GetNativeHeapAllocatedSize(napi_env env, napi_callback_info info)
{
struct mallinfo mi;
napi_value native_heap_allocated_size;
napi_create_int64(env, mi.uordblks, &native_heap_allocated_size);
return native_heap_allocated_size;
}
static napi_value GetNativeHeapFreeSize(napi_env env, napi_callback_info info)
{
struct mallinfo mi;
napi_value native_heap_free_size;
napi_create_int64(env, mi.usmblks, &native_heap_free_size);
return native_heap_free_size;
}
static uint64_t GetProcessMeminfo(const std::string& matchingItem)
{
size_t pid = getpid();
std::string filePath = "/proc/" + std::to_string(pid) + "/smaps_rollup";
FILE* smapsRollupInfo = fopen(filePath.c_str(), "r");
if (smapsRollupInfo == nullptr) {
return -1;
}
char line[256];
while (fgets(line, sizeof(line), smapsRollupInfo)) {
uint64_t meminfo;
if (matchingItem == "pss") {
if (sscanf_s(line, "Pss: %llu kB", &meminfo) == 1) {
fclose(smapsRollupInfo);
return meminfo;
}
} else if (matchingItem == "Shared_Dirty") {
if (sscanf_s(line, "Shared_Dirty: %llu kB", &meminfo) == 1) {
fclose(smapsRollupInfo);
return meminfo;
}
}
}
fclose(smapsRollupInfo);
return -1;
}
bool MatchValueType(napi_env env, napi_value value, napi_valuetype targetType)
{
napi_valuetype valueType = napi_undefined;
napi_typeof(env, value, &valueType);
return valueType == targetType;
}
std::string GetFileNameParam(napi_env env, napi_callback_info info)
{
size_t argc = ONE_VALUE_LIMIT;
napi_value argv[ONE_VALUE_LIMIT] = { nullptr };
napi_value thisVar = nullptr;
void *data = nullptr;
napi_get_cb_info(env, info, &argc, argv, &thisVar, &data);
if (argc != ONE_VALUE_LIMIT) {
HiLog::Error(LABEL, "invalid number = %{public}d of params.", ONE_VALUE_LIMIT);
return "undefined";
}
if (!MatchValueType(env, argv[ARRAY_INDEX_FIRST], napi_string)) {
HiLog::Error(LABEL, "Type error, should be string type!");
return "undefined";
}
size_t bufLen = 0;
napi_status status = napi_get_value_string_utf8(env, argv[0], NULL, 0, &bufLen);
if (status != napi_ok) {
HiLog::Error(LABEL, "Get input filename param length failed.");
return "undefined";
}
char buf[bufLen + 1];
napi_get_value_string_utf8(env, argv[0], buf, bufLen + 1, &bufLen);
std::string fileName = buf;
return fileName;
}
bool GetBundleNameByUid(std::int32_t uid, std::string& bname)
{
std::shared_ptr<EventFwk::BundleManagerHelper> bundleManager = EventFwk::BundleManagerHelper::GetInstance();
if (bundleManager != nullptr) {
bname = bundleManager->GetBundleName(uid);
}
return true;
}
napi_value DeclareHiDebugInterface(napi_env env, napi_value exports)
{
napi_property_descriptor desc[] = {
DECLARE_NAPI_FUNCTION("startProfiling", StartProfiling),
DECLARE_NAPI_FUNCTION("stopProfiling", StopProfiling),
DECLARE_NAPI_FUNCTION("dumpHeapData", DumpHeapData),
DECLARE_NAPI_FUNCTION("getPss", GetPss),
DECLARE_NAPI_FUNCTION("getShareDirty", GetShareDirty),
DECLARE_NAPI_FUNCTION("getNativeHeapSize", GetNativeHeapSize),
DECLARE_NAPI_FUNCTION("getNativeHeapAllocatedSize", GetNativeHeapAllocatedSize),
DECLARE_NAPI_FUNCTION("getNativeHeapFreeSize", GetNativeHeapFreeSize)
};
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
return exports;
}
static napi_module hidebugModule = {
.nm_version = 1,
.nm_flags = 0,
.nm_filename = nullptr,
.nm_register_func = HiviewDFX::DeclareHiDebugInterface,
.nm_modname = "napi_hidebug",
.nm_priv = ((void *)0),
.reserved = {0}
};
extern "C" __attribute__((constructor)) void HiDebugRegisterModule(void)
{
napi_module_register(&hidebugModule);
}
} // HiviewDFX
} // OHOS

View File

@ -0,0 +1,36 @@
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//developtools/profiler/hidebug/hidebug.gni")
import("//build/ohos.gni")
config("hidebug_native_config") {
visibility = [ ":*" ]
include_dirs = [ "include" ]
}
ohos_shared_library("libhidebug") {
public_configs = [ ":hidebug_native_config" ]
deps = [ "//developtools/profiler/hidebug/frameworks/native:libhidebug_source" ]
external_deps = [
"hilog_native:libhilog",
"startup_l2:syspara",
]
output_extension = "so"
part_name = "profiler"
subsystem_name = "developtools"
}

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HIDEBUG_H
#define HIDEBUG_H
#include <string>
#include <map>
namespace OHOS {
namespace HiviewDFX{
class HiDebug {
public:
HiDebug() = delete;
~HiDebug() = delete;
bool InitEnvironmentParam(std::string serviceName);
private:
std::map<std::string, std::string> ParseParam(std::string paramStr);
};
} // HiviewDFX
} // OHOS
#endif // HIDEBUG_H

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HIVIEWDFX_HIDEBUG_BASE_C_H
#define HIVIEWDFX_HIDEBUG_BASE_C_H
#ifdef __cplusplus
extern "C" {
#endif
const int MAX_PARA_LEN = 50;
const int MAX_PARA_CNT = 20;
struct Params {
char key[MAX_PARA_LEN];
char value[MAX_PARA_LEN];
} params[MAX_PARA_CNT];
bool InitEnvironmentParam(const char *serviceName);
#ifdef __cplusplus
}
#endif
#endif // HIVIEWDFX_HIDEBUG_BASE_C_H