for review: the new debugger command set (part 5 of 5)

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Sep 16 18:23:11 AEST 1998


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 scripts
Index: scripts/mdb
===================================================================
RCS file: mdb
diff -N mdb
--- /tmp/cvs274251aa	Wed Sep 16 17:58:36 1998
+++ /dev/null	Wed May 28 10:49:58 1997
@@ -1,39 +0,0 @@
-#!/bin/sh
-#---------------------------------------------------------------------------#
-# Copyright (C) 1998 The University of Melbourne.
-# This file may only be copied under the terms of the GNU General
-# Public License - see the file COPYING in the Mercury distribution.
-#---------------------------------------------------------------------------#
-#
-# IMPORTANT: the manpage is produced automatically from this help
-# message, so if you change the help message, don't forget to check
-# that the manpage still looks OK.
-Help="\
-Name:	mdb - Mercury debugger
-Usage:	mdb <executable> [<options>]...
-Description:
-	The arguments of this command form a command line.
-	If the executable named by this command line is a Mercury program
-	compiled with debugging enabled (e.g. via the \`--debug' option),
-	or if it invokes such a program, then mdb will cause the program
-	to be executed under the supervision of the Mercury internal debugger.
-	Otherwise, mdb will execute the command line as if the mdb prefix
-	weren't there.
-Environment variables:
-	MERCURY_OPTIONS.
-"
-
-case $# in
-	0)	echo "Usage: mdb <executable> [<arg> ...]" 1>&2
-		exit 1;;
-esac
-
-case $1 in
-	--help)
-		echo "$Help"
-		exit 0;;
-esac
-
-MERCURY_OPTIONS="$MERCURY_OPTIONS -Di"
-export MERCURY_OPTIONS
-exec "$@"
Index: scripts/mdb.in
===================================================================
RCS file: mdb.in
diff -N mdb.in
--- /dev/null	Wed May 28 10:49:58 1997
+++ mdb.in	Wed Sep 16 14:46:30 1998
@@ -0,0 +1,41 @@
+#!/bin/sh
+#---------------------------------------------------------------------------#
+# Copyright (C) 1998 The University of Melbourne.
+# This file may only be copied under the terms of the GNU General
+# Public License - see the file COPYING in the Mercury distribution.
+#---------------------------------------------------------------------------#
+#
+# IMPORTANT: the manpage is produced automatically from this help
+# message, so if you change the help message, don't forget to check
+# that the manpage still looks OK.
+Help="\
+Name:	mdb - Mercury debugger
+Usage:	mdb <executable> [<options>]...
+Description:
+	The arguments of this command form a command line.
+	If the executable named by this command line is a Mercury program
+	compiled with debugging enabled (e.g. via the \`--debug' option),
+	or if it invokes such a program, then mdb will cause the program
+	to be executed under the supervision of the Mercury internal debugger.
+	Otherwise, mdb will execute the command line as if the mdb prefix
+	weren't there.
+Environment variables:
+	MERCURY_OPTIONS.
+"
+
+case $# in
+	0)	echo "Usage: mdb <executable> [<arg> ...]" 1>&2
+		exit 1;;
+esac
+
+case $1 in
+	--help)
+		echo "$Help"
+		exit 0;;
+esac
+
+MERCURY_OPTIONS="$MERCURY_OPTIONS -Di"
+export MERCURY_OPTIONS
+DEFAULT_MERCURY_DEBUGGER_INIT=@DEFAULT_MERCURY_DEBUGGER_INIT_DIR@/mdbrc
+export DEFAULT_MERCURY_DEBUGGER_INIT
+exec "$@"
Index: scripts/ml.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/ml.in,v
retrieving revision 1.46
diff -u -u -r1.46 ml.in
--- ml.in	1998/07/27 01:05:17	1.46
+++ ml.in	1998/09/11 03:41:54
@@ -366,13 +366,14 @@
 
 case $mercury_libs in
 	shared)
-		LIBS=${MERCURY_LIBS="-lmercury -lmer $LIBGC $STDLIBS"}
+		LIBS=${MERCURY_LIBS="-lmercury -lmer -lmercury $LIBGC $STDLIBS"}
 		merc_shlib_dirs="$merc_shlib_dirs $LIBDIR/$GRADE/$FULLARCH"
 		merc_shlib_dirs="$merc_shlib_dirs $LIBDIR/$FULLARCH"
 		;;
 	static) LIBS=${MERCURY_LIBS="\
 			$LIBDIR/$GRADE/$FULLARCH/libmercury.a \
 			$LIBDIR/$GRADE/$FULLARCH/libmer.a \
+			$LIBDIR/$GRADE/$FULLARCH/libmercury.a \
 			$LIBGC_STATIC \
 			$STDLIBS"}
 		merc_shlib_dirs=""
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.9
diff -u -u -r1.9 Mmakefile
--- Mmakefile	1998/08/30 04:04:47	1.9
+++ Mmakefile	1998/09/11 08:26:48
@@ -1,8 +1,8 @@
 #-----------------------------------------------------------------------------#
 
-main_target: check
+main_target:	check
 
-include ../Mmake.common
+include		../Mmake.common
 
 RM_C=:
 
@@ -15,10 +15,13 @@
 DEBUGGER_PROGS=	\
 	debugger_regs	\
 	interpreter	\
-#	queens
+	queens
 
-MCFLAGS = --trace all
-C2INITFLAGS = -i
+MCFLAGS = --trace deep
+EXTRA_C2INITFLAGS = -i
 
 # Base grades `jump' and `fast' cannot be used with
 # stack layouts (which are required for tracing).
Index: tests/debugger/debugger_regs.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs.exp,v
retrieving revision 1.2
diff -u -u -r1.2 debugger_regs.exp
<omitted>
Index: tests/debugger/debugger_regs.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs.inp,v
retrieving revision 1.2
diff -u -u -r1.2 debugger_regs.inp
--- debugger_regs.inp	1998/06/18 06:08:29	1.2
+++ debugger_regs.inp	1998/07/06 10:39:20
@@ -1,4 +1,5 @@
+echo on
 
 
-p *
-c
+print *
+continue
Index: tests/debugger/debugger_regs_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs_lib.exp,v
retrieving revision 1.2
diff -u -u -r1.2 debugger_regs_lib.exp
<omitted>
Index: tests/debugger/debugger_regs_lib.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/debugger_regs_lib.inp,v
retrieving revision 1.2
diff -u -u -r1.2 debugger_regs_lib.inp
--- debugger_regs_lib.inp	1998/07/03 02:35:58	1.2
+++ debugger_regs_lib.inp	1998/07/06 10:39:24
@@ -1,4 +1,5 @@
+echo on
 
 
-p *
-c
+print *
+continue
Index: tests/debugger/interpreter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.exp,v
retrieving revision 1.3
diff -u -u -r1.3 interpreter.exp
<omitted>
Index: tests/debugger/interpreter.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.inp,v
retrieving revision 1.2
diff -u -u -r1.2 interpreter.inp
--- interpreter.inp	1998/06/18 06:08:32	1.2
+++ interpreter.inp	1998/09/16 02:31:11
@@ -1,13 +1,14 @@
-h
-10s
-v
-p *
-30 g
-p *
-F
-p *
+register --quiet
+echo on
+10 step
+vars
+print *
+goto 30
+print *
+finish -a
+print *
 
-f
+finish -n
 
 
-c
+continue
Index: tests/debugger/interpreter_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter_lib.exp,v
retrieving revision 1.2
diff -u -u -r1.2 interpreter_lib.exp
<omitted>
Index: tests/debugger/interpreter_lib.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter_lib.inp,v
retrieving revision 1.2
diff -u -u -r1.2 interpreter_lib.inp
--- interpreter_lib.inp	1998/07/03 02:36:01	1.2
+++ interpreter_lib.inp	1998/09/16 02:31:17
@@ -1,14 +1,15 @@
-h
-45s
-v
-p *
-b interpreter_lib database_assert_clause
-c
-p *
-F
-p *
+register --quiet
+echo on
+45step
+vars
+print *
+break database_assert_clause
+continue
+print *
+finish -a
+print *
 
-f
+finish -n
 
 
-c
+continue -S
Index: tests/debugger/queens.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp,v
retrieving revision 1.2
diff -u -u -r1.2 queens.exp
<omitted>
Index: tests/debugger/queens.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.inp,v
retrieving revision 1.2
diff -u -u -r1.2 queens.inp
--- queens.inp	1998/06/18 06:08:35	1.2
+++ queens.inp	1998/09/16 02:31:25
@@ -1,87 +1,92 @@
-p *
+echo on
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
-l 1
-p *
-l 2
-v
-p *
+print *
+level 1
+print *
+up 1
+vars
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+register --quiet
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
-C
+print *
+break print_list
+step -aN 50
+continue -n
+continue -n -S
Index: tests/debugger/queens_lib.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens_lib.exp,v
retrieving revision 1.2
<omitted>
Index: tests/debugger/queens_lib.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens_lib.inp,v
retrieving revision 1.2
diff -u -u -r1.2 queens_lib.inp
--- queens_lib.inp	1998/06/18 06:08:37	1.2
+++ queens_lib.inp	1998/09/16 02:31:30
@@ -1,87 +1,91 @@
-p *
+register --quiet
+echo on
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
-l 1
-p *
-l 2
-v
-p *
+print *
+level 1
+print *
+up 1
+vars
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
+print *
 
-p *
-C
+print *
+break print_list
+continue -aN
+continue -n -S
cvs diff: Diffing tests/general
cvs diff: Diffing tests/hard_coded
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
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.63
diff -u -u -r1.63 bootcheck
--- bootcheck	1998/09/11 01:06:42	1.63
+++ bootcheck	1998/09/16 05:41:19
@@ -289,7 +289,7 @@
 	ln -s $root/doc .
 	ln -s $root/scripts .
 	ln -s $root/util .
-	if test "$copy_profiler" = "true"
+	if "$copy_profiler"
 	then
 		mkdir profiler
 		cd profiler
@@ -460,7 +460,7 @@
 	cp $root/library/Mmake* .
 	ln -s $root/library/libmercury.init .
 	cd $root/stage2
-	if test "$copy_runtime" = "true"
+	if "$copy_runtime"
 	then
 		mkdir runtime
 		cd runtime
@@ -473,7 +473,7 @@
 	else
 		ln -s $root/runtime .
 	fi
-	if test "$copy_boehm_gc" = "true"
+	if "$copy_boehm_gc"
 	then
 		mkdir boehm_gc
 		cd boehm_gc
@@ -491,7 +491,7 @@
 	ln -s $root/doc .
 	ln -s $root/scripts .
 	ln -s $root/util .
-	if test "$copy_profiler" = "true"
+	if "$copy_profiler"
 	then
 		mkdir profiler
 		cd profiler
@@ -746,6 +746,7 @@
 
 		MERCURY_LIBS="$root/library/libmercury.a
 			$root/runtime/libmer.a
+			$root/library/libmercury.a
 			$root/boehm_gc/libgc.a
 			-lm"
 		export MERCURY_LIBS
@@ -771,6 +772,7 @@
 
 		MERCURY_LIBS="$root/stage2/library/libmercury.a
 			$root/stage2/runtime/libmer.a
+			$root/stage2/library/libmercury.a
 			$root/stage2/boehm_gc/libgc.a
 			-lm"
 		export MERCURY_LIBS
@@ -791,6 +793,15 @@
 		PATH=$root/stage2/util:$root/stage2/scripts:$PATH
 		export PATH
 	fi
+
+	# We need to give tests/debugger access to the mdbrc and mdb_doc
+	# files in the doc directory, without hardcoding their pathnames.
+	# We must also compensate for doc/mdbrc having hardcoded within it
+	# the *installed* pathname of mdb_doc and not its current pathname.
+	cat $root/doc/mdb_doc > $root/doc/test_mdbrc
+	sed -e '/^source/d' $root/doc/mdbrc >> $root/doc/test_mdbrc
+	MERCURY_DEBUGGER_INIT=$root/doc/test_mdbrc
+	export $root/doc/test_mdbrc
 
 	if test -d ../tests
 	then
cvs diff: Diffing trial
cvs diff: Diffing util
Index: util/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/util/Mmakefile,v
retrieving revision 1.2
diff -u -u -r1.2 Mmakefile
--- Mmakefile	1997/11/24 14:55:43	1.2
+++ Mmakefile	1998/09/09 10:00:47
@@ -19,11 +19,11 @@
 CFLAGS	= -I$(RUNTIME_DIR) $(EXTRA_CFLAGS)
 # we need -I ../runtime for "mercury_getopt.h"
 
-PROGS=mkinit mdemangle
+PROGS=mkinit mdemangle info_to_mdb
 
 #-----------------------------------------------------------------------------#
 
-all: $(PROGS)
+all:	$(PROGS)
 
 .c:
 	$(MGNUC) --grade $(GRADE) $(CFLAGS) -o $@ $<
Index: util/info_to_mdb.c
===================================================================
RCS file: info_to_mdb.c
diff -N info_to_mdb.c
--- /dev/null	Wed May 28 10:49:58 1997
+++ info_to_mdb.c	Wed Sep  9 20:29:47 1998
@@ -0,0 +1,222 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#define	TRUE		1
+#define	FALSE		0
+#define	bool		char
+
+#define	MAXLINELEN	160
+
+static	bool	is_empty(char *line);
+static	bool	is_all_same_char(char *line, char what);
+static	bool	is_command(char *line, bool *is_concept);
+static	bool	diff_command(char *line, char *command);
+static	void	print_command_line(char *line, bool is_concept);
+
+static	char	*get_next_line(FILE *infp);
+static	void	put_line_back(char *line);
+
+#define	concept_char(c)	(isupper(c) ? tolower(c) : (isspace(c) ? '_' : (c)))
+#define	isalnumunder(c)	(isalnum(c) || (c) == '_')
+
+int
+main(int argc, char **argv)
+{
+	FILE	*infp;
+	char	*line;
+	char	command[MAXLINELEN];
+	int	slot = 0;
+	int	len;
+	int	i;
+	bool	is_concept;
+	bool	next_concept;
+
+	if (argc != 3) {
+		printf("usage: info_to_mdb section_name section_info_file\n");
+		exit(EXIT_FAILURE);
+	}
+
+	if ((infp = fopen(argv[2], "r")) == NULL) {
+		printf("cannot read %s\n", argv[2]);
+		exit(EXIT_FAILURE);
+	}
+
+	/* skip the top part of the node, up to and including */
+	/* the underlined heading */
+
+	while ((line = get_next_line(infp)) != NULL) {
+		if (is_all_same_char(line, '-') || is_all_same_char(line, '='))
+		{
+			break;
+		}
+	}
+
+	while (TRUE) {
+		line = get_next_line(infp);
+		while (line != NULL && is_empty(line)) {
+			line = get_next_line(infp);
+		}
+
+		if (line == NULL) {
+			return 0;
+		}
+
+		if (! is_command(line, &is_concept)) {
+			continue;
+		}
+
+		slot += 100;
+		printf("document %s %d ", argv[1], slot);
+		if (is_concept) {
+			for (i = 0; line[i] != '\n'; i++) {
+				command[i] = concept_char(line[i]);
+				putchar(concept_char(line[i]));
+			}
+			putchar('\n');
+			command[i] = '\0';
+		} else {
+			for (i = 1; isalnumunder(line[i]); i++) {
+				command[i-1] = line[i];
+				putchar(line[i]);
+			}
+			putchar('\n');
+			command[i-1] = '\0';
+		}
+
+		print_command_line(line, is_concept);
+
+		while ((line = get_next_line(infp)) != NULL) {
+			if (is_command(line, &next_concept)) {
+				if (diff_command(line, command)) {
+					put_line_back(line);
+					break;
+				} else {
+					print_command_line(line, next_concept);
+				}
+			} else {
+				printf("%s", line);
+			}
+		}
+
+		printf("end\n");
+	}
+}
+
+static bool
+is_empty(char *line)
+{
+	int	i = 0;
+
+	while (line[i] != '\0') {
+		if (!isspace(line[i])) {
+			return FALSE;
+		}
+
+		i++;
+	}
+
+	return TRUE;
+}
+
+static bool
+is_all_same_char(char *line, char what)
+{
+	int	i = 0;
+
+	while (line[i] != '\0') {
+		if (line[i] != what && line[i] != '\n') {
+			return FALSE;
+		}
+
+		i++;
+	}
+
+	return i > 1;
+}
+
+static bool
+is_command(char *line, bool *is_concept)
+{
+	int	len;
+
+	len = strlen(line);
+	if ((line[0] == '`') && (line[len-2] == '\'')) {
+		*is_concept = FALSE;
+		return TRUE;
+	} else if (isupper(line[0]) && isupper(line[1])) {
+		*is_concept = TRUE;
+		return TRUE;
+	} else {
+		return FALSE;
+	}
+}
+
+static bool
+diff_command(char *line, char *command)
+{
+	int	i;
+
+	for (i = 0; command[i] != '\0' && line[i + 1] == command[i]; i++)
+		;
+
+	if (command[i] == '\0' && ! isalnumunder(line[i+1])) {
+		return FALSE;
+	} else {
+		return TRUE;
+	}
+}
+
+static void
+print_command_line(char *line, bool is_concept)
+{
+	int	len;
+	int	i;
+
+	if (is_concept) {
+		for (i = 0; line[i] != '\n'; i++) {
+			putchar(concept_char(line[i]));
+		}
+		putchar('\n');
+	} else {
+		len = strlen(line);
+		for (i = 1; i < len - 2; i++) {
+			putchar(line[i]);
+		}
+		putchar('\n');
+	}
+}
+
+static	char	*putback_line = NULL;
+static	char	line_buf[MAXLINELEN];
+
+static char *
+get_next_line(FILE *infp)
+{
+	char	*tmp;
+
+	if (putback_line != NULL) {
+		tmp = putback_line;
+		putback_line = NULL;
+		return tmp;
+	} else {
+		if (fgets(line_buf, MAXLINELEN, infp) == NULL) {
+			return NULL;
+		} else {
+			/* printf("read %s", line_buf); */
+			return line_buf;
+		}
+	}
+}
+
+static void
+put_line_back(char *line)
+{
+	if (putback_line != NULL) {
+		printf("trying to put back more than one line\n");
+		exit(EXIT_FAILURE);
+	}
+
+	putback_line = line;
+}
Index: util/mkinit.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mkinit.c,v
retrieving revision 1.40
diff -u -u -r1.40 mkinit.c
--- mkinit.c	1998/08/11 06:23:29	1.40
+++ mkinit.c	1998/09/10 09:33:26
@@ -80,7 +80,7 @@
 static const char mercury_funcs[] =
 	"\n"
 	"Declare_entry(%s);\n"
-	"Declare_entry(mercury__io__print_3_0);\n"
+	"Declare_entry(mercury__io__print_4_0);\n"
 	"\n"
 	"#ifdef CONSERVATIVE_GC\n"
 	"extern char *GC_stackbottom;\n"
@@ -134,7 +134,7 @@
 	"#endif\n"
 	"	MR_library_initializer = ML_io_init_state;\n"
 	"	MR_library_finalizer = ML_io_finalize_state;\n"
-	"	MR_library_trace_browser = ENTRY(mercury__io__print_3_0);\n"
+	"	MR_library_trace_browser = ENTRY(mercury__io__print_4_0);\n"
 	"#ifdef MR_USE_EXTERNAL_DEBUGGER\n"
 	"	MR_type_name = ML_type_name;\n"
 	"	MR_DI_output_current_vars = ML_DI_output_current_vars;\n"



More information about the developers mailing list