Skip to content

Commit 5754130

Browse files
committed
[cppia] Allow generating full debug source paths
1 parent 651a81d commit 5754130

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src-json/define.json

+5
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343
"define": "cppia",
4444
"doc": "Generate cpp instruction assembly."
4545
},
46+
{
47+
"name": "CppiaAbsoluteSourcePaths",
48+
"define": "cppia.absolute-source-paths",
49+
"doc": "Embed absolute paths to source files for debugging."
50+
},
4651
{
4752
"name": "NoCppiaAst",
4853
"define": "nocppiaast",

src/generators/cpp/gen/cppCppia.ml

+6-1
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ class script_writer ctx filename asciiOut =
521521
val fileTable = Hashtbl.create 0
522522
val identBuffer = Buffer.create 0
523523
val cppiaAst = not (Gctx.defined ctx.ctx_common Define.NoCppiaAst)
524+
val absoluteSourcePaths = Gctx.defined ctx.ctx_common Define.CppiaAbsoluteSourcePaths
524525

525526
method stringId name =
526527
try Hashtbl.find identTable name
@@ -785,8 +786,12 @@ class script_writer ctx filename asciiOut =
785786

786787
method wpos p =
787788
if debug then
789+
let filepath = if absoluteSourcePaths then
790+
Path.get_full_path p.pfile
791+
else p.pfile
792+
in
788793
this#write
789-
(this#fileText p.pfile ^ "\t"
794+
(this#fileText filepath ^ "\t"
790795
^ string_of_int (Lexer.get_error_line p)
791796
^ indent)
792797

0 commit comments

Comments
 (0)