![]() |
exceptions4c
version 3.0
An exception handling framework for C
|
exceptions4c gcc stack trace header file More...
#include "e4c.h"
Functions | |
void | e4c_stack_trace_print_exception (const e4c_exception *exception) |
Prints a fatal error message and backtrace regarding the uncaught exception. More... | |
void * | e4c_stack_trace_initialize (const e4c_exception *exception) |
Initializes the backtrace of a newly created exception. More... | |
void | e4c_stack_trace_finalize (void *custom_data) |
Finalizes the backtrace of an exception which is about to be destroyed. More... | |
exceptions4c gcc stack trace header file
This extension allows exceptions4c to print a trace stack regarding an uncaught exception:
You need to set up the provided exception context handlers through the function e4c_context_set_handlers
:
This module needs to be compiled with GCC (the GNU Compiler Collection). It depends on the GCC Function Instrumentation and Generate debugging information functionality. They can be enabled by using the compiler parameters:
-finstrument-functions
-g3
This is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this software. If not, see http://www.gnu.org/licenses/.
void e4c_stack_trace_finalize | ( | void * | custom_data) |
Finalizes the backtrace of an exception which is about to be destroyed.
custom_data | The backtrace to be finalized |
This function disposes of the call stack captured at the moment the exception was thrown.
It must be passed to e4c_context_set_handlers
as the handler for finalizing the custom data of an exception, along with e4c_stack_trace_initialize
and e4c_stack_trace_print_exception
.
void* e4c_stack_trace_initialize | ( | const e4c_exception * | exception) |
Initializes the backtrace of a newly created exception.
exception | The newly created exception |
This function captures the call stack at the moment the exception is being thrown. It expects that the initial value of the custom data is a text string containing the path to the executing program.
It must be passed to e4c_context_set_handlers
as the handler for initializing the custom data of an exception, along with e4c_stack_trace_finalize
and e4c_stack_trace_print_exception
.
void e4c_stack_trace_print_exception | ( | const e4c_exception * | exception) |
Prints a fatal error message and backtrace regarding the uncaught exception.
exception | The uncaught exception |
This function prints the exception and its backtrace to the standard error output. The stack trace represents the reverse path of execution at the moment the exception was thrown.
It must be passed to e4c_context_set_handlers
as the handler for uncaught exceptions, along with e4c_stack_trace_initialize
and e4c_stack_trace_finalize
.