llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

llvm-symbolizer: prints incorrect location with -inlining=0

Open KernelAddress opened this issue 10 years ago • 5 comments

Bugzilla Link 26065
Resolution WONTFIX
Resolved on Jun 08, 2018 23:54
Version unspecified
OS Linux
CC @eugenis,@kcc,@vitalybuka

Extended Description

Output with -inlining=1:

__preempt_count_add ./arch/x86/include/asm/preempt.h:69:0 __rcu_read_lock include/linux/rcupdate.h:301:0 rcu_read_lock include/linux/rcupdate.h:859:0 find_get_entry mm/filemap.c:1035:0

Output with -inlining=0:

find_get_entry ./arch/x86/include/asm/preempt.h:69:0

preempt.h:69 defines __preempt_count_add function. Combination of find_get_entry and preempt.h:69 does not make sense.

-inlining=0 output should be:

find_get_entry mm/filemap.c:1035:0

That is, print matching outermost/physical function name and location.

KernelAddress avatar Jan 07 '16 18:01 KernelAddress

Not sure why I even called llvm-symbolizer manually. Closing.

KernelAddress avatar Jun 09 '18 06:06 KernelAddress

Can we close it?

vitalybuka avatar Jun 09 '18 02:06 vitalybuka

You need to pass "-use-symbol-table=0" to get the following output: Otherwise we overwrite __preempt_count_add with what is stored in the symbol table.

-use-symbol-table is only an optimization to provide more precise info for cases when there is no debug info or debug info is incomplete. It must not affect what we print. While I can use this suggestion as a workaround, it does not look like a correct general guide line to me.

It's not an optimization, it tells the tool whether it should prefer symbol table to debug info (if we suspect debug info is poor). I agree the existing behavior is confusing, of course.

Why should we print outermost location?

Because symbols are more fundamental. That's what one sees in nm and objdump output. Inlined top frame is more artificial construct that is useful is fewer contexts. So if we print only one frame, that should be symbol.

^^ Please justify your statement about "fewer contexts". If you're symbolizing PC, you probably want to see source code corresponding to this instruction, not the part of the object file it's called from.

For instance:

  • I want to find all callers of zzzqxx(). I find all addresses of all "callq " instructions and pipe them through llvm-symbolizer. If "zzzqxx" is called from a single function defined in a header file, I want to see only this function, not 100 larger functions it's inlined into.
  • I look at objdump of an enormous function, and see suboptimal (or weird) generated code. I want to learn which of dozens inlined functions produced that instructions, fire off llvm-symbolizer and feed PC to it.

Check what GDB prints when you type "list" - I don't think it gives you the outermost function.

What are your use cases? Can you run the tool with "-inlining=1" and take the outermost frame?

Also, we can't print inlined top frame when debug info is missing or incomplete. That means that the tool will behave radically differently depending on presence of inlining info.

I don't see this as a problem: we're trying to be as precise as possible. if we can get inlining information from binary: why not use it?

llvmbot avatar Jan 07 '16 21:01 llvmbot

You need to pass "-use-symbol-table=0" to get the following output: Otherwise we overwrite __preempt_count_add with what is stored in the symbol table.

-use-symbol-table is only an optimization to provide more precise info for cases when there is no debug info or debug info is incomplete. It must not affect what we print. While I can use this suggestion as a workaround, it does not look like a correct general guide line to me.

Why should we print outermost location?

Because symbols are more fundamental. That's what one sees in nm and objdump output. Inlined top frame is more artificial construct that is useful is fewer contexts. So if we print only one frame, that should be symbol. Also, we can't print inlined top frame when debug info is missing or incomplete. That means that the tool will behave radically differently depending on presence of inlining info.

KernelAddress avatar Jan 07 '16 20:01 KernelAddress

You need to pass "-use-symbol-table=0" to get the following output:

__preempt_count_add ./arch/x86/include/asm/preempt.h:69:0

Otherwise we overwrite __preempt_count_add with what is stored in the symbol table.

Why should we print outermost location? The address you provided corresponds to corresponds to function __preempt_count_add defined in ./arch/x86/include/asm/preempt.h, why should we print the information about the caller of this function?

I agree that we should be smart enough and not overwrite the function name with symbol table entry if we're printing info for inlined code location, though.

llvmbot avatar Jan 07 '16 20:01 llvmbot