2 * \file libyasm/dbgfmt.h
3 * \brief YASM debug format interface.
6 * Copyright (C) 2002-2007 Peter Johnson
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
34 /** Base #yasm_dbgfmt structure. Must be present as the first element in any
35 * #yasm_dbgfmt implementation.
37 typedef struct yasm_dbgfmt_base {
38 /** #yasm_dbgfmt_module implementation for this debug format. */
39 const struct yasm_dbgfmt_module *module;
43 /** Debug format module interface. */
44 struct yasm_dbgfmt_module {
45 /** One-line description of the debug format. */
48 /** Keyword used to select debug format. */
51 /** NULL-terminated list of directives. NULL if none. */
52 /*@null@*/ const yasm_directive *directives;
54 /** Create debug format.
55 * Module-level implementation of yasm_dbgfmt_create().
56 * The filenames are provided solely for informational purposes.
57 * \param object object
58 * \return NULL if object format does not provide needed support.
60 /*@null@*/ /*@only@*/ yasm_dbgfmt * (*create) (yasm_object *object);
62 /** Module-level implementation of yasm_dbgfmt_destroy().
63 * Call yasm_dbgfmt_destroy() instead of calling this function.
65 void (*destroy) (/*@only@*/ yasm_dbgfmt *dbgfmt);
67 /** Module-level implementation of yasm_dbgfmt_generate().
68 * Call yasm_dbgfmt_generate() instead of calling this function.
70 void (*generate) (yasm_object *object, yasm_linemap *linemap,
71 yasm_errwarns *errwarns);
74 /** Get the keyword used to select a debug format.
75 * \param dbgfmt debug format
78 const char *yasm_dbgfmt_keyword(const yasm_dbgfmt *dbgfmt);
80 /** Initialize debug output for use. Must call before any other debug
81 * format functions. The filenames are provided solely for informational
83 * \param module debug format module
84 * \param object object to generate debugging information for
85 * \return NULL if object format does not provide needed support.
87 /*@null@*/ /*@only@*/ yasm_dbgfmt *yasm_dbgfmt_create
88 (const yasm_dbgfmt_module *module, yasm_object *object);
90 /** Cleans up any allocated debug format memory.
91 * \param dbgfmt debug format
93 void yasm_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt);
95 /** Generate debugging information bytecodes.
96 * \param object object
97 * \param linemap virtual/physical line mapping
98 * \param errwarns error/warning set
99 * \note Errors and warnings are stored into errwarns.
101 void yasm_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap,
102 yasm_errwarns *errwarns);
106 /* Inline macro implementations for dbgfmt functions */
108 #define yasm_dbgfmt_keyword(dbgfmt) \
109 (((yasm_dbgfmt_base *)dbgfmt)->module->keyword)
111 #define yasm_dbgfmt_create(module, object) \
112 module->create(object)
114 #define yasm_dbgfmt_destroy(dbgfmt) \
115 ((yasm_dbgfmt_base *)dbgfmt)->module->destroy(dbgfmt)
116 #define yasm_dbgfmt_generate(object, linemap, ews) \
117 ((yasm_dbgfmt_base *)((object)->dbgfmt))->module->generate \
118 (object, linemap, ews)