aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2014-12-04 13:12:45 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2014-12-04 13:12:45 +0100
commit5735f427bb0e6698eb946b961baadfed0fac31e5 (patch)
tree939d1a2f1bb569c1057107e9760ce800ed235ce6 /powerpc
parent5435a0ac12625b356ecbd9faba1c7ec67f2477a7 (diff)
downloadcompcert-5735f427bb0e6698eb946b961baadfed0fac31e5.tar.gz
compcert-5735f427bb0e6698eb946b961baadfed0fac31e5.zip
Changed the d1line and d1file to d2line and d2file and prologue and epilogue printing for printing the line directives without forcing the assembler to generate debug information.
Diffstat (limited to 'powerpc')
-rw-r--r--powerpc/PrintAsm.ml5
-rw-r--r--powerpc/PrintDiab.ml72
-rw-r--r--powerpc/PrintLinux.ml6
-rw-r--r--powerpc/PrintUtil.ml3
4 files changed, 78 insertions, 8 deletions
diff --git a/powerpc/PrintAsm.ml b/powerpc/PrintAsm.ml
index 3843a84e..485493b1 100644
--- a/powerpc/PrintAsm.ml
+++ b/powerpc/PrintAsm.ml
@@ -549,8 +549,9 @@ let print_program oc p =
| Linux -> (module Linux_System:SYSTEM)
| Diab -> (module Diab_System:SYSTEM)):SYSTEM) in
let module Printer = AsmPrinter(Target) in
+ Printer.set_compilation_unit_addrs 1 2; (* TODO This is dummy code *)
Printer.reset_file_line();
PrintAnnot.print_version_and_options oc Printer.comment;
Printer.print_prologue oc;
- List.iter (Printer.print_globdef oc) p.prog_defs
-
+ List.iter (Printer.print_globdef oc) p.prog_defs;
+ Printer.print_epilogue oc
diff --git a/powerpc/PrintDiab.ml b/powerpc/PrintDiab.ml
index d73c7691..84fd1a22 100644
--- a/powerpc/PrintDiab.ml
+++ b/powerpc/PrintDiab.ml
@@ -70,18 +70,26 @@ module Diab_System =
| false, true -> 'c' (* text *)
| false, false -> 'r') (* const *)
+ let filenum : (string, int) Hashtbl.t = Hashtbl.create 7
+
let last_file = ref ""
- let reset_file_line () = last_file := ""
+
+ let reset_file_line () =
+ last_file := "";
+ Hashtbl.clear filenum
+
let print_file_line oc file line =
if !Clflags.option_g && file <> "" then begin
if file <> !last_file then begin
- fprintf oc " .d1file %S\n" file;
- last_file := file
+ fprintf oc " .d2file %S\n" file;
+ last_file := file;
+ if not (Hashtbl.mem filenum file) then
+ Hashtbl.add filenum file (new_label ());
end;
- fprintf oc " .d1line %s\n" line
+ fprintf oc " .d2line %s\n" line
end
- (* Emit .cfi directives *)
+ (* Emit .cfi directives *)
let cfi_startproc oc = ()
let cfi_endproc oc = ()
@@ -89,12 +97,63 @@ module Diab_System =
let cfi_adjust oc delta = ()
let cfi_rel_offset oc reg ofs = ()
+
+ let debug_line_start = ref (-1)
+
+ let compilation_unit_start_addr = ref (-1)
+
+ let compilation_unit_end_addr = ref (-1)
+
+ (* Mapping from debug addresses to labels *)
+ let addr_label_map: (int,int) Hashtbl.t = Hashtbl.create 7
+
+ let set_compilation_unit_addrs cu_start cu_end =
+ compilation_unit_start_addr := cu_start;
+ compilation_unit_end_addr := cu_end
+
+ let debug_info_start = ref (-1)
+
+ let print_addr_label oc addr =
+ let lbl = try
+ Hashtbl.find addr_label_map addr
+ with Not_found ->
+ let lbl = new_label () in
+ Hashtbl.add addr_label_map addr lbl;
+ lbl in
+ fprintf oc "%a:\n" label lbl
let print_prologue oc =
fprintf oc " .xopt align-fill-text=0x60000000\n";
if !Clflags.option_g then
- fprintf oc " .xopt asm-debug-on\n"
+ begin
+ fprintf oc " .text\n";
+ fprintf oc " .section .debug_line,,n\n";
+ let label_debug_line = new_label () in
+ debug_line_start := label_debug_line;
+ fprintf oc "%a:\n" label label_debug_line;
+ fprintf oc " .text\n";
+ print_addr_label oc !compilation_unit_start_addr;
+ let label_debug_info = new_label () in
+ debug_info_start := label_debug_info;
+ fprintf oc " .0byte %a\n" label label_debug_info;
+ fprintf oc " .d2_line_start .debug_line\n";
+ fprintf oc " .text\n";
+ fprintf oc " .align 2\n"
+ end
+ let print_epilogue oc =
+ if !Clflags.option_g then
+ begin
+ (* Everthink available for printing of the compilation unit *)
+ fprintf oc " .text\n";
+ (* End Address of the compilation unit *)
+ print_addr_label oc !compilation_unit_end_addr;
+ (* Print the filenum which is used for the location expressions *)
+ Hashtbl.iter (fun name lbl ->
+ fprintf oc "%a: .d2filenum \"%s\"\n" label lbl name) filenum;
+ (* The end of the debug line info *)
+ fprintf oc " .d2_line_end\n";
+ end
module AbbrvPrinter = DwarfAbbrvPrinter(struct
let string_of_byte value =
@@ -156,4 +215,5 @@ module Diab_System =
end)
+
end:SYSTEM)
diff --git a/powerpc/PrintLinux.ml b/powerpc/PrintLinux.ml
index 593b6413..ed4ef19b 100644
--- a/powerpc/PrintLinux.ml
+++ b/powerpc/PrintLinux.ml
@@ -110,5 +110,11 @@ module Linux_System =
let print_prologue oc = ()
+
+ let print_epilogue oc = ()
+
+ let set_compilation_unit_addrs _ _ = ()
+
+ let print_addr_label _ _ = ()
end:SYSTEM)
diff --git a/powerpc/PrintUtil.ml b/powerpc/PrintUtil.ml
index 0acb7990..500ff1a3 100644
--- a/powerpc/PrintUtil.ml
+++ b/powerpc/PrintUtil.ml
@@ -35,6 +35,9 @@ module type SYSTEM =
val cfi_adjust: out_channel -> int32 -> unit
val cfi_rel_offset: out_channel -> string -> int32 -> unit
val print_prologue: out_channel -> unit
+ val print_epilogue: out_channel -> unit
+ val print_addr_label: out_channel -> int -> unit
+ val set_compilation_unit_addrs: int -> int -> unit
end
let symbol oc symb =