bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.68k stars 467 forks source link

Compile failure on osx 10.5 ppc #240

Open mgerhardy opened 2 years ago

mgerhardy commented 2 years ago

Not sure if this of interest for anyone except me - but I get this error when using backward.h on OSX 10.5 (ppc)

In file included from backends/stacktraces/stacktrace.cpp:51:0:
backends/stacktraces/backward.h: In static member function 'static void backward::SignalHandling::handleSignal(int, siginfo_t*, void*)':
backends/stacktraces/backward.h:4225:61: error: request for member 'regs' in 'uctx->__darwin_ucontext::uc_mcontext', which is of pointer type '__darwin_mcontext*' (maybe you meant to use '->' ?)
     error_addr = reinterpret_cast<void *>(uctx->uc_mcontext.regs->nip);
                                                             ^~~~
bombela commented 2 years ago

If you can find out how to access the information on this platform, you can then add a preprocessor conditional to handle it. Pull request welcomed ;)

mgerhardy commented 2 years ago

I'm a little bit lost here. But these are the relevant headers:

typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
typedef int __darwin_ct_rune_t;
typedef union {
 char __mbstate8[128];
 long long _mbstateL;
} __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t;
typedef int __darwin_ptrdiff_t;
typedef long unsigned int __darwin_size_t;
typedef __builtin_va_list __darwin_va_list;
typedef int __darwin_wchar_t;
typedef __darwin_wchar_t __darwin_rune_t;
typedef int __darwin_wint_t;
typedef unsigned long __darwin_clock_t;
typedef __uint32_t __darwin_socklen_t;
typedef long __darwin_ssize_t;
typedef long __darwin_time_t;
struct __darwin_pthread_handler_rec
{
 void (*__routine)(void *);
 void *__arg;
 struct __darwin_pthread_handler_rec *__next;
};
struct _opaque_pthread_attr_t { long __sig; char __opaque[36]; };
struct _opaque_pthread_cond_t { long __sig; char __opaque[24]; };
struct _opaque_pthread_condattr_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_mutex_t { long __sig; char __opaque[40]; };
struct _opaque_pthread_mutexattr_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_once_t { long __sig; char __opaque[4]; };
struct _opaque_pthread_rwlock_t { long __sig; char __opaque[124]; };
struct _opaque_pthread_rwlockattr_t { long __sig; char __opaque[12]; };
struct _opaque_pthread_t { long __sig; struct __darwin_pthread_handler_rec *__cleanup_stack; char __opaque[596]; };
typedef __int64_t __darwin_blkcnt_t;
typedef __int32_t __darwin_blksize_t;
typedef __int32_t __darwin_dev_t;
typedef unsigned int __darwin_fsblkcnt_t;
typedef unsigned int __darwin_fsfilcnt_t;
typedef __uint32_t __darwin_gid_t;
typedef __uint32_t __darwin_id_t;
typedef __uint64_t __darwin_ino64_t;
typedef __uint32_t __darwin_ino_t;
typedef __darwin_natural_t __darwin_mach_port_name_t;
typedef __darwin_mach_port_name_t __darwin_mach_port_t;
typedef __uint16_t __darwin_mode_t;
typedef __int64_t __darwin_off_t;
typedef __int32_t __darwin_pid_t;
typedef struct _opaque_pthread_attr_t
   __darwin_pthread_attr_t;
typedef struct _opaque_pthread_cond_t
   __darwin_pthread_cond_t;
typedef struct _opaque_pthread_condattr_t
   __darwin_pthread_condattr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef struct _opaque_pthread_mutex_t
   __darwin_pthread_mutex_t;
typedef struct _opaque_pthread_mutexattr_t
   __darwin_pthread_mutexattr_t;
typedef struct _opaque_pthread_once_t
   __darwin_pthread_once_t;
typedef struct _opaque_pthread_rwlock_t
   __darwin_pthread_rwlock_t;
typedef struct _opaque_pthread_rwlockattr_t
   __darwin_pthread_rwlockattr_t;
typedef struct _opaque_pthread_t
   *__darwin_pthread_t;
