Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
LuaDebuggerDialog Class Reference

Top-level dialog hosting the Lua debugger UI components. More...

#include <lua_debugger_dialog.h>

Inheritance diagram for LuaDebuggerDialog:
GeometryStateDialog GeometryStateDialog

Public Slots

void onCodeViewContextMenu (const QPoint &pos)
 Build and show the editor context menu (right-click in a code tab). Routed through Qt's signal/slot mechanism, so it must be visible from connect() sites in the code-tabs controller.
 
void handleEscapeKey ()
 Escape: hide inline find/go accordions if shown, else close dialog. Invoked from the script editor because keys often go to the viewport, not the top-level dialog event filter.
 
void runToCurrentLineInPausedEditor (LuaDebuggerCodeView *codeView, qint32 line)
 Run-to-line dispatch from the focused paused editor. Public so LuaDebuggerKeyRouter can fire it from the dialog's event filter without reaching into private members. Same entry point used by the gutter context menu's "Run to Line".
 
void handleEscapeKey ()
 Escape: hide inline find/go accordions if shown, else close dialog. Invoked from the script editor because keys often go to the viewport, not the top-level dialog event filter.
 

Public Member Functions

 LuaDebuggerDialog (QWidget *parent=nullptr)
 Construct the dialog and initialize all child widgets.
 
 ~LuaDebuggerDialog ()
 Destroy the dialog and disconnect debugger callbacks.
 
void handlePause (const char *file_path, int64_t line)
 React to the debugger pausing execution at a breakpoint.
 
void reject () override
 Close from Esc or programmatic reject(); queues close() so closeEvent() runs (unsaved-scripts prompt matches the window close button). The base QDialog::reject() hides via done() and skips closeEvent(); synchronous close() from Esc can fail to close.
 
void addWatchFromSpec (const QString &watchSpec)
 Add a watch from an expression/path spec without opening the inline editor. Convenience used by the editor right-click menu and by the Variables panel context menu.
 
LuaDebuggerChangeHighlightTrackerchangeHighlight ()
 Borrowed reference to the change-highlight tracker. Used by controllers that compute "changed since last pause" cues without having to friend the dialog.
 
LuaDebuggerStackControllerstackController ()
 Borrowed reference to the stack controller. Used by Watch / Variables / Eval to read the currently inspected stack frame without friending the dialog.
 
bool isDebuggerPaused () const
 True while the dialog is in a pause-entry / nested event-loop UI. Mirrors the C side's wslua_debugger_is_paused on most paths but is updated from a different code path; controllers that need the Qt-side flag read it via this accessor.
 
bool changeHighlightAllowed () const
 Combined "is the change-highlight cue allowed for paint this pass?" gate. Reads the tracker policy with the active stack selection level; centralised here so callers do not have to thread the level themselves.
 
void applyChangedVisuals (QStandardItem *valueCell, bool changed)
 Stamp valueCell with the change-highlight visuals; the dialog supplies itself as the timer owner so the one-shot row flash gets cleaned up if the dialog is destroyed.
 
QKeySequence addWatchShortcut () const
 Shortcut bound to the Add Watch toolbar action. Watch / Variables context menus mirror it on their "Add Watch" entries.
 
QString pausedFile () const
 Source file path (normalized) of the line the debugger is paused on; empty when not paused. Paired with pausedLine.
 
qlonglong pausedLine () const
 Line number of the pause; zero when the debugger is not paused. Paired with pausedFile.
 
QCheckBox * enabledToggle ()
 Borrowed reference to the toggle that mirrors the core's enable/disable state; the reload coordinator round-trips it across a forced-on reload.
 
QString normalizedFilePath (const QString &file_path) const
 Normalize a path by trimming prefixes and resolving symbolic components. Public so controllers and the capture-suppression helper can canonicalise paths without friending the dialog.
 
void refreshDebuggerStateUi ()
 Refresh checkbox sync + all debugger state chrome/widgets.
 
void updateWidgets ()
 Update all widgets based on the current debugger state.
 
void ensureDebuggerEnabledForActiveBreakpoints ()
 Enable the debugger if any active breakpoint requires it.
 
void refreshVariablesForCurrentStackFrame ()
 Rebuild the variables tree after the stack frame for inspection changed.
 
