public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Need help for doing gcc modifications
@ 2004-09-06 16:53 Perret Yannick
  2004-09-07 22:57 ` James E Wilson
  0 siblings, 1 reply; 3+ messages in thread
From: Perret Yannick @ 2004-09-06 16:53 UTC (permalink / raw)
  To: gcc

Hello,

first, I'm a newcomer in this list, so I hope this mail
is not out of topic.

Here is my "problem":
I'm trying to understand gcc source code (for my own
culture) and I decide to create a modified version of
it (I'm working on source tree 3.4.1) to test and understand
it.

I decided to add a new profiling function "ala"
instrument-functions, which will do exactly the same
job but with transmit additionnal informations to the
__cyg_profile_func_{enter|exit} functions.

As I saw that a function is available in gcc/functions.c
to get the name of the currently treated function
(current_function_name which use the lang_hooks),
I decided to add the name to the parameters of the
profile functions.

I successfully added a new gcc option '-finstrument-functions-full'
with all the needed declarations, and I create the call
code to functions __cyg_profile_function_{enter|exit}_details,
with for the moment the same parameters (from, to).

The modified gcc works fine, recognizing the options and
adding the calls to these functions.


Here is my problem:
I tried to add additionnal parameters for these functions, by
modifying the emit_library_call (in functions.c).
Using other uses of this function I managed to add simple
parameters such as intergers, but I do not know how to add
a 'const char *'... First the name returned by current_function_name
is in a the gcc space, not in the compiled program space, so
I think I have to create inside the compiled program space
a constant string to hold that name.
In addition each parameters need a pair of 'rtx'/'machine_mode',
and I can't figure how to generate them. I suppose that if I manage
to add the string in the program scope, I will obtain a 'rtx', and
that I have to find the 'machine_mode' which correspond to the
'const char *' for the convertion.

Please can you help me for that ? Or give me a good pointer
on a doc which explains that points ?
Maybe also what I'm trying to do is not possible, at least by
this way. Do not hesitate to branch me to other methods.

Thank in advance.

Regards,
--
Yannick Perret


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

* Re: Need help for doing gcc modifications
  2004-09-06 16:53 Need help for doing gcc modifications Perret Yannick
@ 2004-09-07 22:57 ` James E Wilson
  2004-09-10  9:07   ` Perret Yannick
  0 siblings, 1 reply; 3+ messages in thread
From: James E Wilson @ 2004-09-07 22:57 UTC (permalink / raw)
  To: yperret; +Cc: gcc

Perret Yannick wrote:
> I tried to add additionnal parameters for these functions, by
> modifying the emit_library_call (in functions.c).

emit_library_call is for emitting so-called libcalls, which are calls to 
helper functions in libgcc.  It doesn't handle all possible argument 
types correctly, and it isn't wise to use it for anything complicated. 
It is really only useful for integer and floating point arguments and 
return values.

> Using other uses of this function I managed to add simple
> parameters such as intergers, but I do not know how to add
> a 'const char *'... First the name returned by current_function_name
> is in a the gcc space, not in the compiled program space, so
> I think I have to create inside the compiled program space
> a constant string to hold that name.

Strings only exist in the front end and middle end, not in the back end.

Looking at expand_expr, case STRING_CST, I see it calls 
output_constant_def.  So you need to create a STRING_CST tree, and then 
pass it to output_constant_def.  There might be other ways to handle this.

> In addition each parameters need a pair of 'rtx'/'machine_mode',
> and I can't figure how to generate them.

Either you don't what the rtx is, then I probably can't help you much. 
For machine_mode, GET_MODE (rtx) probably works in all cases.  For a 
string pointer, this should be Pmode.

> Please can you help me for that ? Or give me a good pointer
> on a doc which explains that points ?

We don't have good docs for stuff like this.  There is just too much 
different stuff to document, and it all changes so often, and sometimes 
so completely, that attempts to document stuff to the detail you need 
tend to be futile.  If you want to do work on gcc, you just have to put 
in the time needed to learn how the internals work.

We do have some stuff on the Further Readings section of the web site, 
but I'm not sure if anything there will be helpful to you.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

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

* Re: Need help for doing gcc modifications
  2004-09-07 22:57 ` James E Wilson
@ 2004-09-10  9:07   ` Perret Yannick
  0 siblings, 0 replies; 3+ messages in thread
From: Perret Yannick @ 2004-09-10  9:07 UTC (permalink / raw)
  To: James E Wilson; +Cc: gcc



James E Wilson wrote:

> Perret Yannick wrote:
>
>> I tried to add additionnal parameters for these functions, by
>> modifying the emit_library_call (in functions.c).
>
>
> emit_library_call is for emitting so-called libcalls, which are calls 
> to helper functions in libgcc.  It doesn't handle all possible 
> argument types correctly, and it isn't wise to use it for anything 
> complicated. It is really only useful for integer and floating point 
> arguments and return values.

Okay. I first used this because it is the way '-finstrument-functions' 
is managed.
So I have to choose an other approach or I have to add the missing 
features at
least for the types I want to use (int and char*).

>
>> Using other uses of this function I managed to add simple
>> parameters such as intergers, but I do not know how to add
>> a 'const char *'... First the name returned by current_function_name
>> is in a the gcc space, not in the compiled program space, so
>> I think I have to create inside the compiled program space
>> a constant string to hold that name.
>
>
> Strings only exist in the front end and middle end, not in the back end.
>
> Looking at expand_expr, case STRING_CST, I see it calls 
> output_constant_def.  So you need to create a STRING_CST tree, and 
> then pass it to output_constant_def.  There might be other ways to 
> handle this.
>
Yes. After parsing (many) source code I find out this tree type... I was 
thinking that
the way is to add an expression tree inside the function tree...
I will search around that.

>> In addition each parameters need a pair of 'rtx'/'machine_mode',
>> and I can't figure how to generate them.
>
>
> Either you don't what the rtx is, then I probably can't help you much. 
> For machine_mode, GET_MODE (rtx) probably works in all cases.  For a 
> string pointer, this should be Pmode.
>
>> Please can you help me for that ? Or give me a good pointer
>> on a doc which explains that points ?
>
>
> We don't have good docs for stuff like this.  There is just too much 
> different stuff to document, and it all changes so often, and 
> sometimes so completely, that attempts to document stuff to the detail 
> you need tend to be futile.

Ok.

>   If you want to do work on gcc, you just have to put in the time 
> needed to learn how the internals work.

That's what I'm doing. But some help is sometime usefull to accelerate 
learing :o)
Thank you very much for your explanations.

>
> We do have some stuff on the Further Readings section of the web site, 
> but I'm not sure if anything there will be helpful to you.

Yes. I had a look to that section and read some stuff in it, but it is 
visibly not the stuff I need.

Thanks again for your answer. If I manage to finish this change I will 
send a report about that
for people how should be interessed.

Regards,
--
Yannick Perret


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

end of thread, other threads:[~2004-09-10  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-06 16:53 Need help for doing gcc modifications Perret Yannick
2004-09-07 22:57 ` James E Wilson
2004-09-10  9:07   ` Perret Yannick

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