Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
lua_debugger_dialog.h
1/* lua_debugger_dialog.h
2 *
3 * Wireshark - Network traffic analyzer
4 * By Gerald Combs <gerald@wireshark.org>
5 * Copyright 1998 Gerald Combs
6 *
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
9
10#ifndef LUA_DEBUGGER_DIALOG_H
11#define LUA_DEBUGGER_DIALOG_H
12
14#include <QCheckBox>
15#include <QComboBox>
16#include <QEventLoop>
17#include <QFont>
18#include <QPair>
19#include <QPlainTextEdit>
20#include <QPushButton>
21#include <QString>
22#include <QTreeWidget>
23#include <QVariantMap>
24#include <QVector>
25
26#include "epan/wslua/wslua_debugger.h"
27
28class AccordionFrame;
30class QEvent;
31class QChildEvent;
32
33namespace Ui
34{
36}
37
39
44{
45 Q_OBJECT
46
47 public:
52 explicit LuaDebuggerDialog(QWidget *parent = nullptr);
57
62 static int32_t currentTheme();
63
69 static LuaDebuggerDialog *instance(QWidget *parent = nullptr);
70
76 void handlePause(const char *file_path, int64_t line);
77
88 bool ensureFileTreeEntry(const QString &file_path);
89
96 void reject() override;
97
98 public slots:
105
106 protected:
111 void closeEvent(QCloseEvent *event) override;
112 bool eventFilter(QObject *obj, QEvent *event) override;
113 void childEvent(QChildEvent *event) override;
114
115 private slots:
117 void onContinue();
119 void onStepOver();
121 void onStepIn();
123 void onStepOut();
126 void onDebuggerToggled(bool checked);
128 void onClearBreakpoints();
130 void onBreakpointItemChanged(QTreeWidgetItem *item, int column);
133 void onBreakpointItemClicked(QTreeWidgetItem *item, int column);
135 void onBreakpointItemDoubleClicked(QTreeWidgetItem *item, int column);
137 void onCodeViewContextMenu(const QPoint &pos);
139 void onVariableItemExpanded(QTreeWidgetItem *item);
141 void onVariablesContextMenuRequested(const QPoint &pos);
143 void onOpenFile();
145 void onSaveFile();
147 void onCodeTabCloseRequested(int index);
149 void onReloadLuaPlugins();
151 void onStackItemDoubleClicked(QTreeWidgetItem *item, int column);
153 void onStackCurrentItemChanged(QTreeWidgetItem *current,
154 QTreeWidgetItem *previous);
156 void onMonospaceFontUpdated(const QFont &font);
158 void onMainAppInitialized();
160 void onPreferencesChanged();
162 void onEvaluate();
164 void onEvalClear();
166 void evaluateSelection(const QString &text);
168 void onThemeChanged(int idx);
170 void onEditorFind();
172 void onEditorGoToLine();
173
174 private:
175 Ui::LuaDebuggerDialog *ui;
176 static LuaDebuggerDialog *_instance;
177 static int32_t currentTheme_;
178
185 static void onLuaReloadCallback();
186
193 static void onLuaPostReloadCallback();
194
201 static void onScriptLoadedCallback(const char *file_path);
202
203 QEventLoop *eventLoop;
204 QCheckBox *enabledCheckBox;
205 QString lastOpenDirectory;
206 bool breakpointTabsPrimed;
207 QIcon folderIcon;
208 QIcon fileIcon;
209 bool debuggerPaused;
210 bool reloadDeferred;
212 int stackSelectionLevel;
213
214 // Collapsible sections (created programmatically)
215 CollapsibleSection *variablesSection;
216 CollapsibleSection *stackSection;
217 CollapsibleSection *breakpointsSection;
218 CollapsibleSection *filesSection;
219 CollapsibleSection *evalSection;
220 CollapsibleSection *settingsSection;
221
222 // Tree widgets (created programmatically)
223 QTreeWidget *variablesTree;
224 QTreeWidget *stackTree;
225 QTreeWidget *fileTree;
226 QTreeWidget *breakpointsTree;
227
228 // Eval panel widgets (created programmatically)
229 QPlainTextEdit *evalInputEdit;
230 QPlainTextEdit *evalOutputEdit;
231 QPushButton *evalButton;
232 QPushButton *evalClearButton;
233
234 // Settings panel widgets (created programmatically)
235 QComboBox *themeComboBox;
236
238 void updateStack();
251 void updateVariables(QTreeWidgetItem *parent = nullptr,
252 const QString &path = QString());
254 void updateBreakpoints();
260 LuaDebuggerCodeView *loadFile(const QString &file_path);
262 LuaDebuggerCodeView *currentCodeView() const;
264 bool hasUnsavedChanges() const;
266 qint32 unsavedOpenScriptTabCount() const;
273 bool ensureUnsavedChangesHandled(const QString &title);
275 void clearAllDocumentModified();
277 bool saveCodeView(LuaDebuggerCodeView *view);
279 bool saveAllModified();
281 void updateTabTextForCodeView(LuaDebuggerCodeView *view);
283 void updateSaveActionState();
285 void updateWindowModifiedState();
287 void showAccordionFrame(AccordionFrame *frame, bool toggle = false);
293 void installDescendantShortcutFilters();
295 void applyCodeEditorFonts(const QFont &monoFont);
297 void applyMonospacePanelFonts();
299 void refreshAvailableScripts();
305 void scanScriptDirectory(const QString &dir_path);
312 QString normalizedFilePath(const QString &file_path) const;
314 void syncDebuggerToggleWithCore();
316 void updateEnabledCheckboxIcon();
325 QTreeWidgetItem *findChildItemByPath(QTreeWidgetItem *parent,
326 const QString &path) const;
333 bool
334 appendPathComponents(const QString &file_path,
335 QVector<QPair<QString, QString>> &components) const;
340 void openInitialBreakpointFiles(const QVector<QString> &files);
342 void updateStatusLabel();
346 void configureVariablesTreeColumns();
348 void configureStackTreeColumns();
350 void clearPausedStateUi();
352 void clearAllCodeHighlights();
354 void applyMonospaceFonts();
356 void applyCodeViewThemes();
359 void reloadAllScriptFiles();
361 QFont effectiveMonospaceFont(bool zoomed) const;
363 QFont effectiveRegularFont() const;
366 void resumeDebuggerAndExitLoop();
371 void runDebuggerStep(void (*step_fn)(void));
374 void updateEvalPanelState();
376 void updateWidgets();
378 void createCollapsibleSections();
379
380 // ---- Qt-based JSON settings persistence (like import_hexdump) ----
382 QVariantMap settings_;
385 void loadSettingsFile();
388 void saveSettingsFile();
390 void applyDialogSettings();
392 void storeDialogSettings();
393};
394
395#endif // LUA_DEBUGGER_DIALOG_H
A QFrame that shows and hides itself with a slide animation.
Definition accordion_frame.h:21
A collapsible section widget for use in a QSplitter.
Definition collapsible_section.h:31
A dialog that remembers its geometry and splitter state.
Definition geometry_state_dialog.h:20
Editable code editor supporting gutter breakpoints and highlighting.
Definition lua_debugger_code_editor.h:136
Top-level dialog hosting the Lua debugger UI components.
Definition lua_debugger_dialog.h:189
static LuaDebuggerDialog * instance(QWidget *parent=nullptr)
Retrieve the singleton instance, creating it if needed.
void childEvent(QChildEvent *event) override
Handle child widget events.
Definition lua_debugger_dialog.cpp:1046
void updateWidgets()
Update all widgets based on the current debugger state.
Definition lua_debugger_dialog.cpp:1648
void handleEscapeKey()
Escape: hide inline find/go accordions if shown, else close dialog. Invoked from the script editor be...
void handlePause(const char *file_path, int64_t line)
React to the debugger pausing execution at a breakpoint.
void ensureDebuggerEnabledForActiveBreakpoints()
Enable the debugger if any active breakpoint requires it.
Definition lua_debugger_dialog.cpp:1664
void updateLuaEditorAuxFrames()
Point find / goto bars at the active code tab.
Definition lua_debugger_dialog.cpp:1125
void clearPausedStateUi()
Remove paused-state UI artifacts like stacks and highlights.
Definition lua_debugger_dialog.cpp:1428
void onCodeViewContextMenu(const QPoint &pos)
Build and show the editor context menu (right-click in a code tab). Routed through Qt's signal/slot m...
Definition lua_debugger_dialog.cpp:1212
void refreshVariablesForCurrentStackFrame()
Rebuild the variables tree after the stack frame for inspection changed.
Definition lua_debugger_variables.cpp:405
static int32_t currentTheme()
Get the current theme setting.
~LuaDebuggerDialog()
Destroy the dialog and disconnect debugger callbacks.
bool event(QEvent *event) override
Handle general events.
Definition lua_debugger_dialog.cpp:985
bool eventFilter(QObject *obj, QEvent *event) override
Filter events for child objects to intercept shortcuts.
Definition lua_debugger_dialog.cpp:1062
QString normalizedFilePath(const QString &file_path) const
Normalize a path by trimming prefixes and resolving symbolic components. Public so controllers and th...
Definition lua_debugger_dialog.cpp:1399
void updateContinueActionState()
Enable or disable the Continue action based on debugger state.
Definition lua_debugger_dialog.cpp:1618
void reject() override
Close from Esc or programmatic reject(); queues close() so closeEvent() runs (unsaved-scripts prompt ...
LuaDebuggerDialog(QWidget *parent=nullptr)
Construct the dialog and initialize all child widgets.
void closeEvent(QCloseEvent *event) override
Flush state and resume execution when the dialog closes.
bool ensureFileTreeEntry(const QString &file_path)
Ensure the hierarchical file tree contains the supplied script path.