问题
Is there a way to obtain a list of functions that were NOT inlined anywhere? Either by passing an option to gcc or by inspecting the binary?
EDIT: I know how to explicitly ask for a function not to be inlined by using gcc's builtin attribute noinline.
回答1:
Use gcc's -fdump-tree-all and search the dump files for "inline".
回答2:
Add -fdump-ipa-inline to your compiler options.
Grep the file yoursourcefile.inline which is created next to the object file for "Considering inline candidate" to find out all functions that the compiler considered inlining.
Grep the file for "Inlined into" to find out all functions that the compiler finally did inline.
Grep for "inline_failed:" if you are interested for the reason why the compiler turned down a candidate (e.g. "call is unlikely and code size would grow").
回答3:
You can use nm command in Unix/Linux to get list of symbols in a binary.
If the function is not inlined its symbol name will be present in the binary.
回答4:
'inline' is NOT an attribute of a function, a function can be both inlined and non-inlined. when you call a function, the compiler decide whether inline it or not, if there are multiple calls, the compiler may choose different option for different call. if there is at least one non-inlined call, the function will be appear in the symbol table. and if it is exported it will also appear in the symbol table.
so there is no way to check a function is inlined or not, you can only check a specific call is inlined or not by reverse engineer.
来源:https://stackoverflow.com/questions/9190359/how-to-find-out-which-functions-were-not-inlined