public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC Plugin introduction
@ 2021-03-29  9:25 Gabriele Serra
  2021-03-30  9:53 ` SAIFI
  0 siblings, 1 reply; 4+ messages in thread
From: Gabriele Serra @ 2021-03-29  9:25 UTC (permalink / raw)
  To: gcc

Hi,

I have written a very basic article on GCC Plugins (how to build a 
plugin from the ground, some info on APIs, and how to instrument code). 
The material is based on GCC 9. The code is fully documented and working.

Would be a great pleasure to be listed on the GCC plugins page. I'm sure 
this will save headaches for someone!

I leave you the link to my article:
- 
https://gabrieleserra.ml/blog/2020-08-27-an-introduction-to-gcc-and-gccs-plugins.html

I hope community will appreciate,

Gabriele Serra
PhD Student @ Scuola Superiore Sant'Anna
Web: gabrieleserra.ml

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC Plugin introduction
  2021-03-29  9:25 GCC Plugin introduction Gabriele Serra
@ 2021-03-30  9:53 ` SAIFI
  2021-04-01 10:25   ` SAIFI
  0 siblings, 1 reply; 4+ messages in thread
From: SAIFI @ 2021-03-30  9:53 UTC (permalink / raw)
  To: gcc

On Mon, 29 Mar 2021, Gabriele Serra wrote:

>
> I have written a very basic article on GCC Plugins (how to build a plugin 
> from the ground, some info on APIs, and how to instrument code). The material 
> is based on GCC 9. The code is fully documented and working.
>
> https://gabrieleserra.ml/blog/2020-08-27-an-introduction-to-gcc-and-gccs-plugins.html
>

Gabriele thanks for sharing the detailed write up.

in the spirit of 'gcc-help', can you please share pointers as to how one can profile C++ code using GCC plugins ?

in your example you mention 'f1 ()'; i'd like to replace that with a instance of class 'X' created and then profile or instrument a member function.

Have you explored that ? any preliminary thoughts on how does one go about doing it ?



warm regards
Saifi.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC Plugin introduction
  2021-03-30  9:53 ` SAIFI
@ 2021-04-01 10:25   ` SAIFI
  0 siblings, 0 replies; 4+ messages in thread
From: SAIFI @ 2021-04-01 10:25 UTC (permalink / raw)
  To: gcc

On Tue, 30 Mar 2021, SAIFI wrote:

> On Mon, 29 Mar 2021, Gabriele Serra wrote:
>
>>
>>  I have written a very basic article on GCC Plugins (how to build a plugin
>>  from the ground, some info on APIs, and how to instrument code). The
>>  material is based on GCC 9. The code is fully documented and working.
>>
>>  https://gabrieleserra.ml/blog/2020-08-27-an-introduction-to-gcc-and-gccs-plugins.html
>> 
>
> Gabriele thanks for sharing the detailed write up.
>
> in the spirit of 'gcc-help', can you please share pointers as to how one can 
> profile C++ code using GCC plugins ?
>

Gabriele please see Stephen Friedl's blog posts on GCC plugins
https://stephanfr.com/category/gcc/

and git repo
https://github.com/stephanfr/GCCPlugin

Have you had a chance to see these posts during your literature survey ? Any thoughts ?


warm regards
Saifi.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* GCC Plugin introduction
@ 2021-03-30 14:11 Gabriele Serra
  0 siblings, 0 replies; 4+ messages in thread
From: Gabriele Serra @ 2021-03-30 14:11 UTC (permalink / raw)
  To: gcc

Hi, Saifi

On Tue, 30 Mar 2021, SAIFI wrote:

> Gabriele thanks for sharing the detailed write up.
> 
> in the spirit of 'gcc-help', can you please share pointers as to how one can profile C++ code using GCC plugins ?
> 
> in your example you mention 'f1 ()'; i'd like to replace that with a instance of class 'X' created and then profile or instrument a member function.
> 
> Have you explored that ? any preliminary thoughts on how does one go about doing it ?
> 
> warm regards
> Saifi.

to be honest, I hadn't the chance to profile C++ code. I think the problem can be solved in different ways.
A quick and dirty solution, you can build 'X' as a singleton and then, in the profiler function (declared as static) get the singleton instance.
However, if your class need to be instanced multiple times, an idea could be to declare the profiler function as static and then pass "this" as the first parameter.
Clearly in this second scenario, your function must "see" in some way the instance of the class X mentioned.

These are my preliminary thoughts but I think the way you can implement this really depends on the use case.

For instance, if your profiler can be executed after the function prologue,
maybe it is possible to operate directly with GIMPLE and realize something like the C++11 lambda function (with the capture list).
Here, unfortunately, I can't say more than this because I hadn't the chance to analyze deeper the question.

However, in next few days, I will investigate on that.

Thank for the question
Regards,
Gabriele Serra


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-01 10:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-29  9:25 GCC Plugin introduction Gabriele Serra
2021-03-30  9:53 ` SAIFI
2021-04-01 10:25   ` SAIFI
2021-03-30 14:11 Gabriele Serra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).