* here
*/
typedef enum custom_abbrevs {
- abbrev_void_pointer_type = 100,
+ abbrev_void_subprogram = 1,
+ abbrev_subprogram,
+ abbrev_formal_parameter,
abbrev_unnamed_formal_parameter,
abbrev_formal_parameter_no_location,
- abbrev_void_subroutine_type,
- abbrev_void_subprogram,
+ abbrev_variable,
+ abbrev_compile_unit,
+ abbrev_base_type,
+ abbrev_pointer_type,
+ abbrev_void_pointer_type,
+ abbrev_array_type,
+ abbrev_subrange_type,
+ abbrev_structure_type,
+ abbrev_union_type,
+ abbrev_class_type,
+ abbrev_member,
abbrev_bitfield_member,
+ abbrev_subroutine_type,
+ abbrev_void_subroutine_type,
} custom_abbrevs;
/**
static dwarf_t env;
static dwarf_source_language language;
-static const char *comp_dir;
+static char *comp_dir;
static unsigned insert_file(const char *filename)
{
unsigned num;
- void *entry = pmap_get(env.file_map, filename);
+ void *entry = pmap_get(void, env.file_map, filename);
if (entry != NULL) {
return PTR_TO_INT(entry);
}
emit_uleb128(form);
}
-static void begin_abbrev(unsigned code, dwarf_tag tag, dw_children children)
+static void begin_abbrev(custom_abbrevs code, dwarf_tag tag,
+ dw_children children)
{
emit_uleb128(code);
emit_uleb128(tag);
static bool is_extern_entity(const ir_entity *entity)
{
ir_visited_t visibility = get_entity_visibility(entity);
- return visibility == ir_visibility_default
- || visibility == ir_visibility_external;
+ return visibility == ir_visibility_external;
}
static void emit_entity_label(const ir_entity *entity)
static void emit_subprogram_abbrev(void)
{
- begin_abbrev(DW_TAG_subprogram, DW_TAG_subprogram, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_subprogram, DW_TAG_subprogram, DW_CHILDREN_yes);
register_attribute(DW_AT_name, DW_FORM_string);
register_dbginfo_attributes();
register_attribute(DW_AT_type, DW_FORM_ref4);
register_attribute(DW_AT_frame_base, DW_FORM_block1);
end_abbrev();
- begin_abbrev(DW_TAG_formal_parameter, DW_TAG_formal_parameter,
+ begin_abbrev(abbrev_formal_parameter, DW_TAG_formal_parameter,
DW_CHILDREN_no);
register_attribute(DW_AT_name, DW_FORM_string);
register_dbginfo_attributes();
ir_type *param_type = get_method_param_type(type, i);
if (infos != NULL && infos[i].entity != NULL) {
- const ir_entity *entity = infos[i].entity;
- long offset = get_entity_offset(entity);
- emit_uleb128(DW_TAG_formal_parameter);
+ long const offset = get_entity_offset(infos[i].entity);
+ emit_uleb128(abbrev_formal_parameter);
emit_string_printf("arg%u", (unsigned)i);
emit_dbginfo(dbgi);
emit_type_address(param_type);
size_t n_params = get_method_n_params(type);
size_t i;
- (void)parameter_infos;
-
be_gas_emit_switch_section(GAS_SECTION_DEBUG_INFO);
if (n_ress > 0) {
}
emit_entity_label(entity);
- emit_uleb128(n_ress == 0 ? abbrev_void_subprogram : DW_TAG_subprogram);
+ emit_uleb128(n_ress == 0 ? abbrev_void_subprogram : abbrev_subprogram);
emit_string(get_entity_ld_name(entity));
emit_dbginfo(get_entity_dbg_info(entity));
if (n_ress > 0) {
static void emit_base_type_abbrev(void)
{
- begin_abbrev(DW_TAG_base_type, DW_TAG_base_type, DW_CHILDREN_no);
+ begin_abbrev(abbrev_base_type, DW_TAG_base_type, DW_CHILDREN_no);
register_attribute(DW_AT_encoding, DW_FORM_data1);
register_attribute(DW_AT_byte_size, DW_FORM_data1);
register_attribute(DW_AT_name, DW_FORM_string);
ir_print_type(buf, sizeof(buf), type);
emit_type_label(type);
- emit_uleb128(DW_TAG_base_type);
+ emit_uleb128(abbrev_base_type);
if (mode_is_int(mode)) {
/* bool hack */
if (strcmp(buf, "_Bool")==0 || strcmp(buf, "bool")==0) {
static void emit_pointer_type_abbrev(void)
{
- begin_abbrev(DW_TAG_pointer_type, DW_TAG_pointer_type, DW_CHILDREN_no);
+ begin_abbrev(abbrev_pointer_type, DW_TAG_pointer_type, DW_CHILDREN_no);
register_attribute(DW_AT_type, DW_FORM_ref4);
register_attribute(DW_AT_byte_size, DW_FORM_data1);
end_abbrev();
emit_type(points_to);
emit_type_label(type);
- emit_uleb128(DW_TAG_pointer_type);
+ emit_uleb128(abbrev_pointer_type);
emit_type_address(points_to);
} else {
emit_type_label(type);
static void emit_array_type_abbrev(void)
{
- begin_abbrev(DW_TAG_array_type, DW_TAG_array_type, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_array_type, DW_TAG_array_type, DW_CHILDREN_yes);
register_attribute(DW_AT_type, DW_FORM_ref4);
end_abbrev();
- begin_abbrev(DW_TAG_subrange_type, DW_TAG_subrange_type, DW_CHILDREN_no);
+ begin_abbrev(abbrev_subrange_type, DW_TAG_subrange_type, DW_CHILDREN_no);
register_attribute(DW_AT_upper_bound, DW_FORM_udata);
end_abbrev();
}
ir_type *element_type = get_array_element_type(type);
if (get_array_n_dimensions(type) != 1)
- panic("dwarf: multidimensional arrays no supported yet");
+ panic("multidimensional arrays no supported yet");
emit_type(element_type);
emit_type_label(type);
- emit_uleb128(DW_TAG_array_type);
+ emit_uleb128(abbrev_array_type);
emit_type_address(element_type);
if (has_array_upper_bound(type, 0)) {
int bound = get_array_upper_bound_int(type, 0);
- emit_uleb128(DW_TAG_subrange_type);
+ emit_uleb128(abbrev_subrange_type);
emit_uleb128(bound);
}
static void emit_compound_type_abbrev(void)
{
- begin_abbrev(DW_TAG_structure_type, DW_TAG_structure_type, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_structure_type, DW_TAG_structure_type, DW_CHILDREN_yes);
register_attribute(DW_AT_byte_size, DW_FORM_udata);
// TODO register_dbginfo_attributes();
end_abbrev();
- begin_abbrev(DW_TAG_union_type, DW_TAG_union_type, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_union_type, DW_TAG_union_type, DW_CHILDREN_yes);
register_attribute(DW_AT_byte_size, DW_FORM_udata);
// TODO register_dbginfo_attributes();
end_abbrev();
- begin_abbrev(DW_TAG_class_type, DW_TAG_class_type, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_class_type, DW_TAG_class_type, DW_CHILDREN_yes);
register_attribute(DW_AT_byte_size, DW_FORM_udata);
// TODO register_dbginfo_attributes();
end_abbrev();
- begin_abbrev(DW_TAG_member, DW_TAG_member, DW_CHILDREN_no);
+ begin_abbrev(abbrev_member, DW_TAG_member, DW_CHILDREN_no);
register_attribute(DW_AT_type, DW_FORM_ref4);
register_attribute(DW_AT_name, DW_FORM_string);
register_dbginfo_attributes();
emit_type_label(type);
if (is_Struct_type(type)) {
- emit_uleb128(DW_TAG_structure_type);
+ emit_uleb128(abbrev_structure_type);
} else if (is_Union_type(type)) {
- emit_uleb128(DW_TAG_union_type);
+ emit_uleb128(abbrev_union_type);
} else {
assert(is_Class_type(type));
- emit_uleb128(DW_TAG_class_type);
+ emit_uleb128(abbrev_class_type);
}
emit_uleb128(get_type_size_bytes(type));
for (i = 0; i < n_members; ++i) {
emit_uleb128(bit_offset);
member_type = base;
} else {
- emit_uleb128(DW_TAG_member);
+ emit_uleb128(abbrev_member);
}
emit_type_address(member_type);
static void emit_subroutine_type_abbrev(void)
{
- begin_abbrev(DW_TAG_subroutine_type,
+ begin_abbrev(abbrev_subroutine_type,
DW_TAG_subroutine_type, DW_CHILDREN_yes);
register_attribute(DW_AT_prototyped, DW_FORM_flag);
register_attribute(DW_AT_type, DW_FORM_ref4);
}
emit_type_label(type);
- emit_uleb128(n_ress == 0 ? abbrev_void_subroutine_type : DW_TAG_subroutine_type);
+ emit_uleb128(n_ress == 0 ? abbrev_void_subroutine_type : abbrev_subroutine_type);
emit_int8(1); /* prototyped */
if (n_ress > 0) {
/* dwarf only supports 1 return type */
static void emit_type(ir_type *type)
{
- if (pset_new_insert(&env.emitted_types, type))
+ if (!pset_new_insert(&env.emitted_types, type))
return;
switch (get_type_tpop_code(type)) {
case tpo_union: emit_compound_type(type); break;
case tpo_method: emit_subroutine_type(type); break;
default:
- panic("bedwarf: type %+F not implemented yet", type);
+ panic("type %+F not implemented yet", type);
}
}
static void emit_variable_abbrev(void)
{
- begin_abbrev(DW_TAG_variable, DW_TAG_variable, DW_CHILDREN_no);
+ begin_abbrev(abbrev_variable, DW_TAG_variable, DW_CHILDREN_no);
register_attribute(DW_AT_name, DW_FORM_string);
register_attribute(DW_AT_type, DW_FORM_ref4);
register_attribute(DW_AT_external, DW_FORM_flag);
return;
if (get_entity_ld_name(entity)[0] == '\0')
return;
- /* skip external variables */
- if (get_entity_visibility(entity) == ir_visibility_external)
+ if (!entity_has_definition(entity))
return;
be_gas_emit_switch_section(GAS_SECTION_DEBUG_INFO);
emit_type(type);
emit_entity_label(entity);
- emit_uleb128(DW_TAG_variable);
+ emit_uleb128(abbrev_variable);
emit_string(get_entity_ld_name(entity));
emit_type_address(type);
emit_int8(is_extern_entity(entity));
static void emit_compile_unit_abbrev(void)
{
- begin_abbrev(DW_TAG_compile_unit, DW_TAG_compile_unit, DW_CHILDREN_yes);
+ begin_abbrev(abbrev_compile_unit, DW_TAG_compile_unit, DW_CHILDREN_yes);
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);
emit_label("info_section_begin");
emit_label("info_begin");
+ const backend_params *be_params = be_get_backend_param();
+
/* length of compilation unit info */
emit_size("compile_unit_begin", "compile_unit_end");
emit_label("compile_unit_begin");
emit_int16(3); /* dwarf version */
emit_address("abbrev_begin");
- emit_int8(4); /* pointer size, TODO: query backend */
+ emit_int8(be_params->machine_size / 8); /* pointer size */
/* compile_unit die */
- emit_uleb128(DW_TAG_compile_unit);
+ emit_uleb128(abbrev_compile_unit);
emit_address("line_section_begin");
emit_string_printf("libFirm (%u.%u %s)", ir_get_version_major(),
- ir_get_version_minor(),
- ir_get_version_revision());
+ ir_get_version_minor(), ir_get_version_revision());
emit_string(filename);
if (language != 0)
emit_int16(language);
void be_dwarf_set_compilation_directory(const char *new_comp_dir)
{
- comp_dir = new_comp_dir;
+ xfree(comp_dir);
+ comp_dir = xstrdup(new_comp_dir);
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_dwarf)