This is an archive of the discontinued LLVM Phabricator instance.

[Asan] Pack signal context into a structure
ClosedPublic

Authored by kutuzov.viktor.84 on Nov 6 2014, 3:55 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

kutuzov.viktor.84 retitled this revision from to [Asan] Pack signal context into a structure.
kutuzov.viktor.84 updated this object.
kutuzov.viktor.84 edited the test plan for this revision. (Show Details)
kutuzov.viktor.84 added reviewers: kcc, samsonov.
kutuzov.viktor.84 added a subscriber: Unknown Object (MLST).
kutuzov.viktor.84 added inline comments.
asan/asan_internal.h
65 ↗(On Diff #15851)

Umm, we probably don't need this line.

samsonov added inline comments.Nov 6 2014, 11:16 AM
asan/asan_internal.h
73 ↗(On Diff #15851)

explicit is not necessary for two-argument ctors.
Why not make the body empty and just have a single initializer list?

SignalContext(void *context, uptr addr) : context(context), addr(addr), pc(0), sp(0), bp(0) {}

You can also make pc/sp/bp optional ctor arguments (looks like you can use that on Windows)

93 ↗(On Diff #15851)

We generally don't use "struct" keyword for passing our structs around.

asan/asan_report.h
55 ↗(On Diff #15851)

You can make these function take

const SignalContext &sig;

Updated as suggested.

samsonov added inline comments.Nov 11 2014, 11:34 AM
asan/asan_internal.h
91 ↗(On Diff #15983)

Ok, now it becomes somewhat confusing - on POSIX the user must create SignalContext that would initialize half of the fields, and then call GetPcSpBp, that would initialize the rest of them. This looks... weird. It seems that the work done in GetPcSpBp should be done in SignalContext ctor. How do you feel about this: replace SignalContext ctor with a factory function (SignalContext::Create or whatever), that would take two opaque pointers and return a fully-constructed SignalContext object. The meaning of pointers will be different on different platforms:

  • on POSIX that would be context_t* (used to initialize context, pc, sp and bp) and siginfo_t* (used to initialize addr).
  • on Windows that would be CONTEXT* and EXCEPTION_RECORD*
asan/asan_stack.h
84 ↗(On Diff #15983)

Why not (sig).pc ?

Updated. Thanks, Alexey.

samsonov accepted this revision.Nov 24 2014, 8:56 AM
samsonov edited edge metadata.

LGTM (but please the problem for powerpc before commit)

lib/asan/asan_posix.cc
61 ↗(On Diff #16553)

Please fix the code under this #if: s/pc/sig.pc.

This revision is now accepted and ready to land.Nov 24 2014, 8:56 AM
Diffusion closed this revision.Nov 25 2014, 5:00 AM
Diffusion updated this revision to Diff 16610.

Closed by commit rL222756 (authored by vkutuzov).