1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * gimpbacktrace.h
5  * Copyright (C) 2018 Ell
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __GIMP_BACKTRACE_H__
22 #define __GIMP_BACKTRACE_H__
23 
24 
25 typedef struct _GimpBacktraceAddressInfo GimpBacktraceAddressInfo;
26 
27 
28 struct _GimpBacktraceAddressInfo
29 {
30   gchar    object_name[256];
31 
32   gchar    symbol_name[256];
33   guintptr symbol_address;
34 
35   gchar    source_file[256];
36   gint     source_line;
37 };
38 
39 
40 void            gimp_backtrace_init              (void);
41 
42 gboolean        gimp_backtrace_start             (void);
43 void            gimp_backtrace_stop              (void);
44 
45 GimpBacktrace * gimp_backtrace_new               (gboolean                 include_current_thread);
46 void            gimp_backtrace_free              (GimpBacktrace           *backtrace);
47 
48 gint            gimp_backtrace_get_n_threads     (GimpBacktrace           *backtrace);
49 guintptr        gimp_backtrace_get_thread_id     (GimpBacktrace           *backtrace,
50                                                   gint                     thread);
51 const gchar   * gimp_backtrace_get_thread_name   (GimpBacktrace           *backtrace,
52                                                   gint                     thread);
53 gboolean        gimp_backtrace_is_thread_running (GimpBacktrace           *backtrace,
54                                                   gint                     thread);
55 
56 gint            gimp_backtrace_find_thread_by_id (GimpBacktrace           *backtrace,
57                                                   guintptr                 thread_id,
58                                                   gint                     thread_hint);
59 
60 gint            gimp_backtrace_get_n_frames      (GimpBacktrace           *backtrace,
61                                                   gint                     thread);
62 guintptr        gimp_backtrace_get_frame_address (GimpBacktrace           *backtrace,
63                                                   gint                     thread,
64                                                   gint                     frame);
65 
66 gboolean        gimp_backtrace_get_address_info  (guintptr                  address,
67                                                   GimpBacktraceAddressInfo *info);
68 
69 
70 #endif  /*  __GIMP_BACKTRACE_H__  */
71