[llvm-dev] How to handle DWARF Missing due to function elimination?

chuanqi.xcq via llvm-dev
2021-05-27T11:11:07Z

Hi,

Recently I met a problem incurred by DWARF Missing. Simply, if a function gets
inlined to a call site,
the dwarf infomation for the call site maybe:
```
DW_TAG_inlined_subroutine:
    DW_AT_abstract_origin (0x0123456)
```
The gdb would blame when it finds 0x0123456 doesn't refer to any functions
in dwarf format.

From my point of view, the reason there is unexist DW_AT_abstract_origin is due
to function elimination.
For example,
```
static void foo() { ... } // only used by bar
void bar() {
    foo();
}
```
After foo gets inlined to bar, there is no user of foo. So the compiler could
and should remove foo. However,
the compiler removes the debug info of foo, so the callsite in bar can't
find definition of foo in the current module.

There is a brief introduction. I met this problem in ThinLTO. But I believe the
function elimination should be the root cause.
I am not sure if this is a bug about compiler or about the debugger. For
example, the debugger should emit a warning instead
of crashing. It affects how should solve this problem.

I  made a copy to some people who are familiar with debug info to my knowledge.
If this is not polite and disturbing, just inform me.

Thanks,
Chuanqi



-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20210527/8f8634ca/attachment.html>