• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 ASAN_COLLECTOR_H
17 #define ASAN_COLLECTOR_H
18 #include <cstdio>
19 #include <string>
20 #include <unordered_map>
21 
22 #include "sanitizerd_collector.h"
23 #include "sanitizerd_log.h"
24 
25 namespace OHOS {
26 namespace HiviewDFX {
27 // asan collector.
28 class AsanCollector : public SanitizerdCollector {
29 public:
30     explicit AsanCollector(std::unordered_map<std::string, std::string> &stkmap);
31 
32     ~AsanCollector() override;
33     void Collect(const std::string& filepath);
34     bool ComputeStackSignature(const std::string& asanDump,
35                                std::string& asanSignature, bool printDiagnostics);
36 
37 protected:
38     virtual bool ReadRecordToString(std::string& fullFile, const std::string& fileName);
39     virtual void ProcessStackTrace(const std::string& asanDump, bool printDiagnostics, unsigned *hash);
40     int UpdateCollectedData(const std::string& hash, const std::string& rfile);
41     bool IsDuplicate(const std::string& hash);
42     void CalibrateErrTypeProcName();
43     void SetHappenTime();
44 };
45 } // namespace HiviewDFX
46 } // namespace OHOS
47 
48 #endif // ASAN_COLLECTOR_H
49 
50