Skip to content

Commit cd9ba42

Browse files
author
Pascal Beyer
committed
Remove old function debug information generation code.
1 parent 42fb381 commit cd9ba42

File tree

1 file changed

+0
-161
lines changed

1 file changed

+0
-161
lines changed

src/coff_writer.c

Lines changed: 0 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -821,167 +821,6 @@ func b32 global_symbol_stream_hash_table_add(struct gsi_hash_bucket **hash_table
821821

822822
//_____________________________________________________________________________________________________________________
823823

824-
func void tpi_emit_type_index_or_predecl_type_index(struct pdb_write_context *context, struct ast_type *type, enum ast_kind *defined_type){
825-
if(defined_type && *defined_type == AST_enum){
826-
struct ast_type *ast_enum = cast(struct ast_type *)defined_type;
827-
if(ast_enum->flags & TYPE_FLAG_pdb_permanent){
828-
out_int(ast_enum->pdb_type_index, u32);
829-
return;
830-
}
831-
}
832-
833-
if(type->flags & TYPE_FLAG_pdb_permanent){
834-
out_int(type->pdb_type_index, u32);
835-
}else{
836-
assert(type->pdb_predecl_type_index);
837-
out_int(type->pdb_predecl_type_index, u32);
838-
}
839-
}
840-
841-
842-
func void pdb_emit_regrels_for_scope(struct pdb_write_context *context, struct ast_scope *scope){
843-
// @note: it seems, that all declarations need to be at the beginning of the scope.
844-
// so we loop here over all of them instead of doing it recursively
845-
for(smm i = 0; i < scope->current_max_amount_of_declarations; i++){
846-
struct ast_declaration *decl = scope->declarations[i];
847-
if(!decl) continue;
848-
849-
// Skip typedefs.
850-
if(decl->kind != IR_declaration) continue;
851-
852-
// Enums don't get 'S_REGREL32'... @cleanup: maybe they get constants?
853-
if((decl->flags & DECLARATION_FLAGS_is_enum_member)) continue;
854-
855-
if(decl->flags & DECLARATION_FLAGS_is_local_persist){
856-
// @incomplete: emit a LDATA32
857-
continue;
858-
}
859-
s32 offset_of_rbp = to_s32(-decl->offset_on_stack);
860-
861-
begin_symbol(0x1111);{ // S_REGREL32
862-
out_int(offset_of_rbp, u32);
863-
tpi_emit_type_index_or_predecl_type_index(context, decl->type, decl->defined_type);
864-
out_int(334, u16); // CV_AMD64_RBP (cvconst.h)
865-
out_string(decl->identifier->string);
866-
}end_symbol();
867-
}
868-
869-
}
870-
871-
func struct pdb_location pdb_begin_scope(struct pdb_write_context *context, struct ast_function *function, struct ast_scope *scope){
872-
873-
struct pdb_location pointer_to_end_loc;
874-
smm scope_size = 0;
875-
smm offset_in_text_section = function->offset_in_text_section;
876-
877-
if(scope->start_line_index < function->line_information.size){ // Only false for empty functions.
878-
879-
u32 start_offset = function->line_information.data[scope->start_line_index].offset;
880-
u32 end_offset = scope->end_line_index < function->line_information.size ? function->line_information.data[scope->end_line_index].offset : (u32)function->byte_size_without_prolog;
881-
882-
// @cleanup: Does this correctly include function->size_of_prologue?
883-
scope_size = end_offset - start_offset;
884-
offset_in_text_section = function->offset_in_text_section + function->size_of_prolog + start_offset; // relocated by relocation.
885-
}
886-
887-
smm scope_offset_in_symbol_stream = pdb_current_offset_from_location(context, context->module_stream_begin);
888-
begin_symbol(0x1103);{// S_BLOCK32
889-
out_int(context->current_block32_offset_in_stream, u32); // pointer to parent
890-
pointer_to_end_loc = stream_allocate_bytes(context, sizeof(u32));
891-
out_int(scope_size, u32); // size of the scope in bytes
892-
out_int(offset_in_text_section, u32); // offset in segment
893-
out_int(context->text_section_id, u16); // segment
894-
}end_symbol();
895-
context->current_block32_offset_in_stream = scope_offset_in_symbol_stream;
896-
return pointer_to_end_loc;
897-
}
898-
899-
func void emit_debug_info_for_scope__recursive(struct pdb_write_context *context, struct ast_function *function, struct ast_scope *scope){
900-
901-
// @cleanup: skip if there are no declarations in the scope.
902-
903-
904-
struct pdb_location pointer_to_end_loc = zero_struct;
905-
smm old_offset = context->current_block32_offset_in_stream;
906-
907-
if(scope != function->scope){
908-
// @note: do not emit a scope for the initial scope as it is implied by the frameproc
909-
pointer_to_end_loc = pdb_begin_scope(context, function, scope);
910-
}
911-
912-
pdb_emit_regrels_for_scope(context, scope);
913-
914-
for(struct ast_scope *subscope = scope->subscopes.first; subscope; subscope = subscope->subscopes.next){
915-
emit_debug_info_for_scope__recursive(context, function, subscope);
916-
}
917-
918-
if(scope != function->scope){
919-
u32 diff = pdb_current_offset_from_location(context, context->module_stream_begin);
920-
stream_write_bytes(context, &pointer_to_end_loc, &diff, sizeof(u32));
921-
begin_symbol(0x6);{ // S_END
922-
}end_symbol();
923-
}
924-
context->current_block32_offset_in_stream = old_offset; // @cleanup: should maybe be called pointer
925-
}
926-
927-
928-
func void emit_debug_info_for_function(struct pdb_write_context *context, struct ast_function *function){
929-
// @cleanup: is this needed somewhere else?
930-
context->current_block32_offset_in_stream = function->debug_symbol_offset;
931-
emit_debug_info_for_scope__recursive(context, function, function->scope);
932-
}
933-
934-
//_____________________________________________________________________________________________________________________
935-
//
936-
937-
func void emit_one_pdb_line_info(struct pdb_write_context *context){
938-
// @cleanup: line should only have lower bits set.. not sure?
939-
u32 line = save_truncate_smm_to_u32(context->pdb_line_at);
940-
u32 offset = save_truncate_smm_to_u32(context->pdb_offset_at);
941-
942-
out_int(offset, u32);
943-
u32 is_statement = 0x80000000;
944-
out_int(line | is_statement, u32);
945-
context->pdb_amount_of_lines += 1;
946-
}
947-
948-
func void emit_pdb_line_info_for_function(struct pdb_write_context *context, struct ast_function *function){
949-
950-
#if 0
951-
context->pdb_amount_of_lines = 0;
952-
context->pdb_offset_at = 0;
953-
context->pdb_line_at = function->scope->token->line;
954-
emit_one_pdb_line_info(context); // emit an initial one and then we always emit _after_ updating
955-
956-
emit_pdb_line_info_for_ast__recursive(context, function, function->scope);
957-
#else
958-
959-
const u32 is_statement = 0x80000000;
960-
961-
struct ast_scope *scope = function->scope;
962-
963-
//
964-
// Emit an initial line for the prologue.
965-
//
966-
out_int(0, u32);
967-
out_int(scope->token->line | is_statement, u32);
968-
969-
for(smm index = 0; index < function->line_information.size; index++){
970-
struct function_line_information line = function->line_information.data[index];
971-
972-
u32 offset = (u32)(line.offset + function->size_of_prolog);
973-
974-
out_int(offset, u32);
975-
out_int(line.line | is_statement, u32);
976-
}
977-
context->pdb_amount_of_lines = function->line_information.size + 1;
978-
979-
#endif
980-
981-
}
982-
983-
//_____________________________________________________________________________________________________________________
984-
985824

986825
func void print_coff(struct string output_file_path, struct memory_arena *arena, struct memory_arena *scratch){
987826

0 commit comments

Comments
 (0)