How to insert functions?
Hugh Leather
hughleat@hotmail.com
Tue Apr 22 15:42:00 GMT 2008
Hi Andrew,
> Yes, I did a bit. it segfaults at
> cgraphunit.c:cgraph_expand_all_functions:1323
> node->lowered = DECL_STRUCT_FUNCTION (node->decl)->cfg != NULL;
> It seems that the node->decl has been nulled by the time it gets
> here. It definitely isn't NULL after leaving my code.
> Can you think of anything that might do that? I figured I must be
> doing something pretty wrong and that there must be tons of examples
> for this kind of thing but I haven't been able to find one.
>
>
> Cheers for the help,
>
> Hugh.
>
> Andrew Haley wrote:
>> Hugh Leather wrote:
>>
>>> Hi,
>>>
>>> I am trying to add a new destructor function to object files I
>>> compile. I'm doing this to instrument programs and then, once the
>>> program has finished I want to print out the statistics I've gathered.
>>> So, just before pass 'remove_useless_stmts' is called on each function
>>> I try to create a static destructor which will print stats for the
>>> current function (and obviously, I don't do it on the functions just
>>> created).
>>>
>>> Below I've put a simpler form, which should work for a one function
>>> program. Calling createFnDecl() creates a new function called
>>> __my_new_function. It should print "It worked!" when the program exits.
>>> Now, with compiler flag -O0, this works just fine, but with -O1 or
>>> above it seg faults the compiler.
>>>
>>> Can anyone tell me what I'm doing wrong?
>>>
>>
>> Nothing obvious to me. Did you debug the point at which the
>> segfault happened?
>>
>> Andrew.
>>
>>
>>
More information about the Gcc
mailing list