From afccc4b8e0a698b9e9ae39865162c671380e876a Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 31 Jul 2025 14:27:00 -0400 Subject: Add log message dialog for showing stack traces --- ui/logmessagedialog.h | 38 ++++++++++++++++++++++++++++++++++++++ ui/logview.h | 2 ++ ui/uitypes.h | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ui/logmessagedialog.h diff --git a/ui/logmessagedialog.h b/ui/logmessagedialog.h new file mode 100644 index 00000000..c63a3838 --- /dev/null +++ b/ui/logmessagedialog.h @@ -0,0 +1,38 @@ +#pragma once + +#include +#include "binaryninjaapi.h" +#include "uitypes.h" +#include "clickablelabel.h" + +/*! + + \defgroup logmessagedialog LogMessageDialog + \ingroup uiapi +*/ + +/*! + \ingroup logmessagedialog +*/ +class BINARYNINJAUIAPI LogMessageDialog : public QDialog +{ + Q_OBJECT + + QString m_stackTrace; + ClickableLabel* m_showStackTraceLabel = nullptr; + QVBoxLayout* m_stackTraceLayout = nullptr; + bool m_stackTraceVisible = false; + + static constexpr int MAX_WIDTH = 720; + static constexpr int STACK_TRACE_HEIGHT = 300; + + void init(BNLogLevel level, const QString& stackTrace, const QString& message); + +public: + LogMessageDialog(QWidget* parent, BNLogLevel level, const std::optional& stackTrace, + const std::string& message); + LogMessageDialog(QWidget* parent, BNLogLevel level, const QString& stackTrace, const QString& message); + +public Q_SLOTS: + void requestStackTrace(); +}; diff --git a/ui/logview.h b/ui/logview.h index b1ce57a1..36016ff8 100644 --- a/ui/logview.h +++ b/ui/logview.h @@ -49,6 +49,7 @@ struct BINARYNINJAUIAPI LogListItem size_t sessionId; BNLogLevel level; QString text; + QString stackTrace; LogTokenList tokens; bool selected; QString logger; @@ -122,6 +123,7 @@ class BINARYNINJAUIAPI LogListModel : public QAbstractItemModel, BinaryNinja::Lo static constexpr int Session = Qt::UserRole + 5; static constexpr int FormattedMessage = Qt::UserRole + 6; static constexpr int Tokens = Qt::UserRole + 7; + static constexpr int StackTrace = Qt::UserRole + 8; LogListModel(QWidget* parent); ~LogListModel(); diff --git a/ui/uitypes.h b/ui/uitypes.h index 89d2bdcd..b0197adc 100644 --- a/ui/uitypes.h +++ b/ui/uitypes.h @@ -6,7 +6,7 @@ // there are changes to the API that affect linking, including new functions, // new types, modifications to existing functions or types, or new versions // of the Qt libraries. -#define BN_CURRENT_UI_ABI_VERSION 9 +#define BN_CURRENT_UI_ABI_VERSION 10 // Minimum ABI version that is supported for loading of plugins. Plugins that // are linked to an ABI version less than this will not be able to load and -- cgit v1.3.1