Home | History | Annotate | Download | only in cgo
      1 // Copyright 2016 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // +build cgo
      6 // +build linux
      7 
      8 #include <stdint.h>
      9 
     10 struct cgoTracebackArg {
     11 	uintptr_t  Context;
     12 	uintptr_t  SigContext;
     13 	uintptr_t* Buf;
     14 	uintptr_t  Max;
     15 };
     16 
     17 // Call the user's traceback function and then call sigtramp.
     18 // The runtime signal handler will jump to this code.
     19 // We do it this way so that the user's traceback function will be called
     20 // by a C function with proper unwind info.
     21 void
     22 x_cgo_callers(uintptr_t sig, void *info, void *context, void (*cgoTraceback)(struct cgoTracebackArg*), uintptr_t* cgoCallers, void (*sigtramp)(uintptr_t, void*, void*)) {
     23 	struct cgoTracebackArg arg;
     24 
     25 	arg.Context = 0;
     26 	arg.SigContext = (uintptr_t)(context);
     27 	arg.Buf = cgoCallers;
     28 	arg.Max = 32; // must match len(runtime.cgoCallers)
     29 	(*cgoTraceback)(&arg);
     30 	sigtramp(sig, info, context);
     31 }
     32