142 lines
4.1 KiB
Diff
142 lines
4.1 KiB
Diff
http://sourceware.org/ml/gdb-cvs/2012-03/msg00234.html
|
|
|
|
### src/gdb/ChangeLog 2012/03/19 18:13:39 1.14025
|
|
### src/gdb/ChangeLog 2012/03/19 18:16:17 1.14026
|
|
## -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>
|
|
|
|
* gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'.
|
|
Index: gdb-7.3.50.20110722/gdb/main.c
|
|
===================================================================
|
|
--- gdb-7.3.50.20110722.orig/gdb/main.c 2012-04-18 23:38:42.000000000 +0200
|
|
+++ gdb-7.3.50.20110722/gdb/main.c 2012-04-18 23:42:28.152479249 +0200
|
|
@@ -275,6 +275,25 @@ exec_or_core_file_attach (char *filename
|
|
}
|
|
}
|
|
|
|
+/* 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
|
|
captured_main (void *data)
|
|
{
|
|
@@ -301,17 +320,8 @@ captured_main (void *data)
|
|
static int print_version;
|
|
|
|
/* Pointers to all arguments of --command option. */
|
|
- struct cmdarg {
|
|
- enum {
|
|
- CMDARG_FILE,
|
|
- CMDARG_COMMAND
|
|
- } type;
|
|
- char *string;
|
|
- } *cmdarg;
|
|
- /* Allocated size of cmdarg. */
|
|
- int cmdsize;
|
|
- /* Number of elements of cmdarg used. */
|
|
- int ncmd;
|
|
+ VEC (cmdarg_s) *cmdarg_vec = NULL;
|
|
+ struct cmdarg *cmdarg_p;
|
|
|
|
/* Indices of all arguments of --directory option. */
|
|
char **dirarg;
|
|
@@ -344,9 +354,7 @@ captured_main (void *data)
|
|
lim_at_start = (char *) sbrk (0);
|
|
#endif
|
|
|
|
- cmdsize = 1;
|
|
- cmdarg = (struct cmdarg *) xmalloc (cmdsize * sizeof (*cmdarg));
|
|
- ncmd = 0;
|
|
+ make_cleanup (VEC_cleanup (cmdarg_s), &cmdarg_vec);
|
|
dirsize = 1;
|
|
dirarg = (char **) xmalloc (dirsize * sizeof (*dirarg));
|
|
ndir = 0;
|
|
@@ -577,24 +585,19 @@ captured_main (void *data)
|
|
pidarg = optarg;
|
|
break;
|
|
case 'x':
|
|
- cmdarg[ncmd].type = CMDARG_FILE;
|
|
- cmdarg[ncmd++].string = optarg;
|
|
- if (ncmd >= cmdsize)
|
|
- {
|
|
- cmdsize *= 2;
|
|
- cmdarg = xrealloc ((char *) cmdarg,
|
|
- cmdsize * sizeof (*cmdarg));
|
|
- }
|
|
+ {
|
|
+ struct cmdarg cmdarg = { CMDARG_FILE, optarg };
|
|
+
|
|
+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
|
|
+ }
|
|
break;
|
|
case 'X':
|
|
- cmdarg[ncmd].type = CMDARG_COMMAND;
|
|
- cmdarg[ncmd++].string = optarg;
|
|
- if (ncmd >= cmdsize)
|
|
- {
|
|
- cmdsize *= 2;
|
|
- cmdarg = xrealloc ((char *) cmdarg,
|
|
- cmdsize * sizeof (*cmdarg));
|
|
- }
|
|
+ {
|
|
+ struct cmdarg cmdarg = { CMDARG_COMMAND, optarg };
|
|
+
|
|
+ VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg);
|
|
+ }
|
|
+ break;
|
|
break;
|
|
case 'B':
|
|
batch_flag = batch_silent = 1;
|
|
@@ -985,16 +988,18 @@ captured_main (void *data)
|
|
ALL_OBJFILES (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)
|
|
- catch_command_errors (source_script, cmdarg[i].string,
|
|
+ case CMDARG_FILE:
|
|
+ catch_command_errors (source_script, cmdarg_p->string,
|
|
!batch_flag, RETURN_MASK_ALL);
|
|
- else /* cmdarg[i].type == CMDARG_COMMAND */
|
|
- catch_command_errors (execute_command, cmdarg[i].string,
|
|
+ break;
|
|
+ case CMDARG_COMMAND:
|
|
+ catch_command_errors (execute_command, cmdarg_p->string,
|
|
!batch_flag, RETURN_MASK_ALL);
|
|
+ break;
|
|
}
|
|
- xfree (cmdarg);
|
|
|
|
/* Read in the old history after all the command files have been
|
|
read. */
|