From 40b2a0b67f4389fcb097e90247adcd5749406665 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Thu, 2 Jul 2020 06:35:40 +0200 Subject: [PATCH] gdb com, add setting to limit the call stack depth --- CHANGELOG.md | 4 ++++ src/u_gdb.lfm | 2 +- src/u_gdb.pas | 15 +++++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eecd88db..58b5718c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # v3.9.6-dev +## Enhancements + +- GDB commander: added the _macCallStackDepth_ option. It prevents slowdown when on automatic break caused by a stack overflow. + ## Bugs fixed - Editor: wrong position indicated in the call tips when starting to type an array literal, a slice or any other expression involving the square brackets. (#51) diff --git a/src/u_gdb.lfm b/src/u_gdb.lfm index 436d0a22..a43b7143 100644 --- a/src/u_gdb.lfm +++ b/src/u_gdb.lfm @@ -353,7 +353,7 @@ inherited GdbWidget: TGdbWidget end object button4: TDexedToolButton[2] Left = 205 - Height = 28 + Height = 5 Top = 0 AutoSize = True Caption = 'button4' diff --git a/src/u_gdb.pas b/src/u_gdb.pas index 0a3f485d..9a3c9431 100644 --- a/src/u_gdb.pas +++ b/src/u_gdb.pas @@ -8,7 +8,7 @@ uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, RegExpr, ComCtrls, PropEdits, GraphPropEdits, RTTIGrids, Dialogs, ExtCtrls, Menus, Buttons, StdCtrls, process, fpjson, typinfo, Unix, ListViewFilterEdit, SynEdit, - ObjectInspector, + ObjectInspector, math, u_common, u_interfaces, u_widget, u_processes, u_observer, u_synmemo, u_sharedres, u_stringrange, u_dsgncontrols, u_dialogs, u_dbgitf, u_ddemangle, u_writableComponent, EditBtn, strutils, u_controls; @@ -315,10 +315,12 @@ type fHideCpuView: boolean; fDlangBreakpoints: TDlangBreakpoints; fCurrentEvalKind: TGdbEvalKind; + fMaxCallStackDepth: integer; procedure setIgnoredSignals(value: TStringList); procedure setCommandsHistory(value: TStringList); procedure setCustomEvalHistory(value: TStringList); procedure setShortcuts(value: TDebugShortcuts); + procedure setMaxCallStackDepth(value: integer); procedure cleanInvalidHistoryEntries; published property asmSyntax: TAsmSyntax read fAsmSyntax write fAsmSyntax; @@ -335,6 +337,7 @@ type property hideCpuView: boolean read fHideCpuView write fHideCpuView default false; property ignoredSignals: TStringList read fIgnoredSignals write setIgnoredSignals; property keepRedirectedStreams: boolean read fKeepRedirectedStreams write fKeepRedirectedStreams default false; + property maxCallStackDepth: integer read fMaxCallStackDepth write setMaxCallStackDepth default 100; property shortcuts: TDebugShortcuts read fShortcuts write setShortcuts; property showGdbOutput: boolean read fShowGdbOutput write fShowGdbOutput; property showRawMiOutput: boolean read fShowRawMiOutput write fShowRawMiOutput; @@ -679,6 +682,7 @@ var d: TDlangBreakpoint; begin inherited; + fMaxCallStackDepth := 100; fAutoDemangle := true; fAutoGetCallStack:= true; fAutoGetRegisters:= true; @@ -749,6 +753,13 @@ begin fShortcuts.assign(value); end; +procedure TDebugOptionsBase.setMaxCallStackDepth(value: integer); +begin + value := max(1, value); + value := min(1000, value); + fMaxCallStackDepth := value; +end; + procedure TDebugOptionsBase.assign(source: TPersistent); var src: TDebugOptionsBase; @@ -2796,7 +2807,7 @@ end; procedure TGdbWidget.infoStack; begin - gdbCommand('-stack-list-frames', @gdboutJsonize); + gdbCommand('-stack-list-frames 0 ' + intToStr(fOptions.maxCallStackDepth - 1), @gdboutJsonize); end; procedure TGdbWidget.infoVariables;