Recent

Author Topic: Code instrumentation plz  (Read 13971 times)

hinst

  • Sr. Member
  • ****
  • Posts: 303
Code instrumentation plz
« on: July 15, 2014, 04:04:02 pm »
Is there a free tool for Object Pascal code instrumentation which can for example insert calls like:
Code: [Select]
procedure TFffuuu.Meow;
begin
  NotifyProcedureEntered('TFffuuu.Meow'); // <- tool inserts call here 
  ... // method body here
  NotifyProcedureExited('TFffuuu.Meow'); // <- tool inserts call here
end;

any insight appreciated
Too late to escape fate

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12705
  • FPC developer.
Re: Code instrumentation plz
« Reply #1 on: July 15, 2014, 04:05:37 pm »
Afaik the profiler settings insert something like that. But that will be address based, so you'd need a map to transform it back.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Code instrumentation plz
« Reply #2 on: July 15, 2014, 04:16:28 pm »
See also
http://wiki.lazarus.freepascal.org/Profiling
for the various options
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Code instrumentation plz
« Reply #3 on: July 15, 2014, 04:18:52 pm »
Not sure, if it's for profiling task in the end.
Feels like like auto releasing mem approach :)

btw, it should definitely wrap it into try...finally section

Code: [Select]
procedure TFffuuu.Meow;
begin
  NotifyProcedureEntered('TFffuuu.Meow'); // <- tool inserts call here 
  AllocStuff; //ref counting?
  try
  ... // method body here
  finally
    DeallocStuff; //ref counting?
    NotifyProcedureExited('TFffuuu.Meow'); // <- tool inserts call here
  end;
 
end;

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Code instrumentation plz
« Reply #4 on: July 15, 2014, 04:19:45 pm »
I find all profilers not satisfying, I want my own profiler, I only need to automate code instrumentation
Too late to escape fate

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Code instrumentation plz
« Reply #5 on: July 15, 2014, 04:39:27 pm »
I find all profilers not satisfying, I want my own profiler, I only need to automate code instrumentation
Not invented here syndrome?

Check Cody package. Maybe it has something useful.

I'm specifically referring to explode / add "with" block. It feels like something similar to what you need. So with a small patch, you could extend Cody to do what you need.
« Last Edit: July 15, 2014, 04:43:16 pm by skalogryz »

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Code instrumentation plz
« Reply #6 on: July 15, 2014, 05:48:29 pm »
I rather have "everything sucks" syndrome, and not without a reason
Too late to escape fate

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Code instrumentation plz
« Reply #7 on: July 15, 2014, 05:54:26 pm »
Interesting. Have you actually looked at the referenced code or do you have a very precise crystal ball ;)

I would concur with skalogryz' thrust though: perhaps it's easier to fix something that sucks rather than have to write everything from scratch. Your improvements may also help other Lazarus/FPC devs.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Code instrumentation plz
« Reply #8 on: July 15, 2014, 06:21:28 pm »
Well, I currently need profiler which would work for Delphi code as well. I tried two profilers for Delphi and I am not satisfied with them because they provide useless information (at least I could not make any sense of it). They both do not instrument code.

I can't use FPProfiler for this for the following reason: it uses fcl-passrc to parse sources. I already tried using fcl-passrc to parse my sources, it can parse only 100 of 600 units........ yesss....
Too late to escape fate

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Code instrumentation plz
« Reply #9 on: July 15, 2014, 06:25:10 pm »
Ok, so you did do some research - that wasn't apparent from your posts, so I didn't know. Sorry about that.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Code instrumentation plz
« Reply #10 on: July 15, 2014, 06:28:32 pm »
I can't use FPProfiler for this for the following reason: it uses fcl-passrc to parse sources. I already tried using fcl-passrc to parse my sources, it can parse only 100 of 600 units........ yesss....
ok.. any commercial profilers?

btw, what it is in 500 units that passrc cannot handle them?

I know it won't help, but I need to say, that you're profiling in a wrong (non pascalish) manner :)
« Last Edit: July 15, 2014, 06:34:40 pm by skalogryz »

hinst

  • Sr. Member
  • ****
  • Posts: 303
Re: Code instrumentation plz
« Reply #11 on: July 15, 2014, 06:39:09 pm »
btw, what it is in 500 units that passrc cannot handle them?

things like this: {{}   (*{*)   //{
and some other things I can't recall now
Too late to escape fate

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Code instrumentation plz
« Reply #12 on: July 15, 2014, 07:09:25 pm »
things like this: {{}   (*{*)   //{
and some other things I can't recall now
This is odd. Parsing comments is straight forward for Pascal, since comments are not nested.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Code instrumentation plz
« Reply #13 on: July 15, 2014, 07:12:59 pm »
things like this: {{}   (*{*)   //{
and some other things I can't recall now
This is odd. Parsing comments is straight forward for Pascal, since comments are not nested.
It is nestable in Delphi mode, but has to be of different type.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Code instrumentation plz
« Reply #14 on: July 15, 2014, 07:25:14 pm »
It is nestable in Delphi mode, but has to be of different type.
really? Embacradero made comments nestable?

Nestable comments put a serious  restriction on a developer
Code: [Select]
{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
crzy comments like this one
}
would no longer be allowed.

 

TinyPortal © 2005-2018