From 875b4ff565ff494986be7faf18f7fe575f5a5d2c Mon Sep 17 00:00:00 2001 From: Phil Muldoon Date: Thu, 16 Sep 2010 13:47:55 +0000 Subject: [PATCH] 2010-09-16 Phil Muldoon PR mi/11407 * mi/mi-cmd-stack.c (list_args_or_locals): Catch exceptions from read_var_value and common_val_print and print a warning. 2010-09-16 Phil Muldoon Jan Kratochvil PR mi/11407 * gdb.mi/dw2-ref-missing-frame-func.c: New File. * gdb.mi/dw2-ref-missing-frame-main.c New File. * gdb.mi/dw2-ref-missing-frame.S New File. * gdb.mi/dw2-ref-missing-frame.exp New File. --- gdb/ChangeLog | 6 + gdb/mi/mi-cmd-stack.c | 54 ++++-- gdb/testsuite/ChangeLog | 9 + .../gdb.mi/dw2-ref-missing-frame-func.c | 54 ++++++ .../gdb.mi/dw2-ref-missing-frame-main.c | 40 +++++ gdb/testsuite/gdb.mi/dw2-ref-missing-frame.S | 165 ++++++++++++++++++ .../gdb.mi/dw2-ref-missing-frame.exp | 77 ++++++++ 7 files changed, 388 insertions(+), 17 deletions(-) create mode 100644 gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c create mode 100644 gdb/testsuite/gdb.mi/dw2-ref-missing-frame-main.c create mode 100644 gdb/testsuite/gdb.mi/dw2-ref-missing-frame.S create mode 100644 gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2edf5fbf8e1..85e69738b34 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2010-09-16 Phil Muldoon + + PR mi/11407 + * mi/mi-cmd-stack.c (list_args_or_locals): Catch exceptions from + read_var_value and common_val_print and print a warning. + 2010-09-15 Jan Kratochvil * MAINTAINERS (GLOBAL MAINTAINERS) : Move the entry to diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 67970558c0d..7ee075cb8b2 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -31,7 +31,7 @@ #include "gdb_string.h" #include "language.h" #include "valprint.h" - +#include "exceptions.h" enum what_to_list { locals, arguments, all }; @@ -334,27 +334,47 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi) && TYPE_CODE (type) != TYPE_CODE_STRUCT && TYPE_CODE (type) != TYPE_CODE_UNION) { - struct value_print_options opts; - - val = read_var_value (sym2, fi); - get_raw_print_options (&opts); - opts.deref_ref = 1; - common_val_print - (val, stb->stream, 0, &opts, - language_def (SYMBOL_LANGUAGE (sym2))); + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + struct value_print_options opts; + + val = read_var_value (sym2, fi); + get_raw_print_options (&opts); + opts.deref_ref = 1; + common_val_print + (val, stb->stream, 0, &opts, + language_def (SYMBOL_LANGUAGE (sym2))); + } + if (except.reason < 0) + fprintf_filtered (stb->stream, + _(""), + except.message); + ui_out_field_stream (uiout, "value", stb); } break; case PRINT_ALL_VALUES: { - struct value_print_options opts; - - val = read_var_value (sym2, fi); - get_raw_print_options (&opts); - opts.deref_ref = 1; - common_val_print - (val, stb->stream, 0, &opts, - language_def (SYMBOL_LANGUAGE (sym2))); + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + struct value_print_options opts; + + val = read_var_value (sym2, fi); + get_raw_print_options (&opts); + opts.deref_ref = 1; + common_val_print + (val, stb->stream, 0, &opts, + language_def (SYMBOL_LANGUAGE (sym2))); + } + if (except.reason < 0) + fprintf_filtered (stb->stream, + _(""), + except.message); + ui_out_field_stream (uiout, "value", stb); } break; diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index dad5befe605..fc645fe026e 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2010-09-16 Phil Muldoon + Jan Kratochvil + + PR mi/11407 + * gdb.mi/dw2-ref-missing-frame-func.c: New File. + * gdb.mi/dw2-ref-missing-frame-main.c New File. + * gdb.mi/dw2-ref-missing-frame.S New File. + * gdb.mi/dw2-ref-missing-frame.exp New File. + 2010-09-14 Tom Tromey PR symtab/8399: diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c new file mode 100644 index 00000000000..10ddd81aa69 --- /dev/null +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-func.c @@ -0,0 +1,54 @@ +/* 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 . */ + +asm (".globl cu_text_start"); +asm ("cu_text_start:"); + +asm (".globl func_nofb_start"); +asm ("func_nofb_start:"); + +void +func_nofb (void) +{ + /* int func_nofb_var; */ + /* int func_nofb_var2; */ + + extern void func_nofb_marker (void); + func_nofb_marker (); +} + +asm (".globl func_nofb_end"); +asm ("func_nofb_end:"); + +asm (".globl func_loopfb_start"); +asm ("func_loopfb_start:"); + +void +func_loopfb (void) +{ + /* int func_loopfb_var; */ + /* int func_loopfb_var2; */ + + extern void func_loopfb_marker (void); + func_loopfb_marker (); +} + +asm (".globl func_loopfb_end"); +asm ("func_loopfb_end:"); + +asm (".globl cu_text_end"); +asm ("cu_text_end:"); diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-main.c b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-main.c new file mode 100644 index 00000000000..b3ec33aa00a --- /dev/null +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame-main.c @@ -0,0 +1,40 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2009, 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 . */ + +extern void func_nofb (void); +extern void func_loopfb (void); + +void +func_nofb_marker (void) +{ +} + +void +func_loopfb_marker (void) +{ +} + +int +main (void) +{ + int main_var = 1; + + func_nofb (); + func_loopfb (); + + return 0; +} diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.S b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.S new file mode 100644 index 00000000000..a93b3a6b656 --- /dev/null +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.S @@ -0,0 +1,165 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2007, 2008, 2009, 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 . */ + +/* Debug information */ + + .section .debug_info +.Lcu1_begin: + /* CU header */ + .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */ +.Lcu1_start: + .2byte 2 /* DWARF Version */ + .4byte .Labbrev1_begin /* Offset into abbrev section */ + .byte 4 /* Pointer size */ + + /* CU die */ + .uleb128 1 /* Abbrev: DW_TAG_compile_unit */ + .4byte cu_text_end /* DW_AT_high_pc */ + .4byte cu_text_start /* DW_AT_low_pc */ + .ascii "file1.txt\0" /* DW_AT_name */ + .ascii "GNU C 3.3.3\0" /* DW_AT_producer */ + .byte 1 /* DW_AT_language (C) */ + +.Ltype_int: + .uleb128 3 /* Abbrev: DW_TAG_base_type */ + .ascii "int\0" /* DW_AT_name */ + .byte 4 /* DW_AT_byte_size */ + .byte 5 /* DW_AT_encoding */ + + /* func_nofb */ + .uleb128 5 /* Abbrev: DW_TAG_subprogram (no fb) */ + .ascii "func_nofb\0" /* DW_AT_name */ + .4byte func_nofb_start /* DW_AT_low_pc */ + .4byte func_nofb_end /* DW_AT_high_pc */ + + .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ + .ascii "func_nofb_var\0" /* DW_AT_name */ + .byte 2f - 1f /* DW_AT_location */ +1: .byte 0x91 /* DW_OP_fbreg */ + .sleb128 0 /* 0 */ +2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + + .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ + .ascii "func_nofb_var2\0" /* DW_AT_name */ + .byte 2f - 1f /* DW_AT_location */ +1: .byte 0x91 /* DW_OP_fbreg */ + .sleb128 0 /* 0 */ +2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + + .byte 0 /* End of children of func */ + + /* func_loopfb */ + .uleb128 6 /* Abbrev: DW_TAG_subprogram (loop fb) */ + .ascii "func_loopfb\0" /* DW_AT_name */ + .4byte func_loopfb_start /* DW_AT_low_pc */ + .4byte func_loopfb_end /* DW_AT_high_pc */ + .byte 2f - 1f /* DW_AT_frame_base */ +1: .byte 0x91 /* DW_OP_fbreg */ + .sleb128 0 /* 0 */ +2: + + .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ + .ascii "func_loopfb_var\0" /* DW_AT_name */ + .byte 2f - 1f /* DW_AT_location */ +1: .byte 0x91 /* DW_OP_fbreg */ + .sleb128 0 /* 0 */ +2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + + .uleb128 7 /* Abbrev: DW_TAG_variable (location) */ + .ascii "func_loopfb_var2\0" /* DW_AT_name */ + .byte 2f - 1f /* DW_AT_location */ +1: .byte 0x91 /* DW_OP_fbreg */ + .sleb128 0 /* 0 */ +2: .4byte .Ltype_int-.Lcu1_begin /* DW_AT_type */ + + .byte 0 /* End of children of func */ + + .byte 0 /* End of children of CU */ + +.Lcu1_end: + +/* Abbrev table */ + .section .debug_abbrev +.Labbrev1_begin: + .uleb128 1 /* Abbrev code */ + .uleb128 0x11 /* DW_TAG_compile_unit */ + .byte 1 /* has_children */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x25 /* DW_AT_producer */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x13 /* DW_AT_language */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 3 /* Abbrev code */ + .uleb128 0x24 /* DW_TAG_base_type */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0xb /* DW_AT_byte_size */ + .uleb128 0xb /* DW_FORM_data1 */ + .uleb128 0x3e /* DW_AT_encoding */ + .uleb128 0xb /* DW_FORM_data1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 5 /* Abbrev code */ + .uleb128 0x2e /* DW_TAG_subprogram (no fb) */ + .byte 1 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 6 /* Abbrev code */ + .uleb128 0x2e /* DW_TAG_subprogram (loop fb) */ + .byte 1 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x11 /* DW_AT_low_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x12 /* DW_AT_high_pc */ + .uleb128 0x1 /* DW_FORM_addr */ + .uleb128 0x40 /* DW_AT_frame_base */ + .uleb128 0xa /* DW_FORM_block1 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .uleb128 7 /* Abbrev code (location) */ + .uleb128 0x34 /* DW_TAG_variable */ + .byte 0 /* has_children */ + .uleb128 0x3 /* DW_AT_name */ + .uleb128 0x8 /* DW_FORM_string */ + .uleb128 0x2 /* DW_AT_location */ + .uleb128 0xa /* DW_FORM_block1 */ + .uleb128 0x49 /* DW_AT_type */ + .uleb128 0x13 /* DW_FORM_ref4 */ + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ + + .byte 0x0 /* Terminator */ + .byte 0x0 /* Terminator */ diff --git a/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp new file mode 100644 index 00000000000..cd29de51f3b --- /dev/null +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp @@ -0,0 +1,77 @@ +# Copyright 2008, 2009, 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 . + +# This test can only be run on targets which support DWARF-2 and use gas. +# For now pick a sampling of likely targets. +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +if {![istarget *-*-linux*] + && ![istarget *-*-gnu*] + && ![istarget *-*-elf*] + && ![istarget *-*-openbsd*] + && ![istarget arm-*-eabi*] + && ![istarget powerpc-*-eabi*]} { + return 0 +} + +set testfile "dw2-ref-missing-frame" +set srcsfile ${testfile}.S +set objsfile ${objdir}/${subdir}/${testfile}.o +set srcfuncfile ${testfile}-func.c +set objfuncfile ${objdir}/${subdir}/${testfile}-func.o +set srcmainfile ${testfile}-main.c +set objmainfile ${objdir}/${subdir}/${testfile}-main.o +set executable ${testfile} +set binfile ${objdir}/${subdir}/${executable} + +if { [gdb_compile "${srcdir}/${subdir}/${srcsfile}" $objsfile object {}] != "" + || [gdb_compile "${srcdir}/${subdir}/${srcfuncfile}" $objfuncfile object {}] != "" + || [gdb_compile "${srcdir}/${subdir}/${srcmainfile}" $objmainfile object {debug}] != "" + || [gdb_compile "$objsfile $objfuncfile $objmainfile" $binfile executable {}] != "" } { + return -1 +} + +if [mi_gdb_start] { + continue +} + +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +if [mi_runto func_nofb_marker] { + # First try referencing DW_AT_frame_base which is not defined. + mi_gdb_test "300-stack-list-locals --thread 1 --frame 1 --all-values" \ + "300\\^done,locals=\\\[\{name=\"func_nofb_var\",value=\"\\\\"\},\{name=\"func_nofb_var2\",value=\"\\\\"\}\\\].*" \ + "test func_nofb_marker" +} + +# GDB could have crashed. +mi_gdb_exit +if [mi_gdb_start] { + continue +} +mi_delete_breakpoints +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +# And now try referencing DW_AT_frame_base defined using a self-reference +# (DW_OP_fbreg). +if [mi_runto func_loopfb_marker] { + mi_gdb_test "301-stack-list-locals --thread 1 --frame 1 --all-values" \ + "301\\^done,locals=\\\[\{name=\"func_loopfb_var\",value=\"\\\