void syncVariablesTreeToCurrentWatch ()
 Select the Variables row matching the current Watch row, or clear the Variables selection when no match exists.
 
void updateLuaEditorAuxFrames ()
 Point find / goto bars at the active code tab.
 
void updatePausedErrorFrame ()
 Populate/hide the inline error frame for paused break-on-error states.
 
void scheduleErrorFrameHide (int delayMs)
 Schedule a delayed hide to avoid hide/show flicker on rapid re-pauses.
 
void cancelErrorFrameHide ()
 Cancel any pending delayed hide token.
 
void updateContinueActionState ()
 Enable or disable the Continue action based on debugger state.
 
void clearPausedStateUi ()
 Remove paused-state UI artifacts like stacks and highlights.
 
void setSaveActionEnabled (bool enabled)
 Toggle the toolbar Save Script action's enabled state. Surfaced as a typed setter so the code-tabs controller does not need to reach into the dialog's QAction members.
 
bool tearDownPauseLoopForReload ()
 Tear down an active pause loop because the Lua engine is about to be reloaded under us. Returns true if a pause loop was active (the caller may need to defer follow-up work to the post-reload phase). Unlike resumeDebuggerAndExitLoop, the engine is NOT signalled to continue; the reload owns restarting the VM.
 
 LuaDebuggerDialog (QWidget *parent=nullptr)
 Construct the dialog and initialize all child widgets.
 
 ~LuaDebuggerDialog ()
 Destroy the dialog and disconnect debugger callbacks.
 
void handlePause (const char *file_path, int64_t line)
 React to the debugger pausing execution at a breakpoint.
 
bool ensureFileTreeEntry (const QString &file_path)
 Ensure the hierarchical file tree contains the supplied script path.
 
void reject () override
 Close from Esc or programmatic reject(); queues close() so closeEvent() runs (unsaved-scripts prompt matches the window close button). The base QDialog::reject() hides via done() and skips closeEvent(); synchronous close() from Esc can fail to close.
 
Controller accessors

Borrowed references to the dialog's per-panel controllers. Returned by reference because the controllers are direct (non-pointer) members of the dialog and have the same lifetime as the dialog itself. Callers must not store these references past the dialog's destruction.

LuaDebuggerVariablesControllervariablesController ()
 Gets the variables controller.
 
LuaDebuggerCodeTabsControllercodeTabsController ()
 Gets the code tabs controller.
 
LuaDebuggerFilesControllerfilesController ()
 Gets the files controller.
 
LuaDebuggerWatchControllerwatchController ()
 Gets the watch controller.
 
LuaDebuggerBreakpointsControllerbreakpointsController ()
 Gets the breakpoints controller.
 
LuaDebuggerPauseControllerpauseController ()
 Gets the pause controller.
 
LuaDebuggerLuaReloadCoordinatorreloadCoordinator ()
 Gets the Lua reload coordinator.
 
LuaDebuggerEvalControllerevalController ()
 Gets the evaluation controller.
 
LuaDebuggerFontPolicyfontPolicy ()
 Gets the font policy.
 
- Public Member Functions inherited from GeometryStateDialog
 GeometryStateDialog (QWidget *parent, Qt::WindowFlags f=Qt::Window)
 Constructs a new GeometryStateDialog with the specified parent and window flags.
 
 ~GeometryStateDialog ()
 Save the geometry and splitter state and then destroy the GeometryStateDialog.
 
void setWindowModality (Qt::WindowModality windowModality)
 Sets the window modality for the dialog. On non-macOS platforms, this also sets the parent to ensure modal dialogs are always on top of their parent.
 

Static Public Member Functions

static int32_t currentTheme ()
 Get the current theme setting.
 
static LuaDebuggerDialoginstance (QWidget *parent=nullptr)
 Retrieve the singleton instance, creating it if needed.
 
static LuaDebuggerDialoginstanceIfExists ()
 Like instance but never creates the dialog; returns nullptr when no instance exists yet. Used by helpers that may run before the dialog has ever been opened.
 
static bool handleMainCloseIfPaused (QCloseEvent *event)
 If the debugger is paused or owns unsaved scripts, defer the supplied main-window close event so the Lua C stack can unwind first; otherwise return false and let the main window close normally.
 
static int32_t currentTheme ()
 Get the current theme setting.
 
