gdb/
Code cleanup. * main.c (struct cmdarg): Move it here from main. Add more comments. (cmdarg_s, VEC (cmdarg_s)): New. (main): Move struct cmdarg from here. New variables cmdarg_vec and cmdarg_p. Remove variables cmdsize and ncmd and their initialization. Install cleanup for cmdarg_vec. Update filling for options 'x' and 'X'. Replace cmdarg processing by cmdarg_vec processing. Remove xfree of CMDARG.
This commit is contained in:
parent
5ff5c7b436
commit
26743505e3
|
@ -1,3 +1,14 @@
|
||||||
|
2012-03-19 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
Code cleanup.
|
||||||
|
* main.c (struct cmdarg): Move it here from main. Add more comments.
|
||||||
|
(cmdarg_s, VEC (cmdarg_s)): New.
|
||||||
|
(main): Move struct cmdarg from here. New variables cmdarg_vec and
|
||||||
|
cmdarg_p. Remove variables cmdsize and ncmd and their initialization.
|
||||||
|
Install cleanup for cmdarg_vec. Update filling for options 'x' and
|
||||||
|
'X'. Replace cmdarg processing by cmdarg_vec processing. Remove xfree
|
||||||
|
of CMDARG.
|
||||||
|
|
||||||
2012-03-19 Tom Tromey <tromey@redhat.com>
|
2012-03-19 Tom Tromey <tromey@redhat.com>
|
||||||
|
|
||||||
* gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'.
|
* gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'.
|
||||||
|
|
77
gdb/main.c
77
gdb/main.c
|
@ -239,6 +239,25 @@ captured_command_loop (void *data)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Arguments of --command option and its counterpart. */
|
||||||
|
typedef struct cmdarg {
|
||||||
|
/* Type of this option. */
|
||||||
|
enum {
|
||||||
|
/* Option type -x. */
|
||||||
|
CMDARG_FILE,
|
||||||
|
|
||||||
|
/* Option type -ex. */
|
||||||
|
CMDARG_COMMAND
|
||||||
|
} type;
|
||||||
|
|
||||||
|
/* Value of this option - filename or the GDB command itself. String memory
|
||||||
|
is not owned by this structure despite it is 'const'. */
|
||||||
|
char *string;
|
||||||
|
} cmdarg_s;
|
||||||
|
|
||||||
|
/* Define type VEC (cmdarg_s). */
|
||||||
|
DEF_VEC_O (cmdarg_s);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
captured_main (void *data)
|
captured_main (void *data)
|
||||||
{
|
{
|
||||||
|
@ -263,17 +282,8 @@ captured_main (void *data)
|
||||||
static int print_version;
|
static int print_version;
|
||||||
|
|
||||||
/* Pointers to all arguments of --command option. */
|
/* Pointers to all arguments of --command option. */
|
||||||
struct cmdarg {
|
VEC (cmdarg_s) *cmdarg_vec = NULL;
|
||||||
enum {
|
struct cmdarg *cmdarg_p;
|
||||||
CMDARG_FILE,
|
|
||||||
CMDARG_COMMAND
|
|
||||||
} type;
|
|
||||||
char *string;
|
|
||||||
} *cmdarg;
|
|
||||||
/* Allocated size of cmdarg. */
|
|
||||||
int cmdsize;
|
|
||||||
/* Number of elements of cmdarg used. */
|
|
||||||
int ncmd;
|
|
||||||
|
|
||||||
/* Indices of all arguments of --directory option. */
|
/* Indices of all arguments of --directory option. */
|
||||||
char **dirarg;
|
char **dirarg;
|
||||||
|
@ -309,9 +319,7 @@ captured_main (void *data)
|
||||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
textdomain (PACKAGE);
|
textdomain (PACKAGE);
|
||||||
|
|
||||||
cmdsize = 1;
|
make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec);
|
||||||
cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg));
|
|
||||||
ncmd = 0;
|
|
||||||
dirsize = 1;
|
dirsize = 1;
|
||||||
dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
|
dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
|
||||||
ndir = 0;
|
ndir = 0;
|
||||||
|
@ -536,24 +544,19 @@ captured_main (void *data)
|
||||||
pidarg = optarg;
|
pidarg = optarg;
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
cmdarg[ncmd].type = CMDARG_FILE;
|
{
|
||||||
cmdarg[ncmd++].string = optarg;
|
struct cmdarg cmdarg = { CMDARG_FILE, optarg };
|
||||||
if (ncmd >= cmdsize)
|
|
||||||
{
|
VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
|
||||||
cmdsize *= 2;
|
}
|
||||||
cmdarg = xrealloc ((char *) cmdarg,
|
|
||||||
cmdsize * sizeof (*cmdarg));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
cmdarg[ncmd].type = CMDARG_COMMAND;
|
{
|
||||||
cmdarg[ncmd++].string = optarg;
|
struct cmdarg cmdarg = { CMDARG_COMMAND, optarg };
|
||||||
if (ncmd >= cmdsize)
|
|
||||||
{
|
VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
|
||||||
cmdsize *= 2;
|
}
|
||||||
cmdarg = xrealloc ((char *) cmdarg,
|
break;
|
||||||
cmdsize * sizeof (*cmdarg));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
batch_flag = batch_silent = 1;
|
batch_flag = batch_silent = 1;
|
||||||
|
@ -908,16 +911,18 @@ captured_main (void *data)
|
||||||
ALL_OBJFILES (objfile)
|
ALL_OBJFILES (objfile)
|
||||||
load_auto_scripts_for_objfile (objfile);
|
load_auto_scripts_for_objfile (objfile);
|
||||||
|
|
||||||
for (i = 0; i < ncmd; i++)
|
for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++)
|
||||||
|
switch (cmdarg_p->type)
|
||||||
{
|
{
|
||||||
if (cmdarg[i].type == CMDARG_FILE)
|
case CMDARG_FILE:
|
||||||
catch_command_errors (source_script, cmdarg[i].string,
|
catch_command_errors (source_script, cmdarg_p->string,
|
||||||
!batch_flag, RETURN_MASK_ALL);
|
!batch_flag, RETURN_MASK_ALL);
|
||||||
else /* cmdarg[i].type == CMDARG_COMMAND */
|
break;
|
||||||
catch_command_errors (execute_command, cmdarg[i].string,
|
case CMDARG_COMMAND:
|
||||||
|
catch_command_errors (execute_command, cmdarg_p->string,
|
||||||
!batch_flag, RETURN_MASK_ALL);
|
!batch_flag, RETURN_MASK_ALL);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
xfree (cmdarg);
|
|
||||||
|
|
||||||
/* Read in the old history after all the command files have been
|
/* Read in the old history after all the command files have been
|
||||||
read. */
|
read. */
|
||||||
|
|
Loading…
Reference in New Issue