dwarf2-dbgfmt.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * DWARF2 debugging format
  3. *
  4. * Copyright (C) 2006-2007 Peter Johnson
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  18. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
  19. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25. * POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef YASM_DWARF2_DBGFMT_H
  28. #define YASM_DWARF2_DBGFMT_H
  29. #define WITH_DWARF3 1
  30. typedef struct {
  31. char *pathname; /* full filename */
  32. char *filename; /* basename of full filename */
  33. unsigned long dir; /* index into directories array for relative path;
  34. * 0 for current directory. */
  35. } dwarf2_filename;
  36. /* Global data */
  37. typedef struct yasm_dbgfmt_dwarf2 {
  38. yasm_dbgfmt_base dbgfmt; /* base structure */
  39. char **dirs;
  40. unsigned long dirs_size;
  41. unsigned long dirs_allocated;
  42. dwarf2_filename *filenames;
  43. unsigned long filenames_size;
  44. unsigned long filenames_allocated;
  45. enum {
  46. DWARF2_FORMAT_32BIT,
  47. DWARF2_FORMAT_64BIT
  48. } format;
  49. unsigned int sizeof_address, sizeof_offset, min_insn_len;
  50. } yasm_dbgfmt_dwarf2;
  51. /* .loc directive data */
  52. typedef struct dwarf2_loc {
  53. /*@reldef@*/ STAILQ_ENTRY(dwarf2_loc) link;
  54. unsigned long vline; /* virtual line number of .loc directive */
  55. /* source information */
  56. unsigned long file; /* index into table of filenames */
  57. unsigned long line; /* source line number */
  58. unsigned long column; /* source column */
  59. unsigned long discriminator;
  60. int isa_change;
  61. unsigned long isa;
  62. enum {
  63. IS_STMT_NOCHANGE = 0,
  64. IS_STMT_SET,
  65. IS_STMT_CLEAR
  66. } is_stmt;
  67. int basic_block;
  68. int prologue_end;
  69. int epilogue_begin;
  70. yasm_bytecode *bc; /* first bytecode following */
  71. yasm_symrec *sym; /* last symbol preceding */
  72. } dwarf2_loc;
  73. /* Per-section data */
  74. typedef struct dwarf2_section_data {
  75. /* The locations set by the .loc directives in this section, in assembly
  76. * source order.
  77. */
  78. /*@reldef@*/ STAILQ_HEAD(dwarf2_lochead, dwarf2_loc) locs;
  79. } dwarf2_section_data;
  80. extern const yasm_assoc_data_callback yasm_dwarf2__section_data_cb;
  81. yasm_bytecode *yasm_dwarf2__append_bc(yasm_section *sect, yasm_bytecode *bc);
  82. /*@dependent@*/ yasm_symrec *yasm_dwarf2__bc_sym(yasm_symtab *symtab,
  83. yasm_bytecode *bc);
  84. typedef struct dwarf2_head dwarf2_head;
  85. dwarf2_head *yasm_dwarf2__add_head
  86. (yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, yasm_section *sect,
  87. /*@null@*/ yasm_section *debug_ptr, int with_address, int with_segment);
  88. void yasm_dwarf2__set_head_end(dwarf2_head *head, yasm_bytecode *end_prevbc);
  89. /* Line number functions */
  90. yasm_section *yasm_dwarf2__generate_line
  91. (yasm_object *object, yasm_linemap *linemap, yasm_errwarns *errwarns,
  92. int asm_source, /*@out@*/ yasm_section **main_code,
  93. /*@out@*/ size_t *num_line_sections);
  94. void yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams,
  95. yasm_valparamhead *objext_valparams,
  96. unsigned long line);
  97. void yasm_dwarf2__dir_file(yasm_object *object, yasm_valparamhead *valparams,
  98. yasm_valparamhead *objext_valparams,
  99. unsigned long line);
  100. /* Address range table functions */
  101. yasm_section *yasm_dwarf2__generate_aranges(yasm_object *object,
  102. yasm_section *debug_info);
  103. /* Name lookup table functions */
  104. yasm_section *yasm_dwarf2__generate_pubnames(yasm_object *object,
  105. yasm_section *debug_info);
  106. /* Information functions */
  107. yasm_section *yasm_dwarf2__generate_info
  108. (yasm_object *object, yasm_section *debug_line,
  109. /*@null@*/ yasm_section *main_code);
  110. #endif