mirror of
https://github.com/RTimothyEdwards/magic.git
synced 2026-09-07 03:21:20 +02:00
The gdb and valgrind launchers previously passed every argument straight to magic, leaving no way to give the tool its own options. Add a "--" split (shared magic_split_args helper): arguments before "--" go to gdb/valgrind, arguments after go to magic; with no "--", all arguments go to magic (the common case). Examples: ./run_magic_gdb.sh -tui -ex run -- -dnull foo.mag ./run_magic_valgrind.sh --tool=callgrind -- foo.mag Also make the tool binary and its default options overridable from the environment: GDB/GDB_OPTS and VALGRIND/VALGRIND_OPTS (valgrind defaults to --leak-check=full --error-exitcode=0), and warn if the tool is not on PATH. Smoke-tested against a live X display: gdb runs magic to a clean exit and valgrind produces a Memcheck report; option routing verified (a bogus flag after "--" is rejected by magic, not gdb), both headless (-dnull) and GUI. Co-Authored-By: Claude Opus 4.8 <[email protected]>
48 lines
2.1 KiB
Bash
48 lines
2.1 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# run_magic_gdb.sh -- run magic (GUI) under gdb, straight from the build tree.
|
|
# Generated by configure from scripts/run_magic_gdb.sh.in.
|
|
#
|
|
# PURPOSE
|
|
# Debug the just-built magic without `make install`. Stages ${builddir}/CAD_DIR
|
|
# (symlinks) on first run, exports CAD_ROOT, then starts gdb on the self-contained
|
|
# "magicexec". Symbols come straight from the build tree.
|
|
#
|
|
# USAGE
|
|
# ./run_magic_gdb.sh [gdb-opts...] [-- [magic-args...]]
|
|
#
|
|
# A "--" separates gdb's own options from magic's:
|
|
# ./run_magic_gdb.sh # plain interactive gdb
|
|
# ./run_magic_gdb.sh foo.mag # no "--" => all args go to magic
|
|
# ./run_magic_gdb.sh -tui -- foo.mag # gdb gets -tui, magic gets foo.mag
|
|
# ./run_magic_gdb.sh -ex run -- -dnull # gdb runs immediately; magic -dnull
|
|
# With no "--", every argument is passed to magic (the common case).
|
|
#
|
|
# For batch/no-GUI debugging point it at the null device: ... -- -dnull
|
|
#
|
|
# ENVIRONMENT OVERRIDES (all optional; each wins over the baked default)
|
|
# GDB debugger binary to use (default: gdb on PATH)
|
|
# GDB_OPTS default gdb options, prepended before any given on the command line
|
|
# CAD_ROOT reuse an alternate runtime tree instead of staging $builddir/CAD_DIR
|
|
# MAGIC_WISH wish for the Tk console (default: the configure-matched wish)
|
|
# WISH TCLSH wish/tclsh matching this build's Tcl/Tk (--with-tk / --with-tcl)
|
|
# MAGIC_BUILDDIR MAGIC_SRCDIR build/source tops (default: baked-in absolutes)
|
|
# Inherited values are sanity-checked; problems print as stderr warnings.
|
|
# See magic_run_common.sh for the authoritative list and defaults.
|
|
set -eu
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
. "$here/magic_run_common.sh"
|
|
|
|
GDB="${GDB:-gdb}"
|
|
command -v "$GDB" >/dev/null 2>&1 || magic_warn "debugger '$GDB' not found on PATH"
|
|
|
|
magic_require_built
|
|
magic_stage
|
|
magic_split_args "$@"
|
|
|
|
# gdb <opts> --args magicexec -- <magic-args>
|
|
exec "$GDB" ${GDB_OPTS-} \
|
|
${MAGIC_TOOL_OPTS[@]+"${MAGIC_TOOL_OPTS[@]}"} \
|
|
--args "$MAGIC_TCL/magicexec" -- \
|
|
${MAGIC_ARGS[@]+"${MAGIC_ARGS[@]}"}
|