[PATCH] D124493: [symbolizer] Parse DW_TAG_variable DIs to show line info for globals
Mitch Phillips via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 26 18:09:11 PDT 2022
hctim created this revision.
hctim added reviewers: vitalybuka, pcc.
Herald added subscribers: ormris, dexonsmith, rupprecht, steven_wu, hiraditya, mgorny, emaste.
Herald added a reviewer: jhenderson.
Herald added a project: All.
hctim requested review of this revision.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, MaskRay.
Herald added projects: clang, Sanitizers, LLVM.
Currently, llvm-symbolizer doesn't like to parse .debug_info in order to
show the line info for global variables. addr2line does this. In the
future, I'm looking to migrate AddressSanitizer off of internal metadata
over to using debuginfo, and this is predicated on being able to get the
line info for global variables.
This patch adds the requisite support for getting the line info from the
.debug_info section for symbolizing global variables. This only happens
when you ask for a global variable to be symbolized as data.
Move Sanitizer metadata to be on-GlobalValue.
Currently sanitizer metadata is stored in a global LLVM metadata table,
generally "llvm.asan.globals". This contains certain attributes relevant
to the sanitizers that need to be carried around.
A while ago, when working on MTE globals, I discovered that some of the
GlobalOpt passes would delete a global variable, and replace it with
a new global variable. These optimisation passes clean up all the
general references, but don't clean up the sanitizer-specific metadata
because that wasn't associated well with the original global.
I could have just fixed that, but decided to actually fix the
outstanding N-year-old comment of "this should really be part of the
GlobalValue itself". So, remove the old sanitizer-specific global
descriptions, and move the information about sanitization to be on the
Because we don't want to carry around too much information on the
GlobalValue, I also made it so that we don't carry around the line
number and column information for each global variable in the binary in
an ASan-specific way. Instead, this patch (along with some dependencies
that add support in llvm-symbolizer and friends) changes ASan to look
for debuginfo to get this information. This mean that without debuginfo,
global-buffer-overflows and ODR reports now say "variable 'foo' defined
in 'my_source_file.cpp'" instead of "variable 'foo' defined in
'my_source_file.cpp:123:2'" (note that we still have the source line
from the file descriptions). I think this is a reasonable change.
This also provides binary savings of 0.275% when building clang under
rG LLVM Github Monorepo
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 123827 bytes
Desc: not available
More information about the cfe-commits