static LuaDebuggerDialoginstance (QWidget *parent=nullptr)
 Retrieve the singleton instance, creating it if needed.
 

Protected Member Functions

void closeEvent (QCloseEvent *event) override
 Flush state and resume execution when the dialog closes.
 
void showEvent (QShowEvent *event) override
 Handle widget show events.
 
bool event (QEvent *event) override
 Handle general events.
 
bool eventFilter (QObject *obj, QEvent *event) override
 Filter events for child objects to intercept shortcuts.
 
void childEvent (QChildEvent *event) override
 Handle child widget events.
 
void closeEvent (QCloseEvent *event) override
 Flush state and resume execution when the dialog closes.
 
bool eventFilter (QObject *obj, QEvent *event) override
 
void childEvent (QChildEvent *event) override
 
- Protected Member Functions inherited from GeometryStateDialog
void loadGeometry (int width=0, int height=0, const QString &dialog_name=QString())
 Loads the geometry and splitter state for the dialog.
 
void loadSplitterState (QSplitter *splitter=nullptr)
 Loads the state of a splitter for the dialog.
 

Detailed Description

Top-level dialog hosting the Lua debugger UI components.

Constructor & Destructor Documentation

◆ LuaDebuggerDialog() [1/2]

LuaDebuggerDialog::LuaDebuggerDialog ( QWidget *  parent = nullptr)
explicit

Construct the dialog and initialize all child widgets.

Parameters
parentOptional parent widget used for ownership and stacking.

◆ LuaDebuggerDialog() [2/2]

LuaDebuggerDialog::LuaDebuggerDialog ( QWidget *  parent = nullptr)
explicit

Construct the dialog and initialize all child widgets.

Parameters
parentOptional parent widget used for ownership and stacking.

Member Function Documentation

◆ addWatchFromSpec()

void LuaDebuggerDialog::addWatchFromSpec ( const QString &  watchSpec)

Add a watch from an expression/path spec without opening the inline editor. Convenience used by the editor right-click menu and by the Variables panel context menu.

Parameters
watchSpecThe watch specification string.

◆ addWatchShortcut()

QKeySequence LuaDebuggerDialog::addWatchShortcut ( ) const

Shortcut bound to the Add Watch toolbar action. Watch / Variables context menus mirror it on their "Add Watch" entries.

Returns
The key sequence for adding a watch.

◆ applyChangedVisuals()

void LuaDebuggerDialog::applyChangedVisuals ( QStandardItem *  valueCell,
bool  changed 
)
inline

Stamp valueCell with the change-highlight visuals; the dialog supplies itself as the timer owner so the one-shot row flash gets cleaned up if the dialog is destroyed.

Parameters
valueCellThe cell to apply visuals to.
changedTrue to show as changed, false otherwise.

◆ breakpointsController()

LuaDebuggerBreakpointsController & LuaDebuggerDialog::breakpointsController ( )
inline

Gets the breakpoints controller.

Returns
Reference to the breakpoints controller.

◆ changeHighlight()

LuaDebuggerChangeHighlightTracker & LuaDebuggerDialog::changeHighlight ( )
inline

Borrowed reference to the change-highlight tracker. Used by controllers that compute "changed since last pause" cues without having to friend the dialog.

Returns
Reference to the highlight tracker.

◆ changeHighlightAllowed()

bool LuaDebuggerDialog::changeHighlightAllowed ( ) const
inline

Combined "is the change-highlight cue allowed for paint this pass?" gate. Reads the tracker policy with the active stack selection level; centralised here so callers do not have to thread the level themselves.

Returns
True if highlight change visuals are permitted.

◆ childEvent()

void LuaDebuggerDialog::childEvent ( QChildEvent *  event)
overrideprotected

Handle child widget events.

Parameters
eventThe child event.

◆ closeEvent() [1/2]

void LuaDebuggerDialog::closeEvent ( QCloseEvent *  event)
overrideprotected

Flush state and resume execution when the dialog closes.

Parameters
eventClose request metadata from Qt.

◆ closeEvent() [2/2]

void LuaDebuggerDialog::closeEvent ( QCloseEvent *  event)
overrideprotected

Flush state and resume execution when the dialog closes.

Parameters
eventClose request metadata from Qt.

◆ codeTabsController()

LuaDebuggerCodeTabsController & LuaDebuggerDialog::codeTabsController ( )
inline

