Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
848 views
in Technique[技术] by (71.8m points)

delphi - How can I increase the size of the string that an external debugger visualizer can display?

I am once again writing an external debugger visualizer, and am running into a wall. There appears to be a limit to the size of the string that the debugger visualizer can return.

The TStrings debugger visualizer that shipped with Delphi 2010 had a limit of 4K. In a response to a question posted on Embarcadero's newsgroups, Ewe Schuster replied that "You can increase the buffer a little bit, but AFAIR the actual limitation is in IOTAThread.Evaluate with a limit of about 12k chars."

My debugger visualizer is based on the code of the TStrings debugger visualizer, and I can see that the implementation of the TFrame's Evaluate method includes the following declaration of ResultStr, which is used to return the string returned from the IOTAThread.Evaluate call:

  ResultStr: array[0..4095] of Char;

I had hoped that increasing the size of this buffer would help, but no luck.

What can I do, if anything, to increase the size of the string that my external debugger visualizer can display?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I had the same limited patience for that limit... So I made a debug visualizer that work around the limitation mostly by creating a MemoryStream in the debugged process to hold the string result of the Expression, then use something like

CurProcess.ReadProcessMemory(StrToInt(SrcMemoryAddr), DstMemStream.Size, DstMemStream.Memory^);

to copy it into a visualizer's MemoryStream. Then you can do whatever you want to display it (for instance formatting it for human reading if it's an XML string like a CLientDataSet.XMLData).

There are few tricks depending if the Expression is a const string, a var, or needs evaluation etc...

My FGStringVisualizer is not 100% satisfying, which is why I haven't published it yet on my blog, but as it does 99% of what I need, I didn't take the time to clean it a bit and publish it even "as-is". But if there is a need I can certainly do it with all needed disclaimers...

Update: It's the same idea that I used for my FGStringListVisualizer that I presented at the last DelphiLive. By the way, this one also might be worth putting on my blog as I made a few improvements since.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...