• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef HITRACE_COMMON_UTILS_H
17 #define HITRACE_COMMON_UTILS_H
18 
19 #include <cinttypes>
20 #include <string>
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 namespace Hitrace {
25 std::string CanonicalizeSpecPath(const char* src);
26 
27 bool MarkClockSync(const std::string& traceRootPath);
28 
29 bool IsNumber(const std::string& str);
30 
31 int GetCpuProcessors();
32 
33 uint64_t GetCurBootTime();
34 
35 void ReadCurrentCpuFrequencies(std::string& freqs);
36 
37 std::string GetPropertyInner(const std::string& property, const std::string& value);
38 
39 bool SetPropertyInner(const std::string& property, const std::string& value);
40 
41 bool IsHmKernel();
42 
43 bool IsDeveloperMode();
44 
45 bool IsRootVersion();
46 
47 bool IsTraceMounted(std::string& traceRootPath);
48 
49 std::string GetFilePath(const std::string& fileName, const std::string& traceRootPath);
50 
51 std::string ReadFileInner(const std::string& filename);
52 
53 std::string ReadFile(const std::string& filename, const std::string& traceRootPath);
54 
55 bool IsTracingOn(const std::string& traceRootPath);
56 
57 bool StringToInt(const std::string &str, int &val);
58 
59 bool StringToInt64(const std::string &str, int64_t &val);
60 
61 bool StringToUint64(const std::string &str, uint64_t &val);
62 
63 bool StringToDouble(const std::string &str, double &val);
64 
65 void WriteEventFile(const std::string& srcPath, const int fd);
66 
67 std::string GetKernelVersion();
68 
69 uint64_t GetRemainingSpace(const std::string& path);
70 
71 } // namespace Hitrace
72 } // namespace HiviewDFX
73 } // namespace OHOS
74 #endif // HITRACE_COMMON_UTILS_H