CnPack Forum


 
Subject: How to get live object from IDE with OTA
AntonioBakula
新警察
Rank: 1



UID 43595
Digest Posts 0
Credits 10
Posts 4
点点分 10
Reading Access 10
Registered 2009-9-19
Location Croatia
Status Offline
Post at 2009-9-19 21:54  Profile | Site | Blog | P.M. 
How to get live object from IDE with OTA

This question is not related to cnPack, so I apologise in advance for that, but I was thinking that maybe some of you know the answer

I am trying to make debugger Visualizer for Dataset classes for Delphi 2010, using build in StringListVisualizer as a reference, but I can't get
viewed object with IOTAThread.Evaluate, btw. StringListVisualizer gets content with eval as string.

I tried casting  value returned from Evaluate in ResultAddr to TDataset but that is not working, in variable Exppresion is dataset variable
name and EvalRes is returne as erOK, but when I try to use Result access violation occures.

Here is the code (this is a slightly modified code from StringList visualizer) :

function TDatasetViewerFrame.GetDataset(Expression: string): TDataset;
var
  CurProcess: IOTAProcess;
  CurThread: IOTAThread;
  ResultStr: array[0..4095] of Char;
  CanModify: Boolean;
  ResultAddr, ResultSize, ResultVal: LongWord;
  EvalRes: TOTAEvaluateResult;
  DebugSvcs: IOTADebuggerServices;
begin
  begin
    Result := nil;
    if Supports(BorlandIDEServices, IOTADebuggerServices, DebugSvcs) then
      CurProcess := DebugSvcs.CurrentProcess;

    if CurProcess <> nil then
    begin
      CurThread := CurProcess.CurrentThread;
      if CurThread <> nil then
      begin
        EvalRes := CurThread.Evaluate(Expression, @ResultStr, Length(ResultStr), CanModify, eseAll, '', ResultAddr, ResultSize, ResultVal,
'', 0);

        case EvalRes of
          erOK:
            Result := TDataset(ResultAddr);  // Result is shown as Inaccessible value in debugger
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-9-20 10:29  Profile | Blog | P.M. 
Could you check the hex value of returned ResultAddr?

Or just check its classname using TObject(ResultAddr).ClassName,
If AV occured, indicate it's not an object, and not a Dataset object.

I'm afraid it's a string such as "([csInheritable])", like shown in Evaluation/Modify window when evaluating an object var in it.
Top
AntonioBakula
新警察
Rank: 1



UID 43595
Digest Posts 0
Credits 10
Posts 4
点点分 10
Reading Access 10
Registered 2009-9-19
Location Croatia
Status Offline
Post at 2009-9-21 17:01  Profile | Site | Blog | P.M. 
Hi Passion !

In Expression variable i have name of an live object (eg. "AdoDataset1") not "([csInheritable])"

Hex value of ResultAddr is $13A46AC

I tried to chek class name of casted pointer but AV occurred, in embarcadero.public.delphi.opentoolsapi I've got an answer that this is not possible because the object's address is in a different virtual address space, to bad

So it seems that is not possible to make visualizer for TDataset classes, anyway thanks for your time
Top
AntonioBakula
新警察
Rank: 1



UID 43595
Digest Posts 0
Credits 10
Posts 4
点点分 10
Reading Access 10
Registered 2009-9-19
Location Croatia
Status Offline
Post at 2009-9-21 18:05  Profile | Site | Blog | P.M. 
I find workaround, but unfortunatly it will work only for dataset that have SaveToFile method, I will evaluate expression (here is the name of dataset variable) + 'SaveToFile('sometempfile')'

this works for TClientDataset
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-9-21 19:47  Profile | Blog | P.M. 
Oh yes. They're not in same process. We can only obtain needed values using whole expression with properties, such as StringList1.Text to get the simple value. Not the object itself.
Top
AntonioBakula
新警察
Rank: 1



UID 43595
Digest Posts 0
Credits 10
Posts 4
点点分 10
Reading Access 10
Registered 2009-9-19
Location Croatia
Status Offline
Post at 2009-9-22 15:52  Profile | Site | Blog | P.M. 
This makes Debug Visualizers pretty limited, I hope that next OTA version will have this possibility
Top
 




All times are GMT++8, the time now is 2024-11-24 13:12

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.022055 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP