Skip to content

Commit

Permalink
A little hack to declare _Unwind_GetIPInfo with clang.
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
bombela committed Mar 16, 2013
1 parent fc7b6bc commit f46591a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ set(TESTS
invalidread2
)

set(some_definition "BACKWARD_HAS_BFD=1")
set(some_definition "BACKWARD_HAS_DW=1")
#set(some_definition "BACKWARD_NOTHING")
foreach(test ${TESTS})
backward_add_test(test/${test}.cpp backward.cpp ${some_definition})
Expand Down
19 changes: 19 additions & 0 deletions backward.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,26 @@


# if BACKWARD_HAS_UNWIND == 1

# include <unwind.h>
// while gcc's unwind.h defines something like that:
// extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
// extern _Unwind_Ptr _Unwind_GetIPInfo (struct _Unwind_Context *, int *);
//
// clang's unwind.h defines something like this:
// uintptr_t _Unwind_GetIP(struct _Unwind_Context* __context);
//
// Even if the _Unwind_GetIPInfo can be linked to, it is not declared, worse we
// cannot just redeclare it because clang's unwind.h doesn't define _Unwind_Ptr
// anyway.
//
// Luckily we can play on the fact that the guard macros have a different name:
#ifdef __CLANG_UNWIND_H
// In fact, this function still comes from libgcc (on my different linux boxes,
// clang links against libgcc).
extern "C" uintptr_t _Unwind_GetIPInfo(_Unwind_Context*, int*);
#endif

# endif

# include <cxxabi.h>
Expand Down
1 change: 1 addition & 0 deletions test/minitrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/

//#define BACKWARD_SYSTEN_UNKNOWN
#define BACKWARD_HAS_DW 1
//#define BACKWARD_HAS_BFD 0
//#define BACKWARD_CXX98

Expand Down

0 comments on commit f46591a

Please sign in to comment.