Gets the code tabs controller.

Returns
Reference to the code tabs controller.

◆ currentTheme() [1/2]

int32_t LuaDebuggerDialog::currentTheme ( )
static

Get the current theme setting.

Returns
Theme enum value (WSLUA_DEBUGGER_THEME_AUTO, DARK, or LIGHT).

◆ currentTheme() [2/2]

static int32_t LuaDebuggerDialog::currentTheme ( )
static

Get the current theme setting.

Returns
Theme enum value (WSLUA_DEBUGGER_THEME_AUTO, DARK, or LIGHT).

◆ enabledToggle()

QCheckBox * LuaDebuggerDialog::enabledToggle ( )
inline

Borrowed reference to the toggle that mirrors the core's enable/disable state; the reload coordinator round-trips it across a forced-on reload.

Returns
Pointer to the enabled checkbox.

◆ ensureFileTreeEntry()

bool LuaDebuggerDialog::ensureFileTreeEntry ( const QString &  file_path)

Ensure the hierarchical file tree contains the supplied script path.

This is public because it is called from a C callback that iterates loaded Lua scripts.

Parameters
file_pathPath to split and insert.
Returns
True if a new leaf entry was added.

◆ evalController()

LuaDebuggerEvalController & LuaDebuggerDialog::evalController ( )
inline

Gets the evaluation controller.

Returns
Reference to the eval controller.

◆ event()

bool LuaDebuggerDialog::event ( QEvent *  event)
overrideprotected

Handle general events.

Parameters
eventThe event.
Returns
True if handled, false otherwise.

◆ eventFilter()

bool LuaDebuggerDialog::eventFilter ( QObject *  obj,
QEvent *  event 
)
overrideprotected

Filter events for child objects to intercept shortcuts.

Parameters
objThe child object.
eventThe event.
Returns
True if the event is filtered out, false otherwise.

◆ filesController()

LuaDebuggerFilesController & LuaDebuggerDialog::filesController ( )
inline

Gets the files controller.

Returns
Reference to the files controller.

◆ fontPolicy()

LuaDebuggerFontPolicy & LuaDebuggerDialog::fontPolicy ( )
inline

Gets the font policy.

Returns
Reference to the font policy.

◆ handleMainCloseIfPaused()

bool LuaDebuggerDialog::handleMainCloseIfPaused ( QCloseEvent *  event)
static

If the debugger is paused or owns unsaved scripts, defer the supplied main-window close event so the Lua C stack can unwind first; otherwise return false and let the main window close normally.

Called from WiresharkMainWindow::closeEvent / StratosharkMainWindow::closeEvent through LuaDebugger::tryDeferMainWindowClose.

Parameters
eventThe close event from the main window.
Returns
true if the close has been deferred (the caller MUST treat the event as ignored and return without closing); false to let the main window close normally.

◆ handlePause() [1/2]

void LuaDebuggerDialog::handlePause ( const char *  file_path,
int64_t  line 
)

React to the debugger pausing execution at a breakpoint.

Parameters
file_pathPath of the Lua file that triggered the pause.
lineLine number where execution stopped.

◆ handlePause() [2/2]

void LuaDebuggerDialog::handlePause ( const char *  file_path,
int64_t  line 
)

React to the debugger pausing execution at a breakpoint.

Parameters
file_pathPath of the Lua file that triggered the pause.
lineLine number where execution stopped.

◆ instance() [1/2]

LuaDebuggerDialog * LuaDebuggerDialog::instance ( QWidget *  parent = nullptr)
static

Retrieve the singleton instance, creating it if needed.

Parameters
parentOptional parent widget supplied when instantiating.
Returns
Pointer to the global dialog instance.

◆ instance() [2/2]

static LuaDebuggerDialog * LuaDebuggerDialog::instance ( QWidget *  parent = nullptr)
static

Retrieve the singleton instance, creating it if needed.

Parameters
parentOptional parent widget supplied when instantiating.
Returns
Pointer to the global dialog instance.

◆ instanceIfExists()

LuaDebuggerDialog * LuaDebuggerDialog::instanceIfExists ( )
static

Like instance but never creates the dialog; returns nullptr when no instance exists yet. Used by helpers that may run before the dialog has ever been opened.

