mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-21 19:43:25 +02:00
core: Use unique_ptr for holding the interpreter instances
This commit is contained in:
parent
73740d74ed
commit
cee8df6ff0
@ -29,18 +29,16 @@ CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent)
|
||||
|
||||
void CallstackWidget::OnDebugModeEntered()
|
||||
{
|
||||
ARM_Interface* app_core = Core::g_app_core;
|
||||
|
||||
u32 sp = app_core->GetReg(13); //stack pointer
|
||||
u32 ret_addr, call_addr, func_addr;
|
||||
// Stack pointer
|
||||
const u32 sp = Core::g_app_core->GetReg(13);
|
||||
|
||||
Clear();
|
||||
|
||||
int counter = 0;
|
||||
for (u32 addr = 0x10000000; addr >= sp; addr -= 4)
|
||||
{
|
||||
ret_addr = Memory::Read32(addr);
|
||||
call_addr = ret_addr - 4; //get call address???
|
||||
const u32 ret_addr = Memory::Read32(addr);
|
||||
const u32 call_addr = ret_addr - 4; //get call address???
|
||||
|
||||
if (Memory::GetPointer(call_addr) == nullptr)
|
||||
break;
|
||||
@ -60,7 +58,7 @@ void CallstackWidget::OnDebugModeEntered()
|
||||
// Pre-compute the left-shift and the prefetch offset
|
||||
i_offset <<= 2;
|
||||
i_offset += 8;
|
||||
func_addr = call_addr + i_offset;
|
||||
const u32 func_addr = call_addr + i_offset;
|
||||
|
||||
callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0'))));
|
||||
callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0'))));
|
||||
|
@ -59,16 +59,14 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) {
|
||||
}
|
||||
|
||||
void RegistersWidget::OnDebugModeEntered() {
|
||||
ARM_Interface* app_core = Core::g_app_core;
|
||||
|
||||
if (app_core == nullptr)
|
||||
if (!Core::g_app_core)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < core_registers->childCount(); ++i)
|
||||
core_registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetReg(i), 8, 16, QLatin1Char('0')));
|
||||
core_registers->child(i)->setText(1, QString("0x%1").arg(Core::g_app_core->GetReg(i), 8, 16, QLatin1Char('0')));
|
||||
|
||||
for (int i = 0; i < vfp_registers->childCount(); ++i)
|
||||
vfp_registers->child(i)->setText(1, QString("0x%1").arg(app_core->GetVFPReg(i), 8, 16, QLatin1Char('0')));
|
||||
vfp_registers->child(i)->setText(1, QString("0x%1").arg(Core::g_app_core->GetVFPReg(i), 8, 16, QLatin1Char('0')));
|
||||
|
||||
UpdateCPSRValues();
|
||||
UpdateVFPSystemRegisterValues();
|
||||
|
@ -2,6 +2,9 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "common/make_unique.h"
|
||||
#include "common/logging/log.h"
|
||||
|
||||
#include "core/core.h"
|
||||
@ -17,8 +20,8 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
ARM_Interface* g_app_core = nullptr; ///< ARM11 application core
|
||||
ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
|
||||
std::unique_ptr<ARM_Interface> g_app_core; ///< ARM11 application core
|
||||
std::unique_ptr<ARM_Interface> g_sys_core; ///< ARM11 system (OS) core
|
||||
|
||||
/// Run the core CPU loop
|
||||
void RunLoop(int tight_loop) {
|
||||
@ -71,16 +74,16 @@ void Stop() {
|
||||
|
||||
/// Initialize the core
|
||||
int Init() {
|
||||
g_sys_core = new ARM_DynCom(USER32MODE);
|
||||
g_app_core = new ARM_DynCom(USER32MODE);
|
||||
g_sys_core = Common::make_unique<ARM_DynCom>(USER32MODE);
|
||||
g_app_core = Common::make_unique<ARM_DynCom>(USER32MODE);
|
||||
|
||||
LOG_DEBUG(Core, "Initialized OK");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
delete g_app_core;
|
||||
delete g_sys_core;
|
||||
g_app_core.reset();
|
||||
g_sys_core.reset();
|
||||
|
||||
LOG_DEBUG(Core, "Shutdown OK");
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "common/common_types.h"
|
||||
|
||||
class ARM_Interface;
|
||||
@ -23,8 +24,8 @@ struct ThreadContext {
|
||||
u32 fpexc;
|
||||
};
|
||||
|
||||
extern ARM_Interface* g_app_core; ///< ARM11 application core
|
||||
extern ARM_Interface* g_sys_core; ///< ARM11 system (OS) core
|
||||
extern std::unique_ptr<ARM_Interface> g_app_core; ///< ARM11 application core
|
||||
extern std::unique_ptr<ARM_Interface> g_sys_core; ///< ARM11 system (OS) core
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user