Fix typos in comments: s/wether/whether/ and related corrections.
[libfirm] / ir / be / bedbgout.c
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   Stabs support.
23  * @author  Michael Beck
24  * @date    11.9.2006
25  * @version $Id: bestabs.c 17143 2008-01-02 20:56:33Z beck $
26  */
27 #include "config.h"
28
29 #include "be_dbgout_t.h"
30 #include "bemodule.h"
31 #include "irtools.h"
32
33 static dbg_handle *handle = NULL;
34
35 void be_dbg_close(void)
36 {
37         if (handle->ops->close)
38                 handle->ops->close(handle);
39 }
40
41 void be_dbg_unit_begin(const char *filename)
42 {
43         if (handle->ops->unit_begin)
44                 handle->ops->unit_begin(handle, filename);
45 }
46
47 void be_dbg_unit_end(void)
48 {
49         if (handle->ops->unit_end)
50                 handle->ops->unit_end(handle);
51 }
52
53 void be_dbg_method_begin(const ir_entity *ent)
54 {
55         if (handle->ops->method_begin)
56                 handle->ops->method_begin(handle, ent);
57 }
58
59 void be_dbg_method_end(void)
60 {
61         if (handle->ops->method_end)
62                 handle->ops->method_end(handle);
63 }
64
65 void be_dbg_types(void)
66 {
67         if (handle->ops->types)
68                 handle->ops->types(handle);
69 }
70
71 void be_dbg_variable(const ir_entity *ent)
72 {
73         if (handle->ops->variable)
74                 handle->ops->variable(handle, ent);
75 }
76
77 void be_dbg_set_dbg_info(dbg_info *dbgi)
78 {
79         if (handle->ops->set_dbg_info)
80                 handle->ops->set_dbg_info(handle, dbgi);
81 }
82
83 static be_module_list_entry_t       *dbgout_modules         = NULL;
84 static be_create_dbgout_module_func  selected_dbgout_module = NULL;
85
86 void be_dbg_open(void)
87 {
88         handle = selected_dbgout_module();
89 }
90
91 void be_register_dbgout_module(const char *name,
92                                be_create_dbgout_module_func func)
93 {
94         if (selected_dbgout_module == NULL)
95                 selected_dbgout_module = func;
96         be_add_module_to_list(&dbgout_modules, name, (void*)func);
97 }
98
99 static dbg_handle *create_null_dbgout_module(void)
100 {
101         static const debug_ops null_ops = {
102                 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
103         };
104         static dbg_handle null_handle = { &null_ops };
105         return &null_handle;
106 }
107
108 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_dbgout);
109 void be_init_dbgout(void)
110 {
111         lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
112
113         be_add_module_list_opt(be_grp, "debuginfo", "debug info format",
114                                &dbgout_modules, (void**) &selected_dbgout_module);
115         be_register_dbgout_module("none", create_null_dbgout_module);
116 }