Initial work on a ErrorData structure to use globally
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <backend/RomHelpers.hpp>
|
||||
#include <cassert>
|
||||
#include <Core.hpp>
|
||||
#include <unarr.h>
|
||||
#include <Options.hpp>
|
||||
|
||||
namespace n64 {
|
||||
|
||||
@@ -70,9 +70,7 @@ bool MupenMovie::Load(const fs::path &path) {
|
||||
}
|
||||
|
||||
MupenMovie::MupenMovie(const fs::path &path) {
|
||||
if (!Load(path)) {
|
||||
panic("");
|
||||
}
|
||||
Load(path);
|
||||
}
|
||||
|
||||
void MupenMovie::Reset() {
|
||||
|
||||
@@ -1,24 +1,7 @@
|
||||
#pragma once
|
||||
#include <bitset>
|
||||
#include <cstdint>
|
||||
#ifdef USE_NEON
|
||||
#include <sse2neon.h>
|
||||
#else
|
||||
#include <emmintrin.h>
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
|
||||
using u8 = uint8_t;
|
||||
using u16 = uint16_t;
|
||||
using u32 = uint32_t;
|
||||
using u64 = uint64_t;
|
||||
using s8 = int8_t;
|
||||
using s16 = int16_t;
|
||||
using s32 = int32_t;
|
||||
using s64 = int64_t;
|
||||
using u128 = __uint128_t;
|
||||
using s128 = __int128_t;
|
||||
using m128i = __m128i;
|
||||
#include <types.hpp>
|
||||
#include <ErrorData.hpp>
|
||||
|
||||
#define FORCE_INLINE inline __attribute__((always_inline))
|
||||
|
||||
|
||||
20
src/types.hpp
Normal file
20
src/types.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#ifdef USE_NEON
|
||||
#include <sse2neon.h>
|
||||
#else
|
||||
#include <emmintrin.h>
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
|
||||
using u8 = uint8_t;
|
||||
using u16 = uint16_t;
|
||||
using u32 = uint32_t;
|
||||
using u64 = uint64_t;
|
||||
using s8 = int8_t;
|
||||
using s16 = int16_t;
|
||||
using s32 = int32_t;
|
||||
using s64 = int64_t;
|
||||
using u128 = __uint128_t;
|
||||
using s128 = __int128_t;
|
||||
using m128i = __m128i;
|
||||
79
src/utils/ErrorData.hpp
Normal file
79
src/utils/ErrorData.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <types.hpp>
|
||||
#include <format>
|
||||
#include <optional>
|
||||
|
||||
namespace Util {
|
||||
struct Error {
|
||||
enum Severity {
|
||||
NONE,
|
||||
WARN,
|
||||
ERROR,
|
||||
FATAL,
|
||||
};
|
||||
|
||||
union MemoryAccess {
|
||||
struct {
|
||||
unsigned : 3;
|
||||
unsigned is_write : 1;
|
||||
unsigned is_fatal : 1;
|
||||
unsigned size : 3;
|
||||
};
|
||||
|
||||
u8 raw;
|
||||
};
|
||||
|
||||
enum Type {
|
||||
SCHEDULER_EOL,
|
||||
SCHEDULER_UNKNOWN,
|
||||
UNHANDLED_EXCEPTION,
|
||||
UNHANDLED_INSTRUCTION,
|
||||
INVALID_INSTRUCTION_FORMAT,
|
||||
TLB_LIMIT_EXCEEDED,
|
||||
TLB_INVALID_ERROR,
|
||||
TLB_UNHANDLED_ERROR,
|
||||
TLB_UNHANDLED_MAPPING,
|
||||
JIT_BRANCH_INSIDE_DELAY_SLOT,
|
||||
JIT_INVALID_X86_REG_ADDRESSING,
|
||||
COULD_NOT_SYNC_SAVE_DATA,
|
||||
SAVE_DATA_IS_CORRUPT_OR_INVALID_SIZE,
|
||||
MMAP_MAKE_SINK_ERROR,
|
||||
MEM_INVALID_ACCESS,
|
||||
MEM_UNHANDLED_ACCESS,
|
||||
RDP_LIMIT_EXCEEDED,
|
||||
FLASH_EXECUTE_COMMAND_ERROR,
|
||||
PIF_UNHANDLED_CHANNEL,
|
||||
UNHANDLED_COP0_STATUS_BIT,
|
||||
COP0_INVALID_ACCESS,
|
||||
COP0_UNHANDLED_ACCESS,
|
||||
SYSTEM_DIALOG_ERROR,
|
||||
TAS_LOAD_ERROR,
|
||||
ROM_LOAD_ERROR,
|
||||
SAVE_OPTIONS_ERROR,
|
||||
};
|
||||
|
||||
template <class... Args>
|
||||
std::string Format(Severity severity,
|
||||
std::optional<u64> lastPC,
|
||||
std::optional<MemoryAccess> memoryAccess,
|
||||
std::optional<Type> type,
|
||||
const std::format_string<Args...> fmt, Args... args) {
|
||||
this->severity = severity;
|
||||
this->lastPC = lastPC;
|
||||
this->memoryAccess = memoryAccess;
|
||||
this->type = type;
|
||||
return std::format(fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
static Error& Get() {
|
||||
static Error instance;
|
||||
return instance;
|
||||
}
|
||||
private:
|
||||
Severity severity = NONE;
|
||||
Type type = {};
|
||||
std::optional<u64> lastPC = {};
|
||||
std::optional<MemoryAccess> memoryAccess = {};
|
||||
};
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
#include <fstream>
|
||||
#include <log.hpp>
|
||||
#include <vector>
|
||||
#include <unarr.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
namespace Util {
|
||||
FORCE_INLINE std::vector<u8> ReadFileBinary(const std::string &path) {
|
||||
@@ -38,13 +42,13 @@ FORCE_INLINE size_t NextPow2(size_t num) {
|
||||
return num + 1;
|
||||
}
|
||||
|
||||
FORCE_INLINE std::vector<u8> OpenROM(const std::string &, size_t &) {
|
||||
FORCE_INLINE std::vector<u8> OpenROM(const std::string &filename, size_t &sizeAdjusted) {
|
||||
auto buf = Util::ReadFileBinary(filename);
|
||||
sizeAdjusted = Util::NextPow2(buf.size());
|
||||
return buf;
|
||||
}
|
||||
|
||||
FORCE_INLINE std::vector<u8> OpenArchive(const std::string &, size_t &) {
|
||||
FORCE_INLINE std::vector<u8> OpenArchive(const std::string &path, size_t &sizeAdjusted) {
|
||||
const auto stream = ar_open_file(fs::path(path).string().c_str());
|
||||
|
||||
if (!stream) {
|
||||
|
||||
Reference in New Issue
Block a user