Annotation of embedaddon/strongswan/src/libstrongswan/utils/backtrace.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2008 Martin Willi
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  *
        !             5:  * This program is free software; you can redistribute it and/or modify it
        !             6:  * under the terms of the GNU General Public License as published by the
        !             7:  * Free Software Foundation; either version 2 of the License, or (at your
        !             8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
        !             9:  *
        !            10:  * This program is distributed in the hope that it will be useful, but
        !            11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
        !            13:  * for more details.
        !            14:  */
        !            15: 
        !            16: /**
        !            17:  * @defgroup backtrace backtrace
        !            18:  * @{ @ingroup utils
        !            19:  */
        !            20: 
        !            21: #ifndef BACKTRACE_H_
        !            22: #define BACKTRACE_H_
        !            23: 
        !            24: typedef struct backtrace_t backtrace_t;
        !            25: 
        !            26: #include <stdio.h>
        !            27: 
        !            28: #include <library.h>
        !            29: 
        !            30: /**
        !            31:  * A backtrace registers the frames on the stack during creation.
        !            32:  */
        !            33: struct backtrace_t {
        !            34: 
        !            35:        /**
        !            36:         * Log the backtrace to a FILE stream.
        !            37:         *
        !            38:         * If no file pointer is given, the backtrace is reported over the debug
        !            39:         * framework to the registered dbg() callback function.
        !            40:         *
        !            41:         * @param file          FILE to log backtrace to, NULL for dbg() function
        !            42:         * @param detailed      TRUE to resolve line/file using addr2line (slow)
        !            43:         */
        !            44:        void (*log)(backtrace_t *this, FILE *file, bool detailed);
        !            45: 
        !            46:        /**
        !            47:         * Check if the backtrace contains a frame having a function in a list.
        !            48:         *
        !            49:         * @param               function name array
        !            50:         * @param               number of elements in function array
        !            51:         * @return              TRUE if one of the functions is in the stack
        !            52:         */
        !            53:        bool (*contains_function)(backtrace_t *this, char *function[], int count);
        !            54: 
        !            55:        /**
        !            56:         * Check two backtraces for equality.
        !            57:         *
        !            58:         * @param other backtrace to compare to this
        !            59:         * @return              TRUE if backtraces are equal
        !            60:         */
        !            61:        bool (*equals)(backtrace_t *this, backtrace_t *other);
        !            62: 
        !            63:        /**
        !            64:         * Create a copy of this backtrace.
        !            65:         *
        !            66:         * @return              cloned copy
        !            67:         */
        !            68:        backtrace_t* (*clone)(backtrace_t *this);
        !            69: 
        !            70:        /**
        !            71:         * Create an enumerator over the stack frame addresses.
        !            72:         *
        !            73:         * @return              enumerator_t over void*
        !            74:         */
        !            75:        enumerator_t* (*create_frame_enumerator)(backtrace_t *this);
        !            76: 
        !            77:        /**
        !            78:         * Destroy a backtrace instance.
        !            79:         */
        !            80:        void (*destroy)(backtrace_t *this);
        !            81: };
        !            82: 
        !            83: /**
        !            84:  * Create a backtrace of the current stack.
        !            85:  *
        !            86:  * @param skip         how many of the innerst frames to skip
        !            87:  * @return                     backtrace
        !            88:  */
        !            89: backtrace_t *backtrace_create(int skip);
        !            90: 
        !            91: /**
        !            92:  * Create a backtrace, dump it and clean it up.
        !            93:  *
        !            94:  * @param label                description to print for this backtrace, or NULL
        !            95:  * @param file         FILE to log backtrace to, NULL to dbg() function
        !            96:  * @param detailed     TRUE to resolve line/file using addr2line (slow)
        !            97:  */
        !            98: void backtrace_dump(char *label, FILE *file, bool detailed);
        !            99: 
        !           100: /**
        !           101:  * Initialize backtracing framework.
        !           102:  */
        !           103: void backtrace_init();
        !           104: 
        !           105: /**
        !           106:  * Deinitialize backtracing framework.
        !           107:  */
        !           108: void backtrace_deinit();
        !           109: 
        !           110: #endif /** BACKTRACE_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>