OSDN Git Service

[llvm-objdump] --source: drop the warning when there is no debug info
authorFangrui Song <i@maskray.me>
Thu, 4 Feb 2021 17:07:44 +0000 (09:07 -0800)
committerTom Stellard <tstellar@redhat.com>
Sat, 20 Feb 2021 06:09:42 +0000 (22:09 -0800)
commitee7eaf860cde24a91a5b17390b8ad5eddd05f7f9
tree499bfb80e7609bb205c51051e0b1b962b15b4dc8
parentbdafd284b291436d3fa4644f585efe3b06363554
[llvm-objdump] --source: drop the warning when there is no debug info

Warnings have been added for three cases (PR41905): (1) missing debug info, (2)
the source file cannot be found, (3) the debug info points at a line beyond the
end of the file.

(1) is probably less useful. This was brought up once on
http://lists.llvm.org/pipermail/llvm-dev/2020-April/141264.html and two
internal users mentioned it to me that it was annoying. (I personally
find the warning confusing, too.)

Users specify --source to get additional information if sources happen to be
available.  If sources are not available, it should be obvious as the output
will have no interleaved source lines. The warning can be especially annoying
when using llvm-objdump -S on a bunch of files.

This patch drops the warning when there is no debug info.
(If LLVMSymbolizer::symbolizeCode returns an `Error`, there will still be
an error. There is currently no test for an `Error` return value.
The only code path is probably a broken symbol table, but we probably already emit a warning
in that case)

`source-interleave-prefix.test` has an inappropriate "malformed" test - the test simply has no
.debug_* because new llc does not produce debug info when the filename is empty (invalid).
I have tried tampering the header of .debug_info/.debug_line but llvm-symbolizer does not warn.
This patch does not intend to add the missing test coverage.

Differential Revision: https://reviews.llvm.org/D88715

(cherry picked from commit eecbb1c77655d38c06e47cf32e2dcc72da45c517)
llvm/test/tools/llvm-objdump/X86/source-interleave-no-debug-info.test
llvm/test/tools/llvm-objdump/X86/source-interleave-prefix.test
llvm/tools/llvm-objdump/llvm-objdump.cpp