mirror of
https://github.com/openharmony/developtools_bytrace_standard.git
synced 2026-07-19 15:03:32 -04:00
!49 change to readable file names
Merge pull request !49 from anderskov/master
This commit is contained in:
+8
-8
@@ -14,14 +14,14 @@
|
||||
import("//build/ohos.gni")
|
||||
import("//developtools/bytrace_standard/bytrace.gni")
|
||||
|
||||
config("bytrace_inner_config") {
|
||||
config("bytrace_lib_inner_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "${innerkits_path}/native/include" ]
|
||||
}
|
||||
|
||||
ohos_static_library("bytrace_inner") {
|
||||
sources = [ "./src/bytrace_impl.cpp" ]
|
||||
public_configs = [ ":bytrace_inner_config" ]
|
||||
public_configs = [ ":bytrace_lib_inner_config" ]
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
@@ -35,7 +35,7 @@ ohos_static_library("bytrace_inner") {
|
||||
part_name = "bytrace_standard"
|
||||
}
|
||||
|
||||
config("bytrace_capture_inner_config") {
|
||||
config("bytrace_osal_inner_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"./include",
|
||||
@@ -43,9 +43,9 @@ config("bytrace_capture_inner_config") {
|
||||
]
|
||||
}
|
||||
|
||||
ohos_static_library("bytrace_capture_inner") {
|
||||
sources = [ "./src/bytrace_capture.cpp" ]
|
||||
public_configs = [ ":bytrace_capture_inner_config" ]
|
||||
ohos_static_library("bytrace_osal_inner") {
|
||||
sources = [ "./src/bytrace_osal.cpp" ]
|
||||
public_configs = [ ":bytrace_osal_inner_config" ]
|
||||
external_deps = [
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara",
|
||||
@@ -57,10 +57,10 @@ ohos_static_library("bytrace_capture_inner") {
|
||||
|
||||
ohos_executable("bytrace") {
|
||||
install_enable = true
|
||||
sources = [ "./src/bytrace.cpp" ]
|
||||
sources = [ "./src/bytrace_cmd.cpp" ]
|
||||
|
||||
deps = [
|
||||
":bytrace_capture_inner",
|
||||
":bytrace_osal_inner",
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//third_party/zlib:libz",
|
||||
"//utils/native/base:utils",
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceOsal {
|
||||
const int MAX_SYS_FILES = 11;
|
||||
enum TraceType { USER, KERNEL };
|
||||
struct TagCategory {
|
||||
@@ -33,6 +36,9 @@ struct TagCategory {
|
||||
|
||||
std::string GetPropertyInner(const std::string& property, const std::string& value);
|
||||
bool SetPropertyInner(const std::string& property, const std::string& value);
|
||||
void RefreshBinderServices();
|
||||
bool RefreshHalServices();
|
||||
bool RefreshBinderServices(void);
|
||||
bool RefreshHalServices(void);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BIN_INCLUDE_BYTRACE_CAPTURE_H
|
||||
@@ -13,7 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bytrace.h"
|
||||
#include <cinttypes>
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
@@ -31,10 +30,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <zlib.h>
|
||||
#include "bytrace_capture.h"
|
||||
#include "bytrace.h"
|
||||
#include "bytrace_osal.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::Developtools::BytraceOsal;
|
||||
|
||||
namespace {
|
||||
struct option g_longOptions[] = {
|
||||
{ "buffer_size", required_argument, nullptr, 0 },
|
||||
@@ -101,7 +103,7 @@ static bool IsTraceMounted()
|
||||
return true;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Error: Did not find trace folder\n");
|
||||
(void)fprintf(stderr, "Error: Did not find trace folder\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -298,8 +300,14 @@ static bool SetTraceTagsEnabled(uint64_t tags)
|
||||
|
||||
static bool RefreshServices()
|
||||
{
|
||||
RefreshBinderServices();
|
||||
return RefreshHalServices();
|
||||
bool res = false;
|
||||
|
||||
res = RefreshBinderServices();
|
||||
if (!res) {
|
||||
return res;
|
||||
}
|
||||
res = RefreshHalServices();
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool SetUserSpaceSettings()
|
||||
@@ -419,8 +427,7 @@ static void ParseLongOpt(const string& cmd, int optionIndex, bool& isTrue)
|
||||
} else if (!strcmp(g_longOptions[optionIndex].name, "output")) {
|
||||
struct stat buf;
|
||||
size_t len = strnlen(optarg, MAX_OUTPUT_LEN);
|
||||
if (len == MAX_OUTPUT_LEN || len < 1 ||
|
||||
(stat(optarg, &buf) == 0 && (buf.st_mode & S_IFDIR))) {
|
||||
if (len == MAX_OUTPUT_LEN || len < 1 || (stat(optarg, &buf) == 0 && (buf.st_mode & S_IFDIR))) {
|
||||
fprintf(stderr, "Error: output file is illegal\n");
|
||||
isTrue = false;
|
||||
} else {
|
||||
@@ -479,8 +486,7 @@ static bool ParseOpt(int opt, char** argv, int optIndex)
|
||||
case 'o': {
|
||||
struct stat buf;
|
||||
size_t len = strnlen(optarg, MAX_OUTPUT_LEN);
|
||||
if (len == MAX_OUTPUT_LEN || len < 1 ||
|
||||
(stat(optarg, &buf) == 0 && (buf.st_mode & S_IFDIR))) {
|
||||
if (len == MAX_OUTPUT_LEN || len < 1 || (stat(optarg, &buf) == 0 && (buf.st_mode & S_IFDIR))) {
|
||||
fprintf(stderr, "Error: output file is illegal\n");
|
||||
isTrue = false;
|
||||
} else {
|
||||
@@ -569,7 +575,7 @@ static bool StopTrace()
|
||||
|
||||
static void DumpCompressedTrace(int traceFd, int outFd)
|
||||
{
|
||||
z_stream zs { 0 };
|
||||
z_stream zs { nullptr };
|
||||
ssize_t bytesWritten;
|
||||
ssize_t bytesRead;
|
||||
if (memset_s(&zs, sizeof(zs), 0, sizeof(zs)) != 0) {
|
||||
@@ -713,9 +719,12 @@ static void InitDiskSupportTags()
|
||||
g_tagMap["mmc"] = { "mmc", "eMMC commands", 0, KERNEL, {
|
||||
{ "events/mmc/enable" },
|
||||
}};
|
||||
g_tagMap["ufs"] = { "ufs", "UFS commands", 0, KERNEL, {
|
||||
{ "events/ufs/enable" },
|
||||
}};
|
||||
}
|
||||
|
||||
static void InitHardwareSupportTags()
|
||||
static void InitHardwareSupportTags()
|
||||
{
|
||||
g_tagMap["irq"] = { "irq", "IRQ Events", 0, KERNEL, {
|
||||
{ "events/irq/enable" },
|
||||
@@ -737,6 +746,16 @@ static void InitHardwareSupportTags()
|
||||
{ "events/i2c/smbus_result/enable" },
|
||||
{ "events/i2c/smbus_reply/enable" },
|
||||
}};
|
||||
g_tagMap["regulators"] = { "regulators", "Voltage and Current Regulators", 0, KERNEL, {
|
||||
{ "events/regulator/enable" },
|
||||
}};
|
||||
g_tagMap["membus"] = { "membus", "Memory Bus Utilization", 0, KERNEL, {
|
||||
{ "events/memory_bus/enable" },
|
||||
}};
|
||||
}
|
||||
|
||||
static void InitCpuSupportTags()
|
||||
{
|
||||
g_tagMap["freq"] = { "freq", "CPU Frequency", 0, KERNEL, {
|
||||
{ "events/power/cpu_frequency/enable" },
|
||||
{ "events/power/clock_set_rate/enable" },
|
||||
@@ -747,14 +766,11 @@ static void InitHardwareSupportTags()
|
||||
{ "events/clk/clk_enable/enable" },
|
||||
{ "events/power/cpu_frequency_limits/enable" },
|
||||
}};
|
||||
g_tagMap["ufs"] = { "ufs", "UFS commands", 0, KERNEL, {
|
||||
{ "events/ufs/enable" },
|
||||
g_tagMap["idle"] = { "idle", "CPU Idle", 0, KERNEL, {
|
||||
{ "events/power/cpu_idle/enable" },
|
||||
}};
|
||||
g_tagMap["regulators"] = { "regulators", "Voltage and Current Regulators", 0, KERNEL, {
|
||||
{ "events/regulator/enable" },
|
||||
}};
|
||||
g_tagMap["membus"] = { "membus", "Memory Bus Utilization", 0, KERNEL, {
|
||||
{ "events/memory_bus/enable" },
|
||||
g_tagMap["load"] = { "load", "CPU Load", 0, KERNEL, {
|
||||
{ "events/cpufreq_interactive/enable" },
|
||||
}};
|
||||
}
|
||||
|
||||
@@ -777,9 +793,6 @@ static void InitKernelSupportTags()
|
||||
{ "events/preemptirq/preempt_enable/enable" },
|
||||
{ "events/preemptirq/preempt_disable/enable" },
|
||||
}};
|
||||
g_tagMap["idle"] = { "idle", "CPU Idle", 0, KERNEL, {
|
||||
{ "events/power/cpu_idle/enable" },
|
||||
}};
|
||||
|
||||
g_tagMap["binder"] = { "binder", "Binder kernel Info", 0, KERNEL, {
|
||||
{ "events/binder/binder_transaction/enable" },
|
||||
@@ -791,9 +804,6 @@ static void InitKernelSupportTags()
|
||||
{ "events/binder/binder_unlock/enable" },
|
||||
}};
|
||||
|
||||
g_tagMap["load"] = { "load", "CPU Load", 0, KERNEL, {
|
||||
{ "events/cpufreq_interactive/enable" },
|
||||
}};
|
||||
g_tagMap["sync"] = { "sync", "Synchronization", 0, KERNEL, {
|
||||
// linux kernel > 4.9
|
||||
{ "events/dma_fence/enable" },
|
||||
@@ -816,6 +826,7 @@ static void InitKernelSupportTags()
|
||||
{ "events/kmem/ion_heap_grow/enable" },
|
||||
{ "events/kmem/ion_heap_shrink/enable" },
|
||||
}};
|
||||
InitCpuSupportTags();
|
||||
InitHardwareSupportTags();
|
||||
}
|
||||
|
||||
@@ -859,8 +870,8 @@ static void InterruptExit(int signo)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
signal(SIGKILL, InterruptExit);
|
||||
signal(SIGINT, InterruptExit);
|
||||
(void)signal(SIGKILL, InterruptExit);
|
||||
(void)signal(SIGINT, InterruptExit);
|
||||
|
||||
if (!IsTraceMounted()) {
|
||||
exit(-1);
|
||||
@@ -13,12 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bytrace_capture.h"
|
||||
#include "bytrace_osal.h"
|
||||
#include "bytrace.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace std;
|
||||
bool SetPropertyInner(const string& property, const string& value)
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceOsal {
|
||||
bool SetPropertyInner(const std::string& property, const std::string& value)
|
||||
{
|
||||
bool result = OHOS::system::SetParameter(property, value);
|
||||
if (!result) {
|
||||
@@ -32,11 +34,15 @@ std::string GetPropertyInner(const std::string& property, const std::string& val
|
||||
return OHOS::system::GetParameter(property, value);
|
||||
}
|
||||
|
||||
void RefreshBinderServices()
|
||||
{
|
||||
}
|
||||
|
||||
bool RefreshHalServices()
|
||||
bool RefreshBinderServices(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RefreshHalServices(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -24,7 +24,7 @@ ohos_unittest("BytraceNDKTest") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/common/native/bytrace_ndk_test.cpp" ]
|
||||
deps = [
|
||||
"${bytrace_path}/bin:bytrace_capture_inner",
|
||||
"${bytrace_path}/bin:bytrace_osal_inner",
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <hilog/log.h>
|
||||
#include "bytrace.h"
|
||||
#include "bytrace_capture.h"
|
||||
#include "bytrace_osal.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace std;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
using namespace OHOS::Developtools::BytraceOsal;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceTest {
|
||||
|
||||
@@ -16,8 +16,8 @@ import("//build/ohos.gni")
|
||||
group("jsapi_kits_target") {
|
||||
if (support_jsapi) {
|
||||
deps = [
|
||||
"js/napi:bytrace",
|
||||
"js/napi:hitracemeter_napi",
|
||||
"//developtools/bytrace_standard/interfaces/kits/js/napi:bytrace",
|
||||
"//developtools/bytrace_standard/interfaces/kits/js/napi:hitracemeter_napi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import("//developtools/bytrace_standard/bytrace.gni")
|
||||
ohos_shared_library("bytrace") {
|
||||
sources = [
|
||||
"bytrace.cpp",
|
||||
"declare_napi.cpp",
|
||||
"bytrace_napi_common.cpp",
|
||||
]
|
||||
deps = [
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
@@ -33,7 +33,7 @@ ohos_shared_library("bytrace") {
|
||||
|
||||
ohos_shared_library("hitracemeter_napi") {
|
||||
sources = [
|
||||
"declare_napi.cpp",
|
||||
"bytrace_napi_common.cpp",
|
||||
"hitracemeter.cpp",
|
||||
]
|
||||
deps = [
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <hilog/log.h>
|
||||
#include "bytrace.h"
|
||||
#include "declare_napi.h"
|
||||
#include "bytrace_napi_common.h"
|
||||
|
||||
using namespace OHOS::Developtools::BytraceNapi;
|
||||
|
||||
/*
|
||||
* bytrace module definition
|
||||
|
||||
+11
-8
@@ -13,15 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "declare_napi.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <hilog/log.h>
|
||||
#include "bytrace.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "bytrace.h"
|
||||
#include "bytrace_napi_common.h"
|
||||
|
||||
using namespace OHOS::HiviewDFX;
|
||||
namespace {
|
||||
@@ -44,7 +43,7 @@ static napi_value JSTraceStart(napi_env env, napi_callback_info info)
|
||||
char buf[NAME_MAX_SIZE] = {0};
|
||||
size_t len = 0;
|
||||
napi_get_value_string_utf8(env, argv[0], buf, NAME_MAX_SIZE, &len);
|
||||
std::string name = std::string{buf};
|
||||
std::string name = std::string {buf};
|
||||
|
||||
NAPI_CALL(env, napi_typeof(env, argv[1], &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_number, "Second arg type error, should is number");
|
||||
@@ -76,7 +75,7 @@ static napi_value JSTraceFinish(napi_env env, napi_callback_info info)
|
||||
char buf[NAME_MAX_SIZE] = {0};
|
||||
size_t len = 0;
|
||||
napi_get_value_string_utf8(env, argv[0], buf, NAME_MAX_SIZE, &len);
|
||||
std::string name = std::string{buf};
|
||||
std::string name = std::string {buf};
|
||||
|
||||
NAPI_CALL(env, napi_typeof(env, argv[1], &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_number, "Second arg type error, should is number");
|
||||
@@ -100,7 +99,7 @@ static napi_value JSTraceCount(napi_env env, napi_callback_info info)
|
||||
char buf[NAME_MAX_SIZE] = {0};
|
||||
size_t len = 0;
|
||||
napi_get_value_string_utf8(env, argv[0], buf, NAME_MAX_SIZE, &len);
|
||||
std::string name = std::string{buf};
|
||||
std::string name = std::string {buf};
|
||||
|
||||
NAPI_CALL(env, napi_typeof(env, argv[1], &valueType));
|
||||
NAPI_ASSERT(env, valueType == napi_number, "Second arg type error, should is number");
|
||||
@@ -110,7 +109,9 @@ static napi_value JSTraceCount(napi_env env, napi_callback_info info)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EXTERN_C_START
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceNapi {
|
||||
/*
|
||||
* function for module exports
|
||||
*/
|
||||
@@ -124,4 +125,6 @@ napi_value BytraceInit(napi_env env, napi_value exports)
|
||||
NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc));
|
||||
return exports;
|
||||
}
|
||||
EXTERN_C_END
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -19,8 +19,12 @@
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
EXTERN_C_START
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceNapi {
|
||||
napi_value BytraceInit(napi_env env, napi_value exports);
|
||||
EXTERN_C_END
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INTERFACES_KITS_JS_NAPI_DECLARE_NAPI_H
|
||||
@@ -17,8 +17,9 @@
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <hilog/log.h>
|
||||
#include "bytrace.h"
|
||||
#include "declare_napi.h"
|
||||
#include "bytrace_napi_common.h"
|
||||
|
||||
using namespace OHOS::Developtools::BytraceNapi;
|
||||
|
||||
/*
|
||||
* hiTraceMeter module definition
|
||||
|
||||
Reference in New Issue
Block a user