From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Received: (qmail 21434 invoked from network); 10 Jan 2003 17:11:50 -0000 Received: from unknown (HELO hub.ott.qnx.com) (209.226.137.76) by 209.249.29.67 with SMTP; 10 Jan 2003 17:11:50 -0000 Received: from smtp.ott.qnx.com (smtp.ott.qnx.com [10.0.2.158]) by hub.ott.qnx.com (8.9.3/8.9.3) with ESMTP id MAA06634 for ; Fri, 10 Jan 2003 12:03:28 -0500 Received: from catdog ([10.4.2.2]) by smtp.ott.qnx.com (8.8.8/8.6.12) with SMTP id MAA23688 for ; Fri, 10 Jan 2003 12:04:24 -0500 Message-ID: <0b9e01c2b8cb$4a81fd20$0202040a@catdog> From: "Kris Warkentin" To: Subject: patch to use target specific .gdbinit file Date: Fri, 10 Jan 2003 17:11:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-SW-Source: 2003-01/txt/msg00169.txt.bz2 The following code will allow backend writers to define EXTRA_GDBINIT_FILENAME to be an alternate filename for sourcing on startup. For example, since we have gdb versions for 5 different CPU targets, we allow users to create a $HOME/.ntoCPU-gdbinit. This is especially handy if you're dealing with several remote targets that you want to be connected to every time. A simple "source .gdbinit" at the end of .ntoCPU-gdbinit gives a very nice way to have specific initializations followed by generic ones. cheers, Kris Index: top.h =================================================================== RCS file: /cvs/src/src/gdb/top.h,v retrieving revision 1.7 diff -u -r1.7 top.h --- top.h 19 Mar 2002 19:00:04 -0000 1.7 +++ top.h 10 Jan 2003 17:06:43 -0000 @@ -30,6 +30,7 @@ extern int inhibit_gdbinit; extern int epoch_interface; extern char gdbinit[]; +extern char *extragdbinit; extern void print_gdb_version (struct ui_file *); Index: top.c =================================================================== RCS file: /cvs/src/src/gdb/top.c,v retrieving revision 1.69 diff -u -r1.69 top.c --- top.c 9 Dec 2002 00:59:26 -0000 1.69 +++ top.c 10 Jan 2003 17:06:43 -0000 @@ -77,6 +77,12 @@ #endif char gdbinit[] = GDBINIT_FILENAME; +#ifndef EXTRA_GDBINIT_FILENAME +#define EXTRA_GDBINIT_FILENAME 0 +#endif + +char *extragdbinit = EXTRA_GDBINIT_FILENAME; + int inhibit_gdbinit = 0; /* If nonzero, and GDB has been configured to be able to use windows, Index: main.c =================================================================== RCS file: /cvs/src/src/gdb/main.c,v retrieving revision 1.20 diff -u -r1.20 main.c --- main.c 26 Sep 2002 17:46:04 -0000 1.20 +++ main.c 10 Jan 2003 17:06:44 -0000 @@ -530,11 +530,30 @@ homedir = getenv ("HOME"); if (homedir) { - homeinit = (char *) alloca (strlen (homedir) + - strlen (gdbinit) + 10); - strcpy (homeinit, homedir); - strcat (homeinit, "/"); - strcat (homeinit, gdbinit); + /* Allow for a target specific gdbinit that will only override + the default gdbinit if it exists. GP QNX Sep 6 2002 */ + homeinit = 0; + if (extragdbinit) + { + homeinit = (char *) alloca (strlen (homedir) + + strlen (extragdbinit) + 10); + + strcpy (homeinit, homedir); + strcat (homeinit, "/"); + strcat (homeinit, extragdbinit); + + if (stat (homeinit, &homebuf) < 0) + homeinit = 0; + } + + if (!homeinit) + { + homeinit = (char *) alloca (strlen (homedir) + + strlen (gdbinit) + 10); + strcpy (homeinit, homedir); + strcat (homeinit, "/"); + strcat (homeinit, gdbinit); + } if (!inhibit_gdbinit) {