mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-19 17:02:14 +00:00
stratosphere: In-class initialize members
Same thing, less code, less boilerplate.
This commit is contained in:
parent
5b3e8e1c5d
commit
e088a2f414
8 changed files with 42 additions and 54 deletions
|
@ -14,11 +14,9 @@ struct CodeInfo {
|
|||
class CodeList {
|
||||
private:
|
||||
static const size_t max_code_count = 0x10;
|
||||
u32 code_count;
|
||||
u32 code_count = 0;
|
||||
CodeInfo code_infos[max_code_count];
|
||||
public:
|
||||
CodeList() : code_count(0) { }
|
||||
|
||||
public:
|
||||
void ReadCodeRegionsFromProcess(Handle debug_handle, u64 pc, u64 lr);
|
||||
void SaveToFile(FILE *f_report);
|
||||
private:
|
||||
|
|
|
@ -23,30 +23,27 @@ enum class CrashReportResult : Result {
|
|||
|
||||
class CrashReport {
|
||||
private:
|
||||
Handle debug_handle;
|
||||
Handle debug_handle = INVALID_HANDLE;
|
||||
bool has_extra_info;
|
||||
Result result;
|
||||
Result result = static_cast<Result>(CrashReportResult::IncompleteReport);
|
||||
|
||||
/* Attach Process Info. */
|
||||
AttachProcessInfo process_info;
|
||||
u64 dying_message_address;
|
||||
u64 dying_message_size;
|
||||
u8 dying_message[0x1000];
|
||||
AttachProcessInfo process_info{};
|
||||
u64 dying_message_address = 0;
|
||||
u64 dying_message_size = 0;
|
||||
u8 dying_message[0x1000]{};
|
||||
|
||||
static_assert(sizeof(dying_message) == 0x1000, "Incorrect definition for dying message!");
|
||||
|
||||
/* Exception Info. */
|
||||
ExceptionInfo exception_info;
|
||||
ExceptionInfo exception_info{};
|
||||
ThreadInfo crashed_thread_info;
|
||||
|
||||
/* Extra Info. */
|
||||
CodeList code_list;
|
||||
ThreadList thread_list;
|
||||
|
||||
public:
|
||||
CrashReport() : debug_handle(INVALID_HANDLE), result((Result)CrashReportResult::IncompleteReport), process_info{0}, dying_message_address(0),
|
||||
dying_message_size(0), dying_message{0}, exception_info({}) { }
|
||||
|
||||
public:
|
||||
void BuildReport(u64 pid, bool has_extra_info);
|
||||
void SaveReport();
|
||||
|
||||
|
@ -98,4 +95,4 @@ class CrashReport {
|
|||
|
||||
void EnsureReportDirectories();
|
||||
bool GetCurrentTime(u64 *out);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -31,15 +31,13 @@ static_assert(sizeof(DebugThreadContext) == 0x320, "Incorrect DebugThreadContext
|
|||
|
||||
class ThreadInfo {
|
||||
private:
|
||||
DebugThreadContext context;
|
||||
u64 thread_id;
|
||||
u64 stack_top;
|
||||
u64 stack_bottom;
|
||||
u64 stack_trace[0x20];
|
||||
u32 stack_trace_size;
|
||||
public:
|
||||
ThreadInfo() : context{0}, thread_id(0), stack_top(0), stack_bottom(0), stack_trace{0}, stack_trace_size(0) { }
|
||||
|
||||
DebugThreadContext context{};
|
||||
u64 thread_id = 0;
|
||||
u64 stack_top = 0;
|
||||
u64 stack_bottom = 0;
|
||||
u64 stack_trace[0x20]{};
|
||||
u32 stack_trace_size = 0;
|
||||
public:
|
||||
u64 GetPC() { return context.pc; }
|
||||
u64 GetLR() { return context.lr; }
|
||||
u64 GetId() { return thread_id; }
|
||||
|
@ -54,11 +52,9 @@ class ThreadInfo {
|
|||
class ThreadList {
|
||||
private:
|
||||
static const size_t max_thread_count = 0x60;
|
||||
u32 thread_count;
|
||||
u32 thread_count = 0;
|
||||
ThreadInfo thread_infos[max_thread_count];
|
||||
public:
|
||||
ThreadList() : thread_count(0) { }
|
||||
|
||||
public:
|
||||
void SaveToFile(FILE *f_report);
|
||||
void DumpBinary(FILE *f_bin, u64 crashed_id);
|
||||
void ReadThreadsFromProcess(Handle debug_handle, bool is_64_bit);
|
||||
|
|
|
@ -174,13 +174,13 @@ class RomFSBuildContext {
|
|||
RomFSBuildDirectoryContext *root;
|
||||
std::map<char *, RomFSBuildDirectoryContext *, build_ctx_cmp> directories;
|
||||
std::map<char *, RomFSBuildFileContext *, build_ctx_cmp> files;
|
||||
u64 num_dirs;
|
||||
u64 num_files;
|
||||
u64 dir_table_size;
|
||||
u64 file_table_size;
|
||||
u64 dir_hash_table_size;
|
||||
u64 file_hash_table_size;
|
||||
u64 file_partition_size;
|
||||
u64 num_dirs = 0;
|
||||
u64 num_files = 0;
|
||||
u64 dir_table_size = 0;
|
||||
u64 file_table_size = 0;
|
||||
u64 dir_hash_table_size = 0;
|
||||
u64 file_hash_table_size = 0;
|
||||
u64 file_partition_size = 0;
|
||||
|
||||
FsDirectoryEntry dir_entry;
|
||||
RomFSDataSource cur_source_type;
|
||||
|
@ -191,7 +191,7 @@ class RomFSBuildContext {
|
|||
bool AddDirectory(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildDirectoryContext *dir_ctx, RomFSBuildDirectoryContext **out_dir_ctx);
|
||||
bool AddFile(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildFileContext *file_ctx);
|
||||
public:
|
||||
RomFSBuildContext(u64 tid) : title_id(tid), num_dirs(0), num_files(0), dir_table_size(0), file_table_size(0), dir_hash_table_size(0), file_hash_table_size(0), file_partition_size(0) {
|
||||
RomFSBuildContext(u64 tid) : title_id(tid) {
|
||||
this->root = new RomFSBuildDirectoryContext({0});
|
||||
this->root->path = new char[1];
|
||||
this->root->path[0] = '\x00';
|
||||
|
|
|
@ -12,11 +12,11 @@ enum class FspSrvCmd {
|
|||
|
||||
class FsMitMService : public IMitMServiceObject {
|
||||
private:
|
||||
bool has_initialized;
|
||||
u64 init_pid;
|
||||
bool has_initialized = false;
|
||||
u64 init_pid = 0;
|
||||
std::shared_ptr<IStorageInterface> romfs_storage;
|
||||
public:
|
||||
FsMitMService(Service *s) : IMitMServiceObject(s), has_initialized(false), init_pid(0) {
|
||||
FsMitMService(Service *s) : IMitMServiceObject(s) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,11 @@ class MapUtils {
|
|||
|
||||
class AutoCloseMap {
|
||||
private:
|
||||
void *mapped_address;
|
||||
u64 base_address;
|
||||
u64 size;
|
||||
Handle process_handle;
|
||||
void *mapped_address = nullptr;
|
||||
u64 base_address = 0;
|
||||
u64 size = 0;
|
||||
Handle process_handle = 0;
|
||||
public:
|
||||
AutoCloseMap() : mapped_address(0), base_address(0), size(0), process_handle(0) { };
|
||||
~AutoCloseMap() {
|
||||
Close();
|
||||
}
|
||||
|
@ -154,4 +153,4 @@ struct MappedCodeMemory {
|
|||
}
|
||||
*this = (const MappedCodeMemory){0};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -13,11 +13,10 @@ enum RoServiceCmd {
|
|||
};
|
||||
|
||||
class RelocatableObjectsService final : public IServiceObject {
|
||||
Handle process_handle;
|
||||
u64 process_id;
|
||||
bool has_initialized;
|
||||
Handle process_handle = 0;
|
||||
u64 process_id = U64_MAX;
|
||||
bool has_initialized = false;
|
||||
public:
|
||||
RelocatableObjectsService() : process_handle(0), process_id(U64_MAX), has_initialized(false) { }
|
||||
~RelocatableObjectsService() {
|
||||
Registration::CloseRoService(this, this->process_handle);
|
||||
if (this->has_initialized) {
|
||||
|
|
|
@ -14,12 +14,11 @@ enum UserServiceCmd {
|
|||
};
|
||||
|
||||
class UserService final : public IServiceObject {
|
||||
u64 pid;
|
||||
bool has_initialized;
|
||||
u64 deferred_service;
|
||||
u64 pid = U64_MAX;
|
||||
bool has_initialized = false;
|
||||
u64 deferred_service = 0;
|
||||
|
||||
public:
|
||||
UserService() : pid(U64_MAX), has_initialized(false), deferred_service(0) { }
|
||||
Result dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
|
||||
Result handle_deferred() override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue