| OLD | NEW |
| 1 /* | 1 /* |
| 2 * DWARF2 debugging format - info and abbreviation tables | 2 * DWARF2 debugging format - info and abbreviation tables |
| 3 * | 3 * |
| 4 * Copyright (C) 2006-2007 Peter Johnson | 4 * Copyright (C) 2006-2007 Peter Johnson |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| 11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
| 12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
| 13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
| 14 * | 14 * |
| 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS'' | 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 | 16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE | 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE |
| 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 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 | 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 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 | 24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 25 * POSSIBILITY OF SUCH DAMAGE. | 25 * POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 #include <util.h> | 27 #include <util.h> |
| 28 /*@unused@*/ RCSID("$Id: dwarf2-info.c 2130 2008-10-07 05:38:11Z peter $"); | |
| 29 | 28 |
| 30 #include <libyasm.h> | 29 #include <libyasm.h> |
| 31 | 30 |
| 32 #include "dwarf2-dbgfmt.h" | 31 #include "dwarf2-dbgfmt.h" |
| 33 | 32 |
| 34 #define DW_LANG_Mips_Assembler 0x8001 | 33 #define DW_LANG_Mips_Assembler 0x8001 |
| 35 | 34 |
| 36 /* Tag encodings */ | 35 /* Tag encodings */ |
| 37 typedef enum { | 36 typedef enum { |
| 38 DW_TAG_padding = 0x00, | 37 DW_TAG_padding = 0x00, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 } dwarf2_abbrev; | 189 } dwarf2_abbrev; |
| 191 | 190 |
| 192 /* Bytecode callback function prototypes */ | 191 /* Bytecode callback function prototypes */ |
| 193 | 192 |
| 194 static void dwarf2_abbrev_bc_destroy(void *contents); | 193 static void dwarf2_abbrev_bc_destroy(void *contents); |
| 195 static void dwarf2_abbrev_bc_print(const void *contents, FILE *f, | 194 static void dwarf2_abbrev_bc_print(const void *contents, FILE *f, |
| 196 int indent_level); | 195 int indent_level); |
| 197 static int dwarf2_abbrev_bc_calc_len | 196 static int dwarf2_abbrev_bc_calc_len |
| 198 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); | 197 (yasm_bytecode *bc, yasm_bc_add_span_func add_span, void *add_span_data); |
| 199 static int dwarf2_abbrev_bc_tobytes | 198 static int dwarf2_abbrev_bc_tobytes |
| 200 (yasm_bytecode *bc, unsigned char **bufp, void *d, | 199 (yasm_bytecode *bc, unsigned char **bufp, unsigned char *bufstart, void *d, |
| 201 yasm_output_value_func output_value, | 200 yasm_output_value_func output_value, |
| 202 /*@null@*/ yasm_output_reloc_func output_reloc); | 201 /*@null@*/ yasm_output_reloc_func output_reloc); |
| 203 | 202 |
| 204 /* Bytecode callback structures */ | 203 /* Bytecode callback structures */ |
| 205 | 204 |
| 206 static const yasm_bytecode_callback dwarf2_abbrev_bc_callback = { | 205 static const yasm_bytecode_callback dwarf2_abbrev_bc_callback = { |
| 207 dwarf2_abbrev_bc_destroy, | 206 dwarf2_abbrev_bc_destroy, |
| 208 dwarf2_abbrev_bc_print, | 207 dwarf2_abbrev_bc_print, |
| 209 yasm_bc_finalize_common, | 208 yasm_bc_finalize_common, |
| 210 NULL, | 209 NULL, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 dwarf2_append_str(debug_info, object->src_filename); | 329 dwarf2_append_str(debug_info, object->src_filename); |
| 331 | 330 |
| 332 /* compile directory (current working directory) */ | 331 /* compile directory (current working directory) */ |
| 333 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_comp_dir, DW_FORM_string); | 332 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_comp_dir, DW_FORM_string); |
| 334 buf = yasm__getcwd(); | 333 buf = yasm__getcwd(); |
| 335 dwarf2_append_str(debug_info, buf); | 334 dwarf2_append_str(debug_info, buf); |
| 336 yasm_xfree(buf); | 335 yasm_xfree(buf); |
| 337 | 336 |
| 338 /* producer - assembler name */ | 337 /* producer - assembler name */ |
| 339 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_producer, DW_FORM_string); | 338 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_producer, DW_FORM_string); |
| 340 dwarf2_append_str(debug_info, PACKAGE " " VERSION); | 339 if (getenv("YASM_TEST_SUITE")) |
| 340 dwarf2_append_str(debug_info, "yasm HEAD"); |
| 341 else |
| 342 dwarf2_append_str(debug_info, PACKAGE_STRING); |
| 341 | 343 |
| 342 /* language - no standard code for assembler, use MIPS as a substitute */ | 344 /* language - no standard code for assembler, use MIPS as a substitute */ |
| 343 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_language, DW_FORM_data2); | 345 abc->len += dwarf2_add_abbrev_attr(abbrev, DW_AT_language, DW_FORM_data2); |
| 344 dwarf2_append_expr(debug_info, | 346 dwarf2_append_expr(debug_info, |
| 345 yasm_expr_create_ident(yasm_expr_int( | 347 yasm_expr_create_ident(yasm_expr_int( |
| 346 yasm_intnum_create_uint(DW_LANG_Mips_Assembler)), 0), 2, 0); | 348 yasm_intnum_create_uint(DW_LANG_Mips_Assembler)), 0), 2, 0); |
| 347 | 349 |
| 348 /* Terminate list of abbreviations */ | 350 /* Terminate list of abbreviations */ |
| 349 abbrev = yasm_xmalloc(sizeof(dwarf2_abbrev)); | 351 abbrev = yasm_xmalloc(sizeof(dwarf2_abbrev)); |
| 350 abc = yasm_bc_create_common(&dwarf2_abbrev_bc_callback, abbrev, 0); | 352 abc = yasm_bc_create_common(&dwarf2_abbrev_bc_callback, abbrev, 0); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 static int | 389 static int |
| 388 dwarf2_abbrev_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, | 390 dwarf2_abbrev_bc_calc_len(yasm_bytecode *bc, yasm_bc_add_span_func add_span, |
| 389 void *add_span_data) | 391 void *add_span_data) |
| 390 { | 392 { |
| 391 yasm_internal_error(N_("tried to calc_len a dwarf2 aranges head bytecode")); | 393 yasm_internal_error(N_("tried to calc_len a dwarf2 aranges head bytecode")); |
| 392 /*@notreached@*/ | 394 /*@notreached@*/ |
| 393 return 0; | 395 return 0; |
| 394 } | 396 } |
| 395 | 397 |
| 396 static int | 398 static int |
| 397 dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, void *d, | 399 dwarf2_abbrev_bc_tobytes(yasm_bytecode *bc, unsigned char **bufp, |
| 400 unsigned char *bufstart, void *d, |
| 398 yasm_output_value_func output_value, | 401 yasm_output_value_func output_value, |
| 399 yasm_output_reloc_func output_reloc) | 402 yasm_output_reloc_func output_reloc) |
| 400 { | 403 { |
| 401 dwarf2_abbrev *abbrev = (dwarf2_abbrev *)bc->contents; | 404 dwarf2_abbrev *abbrev = (dwarf2_abbrev *)bc->contents; |
| 402 unsigned char *buf = *bufp; | 405 unsigned char *buf = *bufp; |
| 403 dwarf2_abbrev_attr *attr; | 406 dwarf2_abbrev_attr *attr; |
| 404 | 407 |
| 405 if (abbrev->id == 0) { | 408 if (abbrev->id == 0) { |
| 406 YASM_WRITE_8(buf, 0); | 409 YASM_WRITE_8(buf, 0); |
| 407 *bufp = buf; | 410 *bufp = buf; |
| 408 return 0; | 411 return 0; |
| 409 } | 412 } |
| 410 | 413 |
| 411 buf += yasm_get_uleb128(abbrev->id, buf); | 414 buf += yasm_get_uleb128(abbrev->id, buf); |
| 412 buf += yasm_get_uleb128(abbrev->tag, buf); | 415 buf += yasm_get_uleb128(abbrev->tag, buf); |
| 413 YASM_WRITE_8(buf, abbrev->has_children); | 416 YASM_WRITE_8(buf, abbrev->has_children); |
| 414 | 417 |
| 415 STAILQ_FOREACH(attr, &abbrev->attrs, link) { | 418 STAILQ_FOREACH(attr, &abbrev->attrs, link) { |
| 416 buf += yasm_get_uleb128(attr->name, buf); | 419 buf += yasm_get_uleb128(attr->name, buf); |
| 417 buf += yasm_get_uleb128(attr->form, buf); | 420 buf += yasm_get_uleb128(attr->form, buf); |
| 418 } | 421 } |
| 419 | 422 |
| 420 YASM_WRITE_8(buf, 0); | 423 YASM_WRITE_8(buf, 0); |
| 421 YASM_WRITE_8(buf, 0); | 424 YASM_WRITE_8(buf, 0); |
| 422 | 425 |
| 423 *bufp = buf; | 426 *bufp = buf; |
| 424 return 0; | 427 return 0; |
| 425 } | 428 } |
| 426 | 429 |
| OLD | NEW |