mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-10 07:06:34 +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 {
|
class CodeList {
|
||||||
private:
|
private:
|
||||||
static const size_t max_code_count = 0x10;
|
static const size_t max_code_count = 0x10;
|
||||||
u32 code_count;
|
u32 code_count = 0;
|
||||||
CodeInfo code_infos[max_code_count];
|
CodeInfo code_infos[max_code_count];
|
||||||
public:
|
public:
|
||||||
CodeList() : code_count(0) { }
|
|
||||||
|
|
||||||
void ReadCodeRegionsFromProcess(Handle debug_handle, u64 pc, u64 lr);
|
void ReadCodeRegionsFromProcess(Handle debug_handle, u64 pc, u64 lr);
|
||||||
void SaveToFile(FILE *f_report);
|
void SaveToFile(FILE *f_report);
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -23,20 +23,20 @@ enum class CrashReportResult : Result {
|
||||||
|
|
||||||
class CrashReport {
|
class CrashReport {
|
||||||
private:
|
private:
|
||||||
Handle debug_handle;
|
Handle debug_handle = INVALID_HANDLE;
|
||||||
bool has_extra_info;
|
bool has_extra_info;
|
||||||
Result result;
|
Result result = static_cast<Result>(CrashReportResult::IncompleteReport);
|
||||||
|
|
||||||
/* Attach Process Info. */
|
/* Attach Process Info. */
|
||||||
AttachProcessInfo process_info;
|
AttachProcessInfo process_info{};
|
||||||
u64 dying_message_address;
|
u64 dying_message_address = 0;
|
||||||
u64 dying_message_size;
|
u64 dying_message_size = 0;
|
||||||
u8 dying_message[0x1000];
|
u8 dying_message[0x1000]{};
|
||||||
|
|
||||||
static_assert(sizeof(dying_message) == 0x1000, "Incorrect definition for dying message!");
|
static_assert(sizeof(dying_message) == 0x1000, "Incorrect definition for dying message!");
|
||||||
|
|
||||||
/* Exception Info. */
|
/* Exception Info. */
|
||||||
ExceptionInfo exception_info;
|
ExceptionInfo exception_info{};
|
||||||
ThreadInfo crashed_thread_info;
|
ThreadInfo crashed_thread_info;
|
||||||
|
|
||||||
/* Extra Info. */
|
/* Extra Info. */
|
||||||
|
@ -44,9 +44,6 @@ class CrashReport {
|
||||||
ThreadList thread_list;
|
ThreadList thread_list;
|
||||||
|
|
||||||
public:
|
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({}) { }
|
|
||||||
|
|
||||||
void BuildReport(u64 pid, bool has_extra_info);
|
void BuildReport(u64 pid, bool has_extra_info);
|
||||||
void SaveReport();
|
void SaveReport();
|
||||||
|
|
||||||
|
|
|
@ -31,15 +31,13 @@ static_assert(sizeof(DebugThreadContext) == 0x320, "Incorrect DebugThreadContext
|
||||||
|
|
||||||
class ThreadInfo {
|
class ThreadInfo {
|
||||||
private:
|
private:
|
||||||
DebugThreadContext context;
|
DebugThreadContext context{};
|
||||||
u64 thread_id;
|
u64 thread_id = 0;
|
||||||
u64 stack_top;
|
u64 stack_top = 0;
|
||||||
u64 stack_bottom;
|
u64 stack_bottom = 0;
|
||||||
u64 stack_trace[0x20];
|
u64 stack_trace[0x20]{};
|
||||||
u32 stack_trace_size;
|
u32 stack_trace_size = 0;
|
||||||
public:
|
public:
|
||||||
ThreadInfo() : context{0}, thread_id(0), stack_top(0), stack_bottom(0), stack_trace{0}, stack_trace_size(0) { }
|
|
||||||
|
|
||||||
u64 GetPC() { return context.pc; }
|
u64 GetPC() { return context.pc; }
|
||||||
u64 GetLR() { return context.lr; }
|
u64 GetLR() { return context.lr; }
|
||||||
u64 GetId() { return thread_id; }
|
u64 GetId() { return thread_id; }
|
||||||
|
@ -54,11 +52,9 @@ class ThreadInfo {
|
||||||
class ThreadList {
|
class ThreadList {
|
||||||
private:
|
private:
|
||||||
static const size_t max_thread_count = 0x60;
|
static const size_t max_thread_count = 0x60;
|
||||||
u32 thread_count;
|
u32 thread_count = 0;
|
||||||
ThreadInfo thread_infos[max_thread_count];
|
ThreadInfo thread_infos[max_thread_count];
|
||||||
public:
|
public:
|
||||||
ThreadList() : thread_count(0) { }
|
|
||||||
|
|
||||||
void SaveToFile(FILE *f_report);
|
void SaveToFile(FILE *f_report);
|
||||||
void DumpBinary(FILE *f_bin, u64 crashed_id);
|
void DumpBinary(FILE *f_bin, u64 crashed_id);
|
||||||
void ReadThreadsFromProcess(Handle debug_handle, bool is_64_bit);
|
void ReadThreadsFromProcess(Handle debug_handle, bool is_64_bit);
|
||||||
|
|
|
@ -174,13 +174,13 @@ class RomFSBuildContext {
|
||||||
RomFSBuildDirectoryContext *root;
|
RomFSBuildDirectoryContext *root;
|
||||||
std::map<char *, RomFSBuildDirectoryContext *, build_ctx_cmp> directories;
|
std::map<char *, RomFSBuildDirectoryContext *, build_ctx_cmp> directories;
|
||||||
std::map<char *, RomFSBuildFileContext *, build_ctx_cmp> files;
|
std::map<char *, RomFSBuildFileContext *, build_ctx_cmp> files;
|
||||||
u64 num_dirs;
|
u64 num_dirs = 0;
|
||||||
u64 num_files;
|
u64 num_files = 0;
|
||||||
u64 dir_table_size;
|
u64 dir_table_size = 0;
|
||||||
u64 file_table_size;
|
u64 file_table_size = 0;
|
||||||
u64 dir_hash_table_size;
|
u64 dir_hash_table_size = 0;
|
||||||
u64 file_hash_table_size;
|
u64 file_hash_table_size = 0;
|
||||||
u64 file_partition_size;
|
u64 file_partition_size = 0;
|
||||||
|
|
||||||
FsDirectoryEntry dir_entry;
|
FsDirectoryEntry dir_entry;
|
||||||
RomFSDataSource cur_source_type;
|
RomFSDataSource cur_source_type;
|
||||||
|
@ -191,7 +191,7 @@ class RomFSBuildContext {
|
||||||
bool AddDirectory(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildDirectoryContext *dir_ctx, RomFSBuildDirectoryContext **out_dir_ctx);
|
bool AddDirectory(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildDirectoryContext *dir_ctx, RomFSBuildDirectoryContext **out_dir_ctx);
|
||||||
bool AddFile(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildFileContext *file_ctx);
|
bool AddFile(RomFSBuildDirectoryContext *parent_dir_ctx, RomFSBuildFileContext *file_ctx);
|
||||||
public:
|
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 = new RomFSBuildDirectoryContext({0});
|
||||||
this->root->path = new char[1];
|
this->root->path = new char[1];
|
||||||
this->root->path[0] = '\x00';
|
this->root->path[0] = '\x00';
|
||||||
|
|
|
@ -12,11 +12,11 @@ enum class FspSrvCmd {
|
||||||
|
|
||||||
class FsMitMService : public IMitMServiceObject {
|
class FsMitMService : public IMitMServiceObject {
|
||||||
private:
|
private:
|
||||||
bool has_initialized;
|
bool has_initialized = false;
|
||||||
u64 init_pid;
|
u64 init_pid = 0;
|
||||||
std::shared_ptr<IStorageInterface> romfs_storage;
|
std::shared_ptr<IStorageInterface> romfs_storage;
|
||||||
public:
|
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 {
|
class AutoCloseMap {
|
||||||
private:
|
private:
|
||||||
void *mapped_address;
|
void *mapped_address = nullptr;
|
||||||
u64 base_address;
|
u64 base_address = 0;
|
||||||
u64 size;
|
u64 size = 0;
|
||||||
Handle process_handle;
|
Handle process_handle = 0;
|
||||||
public:
|
public:
|
||||||
AutoCloseMap() : mapped_address(0), base_address(0), size(0), process_handle(0) { };
|
|
||||||
~AutoCloseMap() {
|
~AutoCloseMap() {
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,10 @@ enum RoServiceCmd {
|
||||||
};
|
};
|
||||||
|
|
||||||
class RelocatableObjectsService final : public IServiceObject {
|
class RelocatableObjectsService final : public IServiceObject {
|
||||||
Handle process_handle;
|
Handle process_handle = 0;
|
||||||
u64 process_id;
|
u64 process_id = U64_MAX;
|
||||||
bool has_initialized;
|
bool has_initialized = false;
|
||||||
public:
|
public:
|
||||||
RelocatableObjectsService() : process_handle(0), process_id(U64_MAX), has_initialized(false) { }
|
|
||||||
~RelocatableObjectsService() {
|
~RelocatableObjectsService() {
|
||||||
Registration::CloseRoService(this, this->process_handle);
|
Registration::CloseRoService(this, this->process_handle);
|
||||||
if (this->has_initialized) {
|
if (this->has_initialized) {
|
||||||
|
|
|
@ -14,12 +14,11 @@ enum UserServiceCmd {
|
||||||
};
|
};
|
||||||
|
|
||||||
class UserService final : public IServiceObject {
|
class UserService final : public IServiceObject {
|
||||||
u64 pid;
|
u64 pid = U64_MAX;
|
||||||
bool has_initialized;
|
bool has_initialized = false;
|
||||||
u64 deferred_service;
|
u64 deferred_service = 0;
|
||||||
|
|
||||||
public:
|
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 dispatch(IpcParsedCommand &r, IpcCommand &out_c, u64 cmd_id, u8 *pointer_buffer, size_t pointer_buffer_size) override;
|
||||||
Result handle_deferred() override;
|
Result handle_deferred() override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue