| 1 |
// GNU D Compiler bindings for the stack backtrace functions. |
| 2 |
// Copyright (C) 2013-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
// GCC is free software; you can redistribute it and/or modify it under |
| 5 |
// the terms of the GNU General Public License as published by the Free |
| 6 |
// Software Foundation; either version 3, or (at your option) any later |
| 7 |
// version. |
| 8 |
|
| 9 |
// GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
// WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
// for more details. |
| 13 |
|
| 14 |
// Under Section 7 of GPL version 3, you are granted additional |
| 15 |
// permissions described in the GCC Runtime Library Exception, version |
| 16 |
// 3.1, as published by the Free Software Foundation. |
| 17 |
|
| 18 |
// You should have received a copy of the GNU General Public License and |
| 19 |
// a copy of the GCC Runtime Library Exception along with this program; |
| 20 |
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 21 |
// <http://www.gnu.org/licenses/>. |
| 22 |
|
| 23 |
module gcc.libbacktrace; |
| 24 |
|
| 25 |
/* |
| 26 |
* Part of backtrace-supported.h: These are platform specific variables. |
| 27 |
* They are obtained via the configure script |
| 28 |
*/ |
| 29 |
|
| 30 |
enum BACKTRACE_SUPPORTED = @BACKTRACE_SUPPORTED@; |
| 31 |
enum BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@; |
| 32 |
enum BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@; |
| 33 |
|
| 34 |
/* |
| 35 |
* libbacktrace.h |
| 36 |
*/ |
| 37 |
|
| 38 |
static if (BACKTRACE_SUPPORTED) |
| 39 |
{ |
| 40 |
import core.stdc.stddef, core.stdc.stdio, core.stdc.stdint; |
| 41 |
|
| 42 |
extern(C): |
| 43 |
struct backtrace_state {} |
| 44 |
|
| 45 |
alias extern(C) void function(void* data, const(char)* msg, int errnum) |
| 46 |
backtrace_error_callback; |
| 47 |
|
| 48 |
backtrace_state* backtrace_create_state(const(char)* filename, int threaded, |
| 49 |
backtrace_error_callback error_callback, void* data) @nogc nothrow; |
| 50 |
|
| 51 |
alias extern(C) int function(void* data, uintptr_t pc, const(char)* filename, int lineno, const(char)* func) |
| 52 |
backtrace_full_callback; |
| 53 |
|
| 54 |
int backtrace_full(backtrace_state* state, int skip, backtrace_full_callback callback, |
| 55 |
backtrace_error_callback error_callback, void* data) @nogc nothrow; |
| 56 |
|
| 57 |
alias extern(C) int function(void* data, uintptr_t pc) |
| 58 |
backtrace_simple_callback; |
| 59 |
|
| 60 |
int backtrace_simple(backtrace_state* state, int skip, backtrace_simple_callback callback, |
| 61 |
backtrace_error_callback error_callback, void* data) @nogc nothrow; |
| 62 |
|
| 63 |
void backtrace_print(backtrace_state* state, int skip, FILE* file) @nogc nothrow; |
| 64 |
|
| 65 |
int backtrace_pcinfo(backtrace_state* state, uintptr_t pc, backtrace_full_callback callback, |
| 66 |
backtrace_error_callback error_callback, void* data) @nogc nothrow; |
| 67 |
|
| 68 |
alias extern(C) void function(void* data, uintptr_t pc, const(char)* symname, uintptr_t symval) |
| 69 |
backtrace_syminfo_callback; |
| 70 |
|
| 71 |
int backtrace_syminfo(backtrace_state *state, uintptr_t pc, backtrace_syminfo_callback callback, |
| 72 |
backtrace_error_callback error_callback, void* data) @nogc nothrow; |
| 73 |
} |