Returns
Pointer to the global dialog instance if it exists, otherwise nullptr.

◆ isDebuggerPaused()

bool LuaDebuggerDialog::isDebuggerPaused ( ) const
inline

True while the dialog is in a pause-entry / nested event-loop UI. Mirrors the C side's wslua_debugger_is_paused on most paths but is updated from a different code path; controllers that need the Qt-side flag read it via this accessor.

Returns
True if the debugger is paused in the UI.

◆ normalizedFilePath()

QString LuaDebuggerDialog::normalizedFilePath ( const QString &  file_path) const

Normalize a path by trimming prefixes and resolving symbolic components. Public so controllers and the capture-suppression helper can canonicalise paths without friending the dialog.

Parameters
file_pathThe path to normalize.
Returns
The canonicalized path.

◆ onCodeViewContextMenu

void LuaDebuggerDialog::onCodeViewContextMenu ( const QPoint &  pos)
slot

Build and show the editor context menu (right-click in a code tab). Routed through Qt's signal/slot mechanism, so it must be visible from connect() sites in the code-tabs controller.

Parameters
posThe position to show the menu.

◆ pauseController()

LuaDebuggerPauseController & LuaDebuggerDialog::pauseController ( )
inline

Gets the pause controller.

Returns
Reference to the pause controller.

◆ pausedFile()

QString LuaDebuggerDialog::pausedFile ( ) const
inline

Source file path (normalized) of the line the debugger is paused on; empty when not paused. Paired with pausedLine.

Returns
The file path where execution is paused.

◆ pausedLine()

qlonglong LuaDebuggerDialog::pausedLine ( ) const
inline

Line number of the pause; zero when the debugger is not paused. Paired with pausedFile.

Returns
The line number where execution is paused.

◆ reloadCoordinator()

LuaDebuggerLuaReloadCoordinator & LuaDebuggerDialog::reloadCoordinator ( )
inline

Gets the Lua reload coordinator.

Returns
Reference to the reload coordinator.

◆ runToCurrentLineInPausedEditor

void LuaDebuggerDialog::runToCurrentLineInPausedEditor ( LuaDebuggerCodeView codeView,
qint32  line 
)
slot

Run-to-line dispatch from the focused paused editor. Public so LuaDebuggerKeyRouter can fire it from the dialog's event filter without reaching into private members. Same entry point used by the gutter context menu's "Run to Line".

Parameters
codeViewThe code view initiating the run.
lineThe target line number.

◆ scheduleErrorFrameHide()

void LuaDebuggerDialog::scheduleErrorFrameHide ( int  delayMs)

Schedule a delayed hide to avoid hide/show flicker on rapid re-pauses.

Parameters
delayMsDelay in milliseconds before hiding.

◆ setSaveActionEnabled()

void LuaDebuggerDialog::setSaveActionEnabled ( bool  enabled)

Toggle the toolbar Save Script action's enabled state. Surfaced as a typed setter so the code-tabs controller does not need to reach into the dialog's QAction members.

Parameters
enabledTrue to enable the action, false to disable.

◆ showEvent()

void LuaDebuggerDialog::showEvent ( QShowEvent *  event)
overrideprotected

Handle widget show events.

Parameters
eventThe show event.

◆ stackController()

LuaDebuggerStackController & LuaDebuggerDialog::stackController ( )
inline

Borrowed reference to the stack controller. Used by Watch / Variables / Eval to read the currently inspected stack frame without friending the dialog.

Returns
Reference to the stack controller.

◆ tearDownPauseLoopForReload()

bool LuaDebuggerDialog::tearDownPauseLoopForReload ( )

Tear down an active pause loop because the Lua engine is about to be reloaded under us. Returns true if a pause loop was active (the caller may need to defer follow-up work to the post-reload phase). Unlike resumeDebuggerAndExitLoop, the engine is NOT signalled to continue; the reload owns restarting the VM.

Returns
true if a pause loop was active, false otherwise.

◆ variablesController()

LuaDebuggerVariablesController & LuaDebuggerDialog::variablesController ( )
inline

Gets the variables controller.

Returns
Reference to the variables controller.

◆ watchController()

LuaDebuggerWatchController & LuaDebuggerDialog::watchController ( )
inline

Gets the watch controller.

Returns
Reference to the watch controller.

The documentation for this class was generated from the following files: