From 3344bcf59acb1ae8d43a0d15acb4b824689e706d Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 16 Sep 2015 11:10:28 +0200 Subject: Add the debug interface file. The new file Debug.ml contains the interface for generating and printing debug information. In order to generate debug information the init function initializes the necessary functions depending on the -g flag. If the -g is not there all functions are dummy functions which do nothing. --- debug/Debug.mli | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 debug/Debug.mli (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli new file mode 100644 index 00000000..ea72aeb4 --- /dev/null +++ b/debug/Debug.mli @@ -0,0 +1,23 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *) +(* *) +(* AbsInt Angewandte Informatik GmbH. All rights reserved. This file *) +(* is distributed under the terms of the INRIA Non-Commercial *) +(* License Agreement. *) +(* *) +(* *********************************************************************) + +open C +open Camlcoq + + +val init: unit -> unit +val init_compile_unit: string -> unit +val atom_function: ident -> atom -> unit +val atom_global_variable: ident -> atom -> unit +val set_composite_size: ident -> struct_or_union -> int -> unit +val set_member_offset: ident -> string -> int -> int -> unit +val insert_declaration: globdecl -> Env.t -> unit -- cgit From 98cddc7ba45b34fbd71d9a80c27a8e5ec6b311b0 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 16 Sep 2015 19:43:35 +0200 Subject: Move more functionality in the new interface. Added functions to add more information to the debuging interface, like the struct layout with offsets, bitifiled layout and removed the no longer needed mapping from stamp to atom. --- debug/Debug.mli | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index ea72aeb4..ae32af5b 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -18,6 +18,8 @@ val init: unit -> unit val init_compile_unit: string -> unit val atom_function: ident -> atom -> unit val atom_global_variable: ident -> atom -> unit -val set_composite_size: ident -> struct_or_union -> int -> unit -val set_member_offset: ident -> string -> int -> int -> unit -val insert_declaration: globdecl -> Env.t -> unit +val set_composite_size: ident -> struct_or_union -> int option -> unit +val set_member_offset: ident -> string -> int -> unit +val set_bitfield_offset: ident -> string -> int -> string -> int -> unit +val insert_global_declaration: Env.t -> globdecl -> unit +val add_fun_addr: atom -> (int * int) -> unit -- cgit From c8a0b76c6b9c3eb004a7fccdd2ad15cc8615ef93 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 17 Sep 2015 18:19:37 +0200 Subject: First version with computation of dwarf info from debug info. Introduced a new dwarf generation from the information collected in the DebugInformation and removed the old CtODwarf translation. --- debug/Debug.mli | 3 +++ 1 file changed, 3 insertions(+) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index ae32af5b..e712874c 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -12,6 +12,7 @@ open C open Camlcoq +open DwarfTypes val init: unit -> unit @@ -23,3 +24,5 @@ val set_member_offset: ident -> string -> int -> unit val set_bitfield_offset: ident -> string -> int -> string -> int -> unit val insert_global_declaration: Env.t -> globdecl -> unit val add_fun_addr: atom -> (int * int) -> unit +val generate_debug_info: unit -> dw_entry option +val all_files_iter: (string -> unit) -> unit -- cgit From 31aceeb1be64d529432f35bbea16ebafc3a21df0 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 18 Sep 2015 16:42:05 +0200 Subject: Started implementing the scope for the Debug Informations. Scopes will be handled by a stack of all open scopes. This stack then can also be used to generate the debug directives to track the scopes through the rest of the passes. --- debug/Debug.mli | 2 ++ 1 file changed, 2 insertions(+) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index e712874c..69894ba7 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -26,3 +26,5 @@ val insert_global_declaration: Env.t -> globdecl -> unit val add_fun_addr: atom -> (int * int) -> unit val generate_debug_info: unit -> dw_entry option val all_files_iter: (string -> unit) -> unit +val insert_local_declaration: storage -> ident -> typ -> location -> unit +val atom_local_variable: ident -> atom -> unit -- cgit From a34b64ee2e7a535ebc0fc731243ab520c4ba430f Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Sun, 20 Sep 2015 15:36:42 +0200 Subject: New version of adding scopes etc. Instead of reimplementing the whole scope handling in the debug information use the existing functionality and fill the scopes explicitly in the functions. --- debug/Debug.mli | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 69894ba7..087f073f 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -26,5 +26,7 @@ val insert_global_declaration: Env.t -> globdecl -> unit val add_fun_addr: atom -> (int * int) -> unit val generate_debug_info: unit -> dw_entry option val all_files_iter: (string -> unit) -> unit -val insert_local_declaration: storage -> ident -> typ -> location -> unit +val insert_local_declaration: int -> storage -> ident -> typ -> location -> unit val atom_local_variable: ident -> atom -> unit +val enter_scope: int -> int -> unit +val enter_function_scope: ident -> int -> unit -- cgit From d7f75509c290d871cb8cd8aa11a0be2923c9ef17 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 22 Sep 2015 19:44:47 +0200 Subject: Record the scope structure during unblocking. Instead of creating separate annotations for the local variables we call the Debug.add_lvar_scope and we construct a mapping from function id + scope id to scope information. --- debug/Debug.mli | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 087f073f..a7d40382 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -26,7 +26,8 @@ val insert_global_declaration: Env.t -> globdecl -> unit val add_fun_addr: atom -> (int * int) -> unit val generate_debug_info: unit -> dw_entry option val all_files_iter: (string -> unit) -> unit -val insert_local_declaration: int -> storage -> ident -> typ -> location -> unit +val insert_local_declaration: storage -> ident -> typ -> location -> unit val atom_local_variable: ident -> atom -> unit -val enter_scope: int -> int -> unit +val enter_scope: int -> int -> int -> unit val enter_function_scope: ident -> int -> unit +val add_lvar_scope: int -> ident -> int -> unit -- cgit From b448fbba97c1008599610d0c9bc834881b9dc219 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 23 Sep 2015 16:49:13 +0200 Subject: Added support for printing local variables and fixed issue with .text Local variables are now added with bogus lexical scopes to reflect the actually lexical scopes. Also this commit fixes assembler problems of the das when a user section with the name ".text" is defined. --- debug/Debug.mli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index a7d40382..1fabb943 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -29,5 +29,5 @@ val all_files_iter: (string -> unit) -> unit val insert_local_declaration: storage -> ident -> typ -> location -> unit val atom_local_variable: ident -> atom -> unit val enter_scope: int -> int -> int -> unit -val enter_function_scope: ident -> int -> unit +val enter_function_scope: int -> int -> unit val add_lvar_scope: int -> ident -> int -> unit -- cgit From fc8afb9287ab7b1607e5a7d2a03b0078fd9867d0 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 24 Sep 2015 20:11:48 +0200 Subject: Added placing labels for live ranges etc. In order to avoid the usage of too many labels we replace the debug statements during the Asmexpand phase. --- debug/Debug.mli | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 1fabb943..42a0cee7 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -10,9 +10,11 @@ (* *) (* *********************************************************************) +open AST open C open Camlcoq open DwarfTypes +open BinNums val init: unit -> unit @@ -31,3 +33,8 @@ val atom_local_variable: ident -> atom -> unit val enter_scope: int -> int -> int -> unit val enter_function_scope: int -> int -> unit val add_lvar_scope: int -> ident -> int -> unit +val open_scope: atom -> int -> positive -> unit +val close_scope: atom -> int -> positive -> unit +val start_live_range: atom -> positive -> string builtin_arg -> unit +val end_live_range: atom -> positive -> unit +val stack_variable: atom -> string builtin_arg -> unit -- cgit From aff813685455559f6d6a88158dd3d605893ba3a3 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 25 Sep 2015 16:43:18 +0200 Subject: Added support for the locations of stack allocated local variables. This commit adds furher support for location information for local variables and starts with the implementation of the debug_loc section. --- debug/Debug.mli | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 42a0cee7..2954c300 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -26,7 +26,6 @@ val set_member_offset: ident -> string -> int -> unit val set_bitfield_offset: ident -> string -> int -> string -> int -> unit val insert_global_declaration: Env.t -> globdecl -> unit val add_fun_addr: atom -> (int * int) -> unit -val generate_debug_info: unit -> dw_entry option val all_files_iter: (string -> unit) -> unit val insert_local_declaration: storage -> ident -> typ -> location -> unit val atom_local_variable: ident -> atom -> unit @@ -35,6 +34,9 @@ val enter_function_scope: int -> int -> unit val add_lvar_scope: int -> ident -> int -> unit val open_scope: atom -> int -> positive -> unit val close_scope: atom -> int -> positive -> unit -val start_live_range: atom -> positive -> string builtin_arg -> unit +val start_live_range: atom -> positive -> (int * int builtin_arg) -> unit val end_live_range: atom -> positive -> unit -val stack_variable: atom -> string builtin_arg -> unit +val stack_variable: atom -> int * int builtin_arg -> unit +val function_end: atom -> positive -> unit +val add_label: atom -> positive -> int -> unit +val generate_debug_info: unit -> (dw_entry * dw_locations) option -- cgit From 78df4fe4fad46fee83f5044525fd8e530d8da6ff Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Sun, 27 Sep 2015 20:25:21 +0200 Subject: More refactoring of the Debug Information. In order to remove unnecessary dependecies the implemenation type is made and the DebugInit file initializes the fields in the record. This allows it to move more functions behind the Debug interface without introducing circular dependencies. --- debug/Debug.mli | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 2954c300..5ef1e7f5 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -17,7 +17,35 @@ open DwarfTypes open BinNums -val init: unit -> unit +(* Record used for stroring references to the actual implementation functions *) +type implem = + { + mutable init: string -> unit; + mutable atom_function: ident -> atom -> unit; + mutable atom_global_variable: ident -> atom -> unit; + mutable set_composite_size: ident -> struct_or_union -> int option -> unit; + mutable set_member_offset: ident -> string -> int -> unit; + mutable set_bitfield_offset: ident -> string -> int -> string -> int -> unit; + mutable insert_global_declaration: Env.t -> globdecl -> unit; + mutable add_fun_addr: atom -> (int * int) -> unit; + mutable generate_debug_info: unit -> (dw_entry * dw_locations) option; + mutable all_files_iter: (string -> unit) -> unit; + mutable insert_local_declaration: storage -> ident -> typ -> location -> unit; + mutable atom_local_variable: ident -> atom -> unit; + mutable enter_scope: int -> int -> int -> unit; + mutable enter_function_scope: int -> int -> unit; + mutable add_lvar_scope: int -> ident -> int -> unit; + mutable open_scope: atom -> int -> positive -> unit; + mutable close_scope: atom -> int -> positive -> unit; + mutable start_live_range: atom -> positive -> int * int builtin_arg -> unit; + mutable end_live_range: atom -> positive -> unit; + mutable stack_variable: atom -> int * int builtin_arg -> unit; + mutable function_end: atom -> positive -> unit; + mutable add_label: atom -> positive -> int -> unit; + } + +val implem: implem + val init_compile_unit: string -> unit val atom_function: ident -> atom -> unit val atom_global_variable: ident -> atom -> unit -- cgit From 5492b5b55afa68e3d628da07ff583a0cac79b7e3 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 28 Sep 2015 13:36:53 +0200 Subject: Added location for the formal parameters and move the end of all scopes before the last statement. --- debug/Debug.mli | 2 ++ 1 file changed, 2 insertions(+) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index 5ef1e7f5..c5fcddb3 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -42,6 +42,7 @@ type implem = mutable stack_variable: atom -> int * int builtin_arg -> unit; mutable function_end: atom -> positive -> unit; mutable add_label: atom -> positive -> int -> unit; + mutable atom_parameter: ident -> ident -> atom -> unit; } val implem: implem @@ -68,3 +69,4 @@ val stack_variable: atom -> int * int builtin_arg -> unit val function_end: atom -> positive -> unit val add_label: atom -> positive -> int -> unit val generate_debug_info: unit -> (dw_entry * dw_locations) option +val atom_parameter: ident -> ident -> atom -> unit -- cgit From 68ad5472a78d12e0e4fd4eae422122185403d678 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 28 Sep 2015 18:39:43 +0200 Subject: Change the way the debug sections are printed. If a user uses the #pragma use_section for functions the diab linker requires a separate debug_info section for each entry. This commit adds functionality to emulate this behavior. --- debug/Debug.mli | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'debug/Debug.mli') diff --git a/debug/Debug.mli b/debug/Debug.mli index c5fcddb3..166a6759 100644 --- a/debug/Debug.mli +++ b/debug/Debug.mli @@ -28,7 +28,7 @@ type implem = mutable set_bitfield_offset: ident -> string -> int -> string -> int -> unit; mutable insert_global_declaration: Env.t -> globdecl -> unit; mutable add_fun_addr: atom -> (int * int) -> unit; - mutable generate_debug_info: unit -> (dw_entry * dw_locations) option; + mutable generate_debug_info: (atom -> string) -> string -> debug_entries option; mutable all_files_iter: (string -> unit) -> unit; mutable insert_local_declaration: storage -> ident -> typ -> location -> unit; mutable atom_local_variable: ident -> atom -> unit; @@ -43,6 +43,9 @@ type implem = mutable function_end: atom -> positive -> unit; mutable add_label: atom -> positive -> int -> unit; mutable atom_parameter: ident -> ident -> atom -> unit; + mutable add_compilation_section_start: string -> (int * int * int * string) -> unit; + mutable compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit; + mutable exists_section: string -> bool; } val implem: implem @@ -68,5 +71,8 @@ val end_live_range: atom -> positive -> unit val stack_variable: atom -> int * int builtin_arg -> unit val function_end: atom -> positive -> unit val add_label: atom -> positive -> int -> unit -val generate_debug_info: unit -> (dw_entry * dw_locations) option +val generate_debug_info: (atom -> string) -> string -> debug_entries option val atom_parameter: ident -> ident -> atom -> unit +val add_compilation_section_start: string -> (int * int * int * string) -> unit +val compute_file_enum: (string -> int) -> (string-> int) -> (unit -> unit) -> unit +val exists_section: string -> bool -- cgit