From 45930e0621f92e949e8083eb1967e6cae62290d0 Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Mon, 22 Jul 2019 20:47:47 +0800 Subject: [PATCH] citra_qt: Add record dialog This 'View Record' dialog shows all relevant information on a record as well as the command buffers. --- src/citra_qt/CMakeLists.txt | 3 + src/citra_qt/debugger/ipc/record_dialog.cpp | 64 +++++ src/citra_qt/debugger/ipc/record_dialog.h | 36 +++ src/citra_qt/debugger/ipc/record_dialog.ui | 281 ++++++++++++++++++++ 4 files changed, 384 insertions(+) create mode 100644 src/citra_qt/debugger/ipc/record_dialog.cpp create mode 100644 src/citra_qt/debugger/ipc/record_dialog.h create mode 100644 src/citra_qt/debugger/ipc/record_dialog.ui diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 6ac1eb2db..9d5137a4f 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -90,6 +90,9 @@ add_executable(citra-qt debugger/graphics/graphics_tracing.h debugger/graphics/graphics_vertex_shader.cpp debugger/graphics/graphics_vertex_shader.h + debugger/ipc/record_dialog.cpp + debugger/ipc/record_dialog.h + debugger/ipc/record_dialog.ui debugger/lle_service_modules.cpp debugger/lle_service_modules.h debugger/profiler.cpp diff --git a/src/citra_qt/debugger/ipc/record_dialog.cpp b/src/citra_qt/debugger/ipc/record_dialog.cpp new file mode 100644 index 000000000..2a179e10f --- /dev/null +++ b/src/citra_qt/debugger/ipc/record_dialog.cpp @@ -0,0 +1,64 @@ +// Copyright 2019 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include "citra_qt/debugger/ipc/record_dialog.h" +#include "common/assert.h" +#include "core/hle/kernel/ipc_debugger/recorder.h" +#include "ui_record_dialog.h" + +QString RecordDialog::FormatObject(const IPCDebugger::ObjectInfo& object) const { + if (object.id == -1) { + return tr("null"); + } + + return QStringLiteral("%1 (0x%2)") + .arg(QString::fromStdString(object.name)) + .arg(object.id, 8, 16, QLatin1Char('0')); +} + +QString RecordDialog::FormatCmdbuf(const std::vector& cmdbuf) const { + QString result; + for (std::size_t i = 0; i < cmdbuf.size(); ++i) { + result.append( + QStringLiteral("[%1]: 0x%2\n").arg(i).arg(cmdbuf[i], 8, 16, QLatin1Char('0'))); + } + return result; +} + +RecordDialog::RecordDialog(QWidget* parent, const IPCDebugger::RequestRecord& record, + const QString& service, const QString& function) + : QDialog(parent), ui(std::make_unique()) { + + ui->setupUi(this); + + ui->clientProcess->setText(FormatObject(record.client_process)); + ui->clientThread->setText(FormatObject(record.client_thread)); + ui->clientSession->setText(FormatObject(record.client_session)); + + ui->serverProcess->setText(FormatObject(record.server_process)); + ui->serverThread->setText(FormatObject(record.server_thread)); + ui->serverSession->setText(FormatObject(record.server_session)); + + ui->clientPort->setText(FormatObject(record.client_port)); + ui->service->setText(std::move(service)); + ui->function->setText(std::move(function)); + + cmdbufs = {record.untranslated_request_cmdbuf, record.translated_request_cmdbuf, + record.untranslated_reply_cmdbuf, record.translated_reply_cmdbuf}; + + UpdateCmdbufDisplay(); + + connect(ui->cmdbufSelection, qOverload(&QComboBox::currentIndexChanged), this, + &RecordDialog::UpdateCmdbufDisplay); +} + +RecordDialog::~RecordDialog() = default; + +void RecordDialog::UpdateCmdbufDisplay() { + int index = ui->cmdbufSelection->currentIndex(); + + ASSERT_MSG(0 <= index && index <= 3, "Index out of bound"); + ui->cmdbuf->setPlainText(FormatCmdbuf(cmdbufs[index])); +} diff --git a/src/citra_qt/debugger/ipc/record_dialog.h b/src/citra_qt/debugger/ipc/record_dialog.h new file mode 100644 index 000000000..40618b925 --- /dev/null +++ b/src/citra_qt/debugger/ipc/record_dialog.h @@ -0,0 +1,36 @@ +// Copyright 2019 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include "common/common_types.h" + +namespace IPCDebugger { +struct ObjectInfo; +struct RequestRecord; +} // namespace IPCDebugger + +namespace Ui { +class RecordDialog; +} + +class RecordDialog : public QDialog { + Q_OBJECT + +public: + explicit RecordDialog(QWidget* parent, const IPCDebugger::RequestRecord& record, + const QString& service, const QString& function); + ~RecordDialog() override; + +private: + QString FormatObject(const IPCDebugger::ObjectInfo& object) const; + QString FormatCmdbuf(const std::vector& cmdbuf) const; + void UpdateCmdbufDisplay(); + + std::unique_ptr ui; + std::array, 4> cmdbufs; +}; diff --git a/src/citra_qt/debugger/ipc/record_dialog.ui b/src/citra_qt/debugger/ipc/record_dialog.ui new file mode 100644 index 000000000..44c70d386 --- /dev/null +++ b/src/citra_qt/debugger/ipc/record_dialog.ui @@ -0,0 +1,281 @@ + + + RecordDialog + + + View Record + + + + 0 + 0 + 800 + 500 + + + + + + + + + Client + + + + + + + + Process: + + + + + + + true + + + + + + + + + + + Thread: + + + + + + + true + + + + + + + + + + + Session: + + + + + + + true + + + + + + + + + + + + Server + + + + + + + + Process: + + + + + + + true + + + + + + + + + + + Thread: + + + + + + + true + + + + + + + + + + + Session: + + + + + + + true + + + + + + + + + + + + + + General + + + + + + + + Client Port: + + + + + + + true + + + + + + + + + + + Service: + + + + + + + true + + + + + + + + + + + Function: + + + + + + + true + + + + + + + + + + + + Command Buffer + + + + + + + + Select: + + + + + + + + Request Untranslated + + + + + Request Translated + + + + + Reply Untranslated + + + + + Reply Translated + + + + + + + + + + true + + + + + + + + + + + + Qt::Horizontal + + + + + + + OK + + + + + + + +