libmicroemu 0.2.0
ARM Microcontroller Emulator Library
Loading...
Searching...
No Matches
status_code.h
Go to the documentation of this file.
1
5#pragma once
6
7#include "libmicroemu/types.h"
8#include <cstdlib>
9#include <string_view>
10#include <type_traits>
11
12namespace libmicroemu {
13
17enum class StatusCode : u32 {
18
20 kSuccess = 0x0U,
21
22 // Unspecified errors
23
25 kError = 0x1U,
26
28 kUnexpected = 0x1002U,
29
31 kUnsuporrted = 0x1003U,
32
34 kNotImplemented = 0x1004U,
35
36 // Generic errors
37
39 kOutOfRange = 0x2001U,
40
43
45 kBufferTooSmall = 0x2003U,
46
48 kOpenFileFailed = 0x2004U,
49
50 // Memory related errors
51
53 kMemInaccesible = 0x3001U,
54
57
58 // Decoder related errors
59
62
67
70
71 // Executor related errors
72
77
80
83
84 // ELF reader related errors
85
87 kElfNotValid = 0x6001U,
88
90 kElfWrongHeader = 0x6002U,
91
92 // ARM related errors
93
95 kUsageFault = 0x7001U,
96
97 // Execution result
98
101};
102
108static std::string_view StatusCodeToString(const StatusCode &status_code) noexcept {
109 switch (status_code) {
111 return "Success";
112 }
113 case StatusCode::kError: {
114 return "Error";
115 }
117 return "OutOfRange";
118 }
120 return "MemInaccesible";
121 }
123 return "IteratorExhausted";
124 }
126 return "DecoderUnknownOpCode";
127 }
129 return "DecoderUnpredictable";
130 }
132 return "DecoderUndefined";
133 }
135 return "ExecutorUnpredictable";
136 }
138 return "MemWriteNotAllowed";
139 }
141 return "BufferTooSmall";
142 }
144 return "ElfWrongHeader";
145 }
147 return "ElfNotValid";
148 }
150 return "OpenFileFailed";
151 }
153 return "NotImplemented";
154 }
156 return "Unexpected";
157 }
159 return "ExecutorExitWithError";
160 }
162 return "ExecutorUndefined";
163 }
165 return "UsageFault";
166 }
168 return "Unsuporrted";
169 }
171 return "MaxInstructionsReached";
172 }
173 default: {
174 return "UnknownStatusCode";
175 }
176 }
177 return "UnknownStatusCode";
178}
179} // namespace libmicroemu
The libmicroemu namespace contains all classes and functions of the libmicroemu which are public.
Definition bkpt_flags.h:6
@ kError
Error log level.
Definition logger.h:18
@ kUsageFault
Usage fault exception, triggered by errors in the usage of the processor.
Definition exception_type.h:30
static std::string_view StatusCodeToString(const StatusCode &status_code) noexcept
Converts a status code to a string.
Definition status_code.h:108
StatusCode
Enum representing various status codes used throughout the system.
Definition status_code.h:17
@ kElfNotValid
ELF file is not valid.
Definition status_code.h:87
@ kUnsuporrted
Operation or feature is unsupported.
Definition status_code.h:31
@ kBufferTooSmall
Provided buffer is too small.
Definition status_code.h:45
@ kOpenFileFailed
Failed to open the file.
Definition status_code.h:48
@ kMaxInstructionsReached
Maximum instruction count reached.
Definition status_code.h:100
@ kUnexpected
An unexpected error occurred.
Definition status_code.h:28
@ kExecutorExitWithError
Executor exited with an error.
Definition status_code.h:82
@ kIteratorExhausted
Iterator has been exhausted.
Definition status_code.h:42
@ kDecoderUndefined
Decoder encountered an undefined operation.
Definition status_code.h:69
@ kDecoderUnknownOpCode
Decoder encountered an unknown opcode.
Definition status_code.h:61
@ kExecutorUndefined
Executor encountered an undefined operation.
Definition status_code.h:79
@ kSuccess
Operation succeeded successfully.
Definition status_code.h:20
@ kUsageFault
Usage fault occurred.
Definition status_code.h:95
@ kMemInaccesible
Memory is inaccessible.
Definition status_code.h:53
@ kMemWriteNotAllowed
Memory write operation is not allowed.
Definition status_code.h:56
@ kDecoderUnpredictable
Decoder encountered an unpredictable operation.
Definition status_code.h:66
@ kExecutorUnpredictable
Executor encountered an unpredictable operation.
Definition status_code.h:76
@ kElfWrongHeader
ELF file has a wrong header.
Definition status_code.h:90
@ kError
An unspecified error occurred.
Definition status_code.h:25
@ kNotImplemented
Operation or feature is not implemented.
Definition status_code.h:34
@ kOutOfRange
Value is out of the allowed range.
Definition status_code.h:39