From: Jan Kratochvil Date: Mon, 28 Jun 2010 16:59:47 +0000 (+0000) Subject: gdb/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6036c742216f95a45095562947749755601a61f5;p=binutils-gdb.git 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6e700a4d84d..2b889fc9bea 100644 --- 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 diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 57b8dab7027..5f47ec4d910 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 e0465398932..01c11d5549b 100644 --- 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. 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 00000000000..a62e340a78a --- /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; 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 00000000000..8db13edd0bc --- /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_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 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_no_output "set pagination off" +gdb_test "print c" ".*" "first print" +gdb_test "print c" ".*" "second print"