ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

Remove c keywords when parsing function signatures

Open astrelsky opened this issue 1 year ago • 8 comments

This makes life much easier since you can just copy/paste the signature from source.

astrelsky avatar Apr 27 '24 09:04 astrelsky

It is not a C Parser. How do you expect it to handle something like unsigned int?

ghidra1 avatar Apr 30 '24 19:04 ghidra1

It is not a C Parser. How do you expect it to handle something like unsigned int?

The same way it did before. All the changes here do is remove the C keywords Ghidra doesn't support.

I don't know why I didn't specify this initially. Sorry about that.

astrelsky avatar Apr 30 '24 22:04 astrelsky

Sorry, I forgot that the parser handled some C cases like "unsigned int" based upon specific cases defined by the DataTypeUtilities.cPrimitiveMap. So it appears to already support some C-specific syntax.

ghidra1 avatar May 02 '24 17:05 ghidra1

It may be preferable to handle this within the DataTypeUtiliies.getCPrimitiveDataType method so it be handled as a leading modifier which can be ignored.

ghidra1 avatar May 02 '24 17:05 ghidra1

The "struct" and "union" keywords need to be handled special and should agree with any resulting datatype instead of simply being ignored. These cannot be handled in the same manner as the others which can be ignored.

ghidra1 avatar May 02 '24 18:05 ghidra1

The "inline" modifier should probably be handled separately so that it can toggle the function's inline flag and should not apply to all data type parsing

ghidra1 avatar May 02 '24 18:05 ghidra1

If you prefer, I can add this to my cue and address in a more appropriate fashion.

ghidra1 avatar May 02 '24 18:05 ghidra1

If you prefer, I can add this to my cue and address in a more appropriate fashion.

That's fine with me.

The "inline" modifier should probably be handled separately so that it can toggle the function's inline flag and should not apply to all data type parsing

I'm not convinced it should. Mainly because if it is a separate function in the resulting program, then the compiler decided not to inline it and it actually is a function call in the original code.

astrelsky avatar May 02 '24 18:05 astrelsky