This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ mangling, function name to mangled name (or tree)


Le 6 juil. 2011 à 18:40, Pierre Vittet a écrit :

> On 06/07/2011 18:25, Kevin André wrote:
>> On Wed, Jul 6, 2011 at 18:00, Pierre Vittet<piervit@pvittet.com>  wrote:
>> 
>>   
>>> I would like user of the plugin to give in arguments the name of the
>>> functions on which he would like a test to be run. That means that I must
>>> convert the string containing a function name (like "myclass::init") and get
>>> either the mangled name or the tree corresponding to the function. I know
>>> that there might be several results (functions with the same name and
>>> different arguments), a good policy for me would be to recover every
>>> concerned functions (at least for the moment).
>>> 
>>> I guess what I want to do is possible, because there are already some tools
>>> doing it (like gdb).
>>>     
>> Are you absolutely sure about gdb? It could be doing it the other way
>> around, i.e. start from the mangled names in the object file and
>> demangle all of them. Then it would search for a function name in its
>> list of demangled names.
>> Just guessing, though :)
>> 
>> 
>> Regards,
>> 
>> Kevin André
>> 
>>   
> Hello,
> 
> no I am not sure, but I guess it would really have an important cost to do it like you said. Would it no be easier to have a field containing the 'demangled' names? At least in debug since it has an important space complexity.
> 
> Thanks!
> 
> Pierre Vittet

Hello,

Have you considered the reverse way to do that. I mean, why don't you hook on the PLUGIN_PRE_GENERICIZE event to catch all function bodies, and then compare the argument the user gave you to current_function_name() (that will returns you the full protoype of the current function, ie: malloc   full name is "void* malloc(size_t)"). Then, you can store the FUNCTION_DECL tree if there's a match and use it for later processing. That's how i proceed for my plugins.

Romain Geissler


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]