From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5666 invoked by alias); 19 Mar 2012 19:24:57 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 5615 invoked by uid 9079); 19 Mar 2012 19:24:54 -0000 Date: Mon, 19 Mar 2012 19:24:00 -0000 Message-ID: <20120319192454.5600.qmail@sourceware.org> From: kseitz@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-keiths-linespec-rewrite: Merge remote-tracking branch 'gdb/master' into archer-keiths-linespec-rewrite X-Git-Refname: refs/heads/archer-keiths-linespec-rewrite X-Git-Reftype: branch X-Git-Oldrev: 0f2b6d4b7db4a52e143eae4a894be518a651e342 X-Git-Newrev: 380143a6f3b302231b64e104ffbc8725782964ed X-SW-Source: 2012-q1/txt/msg00073.txt.bz2 List-Id: The branch, archer-keiths-linespec-rewrite has been updated via 380143a6f3b302231b64e104ffbc8725782964ed (commit) via e3ec945d53406d7232ec8e043c941e9be1572c78 (commit) via b65ecc84c539325076f4fd8c963e8ee191877a70 (commit) via 03ae95e867a4c94f0bdf7a2358cedc39a19a1fdb (commit) via 35d2e24b5a91d04403d10514e896f68df8b40dea (commit) via dff5a25c1f0ade13d791de1864948696381debeb (commit) via f0a040c143cbcec1244eebc0970b32013fb98a8a (commit) from 0f2b6d4b7db4a52e143eae4a894be518a651e342 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 380143a6f3b302231b64e104ffbc8725782964ed Merge: e3ec945 03ae95e Author: Keith Seitz Date: Mon Mar 19 12:13:02 2012 -0700 Merge remote-tracking branch 'gdb/master' into archer-keiths-linespec-rewrite commit e3ec945d53406d7232ec8e043c941e9be1572c78 Author: Keith Seitz Date: Mon Mar 19 12:00:46 2012 -0700 New dollars-in-linespecs tests. commit b65ecc84c539325076f4fd8c963e8ee191877a70 Author: Keith Seitz Date: Mon Mar 19 11:58:59 2012 -0700 remove c++ compile option commit 03ae95e867a4c94f0bdf7a2358cedc39a19a1fdb Author: Jan Kratochvil Date: Mon Mar 19 18:23:51 2012 +0000 gdb/ Code cleanup. * python/py-auto-load.c (source_section_scripts): New variable back_to. Turn fclose and xfree calls into make_cleanup_fclose and make_cleanup with xfree. (auto_load_objfile_script): Turn fclose into make_cleanup_fclose. commit 35d2e24b5a91d04403d10514e896f68df8b40dea Author: Jan Kratochvil Date: Mon Mar 19 18:19:23 2012 +0000 gdb/ * NEWS: Describe new options --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and CMDARG_INIT_COMMAND. (captured_main): New enum items OPT_IX and OPT_IEX. Add "init-command", "init-eval-command", "ix" and "iex" to the variable long_options. Handle OPT_IX and OPT_IEX. Process them from CMDARG_VEC. New comment for CMDARG_FILE and CMDARG_COMMAND processing. (print_gdb_help): Describe --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. gdb/doc/ * gdb.texinfo (File Options): Describe --init-command=FILE, -ix and --init-eval-command=COMMAND, -iex. (Startup): Describe -iex and -ix. Simplify the example for "set auto-load-scripts off". gdb/testsuite/ * gdb.gdb/selftest.exp (do_steps_and_nexts): New entry for cmdarg_vec = NULL. Remove entries for cmdsize = 1, cmdarg = and ncmd = 0. New entry for VEC_cleanup cmdarg_s. commit dff5a25c1f0ade13d791de1864948696381debeb Author: Jan Kratochvil Date: Mon Mar 19 18:16:17 2012 +0000 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. commit f0a040c143cbcec1244eebc0970b32013fb98a8a Author: Tom Tromey Date: Mon Mar 19 18:13:39 2012 +0000 * gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'. ----------------------------------------------------------------------- Summary of changes: gdb/ChangeLog | 36 +++++++++ gdb/NEWS | 7 ++ gdb/doc/ChangeLog | 7 ++ gdb/doc/gdb.texinfo | 32 +++++++-- gdb/gnu-v3-abi.c | 2 +- gdb/main.c | 121 +++++++++++++++++++++--------- gdb/python/py-auto-load.c | 15 +++- gdb/testsuite/ChangeLog | 6 ++ gdb/testsuite/gdb.gdb/selftest.exp | 20 ++--- gdb/testsuite/gdb.linespec/ls-dollar.cc | 26 +++++++ gdb/testsuite/gdb.linespec/ls-dollar.exp | 38 +++++++++ gdb/testsuite/gdb.linespec/ls-errs.exp | 2 +- 12 files changed, 252 insertions(+), 60 deletions(-) create mode 100644 gdb/testsuite/gdb.linespec/ls-dollar.cc create mode 100644 gdb/testsuite/gdb.linespec/ls-dollar.exp First 500 lines of diff: diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7325047..3059d69 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,39 @@ +2012-03-19 Jan Kratochvil + + Code cleanup. + * python/py-auto-load.c (source_section_scripts): New variable back_to. + Turn fclose and xfree calls into make_cleanup_fclose and make_cleanup + with xfree. + (auto_load_objfile_script): Turn fclose into make_cleanup_fclose. + +2012-03-19 Jan Kratochvil + + * NEWS: Describe new options --init-command=FILE, -ix and + --init-eval-command=COMMAND, -iex. + * main.c (struct cmdarg): New enum items CMDARG_INIT_FILE and + CMDARG_INIT_COMMAND. + (captured_main): New enum items OPT_IX and OPT_IEX. Add + "init-command", "init-eval-command", "ix" and "iex" to the variable + long_options. Handle OPT_IX and OPT_IEX. Process them from CMDARG_VEC. + New comment for CMDARG_FILE and CMDARG_COMMAND processing. + (print_gdb_help): Describe --init-command=FILE, -ix and + --init-eval-command=COMMAND, -iex. + +2012-03-19 Jan Kratochvil + + 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 + + * gnu-v3-abi.c (gnuv3_print_vtable): Initialize 'result_vec'. + 2012-03-16 Jan Kratochvil PR symtab/13777 diff --git a/gdb/NEWS b/gdb/NEWS index e6bf59c..d23a773 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -118,6 +118,13 @@ QProgramSignals: Specify the signals which the remote stub may pass to the debugged program without GDB involvement. +* New command line options + +--init-command=FILE, -ix Like --command, -x but execute it + before loading inferior. +--init-eval-command=COMMAND, -iex Like --eval-command=COMMAND, -ex but + execute it before loading inferior. + *** Changes in GDB 7.4 * GDB now handles ambiguous linespecs more consistently; the existing diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index cb6d0e9..92e3e1b 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2012-03-19 Jan Kratochvil + + * gdb.texinfo (File Options): Describe --init-command=FILE, -ix and + --init-eval-command=COMMAND, -iex. + (Startup): Describe -iex and -ix. Simplify the example + for "set auto-load-scripts off". + 2012-03-16 Gary Benson PR breakpoints/10738 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 56bf5d5..677af3b 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -990,6 +990,22 @@ also be interleaved with @samp{-command} as required. -x setbreakpoints -ex 'run' a.out @end smallexample +@item -init-command @var{file} +@itemx -ix @var{file} +@cindex @code{--init-command} +@cindex @code{-ix} +Execute commands from file @var{file} before loading gdbinit files or the +inferior. +@xref{Startup}. + +@item -init-eval-command @var{command} +@itemx -iex @var{command} +@cindex @code{--init-eval-command} +@cindex @code{-iex} +Execute a single @value{GDBN} command before loading gdbinit files or the +inferior. +@xref{Startup}. + @item -directory @var{directory} @itemx -d @var{directory} @cindex @code{--directory} @@ -1242,6 +1258,13 @@ Sets up the command interpreter as specified by the command line (@pxref{Mode Options, interpreter}). @item +Executes commands and command files specified by the @samp{-iex} and +@samp{-ix} options in their specified order. Usually you should use the +@samp{-ex} and @samp{-x} options instead, but this way you can apply +settings before @value{GDBN} init files get executed and before inferior +gets loaded. + +@item @cindex init file Reads the system-wide @dfn{init file} (if @option{--with-system-gdbinit} was used when building @value{GDBN}; @pxref{System-wide configuration, @@ -1275,14 +1298,11 @@ If you wish to disable the auto-loading during startup, you must do something like the following: @smallexample -$ gdb -ex "set auto-load-scripts off" -ex "file myprogram" +$ gdb -iex "set auto-load-scripts off" myprogram @end smallexample -The following does not work because the auto-loading is turned off too late: - -@smallexample -$ gdb -ex "set auto-load-scripts off" myprogram -@end smallexample +Option @samp{-ex} does not work because the auto-loading is then turned +off too late. @item Executes commands and command files specified by the @samp{-ex} and diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 72ca2a1..1095c60 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -907,7 +907,7 @@ gnuv3_print_vtable (struct value *value) struct value_print_options opts; htab_t offset_hash; struct cleanup *cleanup; - VEC (value_and_voffset_p) *result_vec; + VEC (value_and_voffset_p) *result_vec = NULL; struct value_and_voffset *iter; int i, count; diff --git a/gdb/main.c b/gdb/main.c index a63a385..e528cd1 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -239,6 +239,31 @@ captured_command_loop (void *data) 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, + + /* Option type -ix. */ + CMDARG_INIT_FILE, + + /* Option type -iex. */ + CMDARG_INIT_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) { @@ -263,17 +288,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; @@ -309,9 +325,7 @@ captured_main (void *data) bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); - 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; @@ -386,7 +400,9 @@ captured_main (void *data) OPT_STATISTICS, OPT_TUI, OPT_NOWINDOWS, - OPT_WINDOWS + OPT_WINDOWS, + OPT_IX, + OPT_IEX }; static struct option long_options[] = { @@ -426,6 +442,10 @@ captured_main (void *data) {"version", no_argument, &print_version, 1}, {"x", required_argument, 0, 'x'}, {"ex", required_argument, 0, 'X'}, + {"init-command", required_argument, 0, OPT_IX}, + {"init-eval-command", required_argument, 0, OPT_IEX}, + {"ix", required_argument, 0, OPT_IX}, + {"iex", required_argument, 0, OPT_IEX}, #ifdef GDBTK {"tclcommand", required_argument, 0, 'z'}, {"enable-external-editor", no_argument, 0, 'y'}, @@ -536,24 +556,32 @@ 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; + case OPT_IX: + { + struct cmdarg cmdarg = { CMDARG_INIT_FILE, optarg }; + + VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); + } + break; + case OPT_IEX: + { + struct cmdarg cmdarg = { CMDARG_INIT_COMMAND, optarg }; + + VEC_safe_push (cmdarg_s, cmdarg_vec, &cmdarg); + } break; case 'B': batch_flag = batch_silent = 1; @@ -806,6 +834,20 @@ captured_main (void *data) quit_pre_print = error_pre_print; warning_pre_print = _("\nwarning: "); + /* Process '-ix' and '-iex' options early. */ + for (i = 0; VEC_iterate (cmdarg_s, cmdarg_vec, i, cmdarg_p); i++) + switch (cmdarg_p->type) + { + case CMDARG_INIT_FILE: + catch_command_errors (source_script, cmdarg_p->string, + !batch_flag, RETURN_MASK_ALL); + break; + case CMDARG_INIT_COMMAND: + catch_command_errors (execute_command, cmdarg_p->string, + !batch_flag, RETURN_MASK_ALL); + break; + } + /* Read and execute the system-wide gdbinit file, if it exists. This is done *before* all the command line arguments are processed; it sets global parameters, which are independent of @@ -908,16 +950,19 @@ captured_main (void *data) ALL_OBJFILES (objfile) load_auto_scripts_for_objfile (objfile); - for (i = 0; i < ncmd; i++) + /* Process '-x' and '-ex' options. */ + 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. */ @@ -988,6 +1033,8 @@ Options:\n\n\ Execute a single GDB command.\n\ May be used multiple times and in conjunction\n\ with --command.\n\ + --init-command=FILE, -ix Like -x but execute it before loading inferior.\n\ + --init-eval-command=COMMAND, -iex Like -ex but before loading inferior.\n\ --core=COREFILE Analyze the core dump COREFILE.\n\ --pid=PID Attach to running process PID.\n\ "), stream); diff --git a/gdb/python/py-auto-load.c b/gdb/python/py-auto-load.c index e297bf3..14e75a7 100644 --- a/gdb/python/py-auto-load.c +++ b/gdb/python/py-auto-load.c @@ -254,6 +254,7 @@ source_section_scripts (struct objfile *objfile, const char *source_name, FILE *stream; char *full_path; int opened, in_hash_table; + struct cleanup *back_to; if (*p != 1) { @@ -286,6 +287,13 @@ source_section_scripts (struct objfile *objfile, const char *source_name, opened = find_and_open_script (file, 1 /*search_path*/, &stream, &full_path); + back_to = make_cleanup (null_cleanup, NULL); + if (opened) + { + make_cleanup_fclose (stream); + make_cleanup (xfree, full_path); + } + /* If one script isn't found it's not uncommon for more to not be found either. We don't want to print an error message for each script, too much noise. Instead, we print the warning once and tell @@ -313,9 +321,9 @@ Use `info auto-load-scripts [REGEXP]' to list them."), /* If this file is not currently loaded, load it. */ if (! in_hash_table) source_python_script_for_objfile (objfile, stream, full_path); - fclose (stream); - xfree (full_path); } + + do_cleanups (back_to); } } @@ -420,6 +428,8 @@ auto_load_objfile_script (struct objfile *objfile, const char *suffix) { struct auto_load_pspace_info *pspace_info; + make_cleanup_fclose (input); + /* Add this script to the hash table too so "info auto-load-scripts" can print it. */ pspace_info = @@ -432,7 +442,6 @@ auto_load_objfile_script (struct objfile *objfile, const char *suffix) and these scripts are required to be idempotent under multiple loads anyway. */ source_python_script_for_objfile (objfile, input, debugfile); - fclose (input); } do_cleanups (cleanups); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f2ea686..2a8bf9d 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2012-03-19 Jan Kratochvil + + * gdb.gdb/selftest.exp (do_steps_and_nexts): New entry + for cmdarg_vec = NULL. Remove entries for cmdsize = 1, cmdarg = and + ncmd = 0. New entry for VEC_cleanup cmdarg_s. + 2012-03-19 Siddhesh Poyarekar * gdb.base/cond-eval-mode.exp: Fix the anticipated warning string. diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp index 1ffa945..7645caf 100644 --- a/gdb/testsuite/gdb.gdb/selftest.exp +++ b/gdb/testsuite/gdb.gdb/selftest.exp @@ -88,6 +88,10 @@ proc do_steps_and_nexts {} { set description "step over ttyarg initialization" set command "step" } + -re ".*cmdarg_vec = NULL.*$gdb_prompt $" { + set description "step over cmdarg_vec initialization" + set command "step" + } -re ".*pre_stat_chain = make_command_stats_cleanup.*$gdb_prompt $" { set description "next over make_command_stats_cleanup and everything it calls" set command "next" @@ -124,18 +128,6 @@ proc do_steps_and_nexts {} { set description "next over conditional stack alignment alloca" set command "next" } - -re ".*cmdsize = 1.*$gdb_prompt $" { - set description "step over cmdsize initialization" - set command "next" - } - -re ".*cmdarg = .* xmalloc.*$gdb_prompt $" { - set description "next over cmdarg initialization via xmalloc" - set command "next" - } - -re ".*ncmd = 0.*$gdb_prompt $" { - set description "next over ncmd initialization" - set command "next" - } -re ".*dirsize = 1.*$gdb_prompt $" { set description "next over dirsize initialization" set command "next" @@ -159,6 +151,10 @@ proc do_steps_and_nexts {} { set description "next over textdomain PACKAGE" set command "next" } + -re ".*VEC_cleanup .cmdarg_s.*$gdb_prompt $" { + set description "next over cmdarg_s VEC_cleanup" + set command "next" + } -re "\[0-9\]+\[\t \]+\{\r\n$gdb_prompt $" { set description "step over initial brace" set command "step" diff --git a/gdb/testsuite/gdb.linespec/ls-dollar.cc b/gdb/testsuite/gdb.linespec/ls-dollar.cc new file mode 100644 index 0000000..72e792b --- /dev/null +++ b/gdb/testsuite/gdb.linespec/ls-dollar.cc @@ -0,0 +1,26 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2012 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +static int $dollar_var = 0; + +int $dollar_func (void) { return $dollar_var; } /* dollar_func */ + +int +main (void) +{ + return $dollar_func (); +} diff --git a/gdb/testsuite/gdb.linespec/ls-dollar.exp b/gdb/testsuite/gdb.linespec/ls-dollar.exp new file mode 100644 index 0000000..e82dc08 --- /dev/null +++ b/gdb/testsuite/gdb.linespec/ls-dollar.exp @@ -0,0 +1,38 @@ +# Copyright 2012 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or hooks/post-receive -- Repository for Project Archer.