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 30 #define WITH_DWARF3 1 31 32 typedef struct { 33 char *pathname; /* full filename */ 34 char *filename; /* basename of full filename */ 35 unsigned long dir; /* index into directories array for relative path; 36 * 0 for current directory. */ 37 } dwarf2_filename; 38 39 /* Global data */ 40 typedef struct yasm_dbgfmt_dwarf2 { 41 yasm_dbgfmt_base dbgfmt; /* base structure */ 42 43 char **dirs; 44 unsigned long dirs_size; 45 unsigned long dirs_allocated; 46 47 dwarf2_filename *filenames; 48 unsigned long filenames_size; 49 unsigned long filenames_allocated; 50 51 enum { 52 DWARF2_FORMAT_32BIT, 53 DWARF2_FORMAT_64BIT 54 } format; 55 56 unsigned int sizeof_address, sizeof_offset, min_insn_len; 57 } yasm_dbgfmt_dwarf2; 58 59 /* .loc directive data */ 60 typedef struct dwarf2_loc { 61 /*@reldef@*/ STAILQ_ENTRY(dwarf2_loc) link; 62 63 unsigned long vline; /* virtual line number of .loc directive */ 64 65 /* source information */ 66 unsigned long file; /* index into table of filenames */ 67 unsigned long line; /* source line number */ 68 unsigned long column; /* source column */ 69 unsigned long discriminator; 70 int isa_change; 71 unsigned long isa; 72 enum { 73 IS_STMT_NOCHANGE = 0, 74 IS_STMT_SET, 75 IS_STMT_CLEAR 76 } is_stmt; 77 int basic_block; 78 int prologue_end; 79 int epilogue_begin; 80 81 yasm_bytecode *bc; /* first bytecode following */ 82 yasm_symrec *sym; /* last symbol preceding */ 83 } dwarf2_loc; 84 85 /* Per-section data */ 86 typedef struct dwarf2_section_data { 87 /* The locations set by the .loc directives in this section, in assembly 88 * source order. 89 */ 90 /*@reldef@*/ STAILQ_HEAD(dwarf2_lochead, dwarf2_loc) locs; 91 } dwarf2_section_data; 92 93 extern const yasm_assoc_data_callback yasm_dwarf2__section_data_cb; 94 95 yasm_bytecode *yasm_dwarf2__append_bc(yasm_section *sect, yasm_bytecode *bc); 96 97 /*@dependent@*/ yasm_symrec *yasm_dwarf2__bc_sym(yasm_symtab *symtab, 98 yasm_bytecode *bc); 99 100 typedef struct dwarf2_head dwarf2_head; 101 dwarf2_head *yasm_dwarf2__add_head 102 (yasm_dbgfmt_dwarf2 *dbgfmt_dwarf2, yasm_section *sect, 103 /*@null@*/ yasm_section *debug_ptr, int with_address, int with_segment); 104 void yasm_dwarf2__set_head_end(dwarf2_head *head, yasm_bytecode *end_prevbc); 105 106 /* Line number functions */ 107 yasm_section *yasm_dwarf2__generate_line 108 (yasm_object *object, yasm_linemap *linemap, yasm_errwarns *errwarns, 109 int asm_source, /*@out@*/ yasm_section **main_code, 110 /*@out@*/ size_t *num_line_sections); 111 void yasm_dwarf2__dir_loc(yasm_object *object, yasm_valparamhead *valparams, 112 yasm_valparamhead *objext_valparams, 113 unsigned long line); 114 void yasm_dwarf2__dir_file(yasm_object *object, yasm_valparamhead *valparams, 115 yasm_valparamhead *objext_valparams, 116 unsigned long line); 117 118 /* Address range table functions */ 119 yasm_section *yasm_dwarf2__generate_aranges(yasm_object *object, 120 yasm_section *debug_info); 121 122 /* Name lookup table functions */ 123 yasm_section *yasm_dwarf2__generate_pubnames(yasm_object *object, 124 yasm_section *debug_info); 125 126 /* Information functions */ 127 yasm_section *yasm_dwarf2__generate_info 128 (yasm_object *object, yasm_section *debug_line, 129 /*@null@*/ yasm_section *main_code); 130 131 #endif 132