1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "types.h"
20 #include "utility.h"
21 
22 #include <memory.h>
23 
24 #include "scudo/interface.h"
25 
26 // Forward delcarations
27 class Cause;
28 class Tombstone;
29 
30 namespace unwindstack {
31 class AndroidUnwinder;
32 class Memory;
33 }  // namespace unwindstack
34 
35 class ScudoCrashData {
36  public:
37   ScudoCrashData() = delete;
38   ~ScudoCrashData() = default;
39   ScudoCrashData(unwindstack::Memory* process_memory, const ProcessInfo& process_info);
40 
41   bool CrashIsMine() const;
42 
43   void AddCauseProtos(Tombstone* tombstone, unwindstack::AndroidUnwinder* unwinder) const;
44 
45  private:
46   scudo_error_info error_info_ = {};
47   uintptr_t untagged_fault_addr_;
48 
49   void FillInCause(Cause* cause, const scudo_error_report* report,
50                    unwindstack::AndroidUnwinder* unwinder) const;
51 };
52