From 8494ca68fbbf767664e8786c10211015b5935ff2 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 7 Mar 2023 17:48:20 +0100 Subject: [PATCH] Debugger: Inspect dialog, fix missing data in some rows of a structure (remove line breaks) --- ide/packages/idedebugger/idedebuggerutils.pas | 34 +++++++++++++++++++ ide/packages/idedebugger/inspectdlg.pas | 30 ++++++++-------- ide/packages/idedebugger/watchesdlg.pp | 33 ------------------ 3 files changed, 49 insertions(+), 48 deletions(-) diff --git a/ide/packages/idedebugger/idedebuggerutils.pas b/ide/packages/idedebugger/idedebuggerutils.pas index c6a3803915..9ca7846f79 100644 --- a/ide/packages/idedebugger/idedebuggerutils.pas +++ b/ide/packages/idedebugger/idedebuggerutils.pas @@ -10,6 +10,7 @@ uses function HexDigicCount(ANum: QWord; AByteSize: Integer = 0; AForceAddr: Boolean = False): integer; function QuoteText(AText: Utf8String): UTf8String; function QuoteWideText(AText: WideString): WideString; +function ClearMultiline(const AValue: ansistring): ansistring; implementation @@ -211,5 +212,38 @@ begin until False; end; +function ClearMultiline(const AValue: ansistring): ansistring; +var + j: SizeInt; + ow: SizeInt; + NewLine: Boolean; +begin + ow:=0; + SetLength(Result{%H-},Length(AValue)); + NewLine:=true; + for j := 1 to Length(AValue) do begin + if (AValue[j]=#13) or (AValue[j]=#10) then begin + NewLine:=true; + inc(ow); + Result[ow]:=#32; // insert one space instead of new line + end + else if Avalue[j] in [#9,#32] then begin + if not NewLine then begin // strip leading spaces after new line + inc(ow); + Result[ow]:=#32; + end; + end else begin + inc(ow); + Result[ow]:=AValue[j]; + NewLine:=false; + end; + end; + If ow>255 then begin + //Limit watch to 255 chars in length + Result:=Copy(Result,1,252)+'...'; + end else begin + SetLength(Result,ow); + end; +end; end. diff --git a/ide/packages/idedebugger/inspectdlg.pas b/ide/packages/idedebugger/inspectdlg.pas index 9a0e49c412..02455f6d13 100644 --- a/ide/packages/idedebugger/inspectdlg.pas +++ b/ide/packages/idedebugger/inspectdlg.pas @@ -38,11 +38,11 @@ uses DbgIntfDebuggerBase, DbgIntfBaseTypes, LazClasses, SpinEx, LazDebuggerIntf, LazDebuggerIntfBaseTypes, // IDE - BaseDebugManager, InputHistory, Debugger, - IdeDebuggerWatchResPrinter, IdeDebuggerWatchResult, IdeDebuggerWatchResUtils, - IdeDebuggerBase, ArrayNavigationFrame, IdeDebuggerOpts, - IdeDebuggerBackendValueConv, WatchInspectToolbar, DebuggerDlg, - EnvironmentOpts, RecentListProcs, IdeDebuggerStringConstants; + BaseDebugManager, InputHistory, Debugger, IdeDebuggerWatchResPrinter, + IdeDebuggerWatchResult, IdeDebuggerWatchResUtils, IdeDebuggerBase, + ArrayNavigationFrame, IdeDebuggerOpts, IdeDebuggerBackendValueConv, + WatchInspectToolbar, DebuggerDlg, EnvironmentOpts, RecentListProcs, + IdeDebuggerStringConstants, IdeDebuggerUtils; type @@ -198,7 +198,7 @@ begin WatchInspectNav1.ColTypeEnabled := True; WatchInspectNav1.ColVisibilityEnabled := False; - v := FWatchPrinter.PrintWatchValue(Res, wdfDefault); + v := ClearMultiline(FWatchPrinter.PrintWatchValue(Res, wdfDefault)); StatusBar1.SimpleText:=ShortenedExpression+' : '+Res.TypeName + ' = ' + v; GridDataSetup; @@ -224,11 +224,11 @@ begin WatchInspectNav1.ColTypeEnabled := True; WatchInspectNav1.ColVisibilityEnabled := False; - v := FWatchPrinter.PrintWatchValue(Res, wdfDefault); + v := ClearMultiline(FWatchPrinter.PrintWatchValue(Res, wdfDefault)); StatusBar1.SimpleText:=ShortenedExpression+' : '+Res.TypeName + ' = ' + v; GridDataSetup; - v := FWatchPrinter.PrintWatchValue(Res, wdfPointer); + v := ClearMultiline(FWatchPrinter.PrintWatchValue(Res, wdfPointer)); FGridData.Cells[1,1]:=WatchInspectNav1.Expression; FGridData.Cells[2,1]:=Res.TypeName; FGridData.Cells[3,1]:=v; @@ -238,7 +238,7 @@ begin FGridData.RowCount := 3; FGridData.Cells[1,2]:=Format(lisInspectPointerTo, ['']); FGridData.Cells[2,2]:=Res.TypeName; - FGridData.Cells[3,2]:=FWatchPrinter.PrintWatchValue(Res, wdfDefault); + FGridData.Cells[3,2]:=ClearMultiline(FWatchPrinter.PrintWatchValue(Res, wdfDefault)); end; end; @@ -260,7 +260,7 @@ begin WatchInspectNav1.ColTypeEnabled := True; WatchInspectNav1.ColVisibilityEnabled := False; - v := FWatchPrinter.PrintWatchValue(Res, wdfDefault); + v := ClearMultiline(FWatchPrinter.PrintWatchValue(Res, wdfDefault)); StatusBar1.SimpleText:=ShortenedExpression+' : '+Res.TypeName + ' = ' + v; GridDataSetup; @@ -343,7 +343,7 @@ begin Entry := Res.SelectedEntry; FGridData.Cells[1,i+1-SubStart] := IntToStr(LowBnd + ResIdxOffs + i); FGridData.Cells[2,i+1-SubStart] := Entry.TypeName; - FGridData.Cells[3,i+1-SubStart] := FWatchPrinter.PrintWatchValue(Entry, wdfDefault); + FGridData.Cells[3,i+1-SubStart] := ClearMultiline(FWatchPrinter.PrintWatchValue(Entry, wdfDefault)); end; end; end; @@ -457,7 +457,7 @@ begin else FGridData.Cells[2,f] := ''; if Fld <> nil - then FGridData.Cells[3,f] := FWatchPrinter.PrintWatchValue(Fld, wdfDefault) + then FGridData.Cells[3,f] := ClearMultiline(FWatchPrinter.PrintWatchValue(Fld, wdfDefault)) else FGridData.Cells[3,f] := ''; FGridData.Cells[4,f] := FieldLocationNames[FldInfo.FieldVisibility]; @@ -1220,7 +1220,7 @@ begin // skDecomposable: ; else begin Clear; - StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); + StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, ClearMultiline(FHumanReadable)]); ErrorLabel.Caption :=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); PageControl.ActivePage := ErrorPage; end; @@ -1280,7 +1280,7 @@ begin // rdkConvertRes: InspectResDataStruct; else begin Clear; - StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); + StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, ClearMultiline(FHumanReadable)]); ErrorLabel.Caption :=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); PageControl.ActivePage := ErrorPage; end; @@ -1291,7 +1291,7 @@ begin end; Clear; - StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); + StatusBar1.SimpleText:=Format(lisInspectUnavailableError, [ShortenedExpression, ClearMultiline(FHumanReadable)]); ErrorLabel.Caption :=Format(lisInspectUnavailableError, [ShortenedExpression, FHumanReadable]); PageControl.ActivePage := ErrorPage; end; diff --git a/ide/packages/idedebugger/watchesdlg.pp b/ide/packages/idedebugger/watchesdlg.pp index 4173127783..28311aa66c 100644 --- a/ide/packages/idedebugger/watchesdlg.pp +++ b/ide/packages/idedebugger/watchesdlg.pp @@ -1188,39 +1188,6 @@ end; procedure TWatchesDlg.UpdateItem(const VNode: PVirtualNode; const AWatch: TIdeWatch); - function ClearMultiline(const AValue: ansistring): ansistring; - var - j: SizeInt; - ow: SizeInt; - NewLine: Boolean; - begin - ow:=0; - SetLength(Result{%H-},Length(AValue)); - NewLine:=true; - for j := 1 to Length(AValue) do begin - if (AValue[j]=#13) or (AValue[j]=#10) then begin - NewLine:=true; - inc(ow); - Result[ow]:=#32; // insert one space instead of new line - end - else if Avalue[j] in [#9,#32] then begin - if not NewLine then begin // strip leading spaces after new line - inc(ow); - Result[ow]:=#32; - end; - end else begin - inc(ow); - Result[ow]:=AValue[j]; - NewLine:=false; - end; - end; - If ow>255 then begin - //Limit watch to 255 chars in length - Result:=Copy(Result,1,252)+'...'; - end else begin - SetLength(Result,ow); - end; - end; function DoDelayedDelete: Boolean; begin // In case the debugger did ProcessMessages, and a "delete" action was triggered