[PATCH] [Asan] Pack signal context into a structure

Alexey Samsonov vonosmas at gmail.com
Tue Nov 11 11:34:46 PST 2014


================
Comment at: asan/asan_internal.h:91
@@ -77,3 +90,3 @@
 
-void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
+void GetPcSpBp(SignalContext *sig);
 void AsanOnSIGSEGV(int, void *siginfo, void *context);
----------------
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*

================
Comment at: asan/asan_stack.h:84
@@ -84,1 +83,3 @@
+  GetStackTraceWithPcBpAndContext(&stack, kStackTraceMax,                      \
+                                  (sig)->pc, (sig)->bp, (sig)->context,        \
                                   common_flags()->fast_unwind_on_fatal)
----------------
Why not (sig).pc ?

http://reviews.llvm.org/D6148






More information about the llvm-commits mailing list