This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

patch to use target specific .gdbinit file


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)
  {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]