Files
dolphin/Source/Core/Core/Debugger/Dump.cpp
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.1 KiB
C++
Raw Normal View History

// Copyright 2008 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2008-12-08 05:30:24 +00:00
2017-06-08 00:53:59 -04:00
#include "Core/Debugger/Dump.h"
2014-02-17 05:18:15 -05:00
#include <cstdio>
2014-03-12 15:33:41 -04:00
#include <string>
2008-12-08 05:30:24 +00:00
2014-09-07 20:06:58 -05:00
#include "Common/CommonTypes.h"
2020-09-15 03:29:41 -07:00
#include "Common/IOFile.h"
2014-02-17 05:18:15 -05:00
CDump::CDump(const std::string& filename)
2008-07-12 17:40:22 +00:00
{
2014-03-12 15:33:41 -04:00
File::IOFile pStream(filename, "rb");
if (pStream)
2008-07-12 17:40:22 +00:00
{
m_size = (size_t)pStream.GetSize();
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
m_pData = new u8[m_size];
2008-12-08 05:30:24 +00:00
pStream.ReadArray(m_pData, m_size);
2008-07-12 17:40:22 +00:00
}
}
2008-12-08 05:30:24 +00:00
CDump::~CDump()
2008-07-12 17:40:22 +00:00
{
2014-03-09 21:14:26 +01:00
if (m_pData != nullptr)
2008-07-12 17:40:22 +00:00
{
2010-04-11 11:16:57 +00:00
delete[] m_pData;
2014-03-09 21:14:26 +01:00
m_pData = nullptr;
2008-07-12 17:40:22 +00:00
}
}
2008-12-08 05:30:24 +00:00
int CDump::GetNumberOfSteps()
2008-07-12 17:40:22 +00:00
{
return (int)(m_size / STRUCTUR_SIZE);
}
2008-12-08 05:30:24 +00:00
2014-02-16 15:30:18 -05:00
u32 CDump::GetGPR(int _step, int _gpr)
2008-07-12 17:40:22 +00:00
{
u32 offset = _step * STRUCTUR_SIZE;
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
if (offset >= m_size)
return UINT32_MAX;
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
return Read32(offset + OFFSET_GPR + (_gpr * 4));
}
2008-12-08 05:30:24 +00:00
2014-02-16 15:30:18 -05:00
u32 CDump::GetPC(int _step)
2008-07-12 17:40:22 +00:00
{
u32 offset = _step * STRUCTUR_SIZE;
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
if (offset >= m_size)
return UINT32_MAX;
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
return Read32(offset + OFFSET_PC);
}
2008-12-08 05:30:24 +00:00
2014-02-16 15:30:18 -05:00
u32 CDump::Read32(u32 _pos)
2008-07-12 17:40:22 +00:00
{
u32 result = (m_pData[_pos + 0] << 24) | (m_pData[_pos + 1] << 16) | (m_pData[_pos + 2] << 8) |
2014-02-16 15:30:18 -05:00
(m_pData[_pos + 3] << 0);
2008-12-08 05:30:24 +00:00
2008-07-12 17:40:22 +00:00
return result;
}