From: Matthias Braun Date: Tue, 24 Apr 2012 16:53:59 +0000 (+0200) Subject: dwarf: setter for language and compilation dir X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=7eb9592b75afa78475ceec1625ce2a67b805efbf;p=libfirm dwarf: setter for language and compilation dir --- diff --git a/include/libfirm/be.h b/include/libfirm/be.h index 41d5454eb..028b25d0a 100644 --- a/include/libfirm/be.h +++ b/include/libfirm/be.h @@ -69,6 +69,31 @@ typedef enum asm_constraint_flags_t { } asm_constraint_flags_t; ENUM_BITSET(asm_constraint_flags_t) +/* Dwarf source language codes. */ +typedef enum { + DW_LANG_C89 = 0x0001, + DW_LANG_C = 0x0002, + DW_LANG_Ada83 = 0x0003, + DW_LANG_C_plus_plus = 0x0004, + DW_LANG_Cobol74 = 0x0005, + DW_LANG_Cobol85 = 0x0006, + DW_LANG_Fortran77 = 0x0007, + DW_LANG_Fortran90 = 0x0008, + DW_LANG_Pascal83 = 0x0009, + DW_LANG_Modula2 = 0x000a, + DW_LANG_Java = 0x000b, + DW_LANG_C99 = 0x000c, + DW_LANG_Ada95 = 0x000d, + DW_LANG_Fortran95 = 0x000e, + DW_LANG_PLI = 0x000f, + DW_LANG_ObjC = 0x0010, + DW_LANG_ObjC_plus_plus = 0x0011, + DW_LANG_UPC = 0x0012, + DW_LANG_D = 0x0013, + DW_LANG_Python = 0x0014, + DW_LANG_Go = 0x0016, +} dwarf_source_language; + /** * Build a Trampoline for the closure. * @param block the block where to build the trampoline @@ -193,6 +218,17 @@ FIRM_API asm_constraint_flags_t be_parse_asm_constraints(const char *constraints */ FIRM_API int be_is_valid_clobber(const char *clobber); +/** + * Sets source language for dwarf debug information. + */ +FIRM_API void be_dwarf_set_source_language(dwarf_source_language language); + +/** + * Sets working directory of the compiler (or directory where the compiler + * searched for sources) for dwarf debug information. + */ +FIRM_API void be_dwarf_set_compilation_directory(const char *directory); + /** @} */ #include "end.h" diff --git a/ir/be/bedwarf.c b/ir/be/bedwarf.c index a334a7a54..62d7cfc8d 100644 --- a/ir/be/bedwarf.c +++ b/ir/be/bedwarf.c @@ -432,6 +432,9 @@ typedef struct dwarf_t { unsigned last_line; } dwarf_t; +static dwarf_source_language language; +static const char *comp_dir; + static unsigned insert_file(dwarf_t *env, const char *filename) { unsigned num; @@ -1090,7 +1093,10 @@ static void emit_compile_unit_abbrev(void) register_attribute(DW_AT_stmt_list, DW_FORM_data4); register_attribute(DW_AT_producer, DW_FORM_string); register_attribute(DW_AT_name, DW_FORM_string); - register_attribute(DW_AT_comp_dir, DW_FORM_string); + if (language != 0) + register_attribute(DW_AT_language, DW_FORM_data2); + if (comp_dir != NULL) + register_attribute(DW_AT_comp_dir, DW_FORM_string); end_abbrev(); } @@ -1139,7 +1145,10 @@ static void dwarf_unit_begin(dbg_handle *handle, const char *filename) ir_get_version_minor(), ir_get_version_revision()); emit_string(filename); - emit_string("/foo/bar/"); + if (language != 0) + emit_int16(DW_LANG_C_plus_plus); + if (comp_dir != NULL) + emit_string(comp_dir); } static void dwarf_unit_end(dbg_handle *handle) @@ -1202,3 +1211,13 @@ void be_init_dwarf(void) { be_register_dbgout_module("dwarf", be_dwarf_open); } + +void be_dwarf_set_source_language(dwarf_source_language new_language) +{ + language = new_language; +} + +void be_dwarf_set_compilation_directory(const char *new_comp_dir) +{ + comp_dir = new_comp_dir; +}