commit 47c8c764a9be6d023eca450336e6d9de16970fc0 Author: Jan Kratochvil Date: Mon Jun 28 16:59:43 2010 +0000 gdb/ * cp-valprint.c (cp_print_value_fields) : Call obstack_begin after each obstack_free. gdb/testsuite/ * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New. ### a/gdb/ChangeLog ### b/gdb/ChangeLog ## -1,3 +1,8 @@ +2010-06-28 Jan Kratochvil + + * cp-valprint.c (cp_print_value_fields) : Call + obstack_begin after each obstack_free. + 2010-06-27 Doug Evans * value.c (value_static_field): Use `switch' instead of `if'. ## -12,27 +17,27 @@ 2010-06-25 Paul Hilfinger - * 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 ## -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 --- 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, "{"); ### a/gdb/testsuite/ChangeLog ### b/gdb/testsuite/ChangeLog ## -1,3 +1,7 @@ +2010-06-28 Jan Kratochvil + + * gdb.cp/static-print-quit.exp, gdb.cp/static-print-quit.cc: New. + 2010-06-28 Doug Evans * gdb.base/break-interp.exp (reach): Relax expected output a bit. --- /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 . */ + +class D + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + }; + +class C + { + public: + int loooooooooooooooooooooooooooooooooooooooooooooong; + static D field; + }; + +D C::field; +C c; --- /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 . + +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 "set width 80" +gdb_test "set height 2" + +set test "print c" +gdb_test_multiple $test $test { + -re " = \{loooooooooooooooooooooooooooooooooooooooooooooong = 0, static field = \{\r\n---Type to continue, or q to quit---$" { + pass $test + } + -re " to quit---$" { + fail $test + return -1 + } +} + +gdb_test "q" ".*" + +# Now the obstack is uninitialized. Excercise it. + +gdb_test "set pagination off" +gdb_test "print c" ".*" "first print" +gdb_test "print c" ".*" "second print"