dbgfmt.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /**
  2. * \file libyasm/dbgfmt.h
  3. * \brief YASM debug format interface.
  4. *
  5. * \license
  6. * Copyright (C) 2002-2007 Peter Johnson
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  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.
  16. *
  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.
  28. * \endlicense
  29. */
  30. #ifndef YASM_DBGFMT_H
  31. #define YASM_DBGFMT_H
  32. #ifndef YASM_DOXYGEN
  33. /** Base #yasm_dbgfmt structure. Must be present as the first element in any
  34. * #yasm_dbgfmt implementation.
  35. */
  36. typedef struct yasm_dbgfmt_base {
  37. /** #yasm_dbgfmt_module implementation for this debug format. */
  38. const struct yasm_dbgfmt_module *module;
  39. } yasm_dbgfmt_base;
  40. #endif
  41. /** Debug format module interface. */
  42. struct yasm_dbgfmt_module {
  43. /** One-line description of the debug format. */
  44. const char *name;
  45. /** Keyword used to select debug format. */
  46. const char *keyword;
  47. /** NULL-terminated list of directives. NULL if none. */
  48. /*@null@*/ const yasm_directive *directives;
  49. /** Create debug format.
  50. * Module-level implementation of yasm_dbgfmt_create().
  51. * The filenames are provided solely for informational purposes.
  52. * \param object object
  53. * \return NULL if object format does not provide needed support.
  54. */
  55. /*@null@*/ /*@only@*/ yasm_dbgfmt * (*create) (yasm_object *object);
  56. /** Module-level implementation of yasm_dbgfmt_destroy().
  57. * Call yasm_dbgfmt_destroy() instead of calling this function.
  58. */
  59. void (*destroy) (/*@only@*/ yasm_dbgfmt *dbgfmt);
  60. /** Module-level implementation of yasm_dbgfmt_generate().
  61. * Call yasm_dbgfmt_generate() instead of calling this function.
  62. */
  63. void (*generate) (yasm_object *object, yasm_linemap *linemap,
  64. yasm_errwarns *errwarns);
  65. /**
  66. * --replace params
  67. */
  68. const char** replace_map;
  69. /**
  70. * Number of elements in replace_map
  71. */
  72. int replace_map_size;
  73. };
  74. /** Get the keyword used to select a debug format.
  75. * \param dbgfmt debug format
  76. * \return keyword
  77. */
  78. const char *yasm_dbgfmt_keyword(const yasm_dbgfmt *dbgfmt);
  79. /** Initialize debug output for use. Must call before any other debug
  80. * format functions. The filenames are provided solely for informational
  81. * purposes.
  82. * \param module debug format module
  83. * \param object object to generate debugging information for
  84. * \return NULL if object format does not provide needed support.
  85. */
  86. /*@null@*/ /*@only@*/ yasm_dbgfmt *yasm_dbgfmt_create
  87. (const yasm_dbgfmt_module *module, yasm_object *object);
  88. /** Cleans up any allocated debug format memory.
  89. * \param dbgfmt debug format
  90. */
  91. void yasm_dbgfmt_destroy(/*@only@*/ yasm_dbgfmt *dbgfmt);
  92. /** Generate debugging information bytecodes.
  93. * \param object object
  94. * \param linemap virtual/physical line mapping
  95. * \param errwarns error/warning set
  96. * \note Errors and warnings are stored into errwarns.
  97. */
  98. void yasm_dbgfmt_generate(yasm_object *object, yasm_linemap *linemap,
  99. yasm_errwarns *errwarns);
  100. #ifndef YASM_DOXYGEN
  101. /* Inline macro implementations for dbgfmt functions */
  102. #define yasm_dbgfmt_keyword(dbgfmt) \
  103. (((yasm_dbgfmt_base *)dbgfmt)->module->keyword)
  104. #define yasm_dbgfmt_create(module, object) \
  105. module->create(object)
  106. #define yasm_dbgfmt_destroy(dbgfmt) \
  107. ((yasm_dbgfmt_base *)dbgfmt)->module->destroy(dbgfmt)
  108. #define yasm_dbgfmt_generate(object, linemap, ews) \
  109. ((yasm_dbgfmt_base *)((object)->dbgfmt))->module->generate \
  110. (object, linemap, ews)
  111. #endif
  112. #endif