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

Alexey Samsonov vonosmas at gmail.com
Thu Nov 6 11:16:14 PST 2014


================
Comment at: asan/asan_internal.h:73
@@ +72,3 @@
+
+  explicit SignalContext(void *context_, uptr addr_) {
+    internal_memset(this, 0, sizeof(SignalContext));
----------------
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)

================
Comment at: asan/asan_internal.h:93
@@ -77,3 +92,3 @@
 
-void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
+void GetPcSpBp(struct SignalContext *sig);
 void AsanOnSIGSEGV(int, void *siginfo, void *context);
----------------
We generally don't use "struct" keyword for passing our structs around.

================
Comment at: asan/asan_report.h:55
@@ -54,5 +54,3 @@
 // Different kinds of error reports.
-void NORETURN
-    ReportStackOverflow(uptr pc, uptr sp, uptr bp, void *context, uptr addr);
-void NORETURN ReportSIGSEGV(const char *description, uptr pc, uptr sp, uptr bp,
-                            void *context, uptr addr);
+void NORETURN ReportStackOverflow(struct SignalContext *sig);
+void NORETURN ReportSIGSEGV(const char *description, struct SignalContext *sig);
----------------
You can make these function take
  const SignalContext &sig;

http://reviews.llvm.org/D6148






More information about the llvm-commits mailing list