This is the mail archive of the gdb-patches@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: [PATCH/RFC] interpreters part 2: start up


I like it... for one thing, these changes will let me revisit the
output-capturing patches much more cleanly.

On Mon, Dec 09, 2002 at 10:39:01AM -0500, Elena Zannoni wrote:
> 
> Any comments?
> 
> 
> 
> Elena Zannoni writes:
>  > 
>  > These are the changes that make gdb start the interpreter given on the
>  > command line, or the console by default.
>  > 
>  > [btw, in case it wasn't clear, I am not committing any of this yet]
>  > 
>  > Elena
>  > 
>  > 2002-11-05  Elena Zannoni  <ezannoni@redhat.com>
>  > 
>  > 	Written by Jim Ingham <jingham@apple.com> with changes by Keith
>  > 	Seitz <keiths@redhat.com> and Elena Zannoni <ezannoni@redhat.com>:
>  > 	* top.c (gdb_init): Start the interpreter given on the command
>  > 	line or the default one.
>  > 	* main.c (captured_main): Allocate memory for interpreter_p.
>  > 
>  > 
>  > Index: top.c
>  > ===================================================================
>  > RCS file: /cvs/src/src/gdb/top.c,v
>  > retrieving revision 1.68
>  > retrieving revision 1.62.6.7
>  > diff -u -p -r1.68 -r1.62.6.7
>  > --- top.c       26 Sep 2002 17:46:04 -0000      1.68
>  > +++ top.c       4 Nov 2002 23:27:31 -0000       1.62.6.7
>  > @@ -63,6 +63,7 @@
>  >  #include <ctype.h>
>  >  #include "ui-out.h"
>  >  #include "cli-out.h"
>  > +#include "interps.h"
>  >  
>  >  /* Default command line prompt.  This is overriden in some configs. */
>  >  
>  > @@ -2126,17 +2127,30 @@ gdb_init (char *argv0)
>  >      init_ui_hook (argv0);
>  >  
>  >    /* Install the default UI */
>  > -  if (!init_ui_hook)
>  > -    {
>  > -      uiout = cli_out_new (gdb_stdout);
>  > +  /* All the interpreters should have had a look at things by now.
>  > +     Initialize the selected interpreter. */
>  > +  {
>  >  
>  > -      /* All the interpreters should have had a look at things by now.
>  > -        Initialize the selected interpreter. */
>  > -      if (interpreter_p)
>  > -       {
>  > -         fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
>  > -                             interpreter_p);
>  > -         exit (1);
>  > -       }
>  > -    }
>  > +    /* There will always be an interpreter.  Either the one specified
>  > +       by the user at start up or the console.  */
>  > +
>  > +    struct gdb_interpreter *interp;
>  > +    if (interpreter_p == NULL)
>  > +      interpreter_p = xstrdup (GDB_INTERPRETER_CONSOLE);
>  > +
>  > +    interp = gdb_interpreter_lookup (interpreter_p);
>  > +
>  > +    if (interp == NULL)
>  > +      {
>  > +        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' unrecognized.\n",
>  > +                            interpreter_p);
>  > +        exit (1);
>  > +      }
>  > +    if (!gdb_interpreter_set (interp))
>  > +      {
>  > +        fprintf_unfiltered (gdb_stderr, "Interpreter `%s' failed to initialize.\n",
>  > +                            interpreter_p);
>  > +        exit (1);
>  > +      }
>  > +  }
>  >  }
>  > Index: main.c
>  > ===================================================================
>  > RCS file: /cvs/src/src/gdb/main.c,v
>  > retrieving revision 1.20
>  > retrieving revision 1.16.8.3
>  > diff -u -p -r1.20 -r1.16.8.3
>  > --- main.c      26 Sep 2002 17:46:04 -0000      1.20
>  > +++ main.c      1 Oct 2002 00:46:10 -0000       1.16.8.3
>  > @@ -53,7 +53,9 @@ int display_space;
>  >     processes UI events asynchronously. */
>  >  int event_loop_p = 1;
>  >  
>  > -/* Has an interpreter been specified and if so, which. */
>  > +/* Has an interpreter been specified and if so, which.
>  > +   This will be used as a set command variable, so it should
>  > +   always be malloc'ed - since do_setshow_command will free it. */
>  >  char *interpreter_p;
>  >  
>  >  /* Whether this is the command line version or not */
>  > @@ -359,7 +361,7 @@ extern int gdbtk_test (char *);
>  >             }
>  >  #endif /* GDBTK */
>  >           case 'i':
>  > -           interpreter_p = optarg;
>  > +           interpreter_p = xstrdup (optarg);
>  >             break;
>  >           case 'd':
>  >             dirarg[ndir++] = optarg;
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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