<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 19.02.2018 11:14, Sven Barth via
fpc-devel wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAFMUeB9+f9e8mm+Gtohgso5g-DFtEah4ZuJoamb4HSz-Sw6dKQ@mail.gmail.com">
<div dir="auto">
<div>
<div class="gmail_extra">
<div class="gmail_quote">Am 19.02.2018 11:01 schrieb "Ondrej
Pokorny" <<a href="mailto:lazarus@kluug.net"
moz-do-not-send="true">lazarus@kluug.net</a>>:<br
type="attribution">
<blockquote class="quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">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.</blockquote>
</div>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">It's not the same scenario as heaptrc is
entirely working in the RTL without any compiler extension
(aside from the -gh parameter).</div>
</div>
</blockquote>
<br>
First of all - if you read my sentence again I said it is a <b><i>similar</i></b>
scenario and not the <b><i>same</i></b> scenario.<br>
<br>
BUT: to be completely exact a small compiler extension comes with
-gh as well and that you cannot achieve with the RTL - if
<a class="moz-txt-link-freetext" href="http://wiki.freepascal.org/heaptrc">http://wiki.freepascal.org/heaptrc</a> is not wrong: <i>Note: Do not
add the heaptrc unit manually. The heaptrc unit needs to be loaded
before lineinfo and only the compiler can do that.</i><br>
<br>
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 :)<br>
<br>
Second: FPProfiler works already now entirely in the RTL without any
compiler extension. Your above statement just doesn't make sense.<br>
<br>
<blockquote type="cite"
cite="mid:CAFMUeB9+f9e8mm+Gtohgso5g-DFtEah4ZuJoamb4HSz-Sw6dKQ@mail.gmail.com">
<div dir="auto">
<div dir="auto">Profiling code however would require extensions
to the compiler whereby it would also need to handle
exceptions correctly and such things.</div>
</div>
</blockquote>
<br>
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:<br>
<br>
procedure Test;<br>
begin<br>
 EnterProfiling('MyUnit.Test');<br>
 try<br>
   // <<< real code here<br>
 finally<br>
   LeaveProfiling('MyUnit.Test');<br>
 end;<br>
end;<br>
<br>
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.<br>
<br>
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".<br>
<br>
Ondrej<br>
</body>
</html>