mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 02:08:49 +12:00
log frame support / parse_hex_qstring
This commit is contained in:
parent
34bcbfacc5
commit
c0f312af84
4 changed files with 48 additions and 12 deletions
|
@ -1730,21 +1730,13 @@ void debugger_frame::RegsShowMemoryViewerAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
const QTextDocumentFragment frag(cursor);
|
const QTextDocumentFragment frag(cursor);
|
||||||
QString selected = frag.toPlainText().trimmed();
|
const QString selected = frag.toPlainText().trimmed();
|
||||||
|
quint64 pc = 0;
|
||||||
int pos = 0;
|
if (!parse_hex_qstring(selected, &pc))
|
||||||
const HexValidator validator(this);
|
|
||||||
const QValidator::State st = validator.validate(selected, pos);
|
|
||||||
if (st != QValidator::Acceptable)
|
|
||||||
{
|
{
|
||||||
QMessageBox::critical(this, tr("Invalid Hex"), tr("“%0” is not a valid 32-bit hex value.").arg(selected));
|
QMessageBox::critical(this, tr("Invalid Hex"), tr("“%0” is not a valid 32-bit hex value.").arg(selected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString norm = normalize_hex_qstring(selected);
|
memory_viewer_panel::ShowAtPC(static_cast<u32>(pc));
|
||||||
bool ok = false;
|
|
||||||
const quint64 value = norm.toULongLong(&ok, 16);
|
|
||||||
const u32 pc = static_cast<u32>(value);
|
|
||||||
|
|
||||||
memory_viewer_panel::ShowAtPC(pc);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,3 +69,23 @@ inline QString normalize_hex_qstring(const QString& input)
|
||||||
s.chop(1);
|
s.chop(1);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool parse_hex_qstring(const QString& input, quint64* result, int max_bits = 32)
|
||||||
|
{
|
||||||
|
QString s = input;
|
||||||
|
int pos = 0;
|
||||||
|
const HexValidator validator(nullptr, max_bits);
|
||||||
|
const QValidator::State st = validator.validate(s, pos);
|
||||||
|
|
||||||
|
if (st != QValidator::Acceptable)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QString norm = normalize_hex_qstring(input);
|
||||||
|
bool ok = false;
|
||||||
|
const quint64 value = norm.toULongLong(&ok, 16);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
*result = static_cast<u64>(value);
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include "log_frame.h"
|
#include "log_frame.h"
|
||||||
#include "qt_utils.h"
|
#include "qt_utils.h"
|
||||||
#include "gui_settings.h"
|
#include "gui_settings.h"
|
||||||
|
#include "hex_validator.h"
|
||||||
|
#include "memory_viewer_panel.h"
|
||||||
|
|
||||||
#include "Utilities/lockless.h"
|
#include "Utilities/lockless.h"
|
||||||
#include "util/asm.hpp"
|
#include "util/asm.hpp"
|
||||||
|
@ -250,6 +252,21 @@ void log_frame::CreateAndConnectActions()
|
||||||
Q_EMIT PerformGoToOnDebugger(pte->textCursor().selectedText(), true);
|
Q_EMIT PerformGoToOnDebugger(pte->textCursor().selectedText(), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_perform_show_in_mem_viewer = new QAction(tr("Show in Memory Viewer"), this);
|
||||||
|
connect(m_perform_show_in_mem_viewer, &QAction::triggered, [this]()
|
||||||
|
{
|
||||||
|
QPlainTextEdit* pte = (m_tabWidget->currentIndex() == 1 ? m_tty : m_log);
|
||||||
|
const QString selected = pte->textCursor().selectedText();
|
||||||
|
quint64 pc = 0;
|
||||||
|
if (!parse_hex_qstring(selected, &pc))
|
||||||
|
{
|
||||||
|
QMessageBox::critical(this, tr("Invalid Hex"), tr("“%0” is not a valid 32-bit hex value.").arg(selected));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
memory_viewer_panel::ShowAtPC(static_cast<u32>(pc));
|
||||||
|
});
|
||||||
|
|
||||||
m_perform_goto_thread_on_debugger = new QAction(tr("Show Thread On The Debugger"), this);
|
m_perform_goto_thread_on_debugger = new QAction(tr("Show Thread On The Debugger"), this);
|
||||||
connect(m_perform_goto_thread_on_debugger, &QAction::triggered, [this]()
|
connect(m_perform_goto_thread_on_debugger, &QAction::triggered, [this]()
|
||||||
{
|
{
|
||||||
|
@ -354,13 +371,16 @@ void log_frame::CreateAndConnectActions()
|
||||||
menu->addAction(m_clear_act);
|
menu->addAction(m_clear_act);
|
||||||
menu->addAction(m_perform_goto_on_debugger);
|
menu->addAction(m_perform_goto_on_debugger);
|
||||||
menu->addAction(m_perform_goto_thread_on_debugger);
|
menu->addAction(m_perform_goto_thread_on_debugger);
|
||||||
|
menu->addAction(m_perform_show_in_mem_viewer);
|
||||||
|
|
||||||
std::shared_ptr<bool> goto_signal_accepted = std::make_shared<bool>(false);
|
std::shared_ptr<bool> goto_signal_accepted = std::make_shared<bool>(false);
|
||||||
Q_EMIT PerformGoToOnDebugger("", true, true, goto_signal_accepted);
|
Q_EMIT PerformGoToOnDebugger("", true, true, goto_signal_accepted);
|
||||||
m_perform_goto_on_debugger->setEnabled(m_log->textCursor().hasSelection() && *goto_signal_accepted);
|
m_perform_goto_on_debugger->setEnabled(m_log->textCursor().hasSelection() && *goto_signal_accepted);
|
||||||
m_perform_goto_thread_on_debugger->setEnabled(m_log->textCursor().hasSelection() && *goto_signal_accepted);
|
m_perform_goto_thread_on_debugger->setEnabled(m_log->textCursor().hasSelection() && *goto_signal_accepted);
|
||||||
|
m_perform_show_in_mem_viewer->setEnabled(m_log->textCursor().hasSelection() && *goto_signal_accepted);
|
||||||
m_perform_goto_on_debugger->setToolTip(tr("Jump to the selected hexadecimal address from the log text on the debugger."));
|
m_perform_goto_on_debugger->setToolTip(tr("Jump to the selected hexadecimal address from the log text on the debugger."));
|
||||||
m_perform_goto_thread_on_debugger->setToolTip(tr("Show the thread that corresponds to the thread ID from the log text on the debugger."));
|
m_perform_goto_thread_on_debugger->setToolTip(tr("Show the thread that corresponds to the thread ID from the log text on the debugger."));
|
||||||
|
m_perform_show_in_mem_viewer->setToolTip(tr("Jump to the selected hexadecimal address from the log text on the memory viewer."));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addActions(m_log_level_acts->actions());
|
menu->addActions(m_log_level_acts->actions());
|
||||||
|
@ -376,11 +396,14 @@ void log_frame::CreateAndConnectActions()
|
||||||
QMenu* menu = m_tty->createStandardContextMenu();
|
QMenu* menu = m_tty->createStandardContextMenu();
|
||||||
menu->addAction(m_clear_tty_act);
|
menu->addAction(m_clear_tty_act);
|
||||||
menu->addAction(m_perform_goto_on_debugger);
|
menu->addAction(m_perform_goto_on_debugger);
|
||||||
|
menu->addAction(m_perform_show_in_mem_viewer);
|
||||||
|
|
||||||
std::shared_ptr<bool> goto_signal_accepted = std::make_shared<bool>(false);
|
std::shared_ptr<bool> goto_signal_accepted = std::make_shared<bool>(false);
|
||||||
Q_EMIT PerformGoToOnDebugger("", false, true, goto_signal_accepted);
|
Q_EMIT PerformGoToOnDebugger("", false, true, goto_signal_accepted);
|
||||||
m_perform_goto_on_debugger->setEnabled(m_tty->textCursor().hasSelection() && *goto_signal_accepted);
|
m_perform_goto_on_debugger->setEnabled(m_tty->textCursor().hasSelection() && *goto_signal_accepted);
|
||||||
|
m_perform_show_in_mem_viewer->setEnabled(m_tty->textCursor().hasSelection() && *goto_signal_accepted);
|
||||||
m_perform_goto_on_debugger->setToolTip(tr("Jump to the selected hexadecimal address from the TTY text on the debugger."));
|
m_perform_goto_on_debugger->setToolTip(tr("Jump to the selected hexadecimal address from the TTY text on the debugger."));
|
||||||
|
m_perform_show_in_mem_viewer->setToolTip(tr("Jump to the selected hexadecimal address from the TTY text on the memory viewer."));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction(m_tty_act);
|
menu->addAction(m_tty_act);
|
||||||
|
|
|
@ -74,6 +74,7 @@ private:
|
||||||
QAction* m_clear_tty_act = nullptr;
|
QAction* m_clear_tty_act = nullptr;
|
||||||
QAction* m_perform_goto_on_debugger = nullptr;
|
QAction* m_perform_goto_on_debugger = nullptr;
|
||||||
QAction* m_perform_goto_thread_on_debugger = nullptr;
|
QAction* m_perform_goto_thread_on_debugger = nullptr;
|
||||||
|
QAction* m_perform_show_in_mem_viewer = nullptr;
|
||||||
|
|
||||||
QActionGroup* m_log_level_acts = nullptr;
|
QActionGroup* m_log_level_acts = nullptr;
|
||||||
QAction* m_nothing_act = nullptr;
|
QAction* m_nothing_act = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue