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]

Re: how to access show/set data


Not quite that simple.  If I have to provide a .gdbinit file for EVERY user
in order for gdb to properly find our libs, how do I write an installer that
does the right thing?  Some users might use Cygwin, some might not.  $HOME
might be set, it might not.  If I'm installing to Solaris or Linux, which
user accounts do I install a .gdbinit in?  It's non-trivial, especially when
you ship tools where various cpu targets have their libs in
$QNX_TARGET/$CPU/lib, and so on.  We ship gdb targetting 5 different CPU's
(arm, mips, powerpc, sh, i386) on 4 different hosts (QNX, Solaris, Linux and
Windows) so having a routine that programmatically sets up some defaults for
where host and target files are is the only sensible way to go.

Either way, I found a nice clean way to do it so I'm happy.  By the way, one
my coworkers wrote a very small enhancement to the .gdbinit code that I
would like to submit.  Basically it allows a backend writer to define
EXTRA_GDBINIT_FILENAME to a string which will be pre-pended to .gdbinit for
initial sourcing.  ie. We define it to be .ntoCPU-gdbinit and then if, for
instance, our x86 targetting gdb finds $HOME/.ntox86-gdbinit, it reads it
instead.  This is really handy for us because most of our development is
targetting remote machines so this way you can automatically connect to the
cpu target when you start gdb.  All you need then is 'source .gdbinit' at
the end of your cpu specific one and you can have specific and generic
sections for your init code.

Sorry about the patch (I just diffed it from CVS so you could take a look).
If you're interested in accepting this, I'll patch your CVS head branch and
submit a diff against that.

cheers,

Kris

Index: main.c
===================================================================
RCS file: /product/tools/gdb/gdb/main.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** main.c 6 Sep 2002 20:20:43 -0000 1.2
--- main.c 6 Sep 2002 21:23:46 -0000 1.3
***************
*** 524,534 ****
    homedir = getenv ("HOME");
    if (homedir)
      {
!       homeinit = (char *) alloca (strlen (homedir) +
!       strlen (gdbinit) + 10);
!       strcpy (homeinit, homedir);
!       strcat (homeinit, "/");
!       strcat (homeinit, gdbinit);

        if (!inhibit_gdbinit)
   {
--- 524,553 ----
    homedir = getenv ("HOME");
    if (homedir)
      {
!       /* 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: top.h
===================================================================
RCS file: /product/tools/gdb/gdb/top.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** top.h 6 Sep 2002 20:20:47 -0000 1.2
--- top.h 6 Sep 2002 21:23:46 -0000 1.3
***************
*** 30,35 ****
--- 30,36 ----
  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: /product/tools/gdb/gdb/top.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -c -r1.2 -r1.3
*** top.c 6 Sep 2002 20:20:47 -0000 1.2
--- top.c 6 Sep 2002 21:23:46 -0000 1.3
***************
*** 76,81 ****
--- 76,87 ----
  #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,

----- Original Message -----
From: "Christopher Faylor" <cgf@redhat.com>
To: <gdb@sources.redhat.com>
Sent: Thursday, January 09, 2003 1:21 PM
Subject: Re: how to access show/set data


> On Thu, Jan 09, 2003 at 08:32:15AM -0500, Kris Warkentin wrote:
> >Besides, where do you put your gdbinit on a windows host?  ;-)
>
> In your home directory, same as UNIX.
>
> cgf
>


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