1 /****************************************************************************
3 * GNAT RUN-TIME COMPONENTS *
5 * T R A C E B A C K - I t a n i u m / V M S *
7 * C Implementation File *
9 * Copyright (C) 2007-2011, AdaCore *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 3, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. *
18 * As a special exception under Section 7 of GPL version 3, you are granted *
19 * additional permissions described in the GCC Runtime Library Exception, *
20 * version 3.1, as published by the Free Software Foundation. *
22 * You should have received a copy of the GNU General Public License and *
23 * a copy of the GCC Runtime Library Exception along with this program; *
24 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see *
25 * <http://www.gnu.org/licenses/>. *
27 * GNAT was originally developed by the GNAT team at New York University. *
28 * Extensive contributions were provided by Ada Core Technologies Inc. *
30 ****************************************************************************/
32 /* Itanium Open/VMS implementation of backtrace. Use ICB (Invocation
33 Context Block) routines. */
35 #include <vms/libicb.h>
37 /* Declare libicb routines. */
38 extern INVO_CONTEXT_BLK
*LIB$
I64_CREATE_INVO_CONTEXT (void *(*)(size_t),
41 extern void LIB$
I64_FREE_INVO_CONTEXT (INVO_CONTEXT_BLK
*);
42 extern int LIB$
I64_GET_CURR_INVO_CONTEXT(INVO_CONTEXT_BLK
*);
43 extern int LIB$
I64_GET_PREV_INVO_CONTEXT(INVO_CONTEXT_BLK
*);
45 /* Gcc internal headers poison malloc. So use xmalloc() when building the
48 #define BT_MALLOC malloc
50 #define BT_MALLOC xmalloc
54 __gnat_backtrace (void **array
, int size
,
55 void *exclude_min
, void *exclude_max
, int skip_frames
)
57 INVO_CONTEXT_BLK
*ctxt
;
61 /* Create the context. */
62 ctxt
= LIB$
I64_CREATE_INVO_CONTEXT (BT_MALLOC
, free
, 0);
66 LIB$
I64_GET_CURR_INVO_CONTEXT (ctxt
);
70 void *pc
= (void *)ctxt
->libicb$ih_pc
;
73 if (ctxt
->libicb$v_bottom_of_stack
)
75 if (n
>= skip_frames
&& (pc
< exclude_min
|| pc
> exclude_max
))
77 array
[res
++] = (void *)(ctxt
->libicb$ih_pc
);
82 LIB$
I64_GET_PREV_INVO_CONTEXT (ctxt
);
85 /* Free the context. */
86 LIB$
I64_FREE_INVO_CONTEXT (ctxt
);