From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Cc: Jerome Guitton <guitton@adacore.com>, Eli Zaretskii <eliz@gnu.org>
Subject: Add support for --with-system-gdbinit
Date: Wed, 14 Jan 2009 13:56:00 -0000 [thread overview]
Message-ID: <20090114135619.GA24456@caradoc.them.org> (raw)
As described on gdb@ last month, this patch adds support for a
system-wide gdbinit file. The path will be automatically relocated if
the GDB binary is moved, so it can be used for a system-wide directory
like /etc or a prefixed directory like /opt/vendor/share.
Eli, is the doc patch OK?
--
Daniel Jacobowitz
CodeSourcery
2008-12-15 Daniel Jacobowitz <dan@codesourcery.com>
* configure, config.in: Regenerated.
* configure.ac: Add --with-system-gdbinit.
* main.c (system_gdbinit): New.
(captured_main): Relocate system_gdbinit. Load it before
$HOME/.gdbinit.
2008-12-15 Daniel Jacobowitz <dan@codesourcery.com>
* gdb.texinfo (Startup): Document --with-system-gdbinit.
Index: config.in
===================================================================
RCS file: /cvs/src/src/gdb/config.in,v
retrieving revision 1.103
diff -u -p -r1.103 config.in
--- config.in 6 Aug 2008 19:41:31 -0000 1.103
+++ config.in 15 Dec 2008 15:40:34 -0000
@@ -646,6 +646,13 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
+/* System-wide gdbinit file. */
+#undef SYSTEM_GDBINIT
+
+/* Define if the system-wide gdbinit file should be relocated when GDB is
+ moved. */
+#undef SYSTEM_GDBINIT_RELOCATABLE
+
/* Define if <thread_db.h> has the TD_NOTALLOC error code. */
#undef THREAD_DB_HAS_TD_NOTALLOC
Index: configure
===================================================================
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.262
diff -u -p -r1.262 configure
--- configure 21 Nov 2008 22:35:57 -0000 1.262
+++ configure 15 Dec 2008 15:40:36 -0000
@@ -895,6 +895,7 @@ Optional Packages:
on systems with version 2 of the GNU C library
(use with caution on other system)
--with-sysroot=DIR Search for usr/lib et al within DIR.
+ --with-system-gdbinit=file Automatically load a system-wide gdbinit file
--with-tcl directory containing tcl configuration (tclConfig.sh)
--with-tk directory containing tk configuration (tkConfig.sh)
--with-x use the X Window System
@@ -19417,6 +19418,49 @@ fi;
+system_gdbinit=
+
+# Check whether --with-system-gdbinit or --without-system-gdbinit was given.
+if test "${with_system_gdbinit+set}" = set; then
+ withval="$with_system_gdbinit"
+ system_gdbinit=${withval}
+fi;
+
+
+ test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+ test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+ ac_define_dir=`eval echo $system_gdbinit`
+ ac_define_dir=`eval echo $ac_define_dir`
+
+cat >>confdefs.h <<_ACEOF
+#define SYSTEM_GDBINIT "$ac_define_dir"
+_ACEOF
+
+
+
+if test "x$prefix" = xNONE; then
+ test_prefix=$ac_default_prefix
+else
+ test_prefix=$prefix
+fi
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+ test_exec_prefix=$test_prefix
+else
+ test_exec_prefix=$exec_prefix
+fi
+case ${system_gdbinit} in
+ "${test_prefix}"|"${test_prefix}/"*|\
+ "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
+ '${prefix}'|'${prefix}/'*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+
+cat >>confdefs.h <<\_ACEOF
+#define SYSTEM_GDBINIT_RELOCATABLE 1
+_ACEOF
+
+ ;;
+esac
+
# Check whether --enable-werror or --disable-werror was given.
if test "${enable_werror+set}" = set; then
enableval="$enable_werror"
Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.82
diff -u -p -r1.82 configure.ac
--- configure.ac 21 Nov 2008 22:35:58 -0000 1.82
+++ configure.ac 15 Dec 2008 15:40:36 -0000
@@ -1488,6 +1488,34 @@ AC_ARG_WITH(sysroot,
AC_SUBST(TARGET_SYSTEM_ROOT)
AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
+system_gdbinit=
+AC_ARG_WITH(system-gdbinit,
+[ --with-system-gdbinit=file Automatically load a system-wide gdbinit file],
+[system_gdbinit=${withval}])
+
+AC_DEFINE_DIR(SYSTEM_GDBINIT, system_gdbinit,
+ [System-wide gdbinit file.])
+
+if test "x$prefix" = xNONE; then
+ test_prefix=$ac_default_prefix
+else
+ test_prefix=$prefix
+fi
+if test "x$exec_prefix" = xNONE || test "x$exec_prefix" = 'x${prefix}'; then
+ test_exec_prefix=$test_prefix
+else
+ test_exec_prefix=$exec_prefix
+fi
+case ${system_gdbinit} in
+ "${test_prefix}"|"${test_prefix}/"*|\
+ "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
+ '${prefix}'|'${prefix}/'*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+ AC_DEFINE(SYSTEM_GDBINIT_RELOCATABLE, 1,
+ [Define if the system-wide gdbinit file should be relocated when GDB is moved.])
+ ;;
+esac
+
AC_ARG_ENABLE(werror,
[ --enable-werror treat compile warnings as errors],
[case "${enableval}" in
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.70
diff -u -p -r1.70 main.c
--- main.c 29 Jul 2008 14:16:15 -0000 1.70
+++ main.c 15 Dec 2008 15:40:36 -0000
@@ -83,6 +83,9 @@ int return_child_result_value = -1;
/* Whether to enable writing into executable and core files */
extern int write_files;
+/* The system-wide gdbinit file. */
+static char *system_gdbinit = SYSTEM_GDBINIT;
+
static void print_gdb_help (struct ui_file *);
/* These two are used to set the external editor commands when gdb is farming
@@ -268,6 +271,24 @@ captured_main (void *data)
}
}
+#ifdef SYSTEM_GDBINIT_RELOCATABLE
+ system_gdbinit = make_relative_prefix (argv[0], BINDIR, SYSTEM_GDBINIT);
+ if (system_gdbinit)
+ {
+ struct stat s;
+ int res = 0;
+
+ if (stat (system_gdbinit, &s) == 0)
+ res = 1;
+
+ if (res == 0)
+ {
+ xfree (system_gdbinit);
+ system_gdbinit = SYSTEM_GDBINIT;
+ }
+ }
+#endif
+
/* There will always be an interpreter. Either the one passed into
this captured main, or one specified by the user at start up, or
the console. Initialize the interpreter to the one requested by
@@ -679,6 +700,13 @@ Excess command line arguments ignored. (
quit_pre_print = error_pre_print;
warning_pre_print = _("\nwarning: ");
+ /* Read and execute the system-wide gdbinit file, if it exists.
+ This is done *before* all the command line arguments are
+ processed; it sets global parameters, which are independent of
+ what file you are debugging or what directory you are in. */
+ if (system_gdbinit[0] && !inhibit_gdbinit)
+ catch_command_errors (source_script, system_gdbinit, 0, RETURN_MASK_ALL);
+
/* Read and execute $HOME/.gdbinit file, if it exists. This is done
*before* all the command line arguments are processed; it sets
global parameters, which are independent of what file you are
Index: doc/gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.537
diff -u -p -r1.537 gdb.texinfo
--- doc/gdb.texinfo 27 Nov 2008 09:23:01 -0000 1.537
+++ doc/gdb.texinfo 15 Dec 2008 15:40:42 -0000
@@ -1219,6 +1219,10 @@ Sets up the command interpreter as speci
@item
@cindex init file
+Reads the system-wide @dfn{init file} (if @option{--with-system-gdbinit} was
+used when building @value{GDBN}) and executes all the commands in that file.
+
+@item
Reads the @dfn{init file} (if any) in your home directory@footnote{On
DOS/Windows systems, the home directory is the one pointed to by the
@code{HOME} environment variable.} and executes all the commands in
next reply other threads:[~2009-01-14 13:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-14 13:56 Daniel Jacobowitz [this message]
2009-01-14 19:39 ` Eli Zaretskii
2009-01-14 19:50 ` Daniel Jacobowitz
2009-01-14 20:22 ` Eli Zaretskii
2009-01-14 20:38 ` Daniel Jacobowitz
2009-01-14 21:55 ` Eli Zaretskii
2009-01-14 23:07 ` Daniel Jacobowitz
2009-01-15 4:10 ` Eli Zaretskii
2009-01-19 14:11 ` Jerome Guitton
2009-01-19 14:20 ` Daniel Jacobowitz
2009-01-19 18:40 ` Eli Zaretskii
2009-01-21 10:54 ` Jerome Guitton
2009-01-21 19:03 ` Eli Zaretskii
2009-01-23 17:24 ` Jerome Guitton
2009-01-23 22:55 ` Eli Zaretskii
2009-01-28 18:00 ` Jerome Guitton
2009-01-23 17:42 ` Daniel Jacobowitz
2009-01-26 9:12 ` Jerome Guitton
2009-01-26 14:59 ` Daniel Jacobowitz
2009-01-28 15:06 ` Jerome Guitton
2009-01-16 11:54 ` Jerome Guitton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090114135619.GA24456@caradoc.them.org \
--to=drow@false.org \
--cc=eliz@gnu.org \
--cc=gdb-patches@sourceware.org \
--cc=guitton@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox