kernel: Add LLE request/reply recording

The 'translate' function is a great place to put this in IMO as it is possible to get both untranslated and translated cmdbufs. However a kernel reference has to be passed here, but it is not too hard fortunately.
This commit is contained in:
zhupengfei 2019-07-22 20:19:03 +08:00
parent cb0bd6530c
commit a27dfc269a
No known key found for this signature in database
GPG key ID: DD129E108BD09378
3 changed files with 38 additions and 14 deletions

View file

@ -8,6 +8,7 @@
#include "core/hle/ipc.h"
#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/ipc.h"
#include "core/hle/kernel/ipc_debugger/recorder.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/memory.h"
#include "core/hle/kernel/process.h"
@ -16,7 +17,8 @@
namespace Kernel {
ResultCode TranslateCommandBuffer(Memory::MemorySystem& memory, std::shared_ptr<Thread> src_thread,
ResultCode TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory,
std::shared_ptr<Thread> src_thread,
std::shared_ptr<Thread> dst_thread, VAddr src_address,
VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context,
@ -37,6 +39,13 @@ ResultCode TranslateCommandBuffer(Memory::MemorySystem& memory, std::shared_ptr<
std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
memory.ReadBlock(*src_process, src_address, cmd_buf.data(), command_size * sizeof(u32));
const bool should_record = kernel.GetIPCRecorder().IsEnabled();
std::vector<u32> untranslated_cmdbuf;
if (should_record) {
untranslated_cmdbuf = std::vector<u32>{cmd_buf.begin(), cmd_buf.begin() + command_size};
}
std::size_t i = untranslated_size;
while (i < command_size) {
u32 descriptor = cmd_buf[i];
@ -218,6 +227,17 @@ ResultCode TranslateCommandBuffer(Memory::MemorySystem& memory, std::shared_ptr<
}
}
if (should_record) {
std::vector<u32> translated_cmdbuf{cmd_buf.begin(), cmd_buf.begin() + command_size};
if (reply) {
kernel.GetIPCRecorder().SetReplyInfo(dst_thread, std::move(untranslated_cmdbuf),
std::move(translated_cmdbuf));
} else {
kernel.GetIPCRecorder().SetRequestInfo(src_thread, std::move(untranslated_cmdbuf),
std::move(translated_cmdbuf), dst_thread);
}
}
memory.WriteBlock(*dst_process, dst_address, cmd_buf.data(), command_size * sizeof(u32));
return RESULT_SUCCESS;