ObjFW  Artifact [3edc7f9b6e]

Artifact 3edc7f9b6ecebf2802ea2ce7922785e81d7f710b6a02929a6b176f0e1cd9b13a:

  • File src/exceptions/OFException.h — 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: 1912) [annotate] [blame] [check-ins using]


/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"

@class OFString;
@class OFArray;
@class OFMutableArray;

/*!
 * @brief The base class for all exceptions in ObjFW
 *
 * The OFException class is the base class for all exceptions in ObjFW, except
 * the OFAllocFailedException.
 */
@interface OFException: OFObject
{
	Class _inClass;
	void *_backtrace[32];
	int _backtraceSize;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly) Class inClass;
#endif

/*!
 * @brief Creates a new, autoreleased exception.
 *
 * @param class_ The class of the object which caused the exception
 * @return A new, autoreleased exception
 */
+ (instancetype)exceptionWithClass: (Class)class_;

/*!
 * @brief Initializes an already allocated OFException.
 *
 * @param class_ The class of the object which caused the exception
 * @return An initialized OFException
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class of the object in which the exception occurred.
 *
 * @return The class of the object in which the exception occurred
 */
- (Class)inClass;

/*!
 * @brief Returns a description of the exception.
 *
 * @return A description of the exception
 */
- (OFString*)description;

/*!
 * @brief Returns a backtrace of when the exception was created or nil if no
 *	  backtrace is available.
 *
 * @return A backtrace of when the exception was created
 */
- (OFArray*)backtrace;
@end