vm: Deallocate memory early, check no PS3 memory leaks
This commit is contained in:
@@ -15,7 +15,7 @@ u32 SPUDisAsm::disasm(u32 pc)
|
|||||||
{
|
{
|
||||||
last_opcode.clear();
|
last_opcode.clear();
|
||||||
|
|
||||||
if (pc < m_start_pc || pc >= SPU_LS_SIZE)
|
if (!m_shm || pc < m_start_pc || pc >= SPU_LS_SIZE)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-1
@@ -1329,6 +1329,16 @@ namespace vm
|
|||||||
std::vector<std::pair<u64, u64>> event_data;
|
std::vector<std::pair<u64, u64>> event_data;
|
||||||
ensure(size == _page_unmap(it->first, size, this->flags, it->second.second.get(), unmapped ? *unmapped : event_data));
|
ensure(size == _page_unmap(it->first, size, this->flags, it->second.second.get(), unmapped ? *unmapped : event_data));
|
||||||
|
|
||||||
|
if (it->second.second && addr < 0xE0000000)
|
||||||
|
{
|
||||||
|
if (it->second.second.use_count() != 1)
|
||||||
|
{
|
||||||
|
fmt::throw_exception("External memory usage at block 0x%x (addr=0x%x, size=0x%x)", this->addr, it->first, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
it->second.second.reset();
|
||||||
|
}
|
||||||
|
|
||||||
it = next;
|
it = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1338,6 +1348,8 @@ namespace vm
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
m_common->unmap_critical(vm::get_super_ptr(addr));
|
m_common->unmap_critical(vm::get_super_ptr(addr));
|
||||||
#endif
|
#endif
|
||||||
|
ensure(m_common.use_count() == 1);
|
||||||
|
m_common.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -1349,6 +1361,7 @@ namespace vm
|
|||||||
block_t::~block_t()
|
block_t::~block_t()
|
||||||
{
|
{
|
||||||
ensure(!is_valid());
|
ensure(!is_valid());
|
||||||
|
ensure(!m_common || m_common.use_count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 block_t::alloc(const u32 orig_size, const std::shared_ptr<utils::shm>* src, u32 align, u64 flags)
|
u32 block_t::alloc(const u32 orig_size, const std::shared_ptr<utils::shm>* src, u32 align, u64 flags)
|
||||||
@@ -2244,7 +2257,11 @@ namespace vm
|
|||||||
|
|
||||||
for (auto& block : g_locations)
|
for (auto& block : g_locations)
|
||||||
{
|
{
|
||||||
if (block) _unmap_block(block);
|
if (block)
|
||||||
|
{
|
||||||
|
_unmap_block(block);
|
||||||
|
ensure(block.use_count() == 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_locations.clear();
|
g_locations.clear();
|
||||||
|
|||||||
@@ -241,6 +241,9 @@ void debugger_frame::closeEvent(QCloseEvent* event)
|
|||||||
|
|
||||||
QDockWidget::closeEvent(event);
|
QDockWidget::closeEvent(event);
|
||||||
Q_EMIT DebugFrameClosed();
|
Q_EMIT DebugFrameClosed();
|
||||||
|
|
||||||
|
m_spu_disasm_memory.reset();
|
||||||
|
m_cpu.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void debugger_frame::showEvent(QShowEvent* event)
|
void debugger_frame::showEvent(QShowEvent* event)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include <QWheelEvent>
|
#include <QWheelEvent>
|
||||||
#include <QHoverEvent>
|
#include <QHoverEvent>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QCloseEvent>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
@@ -732,7 +733,7 @@ void* memory_viewer_panel::to_ptr(u32 addr, u32 size) const
|
|||||||
}
|
}
|
||||||
case thread_class::spu:
|
case thread_class::spu:
|
||||||
{
|
{
|
||||||
if (size <= SPU_LS_SIZE && SPU_LS_SIZE - size >= (addr % SPU_LS_SIZE))
|
if (m_spu_shm && size <= SPU_LS_SIZE && SPU_LS_SIZE - size >= (addr % SPU_LS_SIZE))
|
||||||
{
|
{
|
||||||
return m_spu_shm->map_self() + (addr % SPU_LS_SIZE);
|
return m_spu_shm->map_self() + (addr % SPU_LS_SIZE);
|
||||||
}
|
}
|
||||||
@@ -961,6 +962,14 @@ void memory_viewer_panel::keyPressEvent(QKeyEvent* event)
|
|||||||
QDialog::keyPressEvent(event);
|
QDialog::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void memory_viewer_panel::closeEvent(QCloseEvent* event)
|
||||||
|
{
|
||||||
|
event->accept();
|
||||||
|
m_spu_shm.reset();
|
||||||
|
m_disasm.reset();
|
||||||
|
m_get_cpu = [](){ return std::add_pointer_t<cpu_thread>{}; };
|
||||||
|
}
|
||||||
|
|
||||||
void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const
|
void memory_viewer_panel::ShowImage(QWidget* parent, u32 addr, color_format format, u32 width, u32 height, bool flipv) const
|
||||||
{
|
{
|
||||||
u32 texel_bytes = 4;
|
u32 texel_bytes = 4;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class QLabel;
|
|||||||
class QThread;
|
class QThread;
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class QKeyEvent;
|
class QKeyEvent;
|
||||||
|
class QCloseEvent;
|
||||||
|
|
||||||
class cpu_thread;
|
class cpu_thread;
|
||||||
class CPUDisAsm;
|
class CPUDisAsm;
|
||||||
@@ -95,10 +96,10 @@ private:
|
|||||||
QHBoxLayout* m_hbox_mem_panel = nullptr;
|
QHBoxLayout* m_hbox_mem_panel = nullptr;
|
||||||
QThread* m_search_thread = nullptr;
|
QThread* m_search_thread = nullptr;
|
||||||
|
|
||||||
const std::function<cpu_thread*()> m_get_cpu;
|
std::function<cpu_thread*()> m_get_cpu;
|
||||||
const thread_class m_type;
|
const thread_class m_type;
|
||||||
const std::add_pointer_t<rsx::thread> m_rsx;
|
const std::add_pointer_t<rsx::thread> m_rsx;
|
||||||
const std::shared_ptr<utils::shm> m_spu_shm;
|
std::shared_ptr<utils::shm> m_spu_shm;
|
||||||
const u32 m_addr_mask;
|
const u32 m_addr_mask;
|
||||||
|
|
||||||
std::shared_ptr<CPUDisAsm> m_disasm;
|
std::shared_ptr<CPUDisAsm> m_disasm;
|
||||||
@@ -119,6 +120,7 @@ private:
|
|||||||
u64 OnSearch(std::string wstr, u32 mode);
|
u64 OnSearch(std::string wstr, u32 mode);
|
||||||
|
|
||||||
void keyPressEvent(QKeyEvent* event) override;
|
void keyPressEvent(QKeyEvent* event) override;
|
||||||
|
void closeEvent(QCloseEvent* event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Lifetime management with IDM
|
// Lifetime management with IDM
|
||||||
|
|||||||
Reference in New Issue
Block a user