title: Retrieving sigcontext during backtrace
body: <p>In writing some code to print backtraces in C++, I came across <a href="https://stackoverflow.com/a/1925461/2069064">this answer</a>, which includes copying the definition of a type:</p>
  
  <pre><code>/* This structure mirrors the one found in /usr/include/asm/ucontext.h */
  typedef struct _sig_ucontext {
   unsigned long     uc_flags;
   struct ucontext   *uc_link;
   stack_t           uc_stack;
   struct sigcontext uc_mcontext;
   sigset_t          uc_sigmask;
  } sig_ucontext_t;
  </code></pre>
  
  <p>I can't just include <code>&lt;asm/ucontext.h&gt;</code> since there it is defined as simply <code>ucontext</code> which collides with a similarly named type from <code>&lt;sys/ucontext.h&gt;</code> (which is included from the necessary <code>&lt;signal.h&gt;</code>):</p>
  
  <pre><code>/* Userlevel context.  */
  typedef struct ucontext
    {
      unsigned long int uc_flags;
      struct ucontext *uc_link;
      stack_t uc_stack;
      mcontext_t uc_mcontext;
      __sigset_t uc_sigmask;
      struct _libc_fpstate __fpregs_mem;
    } ucontext_t;
  </code></pre>
  
  <p>All I need here is the <code>struct sigcontext uc_mcontext</code> member from the <code>asm</code> version. Is there a better way to retrieve that value than just copying out this struct? That seems incredibly hackish and error-prone to me. </p>