• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2024 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 PANDA_RUNTIME_TOOLING_THREAD_SAMPLING_INFO_H
17 #define PANDA_RUNTIME_TOOLING_THREAD_SAMPLING_INFO_H
18 
19 #include <csetjmp>
20 #include "libpandabase/macros.h"
21 
22 namespace ark::tooling::sampler {
23 
24 class ThreadSamplingInfo {
25 public:
26     ThreadSamplingInfo() = default;
27     ~ThreadSamplingInfo() = default;
28 
29     NO_COPY_SEMANTIC(ThreadSamplingInfo);
30     NO_MOVE_SEMANTIC(ThreadSamplingInfo);
31 
IsThreadSampling()32     bool IsThreadSampling() const
33     {
34         return isThreadSampling_;
35     }
36 
SetThreadSampling(bool threadSampling)37     void SetThreadSampling(bool threadSampling)
38     {
39         isThreadSampling_ = threadSampling;
40     }
41 
GetSigSegvJmpEnv()42     jmp_buf &GetSigSegvJmpEnv()
43     {
44         return sigsegvJmpEnv_;
45     }
46 
47 private:
48     bool isThreadSampling_ {false};
49 
50     // Environment that saved by setjmp in SIGPROF handler in Sampler
51     // Used for longjmp in case of SIGSEGV during thread sampling
52     jmp_buf sigsegvJmpEnv_ {};
53 };
54 
55 }  // namespace ark::tooling::sampler
56 
57 #endif  // PANDA_RUNTIME_TOOLING_THREAD_SAMPLING_INFO_H
58