DBMonitor CallStack

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
a-s-z
Posts: 106
Joined: Wed 03 Dec 2008 06:01

DBMonitor CallStack

Post by a-s-z » Wed 20 Jan 2010 11:14

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?

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Wed 20 Jan 2010 17:26

Will you publish your changes :-)

a-s-z
Posts: 106
Joined: Wed 03 Dec 2008 06:01

Post by a-s-z » Thu 21 Jan 2010 05:09

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.

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Thu 21 Jan 2010 07:04

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 21 Jan 2010 09:17

We will add this code to the next ODAC build.

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Thu 21 Jan 2010 23:03

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

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 25 Jan 2010 09:20

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;

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Mon 25 Jan 2010 11:57

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]

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 26 Jan 2010 08:46

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)'

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Tue 26 Jan 2010 09:37

But isn't it interesting to get the values of the method parameter's?

Kind regards
Jens

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 28 Jan 2010 13:50

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.

jfudickar
Posts: 202
Joined: Fri 10 Mar 2006 13:03
Location: Oberursel / Germany

Post by jfudickar » Thu 28 Jan 2010 23:30

@ a-s-z:

Will you publish your madexcept code. I'm a little bit busy :-)

Kind regards
Jens

a-s-z
Posts: 106
Joined: Wed 03 Dec 2008 06:01

Post by a-s-z » Fri 29 Jan 2010 06:40

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;

Post Reply