This is an archive of the discontinued LLVM Phabricator instance.

Refactor MemoryMappingLayout::Next to use a single struct instead of output parameters. NFC.
ClosedPublic

Authored by fjricci on Jul 7 2017, 11:18 AM.

Details

Summary

This is the first in a series of patches to refactor sanitizer_procmaps
to allow MachO section information to be exposed on darwin.

In addition, grouping all segment information in a single struct is
cleaner than passing it through a large set of output parameters, and
avoids the need for annotations of NULL parameters for unneeded
information.

The filename string is optional and must be managed and supplied by the
calling function. This is to allow the MemoryMappedSegment struct to be
stored on the stack without causing overly large stack sizes.

Diff Detail

Repository
rL LLVM

Event Timeline

fjricci created this revision.Jul 7 2017, 11:18 AM
kubamracek edited edge metadata.Jul 7 2017, 2:58 PM

Overall, this is a great improvement of the procmaps, thanks for working on this!

alekseyshl added inline comments.Jul 10 2017, 3:21 PM
lib/sanitizer_common/sanitizer_procmaps.h
35 ↗(On Diff #105666)

This is struct, everything is public by default.

39 ↗(On Diff #105666)

I think it might improve readability a bit if we add IsReadable(), IsWriteable(), IsExecutable() and IsShared() functions here (although latter is not needed at the moment).

86 ↗(On Diff #105666)

Nit: what would you say about moving output parameter to be the last one and renaming function to Set...?

void SetSegmentAddrRange(uptr vmaddr, uptr vmsize, MemoryMappedSegment *segment);

Also, it's not that big, it is called from one place only, maybe just inline it? We do not have GetSegmentFileName and such after all.

lib/sanitizer_common/sanitizer_procmaps_common.cc
123 ↗(On Diff #105666)

kMaxPathLength -> module_name.size()

lib/sanitizer_common/sanitizer_procmaps_mac.cc
109 ↗(On Diff #105666)

Remove it

240 ↗(On Diff #105666)

Remove it

fjricci updated this revision to Diff 106072.Jul 11 2017, 11:08 AM

Address comments

lib/sanitizer_common/sanitizer_procmaps.h
86 ↗(On Diff #105666)

Addressed this in a follow-up commit: D35270

fjricci added inline comments.Jul 11 2017, 11:10 AM
lib/sanitizer_common/sanitizer_procmaps.h
39 ↗(On Diff #105666)

This cleans things up a lot more than I would've expected initially, thanks!

alekseyshl accepted this revision.Jul 11 2017, 11:26 AM
alekseyshl added inline comments.
lib/asan/asan_errors.cc
66 ↗(On Diff #106072)

IsReadable -> IsExecutable

This revision is now accepted and ready to land.Jul 11 2017, 11:26 AM
This revision was automatically updated to reflect the committed changes.