This is an archive of the discontinued LLVM Phabricator instance.

llvm-symbolizer: Add a FRAME command.
ClosedPublic

Authored by pcc on Jun 17 2019, 8:35 PM.

Details

Summary

This command prints a description of the referenced function's stack frame.
For each formal parameter and local variable, the tool prints:

  • function name
  • variable name
  • file/line of declaration
  • FP-relative variable location (if available)
  • size in bytes
  • HWASAN tag offset

This information will be used by the HWASAN runtime to identify local
variables in UAR reports.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Jun 17 2019, 8:35 PM

More ideas for tests: multi dimensional arrays, two levels of inlining, lexical scopes.

llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
987 ↗(On Diff #205237)

I'm not very familiar with this: is that true for all targets?

1006 ↗(On Diff #205237)

I think this is not correct for multi-dimensional arrays.

This is a int [10][20] array:

0x00000053: DW_TAG_array_type

DW_AT_type	(0x00000065 "int")

0x00000058: DW_TAG_subrange_type

DW_AT_type	(0x0000006c "__ARRAY_SIZE_TYPE__")
DW_AT_count	(0x0a)

0x0000005e: DW_TAG_subrange_type

DW_AT_type	(0x0000006c "__ARRAY_SIZE_TYPE__")
DW_AT_count	(0x14)
1014 ↗(On Diff #205237)

Do you want to look at lower bound, too?

llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
144 ↗(On Diff #205237)

Should we simply not print anything when tag offset is missing? It's completely optional, after all. It's a bit confusing to see "??" in the output for normal (non-hwasan) binary and makes me think that some debug info got lost or stripped.

pcc marked 4 inline comments as done.Jun 21 2019, 4:34 PM
pcc added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
987 ↗(On Diff #205237)

It's true for pointers to member functions on all Itanium targets:
http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp#510

I forgot about pointers to data members,which are a single pointer width. I'll add a case for that.

It's not true with the Microsoft ABI, but in that case the debug info format will be CodeView not DWARF anyway.

1006 ↗(On Diff #205237)

Good catch. That's a... surprising way to represent that.

1014 ↗(On Diff #205237)

Might as well. I don't think this can actually happen in C/C++ but it could in Fortran or other languages with one-based arrays.

llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp
144 ↗(On Diff #205237)

I guess the other fields are technically optional as well (e.g. debug info could represent location without frame offset, or no location at all, or without type information) so it seems simplest to handle all of them the same way.

pcc updated this revision to Diff 206110.Jun 21 2019, 6:16 PM
  • Address review comments
pcc marked 3 inline comments as done.Jun 21 2019, 6:17 PM
This revision is now accepted and ready to land.Jun 24 2019, 11:15 AM
ormris removed a subscriber: ormris.Jun 24 2019, 11:20 AM

Do this mean that to report this HWASAN will need binary compiled with -g ?

pcc added a comment.Jun 24 2019, 12:55 PM

Do this mean that to report this HWASAN will need binary compiled with -g ?

Yes, it depends on debug info that isn't included with -g1.

This revision was automatically updated to reflect the committed changes.