ObjFW  Diff

Differences From Artifact [fbd2e39b2b]:

  • File src/exceptions/OFException.m — part of check-in [f2a8bdf254] at 2013-05-25 11:40:28 on branch trunk — Switch back to backtrace().

    The reason is that __builtin_frame_address(n) for n > 0 seems to just
    crash on most platforms when -fomit-stack-pointer is specified, which
    seems to be the default for many platforms on -O2. The documentation
    says that __builtin_frame_address() should return NULL in case it can't
    get the frame, but it seems to crash instead.

    Therefore, this commit reverts to using backtrace() from execinfo.h, if
    available. However, as __builtin_frame_address() seems to always work on
    PPC (even with -fomit-frame-pointer) and seems to be the only way to get
    a backtrace on the Wii, this is still used if backtrace() is unavailable
    and __ppc__ defined. (user: js, size: 3823) [annotate] [blame] [check-ins using]

To Artifact [d08e1839ba]:


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- initWithClass: (Class)class
{
	self = [super init];

	_inClass = class;
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
	_backtraceSize = backtrace(_backtrace, 32);
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS) && defined(__ppc__)
	/*
	 * We can't use a loop here, as __builtin_return_address() and
	 * __builtin_frame_address() only allow a constant as parameter.
	 */
# define GET_FRAME(i)							\
	if (__builtin_frame_address(i + 1) == NULL)			\
		goto backtrace_done;					\







|







52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- initWithClass: (Class)class
{
	self = [super init];

	_inClass = class;
#if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
	_backtraceSize = backtrace(_backtrace, 32);
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS)
	/*
	 * We can't use a loop here, as __builtin_return_address() and
	 * __builtin_frame_address() only allow a constant as parameter.
	 */
# define GET_FRAME(i)							\
	if (__builtin_frame_address(i + 1) == NULL)			\
		goto backtrace_done;					\
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	}

	objc_autoreleasePoolPop(pool);

	[backtrace makeImmutable];

	return backtrace;
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS) && defined(__ppc__)
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;

	for (i = 0; i < 32 && _backtrace[i] != NULL; i++) {
		void *addr =
		    __builtin_extract_return_addr(_backtrace[i]);







|







142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
	}

	objc_autoreleasePoolPop(pool);

	[backtrace makeImmutable];

	return backtrace;
#elif defined(HAVE_BUILTIN_RETURN_ADDRESS)
	OFMutableArray *backtrace = [OFMutableArray array];
	void *pool = objc_autoreleasePoolPush();
	uint_fast8_t i;

	for (i = 0; i < 32 && _backtrace[i] != NULL; i++) {
		void *addr =
		    __builtin_extract_return_addr(_backtrace[i]);