• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 HIVIEWDFX_HIVIEW_TRACE_DYNAMIC_STATE_H
17 #define HIVIEWDFX_HIVIEW_TRACE_DYNAMIC_STATE_H
18 
19 #include "time_util.h"
20 #include "trace_common.h"
21 #include "trace_base_state.h"
22 
23 namespace OHOS::HiviewDFX {
24 class DynamicState : public TraceBaseState {
25 public:
DynamicState(int32_t appPid)26     explicit DynamicState(int32_t appPid) : appPid_(appPid)
27     {
28         taskBeginTime_ = TimeUtil::GetMilliseconds();
29     }
30 
31     TraceRet OpenTrace(TraceScenario scenario, const std::vector<std::string> &tagGroups) override;
32     TraceRet OpenTrace(TraceScenario scenario, const std::string &args) override;
33     TraceRet OpenAppTrace(int32_t appPid) override;
34     TraceRet OpenTelemetryTrace(const std::string &args, TelemetryPolicy policy) override;
35     TraceRet DumpTrace(TraceScenario scenario, uint32_t maxDuration, uint64_t happenTime, TraceRetInfo &info) override;
36     TraceRet CloseTrace(TraceScenario scenario) override;
37 
GetTaskBeginTime()38     uint64_t GetTaskBeginTime() override
39     {
40         return taskBeginTime_;
41     }
42 
GetAppPid()43     int32_t GetAppPid() override
44     {
45         return appPid_;
46     }
47 
48 protected:
GetTag()49     std::string GetTag() override
50     {
51         return "DynamicState";
52     }
53 
54 private:
55     int32_t appPid_ = -1;
56     uint64_t taskBeginTime_ = 0;
57 };
58 }
59 #endif //HIVIEWDFX_HIVIEW_TRACE_DYNAMIC_STATE_H
60