2018-09-07 16:00:13 +01:00
|
|
|
/*
|
2019-04-07 19:00:49 -07:00
|
|
|
* Copyright (c) 2018-2019 Atmosphère-NX
|
2018-09-07 16:00:13 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-05-25 13:32:34 -07:00
|
|
|
|
2018-06-25 04:38:54 -06:00
|
|
|
#pragma once
|
|
|
|
#include <switch.h>
|
2018-06-26 00:44:58 -06:00
|
|
|
#include <cstdio>
|
2018-06-25 04:38:54 -06:00
|
|
|
|
|
|
|
#include "creport_debug_types.hpp"
|
2018-11-11 19:52:19 -08:00
|
|
|
#include "creport_thread_info.hpp"
|
2018-06-25 04:38:54 -06:00
|
|
|
|
|
|
|
struct CodeInfo {
|
|
|
|
char name[0x20];
|
2018-06-25 09:50:36 -06:00
|
|
|
u8 build_id[0x20];
|
2018-06-25 04:38:54 -06:00
|
|
|
u64 start_address;
|
|
|
|
u64 end_address;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CodeList {
|
2018-11-13 20:22:54 -08:00
|
|
|
public:
|
2018-11-11 19:52:19 -08:00
|
|
|
static const size_t max_code_count = 0x60;
|
2018-07-02 16:26:03 +02:00
|
|
|
u32 code_count = 0;
|
2018-06-25 04:38:54 -06:00
|
|
|
CodeInfo code_infos[max_code_count];
|
2019-05-25 13:32:34 -07:00
|
|
|
|
2018-07-27 20:34:09 -07:00
|
|
|
/* For pretty-printing. */
|
|
|
|
char address_str_buf[0x280];
|
2019-05-25 13:32:34 -07:00
|
|
|
public:
|
2018-11-11 19:52:19 -08:00
|
|
|
void ReadCodeRegionsFromThreadInfo(Handle debug_handle, const ThreadInfo *thread);
|
2018-07-27 20:34:09 -07:00
|
|
|
const char *GetFormattedAddressString(u64 address);
|
2018-06-26 00:44:58 -06:00
|
|
|
void SaveToFile(FILE *f_report);
|
2018-06-25 04:38:54 -06:00
|
|
|
private:
|
|
|
|
bool TryFindCodeRegion(Handle debug_handle, u64 guess, u64 *address);
|
2018-11-11 19:52:19 -08:00
|
|
|
void AddCodeRegion(u64 debug_handle, u64 code_address);
|
2018-08-11 18:46:41 -07:00
|
|
|
void GetCodeInfoName(u64 debug_handle, u64 rx_address, u64 ro_address, char *name);
|
2018-06-25 09:50:36 -06:00
|
|
|
void GetCodeInfoBuildId(u64 debug_handle, u64 ro_address, u8 *build_id);
|
2018-06-25 04:38:54 -06:00
|
|
|
};
|