PIPS
exception.c
Go to the documentation of this file.
1 /*
2 
3  $Id: exception.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* Stack management for PIPS contexts
28  *
29  * A PIPS context contains a pointer in the PIPS debug level stack.
30  * When a PIPS context is popped, the debug level stack is restored.
31  * It may be the current level!
32  *
33  * Example: voir catch_user_error() in library pipmake, or a PIPS user
34  * interface such as wpips, tpips or pips
35  */
36 
37 #include <stdio.h>
38 #include <genC.h>
39 #include "misc.h"
40 
41 static stack debug_stack = NULL;
42 
43 void push_pips_context(char const * file, char const * function, int line)
44 {
45  pips_debug(9, "%s %s:%d\n", function, file, line);
46  if (!debug_stack) debug_stack = stack_make(0, 50, 0);
48 }
49 
50 void pop_pips_context(char const * file, char const * function, int line)
51 {
52  pips_debug(9, "%s %s:%d\n", function, file, line);
53  if (!debug_stack)
54  pips_internal_error("unexpected pop without push %s %s:%d",
55  function, file, line);
57 }
58 
59 /* That's all */
static stack debug_stack
Stack management for PIPS contexts.
Definition: exception.c:41
void push_pips_context(char const *file, char const *function, int line)
exception.c
Definition: exception.c:43
void pop_pips_context(char const *file, char const *function, int line)
Definition: exception.c:50
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_internal_error
Definition: misc-local.h:149
void set_debug_stack_pointer(const int i)
Definition: debug.c:97
_int get_debug_stack_pointer(void)
The pair get_ and set_debug_stack_pointer() should never be used except to clean up the stack after a...
Definition: debug.c:92
void stack_push(void *, stack)
stack use
Definition: stack.c:373
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
void * stack_pop(stack)
POPs one item from stack s.
Definition: stack.c:399
intptr_t _int
_INT
Definition: newgen_types.h:53
static int line
FLEX_SCANNER.
Definition: scanner.c:852
the stack head
Definition: stack.c:62