Files
mercury/scripts/mgnuc.in
Fergus Henderson 6921e0e015 Add a `--debug' option for Mercury-level debugging
Estimated hours taken: 6

Add a `--debug' option for Mercury-level debugging
using the trace-based debugger.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/ml.in:
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
	Split the old `--debug' option into `--low-level-debug'
	(formerly the absence of -DSPEED, now handle by -DLOWLEVEL_DEBUG)
	and `--c-debug' (passes -g to C compiler).
	Delete the old `debug' grade.
	Add support for new options `--require-tracing'
	(makes --trace minimum equivalent to --trace interfaces,
	and passes -DMR_REQUIRE_TRACING to C compiler)
	`--stack-trace' (passes -DMR_STACK_TRACE to C compiler;
	actually this one was already supported)
	and `--debug' (implies previous two),
	with corresponding grade modifiers `.trace', `.strce', and `.debug'.
	Actually I think there's little point in specifying just one
	of `--require-tracing' and `--stack-trace' so for the moment
	I'm just providing `--debug': the code for the more fine-grained
	options and grade modifiers has been added but commented out.

runtime/mercury_conf_param.h:
	Document the new configuration parameter MR_REQUIRE_TRACING
	and the existing but undocumented parameter MR_STACK_TRACE.

runtime/mercury_grade.h:
	Include MR_REQUIRE_TRACING in the mangled grade identifier.

compiler/globals.m:
compiler/handle_options.m:
compiler/options.m:
	Allow new tracing type `--trace default', and make it the default.
	This gets replaced with `full' if require_tracing is yes
	or `minimal' if require_tracing is no.
	Also `--trace minimum' gets replaced with `interface' if
	require_tracing is yes.

doc/user_guide.texi:
	Document the new `--debug', `--low-level-debug', and `--c-debug'
	options.

scripts/mgnuc.in:
compiler/mercury_compile.m:
doc/user_guide.texi:
	Change things so that `--c-debug' does not imply `--no-c-optimize'.

