On 19.02.2018 11:14, Sven Barth via fpc-devel wrote:
Am 19.02.2018 11:01 schrieb "Ondrej Pokorny" <laza...@kluug.net
<mailto:laza...@kluug.net>>:
I agree with Simon here. It's a similar scenario like heaptrc. Why
not to add a compiler parameter to include profiling info? That
would be just great.
It's not the same scenario as heaptrc is entirely working in the RTL
without any compiler extension (aside from the -gh parameter).
First of all - if you read my sentence again I said it is a */similar/*
scenario and not the */same/* scenario.
BUT: to be completely exact a small compiler extension comes with -gh as
well and that you cannot achieve with the RTL - if
http://wiki.freepascal.org/heaptrc is not wrong: /Note: Do not add the
heaptrc unit manually. The heaptrc unit needs to be loaded before
lineinfo and only the compiler can do that./
So yes, -gh injects the heaptrc unit in front of lineinfo and the
profiling compiler parameter injects profiling code into every compiled
procedure/method. Don't tell me you don't see any similarities here :)
And yes, even the word "same" can be seen as valid here, if you like
word games :)
Second: FPProfiler works already now entirely in the RTL without any
compiler extension. Your above statement just doesn't make sense.
Profiling code however would require extensions to the compiler
whereby it would also need to handle exceptions correctly and such things.
Yes, I am again absolutely aware of this and I still believe it's
possible and probably even not that hard to achieve. You just need to
inject a try-finally block (= "handles exceptions correctly") around
every procedure/function block:
procedure Test;
begin
EnterProfiling('MyUnit.Test');
try
// <<< real code here
finally
LeaveProfiling('MyUnit.Test');
end;
end;
Of course EnterProfiling and LeaveProfiling must be thread safe (every
thread to be profiled separately) - and they even can be a part of the
RTL, the same as heaptrc code is. EnterProfiling and LeaveProfiling must
eat all intern exceptions - this is perfectly doable in the RTL.
All in all, in my eyes absolutely doable and a great and valid compiler
extension. And again - very very similar scenario to heaptrc, if you
don't like the word "same".
Ondrej
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel