for review: new option --no-c-line-numbers

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Apr 15 14:58:08 AEST 1999


For review by anyone.

Estimated hours taken: 1.5

Add a new option that prevents the generation of #line directives in
the generated C code. This makes it easier to debug problems in the
interaction of compiler-generated C code and pragma included C code
with gdb, since the line numbers don't jump around on you.

compiler/options.m:
	Add a new option --c-line-numbers, to control this, which defaults
	to on.

compiler/llds_out.m:
	Check the option before emitting #line.

doc/user_guide.texi:
	Document the new option.

Zoltan.
cvs diff: Diffing .

cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.104
diff -u -b -u -r1.104 llds_out.m
--- llds_out.m	1999/03/22 08:07:20	1.104
+++ llds_out.m	1999/03/27 08:06:30
@@ -1571,9 +1571,11 @@
 	{ term__context_line(Context, Line) },
 	% The context is unfortunately bogus for pragma_c_codes inlined
 	% from a .opt file.
+	globals__io_lookup_bool_option(c_line_numbers, CLineNumbers),
 	(
 		{ Line > 0 },
-		{ File \= "" }
+		{ File \= "" },
+		{ CLineNumbers = yes }
 	->
 		io__write_string("#line "),
 		io__write_int(Line),
@@ -1592,9 +1594,11 @@
 	% idea of what it is processing back to the file we are generating.
 	io__get_output_line_number(Line),
 	io__output_stream_name(FileName),
+	globals__io_lookup_bool_option(c_line_numbers, CLineNumbers),
 	(
 		{ Line > 0 },
-		{ FileName \= "" }
+		{ FileName \= "" },
+		{ CLineNumbers = yes }
 	->
 		io__write_string("#line "),
 		{ NextLine is Line + 1 },
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.121
diff -u -b -u -r1.121 mercury_compile.m
--- mercury_compile.m	1999/03/28 07:30:40	1.121
+++ mercury_compile.m	1999/04/05 12:03:53
@@ -2485,7 +2485,14 @@
 		    { join_string_list(LinkLibraryDirectoriesList, "-L", "",
 				" ", LinkLibraryDirectories) },
 		    globals__io_lookup_accumulating_option(link_libraries,
-				LinkLibrariesList),
+				LinkLibrariesOptions),
+		    { TraceLevel \= none ->
+		    	LinkLibrariesList = LinkLibrariesOptions
+		    ;
+		    	list__append(LinkLibrariesOptions,
+				["mer_trace", "mer_browser"],
+				LinkLibrariesList)
+		    },
 		    { join_string_list(LinkLibrariesList, "-l", "", " ",
 				LinkLibraries) },
 		    globals__io_lookup_accumulating_option(link_objects,
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.255
diff -u -b -u -r1.255 options.m
--- options.m	1999/04/05 07:35:17	1.255
+++ options.m	1999/04/05 12:03:55
@@ -103,6 +103,7 @@
 		;	generate_prolog
 		;	prolog_dialect
 		;	line_numbers
+		;	c_line_numbers
 		;	auto_comments
 		;	show_dependency_graph
 		;	dump_hlds
@@ -410,6 +411,7 @@
 	generate_prolog		-	bool(no),
 	prolog_dialect		-	string("default"),
 	line_numbers		-	bool(no),
+	c_line_numbers		-	bool(yes),
 	auto_comments		-	bool(no),
 	show_dependency_graph	-	bool(no),
 	dump_hlds		-	accumulating([]),
@@ -765,6 +767,7 @@
 long_option("generate-Prolog",		generate_prolog).
 long_option("prolog-dialect",		prolog_dialect).
 long_option("line-numbers",		line_numbers).
+long_option("c-line-numbers",		c_line_numbers).
 long_option("auto-comments",		auto_comments).
 long_option("show-dependency-graph",	show_dependency_graph).
 long_option("dump-hlds",		dump_hlds).
@@ -1500,6 +1503,12 @@
 		"-l, --line-numbers",
 		"\tOutput line numbers in the generated code.",
 		"\tOnly works with the `-G' and `-P' options.",
+		"--no-c-line-numbers",
+		"\tDisable the generation of #line directives in the <module>.c",
+		"\tfile. This is may be useful when debugging the interactions",
+		"\tbetween C code generated by the compiler and pragma C code",
+		"\tfrom the Mercury source (such situations arise e.g. when",
+		"\tdebugging the Mercury compiler).",
 		"--auto-comments",
 		"\tOutput comments in the `<module>.c' file.",
 		"\t(The code may be easier to understand if you also",
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.164
diff -u -b -u -r1.164 user_guide.texi
--- user_guide.texi	1999/04/14 22:50:54	1.164
+++ user_guide.texi	1999/04/15 02:12:43
@@ -2604,6 +2604,14 @@
 
 @sp 1
 @item -n
+ at itemx --no-c-line-numbers
+Disable the generation of #line directives in the @file{@var{module}.c} file.
+This is may be useful when debugging the interactions between
+C code generated by the compiler and pragma C code from the Mercury source
+(such situations arise e.g. when debugging the Mercury compiler).
+
+ at sp 1
+ at item -n
 @itemx --line-numbers
 Output source line numbers in the generated code.
 This option only works in conjunction with the
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/exceptions
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/rot13
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trial
cvs diff: Diffing util



More information about the developers mailing list