How to show TStringList contents in debugger?

I want to display all TStringList content while debugging the application. Instead, I just get pointers. Flist shows only the address.

+6
source share
5 answers

I am using visualizers now that I have D2010. I used a function called CArray, which will return an array of strings. If I add a CArray (MyStringList) to the viewport, I can examine the contents of the list of strings. I used to be used to write VB6 code, and I liked the various "C" functions to convert to a useful type. CArray for string lists and CArray fields for ClientDataset were mostly useful for debugging.

function CArray(List: TStrings): TStrArray; Overload; var i, iCount: Integer; begin iCount := List.Count; SetLength(Result, iCount); for i := 0 to Pred(iCount) do Result[i] := List[i]; end; 
+2
source

If you are using Delphi 2010 or later, the debugger allows this using debugging visualizers .

For older versions, you can reset the contents of the Text property in the Watch window or using OutputDebugString, but this is difficult to read. You can set the clock for each item in the list, but this is only practical for very short lists.

I would probably use an external logging application like CodeSite or SmartInspect , which allows you to flush the contents of a TStringList in one call.

+7
source

Inspect the Text property. This is a concatenated version of a string list.

+4
source

Since I use BDS MMVI, I use the โ€œultra smart smartโ€ method for this problem, I use it for large XML documents. I start the context editor (by the way, a very convenient text editor written in delphi). In the debugger window, simply execute FList.SaveToFile ('contents.txt'), since the context can track file changes, I can see what is happening in my xml files.

Sorry for the smart joke, but it works for me.

World

+3
source

My two cents:

You can evaluate the expression list_instance_variable.SaveToFile('temp_file_name.txt') and then examine the contents of the file in any editor.

To do this, you must use this function anywhere in the code and disable optimization (at least in Delphi 7), otherwise the SaveToFile object code will be deleted by the linker.

+2
source

Source: https://habr.com/ru/post/895077/


All Articles