configure.in:
	Add `-fomit-frame-pointer' to CFLAGS_FOR_GOTOS on alpha-*.
	Empirically, this seems to be needed, otherwise lots of
	the test cases fail when compiled with `--no-c-optimize'.
	(It might also be needed for other architectures, I don't know.)
1998-05-20 11:11:57 +00:00

401 lines
9.1 KiB
Bash

#! /bin/sh
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 1995-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: mgnuc - Mercury front-end to GNU C
Usage: mgnuc [<options>] [-- <gcc options>] files...
Options:
-v, --verbose
Echo gcc command before executing it.
--no-ansi
Don't pass \`-ansi' to gcc.
--no-check
Don't enable any of gcc's warnings.
-s <grade>, --grade <grade>
--asm-labels
--gcc-non-local-gotos
--gcc-global-registers
--gc {conservative, accurate, none}
-p, --profiling
--profile-calls
--profile-time
--profile-memory
--debug
--low-level-debug
-g, --c-debug
--no-c-optimize
--use-trail
--args {simple, compact}
--pic-reg
--inline-alloc
--split-c-files
See the documentation in the \"Invocation\" section
of the Mercury User's Guide.
Description:
This runs gcc with the appropriate options for compiling Mercury
programs.
Normally it invokes gcc in ANSI mode with almost all warnings enabled,
but this can be changed using the \`--no-ansi' or \`--no-check'
options.
Environment variables:
MERCURY_C_INCL_DIR, MERCURY_ALL_C_INCL_DIRS, MERCURY_DEFAULT_GRADE.
"
# *************************************************************************
# *** IMPORTANT NOTE: any changes to this file may also require similar ***
# *** changes to compiler/mercury_compile.m ***
# *************************************************************************
FULLARCH=@FULLARCH@
NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
C_INCL_DIR=${MERCURY_C_INCL_DIR=@LIBDIR@/inc}
ALL_C_INCL_DIRS=${MERCURY_ALL_C_INCL_DIRS=-I$C_INCL_DIR}
DEFAULT_GRADE=${MERCURY_DEFAULT_GRADE=@DEFAULT_GRADE@}
CC=${MERCURY_C_COMPILER="@CC@"}
CFLAGS_FOR_REGS="@CFLAGS_FOR_REGS@"
CFLAGS_FOR_GOTOS="@CFLAGS_FOR_GOTOS@"
AS=as
case "$CC" in
*gcc*)
ANSI_OPTS="-ansi"
CHECK_OPTS="
-Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wtraditional
-Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wno-unused"
# Note: we do not enable the following gcc warnings:
# -Wredundant-decls causes too many complaints in system header files
# -Wconversion really only intended to help people using \`unprotoize'
# -Waggregate-return not useful, IMHO
# -Wcast-align causes redundant warnings in memory.c
# -pedantic causes unsuppressable warnings about LVALUE_CAST()
# -Wnested-externs causes unsuppressable warnings about callentry()
# -Wid-clash-31 causes warnings about entry_mercury__xxx ...
# -Wenum-clash is for C++ only
# -Wunused causes various spurious warnings
OPT_OPTS="-O2 -fomit-frame-pointer"
COMPILER=gcc
;;
*lcc*)
ANSI_OPTS=
CHECK_OPTS=
OPT_OPTS=""
COMPILER=lcc
;;
*)
ANSI_OPTS=
CHECK_OPTS=
OPT_OPTS="-O"
COMPILER=unknown
;;
esac
AS_OPTS=""
SPLIT_OPTS=""
INLINE_ALLOC_OPTS=""
verbose=false
assemble=false
c_debug=false
c_optimize=true
# include the file `init_grade_options.sh-subr'
@INIT_GRADE_OPTIONS@
while : ; do
case "$1" in
-h|--help|"-?")
echo "$Help"
exit 0
;;
-v|--verbose)
verbose=true
;;
-v-|--no-verbose)
verbose=false
;;
--assemble)
assemble=true
;;
--no-ansi)
ANSI_OPTS=
;;
--no-check)
CHECK_OPTS=
;;
--split-c-files)
SPLIT_OPTS=-DSPLIT_C_FILES
;;
--no-split-c-files)
SPLIT_OPTS=
;;
--inline-alloc)
INLINE_ALLOC_OPTS="-DINLINE_ALLOC -DSILENT"
;;
--no-inline-alloc)
INLINE_ALLOC_OPTS=""
;;
-g|--c-debug)
c_debug=true
;;
-g-|--no-c-debug)
c_debug=false
;;
--c-optimize)
c_optimize=true
;;
--no-c-optimize)
c_optimize=false
;;
--low-level-debug)
low_level_debug=true ;;
--no-low-level-debug)
low_level_debug=false ;;
# include the file `parse_grade_options.sh-subr'
@PARSE_GRADE_OPTIONS@
--)
shift
break
;;
*)
break
;;
esac
shift
done
#
# convert mgnuc options into gcc options
#
# IMPORTANT: any changes here will require similar changes to
# compiler/mercury_compile.m.
#
case $asm_labels in
true) ASM_OPTS="-DUSE_ASM_LABELS" ;;
false) ASM_OPTS="" ;;
esac
case $non_local_gotos in
true) GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS" ;;
false) GOTO_OPTS="" ;;
esac
case $global_regs in
true) REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS" ;;
false) REG_OPTS="" ;;
esac
case $stack_trace in
true) STACK_TRACE_OPTS="-DMR_STACK_TRACE" ;;
false) STACK_TRACE_OPTS="" ;;
esac
case $require_tracing in
true) TRACE_OPTS="-DMR_REQUIRE_TRACING" ;;
false) TRACE_OPTS="" ;;
esac
case $c_debug in
true) C_DEBUG_OPTS="-g" ;;
false) C_DEBUG_OPTS="" ;;
esac
case $c_optimize in
true) ;;
false) OPT_OPTS="" ;;
esac
case $low_level_debug in
true) LLDEBUG_OPTS="-DMR_LOWLEVEL_DEBUG" ;;
false) LLDEBUG_OPTS="" ;;
esac
case $gc_method in
accurate) GC_OPTS="-DNATIVE_GC" ;;
conservative) GC_OPTS="-DCONSERVATIVE_GC" ;;
none) GC_OPTS="" ;;
esac
case $profile_time in
true) PROF_TIME_OPTS="-DPROFILE_TIME" ;;
false) PROF_TIME_OPTS="-DNO_SIGNALS" ;;
esac
case $profile_calls in
true) PROF_CALLS_OPTS="-DPROFILE_CALLS" ;;
false) PROF_CALLS_OPTS="" ;;
esac
case $profile_memory in
true) PROF_MEMORY_OPTS="-DPROFILE_MEMORY" ;;
false) PROF_MEMORY_OPTS="" ;;
esac
case $use_trail in
true) TRAIL_OPTS="-DMR_USE_TRAIL" ;;
false) TRAIL_OPTS="" ;;
esac
case $args_method in
simple) ARG_OPTS="" ;;
compact) ARG_OPTS="-DCOMPACT_ARGS" ;;
esac
case $pic_reg in
true) PICREG_OPTS="-DPIC_REG" ;;
false) PICREG_OPTS="" ;;
esac
GRADE_OPTS="$ASM_OPTS $GOTO_OPTS $REG_OPTS"
# check that special grades are only used with gcc
case $COMPILER in
gcc) ;;
*) case "$GRADE_OPTS" in
*USE_GCC*)
echo "$0: For compilers other than GNU C, the only" 1>&2
echo "$0: base grade allowed is \`none'" 1>&2
;;
esac
esac
# if we're using global registers, add CFLAGS_FOR_REGS
case $global_regs in
true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS" ;;
false) ;;
esac
# if we're using non-local gotos, add CFLAGS_FOR_GOTOS
case $non_local_gotos in
true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_GOTOS" ;;
false) ;;
esac
#
# Special case hacks for particular architectures
# Any code here needs to be duplicated in ../configure.in.
#
ARCH_OPTS=""
case "$FULLARCH" in
mips-sgi-irix5.*)
# nonlocal gotos don't work with PIC, which is the
# default for Irix 5, so if nonlocal gotos are enabled
# we need to disable the use of shared libraries.
case $non_local_gotos in
true)
LIBRARY_PATH="$NONSHARED_LIB_DIR:/usr/lib/nonshared:$LIBRARY_PATH"
export LIBRARY_PATH
AS_OPTS="-non_shared"
;;
esac
;;
i?86-*)
# the use of stack_pointer in the ASM_JUMP macro
# defined in runtime/goto.h causes lots of warnings
# about using possibly uninitialized variables;
# there's no easy way to supress them except by
# disabling the warning.
CHECK_OPTS="$CHECK_OPTS -Wno-uninitialized"
;;
esac
#
# Kludge for gcc-2.6.3 bug on mips: if you use gcc global registers and -O2,
# gcc 2.6.3 gets an internal error compiling library/int.c and
# compiler/bytecode.c. As a work-around, we compile those file with -O1.
# Similarly library/bag.c needs to be compiled with -O0.
# Similarly for gcc-2.6.3 on alpha with compiler/modules.c.
#
case $COMPILER in gcc)
case "$FULLARCH" in
mips*)
case "$*" in
*" int.c "*|*" int.dir/int_"*".c "*)
case "`$CC --version 2>/dev/null`" in 2.6.*)
ARCH_OPTS="$ARCH_OPTS -O1" ;;
esac;;
*" bytecode.c "*|*" bytecode.dir/bytecode_"*".c "*)
case "`$CC --version 2>/dev/null`" in 2.6.*)
ARCH_OPTS="$ARCH_OPTS -O1" ;;
esac;;
*" bag.c "*)
case "`$CC --version 2>/dev/null`" in 2.6.*)
ARCH_OPTS="$ARCH_OPTS -O0" ;;
esac;;
esac ;;
alpha*)
case "$*" in
*" modules.c "*|*" modules.dir/modules_"*".c "*)
case "`$CC --version 2>/dev/null`" in 2.6.*)
ARCH_OPTS="$ARCH_OPTS -O1" ;;
esac
esac ;;
i?86*)
case "$*" in
*" call_gen.c "*|*" modules.dir/call_gen"*".c "*)
ARCH_OPTS="$ARCH_OPTS -O0" ;;
esac ;;
esac ;;
esac
#
# On sparc-sun-solaris2, we need to use -fPIC rather than -fpic if we're
# using grade `none', because otherwise the Mercury standard library
# overflows the fixed limit on the number of "small pic" references.
#
case "$FULLARCH" in sparc-sun-solaris2*)
case "$grade" in none)
case "$*" in *-fpic*)
echo "mgnuc: using -fPIC rather than -fpic"
OVERRIDE_OPTS="$OVERRIDE_OPTS -fPIC" ;;
esac ;;
esac ;;
esac
case $assemble in true)
case $verbose in true)
echo $AS $AS_OPTS "$@" ;;
esac
exec $AS $AS_OPTS "$@" ;;
esac
ALL_CC_OPTS="$ALL_C_INCL_DIRS $ANSI_OPTS $CHECK_OPTS $OPT_OPTS \
$GRADE_OPTS $GC_OPTS \
$TRACE_OPTS $STACK_TRACE_OPTS $LLDEBUG_OPTS $C_DEBUG_OPTS \
$PROF_TIME_OPTS $PROF_CALLS_OPTS $PROF_MEMORY_OPTS \
$INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
$PICREG_OPTS $ARCH_OPTS $ARG_OPTS"
case $verbose in true)
echo $CC $ALL_CC_OPTS "$@" $OVERRIDE_OPTS ;;
esac
case $# in
0) exec $CC $ALL_CC_OPTS $OVERRIDE_OPTS ;;
*) exec $CC $ALL_CC_OPTS "$@" $OVERRIDE_OPTS ;;
esac