typedef __uint32_t __darwin_sigset_t;
typedef __int32_t __darwin_suseconds_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_useconds_t;
typedef unsigned char __darwin_uuid_t[16];
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
typedef unsigned long __darwin_wctype_t;
typedef int sig_atomic_t;
struct __darwin_sigcontext
{
    int __sc_onstack;
    int __sc_mask;
    int __sc_ir;
    int __sc_psw;
    int __sc_sp;
    void *__sc_regs;
};
struct __darwin_sigcontext32
{
    int __sc_onstack;
    int __sc_mask;
    int __sc_ir;
    int __sc_psw;
    int __sc_sp;
    void *__sc_regs;
};
struct __darwin_sigcontext64
{
    int __sc_onstack;
    int __sc_mask;
    long long __sc_ir;
    long long __sc_psw;
    long long __sc_sp;
    void *__sc_regs;
};
typedef enum {
 REGS_SAVED_NONE,
 REGS_SAVED_CALLER,
 REGS_SAVED_ALL
} regs_saved_t;
struct __darwin_ppc_thread_state
{
 unsigned int __srr0;
 unsigned int __srr1;
 unsigned int __r0;
 unsigned int __r1;
 unsigned int __r2;
 unsigned int __r3;
 unsigned int __r4;
 unsigned int __r5;
 unsigned int __r6;
 unsigned int __r7;
 unsigned int __r8;
 unsigned int __r9;
 unsigned int __r10;
 unsigned int __r11;
 unsigned int __r12;
 unsigned int __r13;
 unsigned int __r14;
 unsigned int __r15;
 unsigned int __r16;
 unsigned int __r17;
 unsigned int __r18;
 unsigned int __r19;
 unsigned int __r20;
 unsigned int __r21;
 unsigned int __r22;
 unsigned int __r23;
 unsigned int __r24;
 unsigned int __r25;
 unsigned int __r26;
 unsigned int __r27;
 unsigned int __r28;
 unsigned int __r29;
 unsigned int __r30;
 unsigned int __r31;
 unsigned int __cr;
 unsigned int __xer;
 unsigned int __lr;
 unsigned int __ctr;
 unsigned int __mq;
 unsigned int __vrsave;
};
#pragma pack(4)
struct __darwin_ppc_thread_state64
{
 unsigned long long __srr0;
 unsigned long long __srr1;
 unsigned long long __r0;
 unsigned long long __r1;
 unsigned long long __r2;
 unsigned long long __r3;
 unsigned long long __r4;
 unsigned long long __r5;
 unsigned long long __r6;
 unsigned long long __r7;
 unsigned long long __r8;
 unsigned long long __r9;
 unsigned long long __r10;
 unsigned long long __r11;
 unsigned long long __r12;
 unsigned long long __r13;
 unsigned long long __r14;
 unsigned long long __r15;
 unsigned long long __r16;
 unsigned long long __r17;
 unsigned long long __r18;
 unsigned long long __r19;
 unsigned long long __r20;
 unsigned long long __r21;
 unsigned long long __r22;
 unsigned long long __r23;
 unsigned long long __r24;
 unsigned long long __r25;
 unsigned long long __r26;
 unsigned long long __r27;
 unsigned long long __r28;
 unsigned long long __r29;
 unsigned long long __r30;
 unsigned long long __r31;
 unsigned int __cr;
 unsigned long long __xer;
 unsigned long long __lr;
 unsigned long long __ctr;
 unsigned int __vrsave;
};
#pragma pack()
struct __darwin_ppc_float_state
{
 double __fpregs[32];
 unsigned int __fpscr_pad;
 unsigned int __fpscr;
};
#pragma pack(4)
struct __darwin_ppc_vector_state
{
 unsigned long __save_vr[32][4];
 unsigned long __save_vscr[4];
 unsigned int __save_pad5[4];
 unsigned int __save_vrvalid;
 unsigned int __save_pad6[7];
};
#pragma pack()
#pragma pack(4)
struct __darwin_ppc_exception_state
{
 unsigned long __dar;
 unsigned long __dsisr;
 unsigned long __exception;
 unsigned long __pad0;
 unsigned long __pad1[4];
};
struct __darwin_ppc_exception_state64
{
 unsigned long long __dar;
 unsigned long __dsisr;
 unsigned long __exception;
 unsigned long __pad1[4];
};
#pragma pack()
struct __darwin_mcontext
{
 struct __darwin_ppc_exception_state __es;
 struct __darwin_ppc_thread_state __ss;
 struct __darwin_ppc_float_state __fs;
 struct __darwin_ppc_vector_state __vs;
};
struct __darwin_mcontext64
{
 struct __darwin_ppc_exception_state64 __es;
 struct __darwin_ppc_thread_state64 __ss;
 struct __darwin_ppc_float_state __fs;
 struct __darwin_ppc_vector_state __vs;
};
typedef struct __darwin_mcontext *mcontext_t;
typedef struct __darwin_mcontext64 *mcontext64_t;
struct __darwin_sigaltstack
{
 void *ss_sp;
 __darwin_size_t ss_size;
 int ss_flags;
};
struct __darwin_ucontext
{
 int uc_onstack;
 __darwin_sigset_t uc_sigmask;
 struct __darwin_sigaltstack uc_stack;
 struct __darwin_ucontext *uc_link;
 __darwin_size_t uc_mcsize;
 struct __darwin_mcontext *uc_mcontext;
};
struct __darwin_ucontext64
{
 int uc_onstack;
 __darwin_sigset_t uc_sigmask;
 struct __darwin_sigaltstack uc_stack;
 struct __darwin_ucontext64 *uc_link;
 __darwin_size_t uc_mcsize;
 struct __darwin_mcontext64 *uc_mcontext64;
};
typedef struct __darwin_sigaltstack stack_t;
typedef struct __darwin_ucontext ucontext_t;
typedef struct __darwin_ucontext64 ucontext64_t;
typedef __darwin_pid_t pid_t;
typedef __darwin_pthread_attr_t pthread_attr_t;
typedef __darwin_sigset_t sigset_t;
typedef __darwin_size_t size_t;
typedef __darwin_uid_t uid_t;
mgerhardy commented 2 years ago

it could get guarded by

#if MAC_OS_X_VERSION_MAX_ALLOWED == 1050
  [...]
#endif

but I have no clue where to find information about what would be the error address.

bombela commented 2 years ago

I think it's the PPC architecture that makes it different. Not the MacOS version.

On Fri, 17 Sep 2021, 06:56 Martin Gerhardy, @.***> wrote:

it could get guarded by

if MAC_OS_X_VERSION_MAX_ALLOWED == 1050

[...]

endif

but I have no clue where to find information about what would be the error address.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bombela/backward-cpp/issues/240#issuecomment-921817124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABUZDG4PNSBO3QPDKR3HVLUCNCHTANCNFSM5EGJHNMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.