Page 1 of 1
DBMonitor CallStack
Posted: Wed 20 Jan 2010 11:14
by a-s-z
Hi,
I wan to extend the db monitor to transfer the delphi call stack. I have changed the implementation of SendDBMonitorEvent to fill the CallStack field of TMonitorEvent, but what is the required format to enable the call tree in db monitor app?
Posted: Wed 20 Jan 2010 17:26
by jfudickar
Will you publish your changes

Posted: Thu 21 Jan 2010 05:09
by a-s-z
Hi,
I have added a new procedure variable to interface part of DASQLMonitor.pas:
Code: Select all
var
GetCallStackProc: procedure (var ACallStack: TWideStringDynArray);
and added the call of this procedure to SendDBMonitorEvent:
Code: Select all
if Assigned(GetCallStackProc) then
GetCallStackProc(Msg.CallStack);
in the custom procedure I am using madExcept to get the current call stack and make up the call stack string array.
Posted: Thu 21 Jan 2010 07:04
by jfudickar
Hi,
this sounds easy.
@Oleg: I hope that you can integrate something similar into the production code, that we don't need to do this every time.
Kind regards
Jens
Posted: Thu 21 Jan 2010 09:17
by Plash
We will add this code to the next ODAC build.
Posted: Thu 21 Jan 2010 23:03
by jfudickar
Realy good news!!
Will you also include a sample of the structure of the result list, and how it could be filled?
kind regards
Jens
Posted: Mon 25 Jan 2010 09:20
by Plash
This is just an array of method names:
Code: Select all
procedure FillCallStack(var CallStack: TWideStringDynArray);
begin
SetLength(CallStack, 3);
CallStack[0] := 'TClass1.Method1';
CallStack[1] := 'TClass2.Method2';
CallStack[2] := 'TClass3.Method3';
end;
Posted: Mon 25 Jan 2010 11:57
by jfudickar
So something like would work also:
Code: Select all
procedure FillCallStack(var CallStack: TWideStringDynArray);
begin
SetLength(CallStack, 3);
CallStack[0] := 'TClass1.Method1 (p1 : ''abcd'', p2 : 123)';
CallStack[1] := 'TClass2.Method2 (p1 : ''abcd'')';
CallStack[2] := 'TClass3.Method3';
end;
Kind regards
Jens[/quote]
Posted: Tue 26 Jan 2010 08:46
by Plash
Method name should be the same for each call. Otherwise dbMonitor duplicates methods in Call Tree.
Normally you pass the parameter data types but not values:
Code: Select all
'TClass1.Method1 (p1 : string, p2 : integer)'
Posted: Tue 26 Jan 2010 09:37
by jfudickar
But isn't it interesting to get the values of the method parameter's?
Kind regards
Jens
Posted: Thu 28 Jan 2010 13:50
by Plash
You can pass the parameter values in the method names. But dbMonitor does not support this. You will see correct call stack for each event. But Call Tree will not be correct.
Posted: Thu 28 Jan 2010 23:30
by jfudickar
@ a-s-z:
Will you publish your madexcept code. I'm a little bit busy
Kind regards
Jens
Posted: Fri 29 Jan 2010 06:40
by a-s-z
Hi Jens,
jfudickar wrote:@ a-s-z:
Will you publish your madexcept code. I'm a little bit busy
Kind regards
Jens
Here it goes:
Code: Select all
procedure GetCallStackMadExcept(var ACallStack: TWideStringDynArray);
var
off, idx: Integer;
AStackTrace: TStackTrace;
begin
madExcept.GetThreadStackTrace(0, False, True, True, @AStackTrace);
off := 1;
while off 0 then
ACallStack[idx] := 'line: ' + IntToStr(relLine) + ', '
else
ACallStack[idx] := '';
ACallStack[idx] := UnitName + '.' + FunctionName + ' (' +
ACallStack[idx] + '[' + ModuleName + '])@$' + IntToHex(Integer(Addr) - relAddr, 8);
end;
end;