• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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 <stdint.h>
20 
21 namespace unwindstack {
22 
23 // A bit map of warnings, multiple warnings can be set at the same time.
24 enum WarningCode : uint64_t {
25   WARNING_NONE = 0,
26   WARNING_DEX_PC_NOT_IN_MAP = 0x1,  // A dex pc was found, but it doesn't exist
27                                     // in any valid map.
28 };
29 
30 enum ErrorCode : uint8_t {
31   ERROR_NONE,                   // No error.
32   ERROR_MEMORY_INVALID,         // Memory read failed.
33   ERROR_UNWIND_INFO,            // Unable to use unwind information to unwind.
34   ERROR_UNSUPPORTED,            // Encountered unsupported feature.
35   ERROR_INVALID_MAP,            // Unwind in an invalid map.
36   ERROR_MAX_FRAMES_EXCEEDED,    // The number of frames exceed the total allowed.
37   ERROR_REPEATED_FRAME,         // The last frame has the same pc/sp as the next.
38   ERROR_INVALID_ELF,            // Unwind in an invalid elf.
39   ERROR_THREAD_DOES_NOT_EXIST,  // Attempt to unwind a local thread that does
40                                 // not exist.
41   ERROR_THREAD_TIMEOUT,         // Timeout trying to unwind a local thread.
42   ERROR_SYSTEM_CALL,            // System call failed while unwinding.
43   ERROR_BAD_ARCH,               // Arch invalid (none, or mismatched).
44   ERROR_MAPS_PARSE,             // Failed to parse maps data.
45   ERROR_INVALID_PARAMETER,      // Invalid parameter passed to function.
46   ERROR_MAX = ERROR_INVALID_PARAMETER,
47 };
48 
GetErrorCodeString(ErrorCode error)49 static inline const char* GetErrorCodeString(ErrorCode error) {
50   switch (error) {
51     case ERROR_NONE:
52       return "None";
53     case ERROR_MEMORY_INVALID:
54       return "Memory Invalid";
55     case ERROR_UNWIND_INFO:
56       return "Unwind Info";
57     case ERROR_UNSUPPORTED:
58       return "Unsupported";
59     case ERROR_INVALID_MAP:
60       return "Invalid Map";
61     case ERROR_MAX_FRAMES_EXCEEDED:
62       return "Maximum Frames Exceeded";
63     case ERROR_REPEATED_FRAME:
64       return "Repeated Frame";
65     case ERROR_INVALID_ELF:
66       return "Invalid Elf";
67     case ERROR_THREAD_DOES_NOT_EXIST:
68       return "Thread Does Not Exist";
69     case ERROR_THREAD_TIMEOUT:
70       return "Thread Timeout";
71     case ERROR_SYSTEM_CALL:
72       return "System Call Failed";
73     case ERROR_BAD_ARCH:
74       return "Invalid arch detected";
75     case ERROR_MAPS_PARSE:
76       return "Failed to parse maps";
77     case ERROR_INVALID_PARAMETER:
78       return "Invalid parameter";
79   }
80 }
81 
82 struct ErrorData {
83   ErrorCode code;
84   uint64_t address;  // Only valid when code is ERROR_MEMORY_INVALID.
85                      // Indicates the failing address.
86 };
87 
88 }  // namespace unwindstack
89