SPU LLVM: improve debugging RPCS3

Build cache in reverse order
Catch exceptions in instruction loop: print IR
This commit is contained in:
Nekotekina 2018-08-03 15:34:51 +03:00
parent 711e0f75ee
commit 14e6577700
2 changed files with 23 additions and 10 deletions

View File

@ -33,9 +33,9 @@ spu_cache::~spu_cache()
{
}
std::vector<std::vector<u32>> spu_cache::get()
std::deque<std::vector<u32>> spu_cache::get()
{
std::vector<std::vector<u32>> result;
std::deque<std::vector<u32>> result;
if (!m_file)
{
@ -64,7 +64,7 @@ std::vector<std::vector<u32>> spu_cache::get()
break;
}
result.emplace_back(std::move(func));
result.emplace_front(std::move(func));
}
return result;
@ -2161,6 +2161,11 @@ public:
fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log);
}
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
}
using namespace llvm;
// Create LLVM module
@ -2447,7 +2452,19 @@ public:
}
// Execute recompiler function (TODO)
(this->*g_decoder.decode(op))({op});
try
{
(this->*g_decoder.decode(op))({op});
}
catch (const std::exception& e)
{
std::string dump;
raw_string_ostream out(dump);
out << *module; // print IR
out.flush();
LOG_ERROR(SPU, "[0x%x] LLVM dump:\n%s", m_pos, dump);
throw;
}
}
// Finalize block with fallthrough if necessary
@ -2780,11 +2797,6 @@ public:
fs::file(m_spurt->m_cache_path + "spu.log", fs::write + fs::append).write(log);
}
if (m_cache && g_cfg.core.spu_cache)
{
m_cache->add(func);
}
return fn;
}

View File

@ -6,6 +6,7 @@
#include <bitset>
#include <memory>
#include <string>
#include <deque>
// Helper class
class spu_cache
@ -22,7 +23,7 @@ public:
return m_file.operator bool();
}
std::vector<std::vector<u32>> get();
std::deque<std::vector<u32>> get();
void add(const std::vector<u32>& func);