-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Compiler: emit DWARF2 line number information
- Loading branch information
Showing
5 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
open Utils | ||
open Location | ||
open Format | ||
|
||
(* TODO: remove global mutable state *) | ||
|
||
(** Give a unique number to the given file name. | ||
Second return value is true the first time this file name is seed. *) | ||
let internFile = | ||
let count = ref 0 in | ||
let internedFiles = Hashtbl.create 17 in | ||
fun s -> | ||
match Hashtbl.find internedFiles s with | ||
| v -> (v, false) | ||
| exception Not_found -> | ||
incr count; | ||
let v = !count in | ||
Hashtbl.add internedFiles s v; | ||
(v, true) | ||
|
||
let source_positions ii = | ||
if Location.isdummy ii then [] | ||
else | ||
let n, isFresh = internFile ii.loc_fname in | ||
let line, col = ii.loc_start in | ||
let loc = [ asprintf ".loc %d %d %d\n" n line col ] in | ||
if isFresh then asprintf ".file %d %S\n" n ii.loc_fname :: loc else loc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
val source_positions : Location.t -> string list | ||
(** List of .file and .loc directives to decorate assembly listings. *) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters