diff options
-rw-r--r-- | gdb/ChangeLog | 49 | ||||
-rw-r--r-- | gdb/cp-valprint.c | 13 | ||||
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/static-print-quit.cc | 32 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/static-print-quit.exp | 50 |
5 files changed, 124 insertions, 24 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6e700a4..2b889fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com> + + * cp-valprint.c (cp_print_value_fields) <recurse == 0>: Call + obstack_begin after each obstack_free. + 2010-06-27 Doug Evans <dje@google.com> * value.c (value_static_field): Use `switch' instead of `if'. @@ -12,27 +17,27 @@ 2010-06-25 Paul Hilfinger <hilfinger@adacore.com> - * defs.h (make_command_stats_cleanup): Declare. - (set_display_time): Declare. - (set_display_space): Declare. - * event-top.c (command_handler): Use make_command_stats_cleanup. - * main.c (display_time, display_space): Move definitions to utils.c. - (captured_main): Use make_command_stats_cleanup to get start-up - statistics. - Use set_display_time and set_display_space for processing OPT_STATISTICS - case. - * maint.c (maintenance_time_display): Use set_display_time. - (maintenance_space_display): Use set_display_space. - * top.c (execute_command): Remove obsolete 'maint time' code. - (command_loop): Use make_command_stats_cleanup. - * utils.c (struct cmd_stats): Structure for storing initial time - and space usage. - (display_time, display_space): Move definitions here from utils.c. - (set_display_time): New function. - (set_display_space): New function. - (make_command_stats_cleanup): New function. - (report_command_stats): New auxiliary function for - make_command_stats_cleanup. + * defs.h (make_command_stats_cleanup): Declare. + (set_display_time): Declare. + (set_display_space): Declare. + * event-top.c (command_handler): Use make_command_stats_cleanup. + * main.c (display_time, display_space): Move definitions to utils.c. + (captured_main): Use make_command_stats_cleanup to get start-up + statistics. + Use set_display_time and set_display_space for processing OPT_STATISTICS + case. + * maint.c (maintenance_time_display): Use set_display_time. + (maintenance_space_display): Use set_display_space. + * top.c (execute_command): Remove obsolete 'maint time' code. + (command_loop): Use make_command_stats_cleanup. + * utils.c (struct cmd_stats): Structure for storing initial time + and space usage. + (display_time, display_space): Move definitions here from utils.c. + (set_display_time): New function. + (set_display_space): New function. + (make_command_stats_cleanup): New function. + (report_command_stats): New auxiliary function for + make_command_stats_cleanup. 2010-06-25 Ulrich Weigand <uweigand@de.ibm.com> @@ -6103,7 +6108,7 @@ PR gdb/9067 * cp-valprint.c (cp_print_value_fields) Fix use of obstacks. - cp_print_static_field) Fix use of obstacks. + (cp_print_static_field) Fix use of obstacks. 2010-02-08 Pedro Alves <pedro@codesourcery.com> diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 57b8dab..5f47ec4 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -164,10 +164,19 @@ cp_print_value_fields (struct type *type, struct type *real_type, if (recurse == 0) { + /* Any object can be left on obstacks only during an unexpected error. */ + if (obstack_object_size (&dont_print_statmem_obstack) > 0) - obstack_free (&dont_print_statmem_obstack, NULL); + { + obstack_free (&dont_print_statmem_obstack, NULL); + obstack_begin (&dont_print_statmem_obstack, 32 * sizeof (CORE_ADDR)); + } if (obstack_object_size (&dont_print_stat_array_obstack) > 0) - obstack_free (&dont_print_stat_array_obstack, NULL); + { + obstack_free (&dont_print_stat_array_obstack, NULL); + obstack_begin (&dont_print_stat_array_obstack, + 32 * sizeof (struct type *)); + } } fprintf_filtered (stream, "{"); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e046539..01c11d5 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com> + + * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New. + 2010-06-28 Doug Evans <dje@google.com> * gdb.base/break-interp.exp (reach): Relax expected output a bit. diff --git a/gdb/testsuite/gdb.cp/static-print-quit.cc b/gdb/testsuite/gdb.cp/static-print-quit.cc new file mode 100644 index 0000000..a62e340 --- /dev/null +++ b/gdb/testsuite/gdb.cp/static-print-quit.cc @@ -0,0 +1,32 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2010 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 <http://www.gnu.org/licenses/>. */ + +class D + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + }; + +class C + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + static D field; + }; + +D C::field; +C c; diff --git a/gdb/testsuite/gdb.cp/static-print-quit.exp b/gdb/testsuite/gdb.cp/static-print-quit.exp new file mode 100644 index 0000000..8db13ed --- /dev/null +++ b/gdb/testsuite/gdb.cp/static-print-quit.exp @@ -0,0 +1,50 @@ +# Copyright 2010 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 <http://www.gnu.org/licenses/>. + +if { [skip_cplus_tests] } { continue } + +set testfile static-print-quit +set srcfile ${testfile}.cc +set executable $testfile.o +set objfile ${objdir}/${subdir}/${executable} + +if { [gdb_compile $srcdir/$subdir/$srcfile $objfile object {debug c++}] != ""} { + untested ${testfile}.exp + return -1 +} + +clean_restart $executable + +gdb_test_no_output "set width 80" +gdb_test_no_output "set height 2" + +set test "print c" +gdb_test_multiple $test $test { + -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type <return> to continue, or q <return> to quit---$" { + pass $test + } + -re " to quit---$" { + fail $test + return -1 + } +} + +gdb_test "q" ".*" + +# Now the obstack is uninitialized. Excercise it. + +gdb_test_no_output "set pagination off" +gdb_test "print c" ".*" "first print" +gdb_test "print c" ".*" "second print" |