0655f85e59eb0f1b91dda8f1746742daa7481b5c
[libfirm] / include / libfirm / seqnumbers.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Implements simple sequence numbers for Firm debug info.
23  * @author   Michael Beck
24  * @date     2005
25  * @version  $Id$
26  * @brief
27  *  Sequence numbers for Firm.
28  *
29  *  A sequence number is an unique number representing a filename
30  *  and a line number. The number 0 represents empty information.
31  *  This module is an optional "snap-in" for the Firm debug info.
32  *  In simple cases it should be possible to use sequence numbers
33  *  as dbg_info.
34  */
35 #ifndef FIRM_DEBUG_SEQNUMBERS_H
36 #define FIRM_DEBUG_SEQNUMBERS_H
37
38 #include "ident.h"
39
40 /**
41  * @typedef seqno_t
42  *
43  * An opaque type for a sequence number.
44  */
45
46 /**
47  * Create a new sequence number from a filename and a line number.
48  *
49  * @param filename  a file name
50  * @param lineno    a line number
51  *
52  * @return  a sequence number for this position.
53  */
54 seqno_t firm_seqno_enter(const char *filename, unsigned lineno);
55
56 /**
57  * Create a new sequence number from a filename ident and a line number.
58  *
59  * @param filename  an ident
60  * @param lineno    a line number
61  *
62  * @return  a sequence number for this position.
63  */
64 seqno_t firm_seqno_enter_id(ident *filename, unsigned lineno);
65
66 /**
67  * Retrieve filename and line number from a sequence number.
68  *
69  * @param seqno   a sequence number
70  * @param lineno  after return contains the line number of this position
71  *
72  * @return  the file name of this position.
73  */
74 const char *firm_seqno_retrieve(seqno_t seqno, unsigned *lineno);
75
76 /**
77  * Creates the sequence number pool.
78  * Is not called by init_firm(), because the sequence number
79  * support is optional. Call firm_seqno_init() after init_firm()
80  * if sequence numbers should be used.
81  */
82 void firm_seqno_init(void);
83
84 /**
85  * Terminates the sequence number pool.
86  * Sequence numbers cannot be resolved anymore.
87  * Call this function to terminate the sequence
88  * pool.
89  */
90 void firm_seqno_term(void);
91
92 #endif