* [patch] PR python/11407 @ 2010-06-24 11:33 Phil Muldoon 2010-06-24 15:10 ` Jan Kratochvil 2010-06-24 18:10 ` Tom Tromey 0 siblings, 2 replies; 16+ messages in thread From: Phil Muldoon @ 2010-06-24 11:33 UTC (permalink / raw) To: gdb-patches Hi, This patch is for PR 11407. It also cures the ills in Jan's test-case from last night: [patch 1/2] testsuite: dw2-ref-missing-frame cleanup http://sourceware.org/ml/gdb-patches/2010-06/msg00516.html [patch 2/2] testsuite: dw2-ref-missing-frame for PR python/11407 http://sourceware.org/ml/gdb-patches/2010-06/msg00515.html As the source between the Python issues and Jan's are similar, Jan's patch will form the test-case for this patch. There are many functions/commands in GDB that iterate over variables to produce output of one type or another. bt full, info locals, -stack-list-locals are just a few of many different sources that rely on this functionality. In the current GDB, if during this recursion an error is raised at any point from the request down (and some of these calls result in very deep calls stacks), the whole recursion is terminated (as the exception reached the top level). This is undesirable -- we should cope with the error and continue to recurse the other data. This patch fixes this issue in the last common denominator in each of the commands before they diverge. This patch catches the exception at the print level and prints a message with the exception message. Test on X8664 with no regressions. OK? Cheers, Phil Muldoon -- 2010-06-24 Phil Muldoon <pmuldoon@redhat.com> PR python/11407 * printcmd.c (print_variable_and_value): Print error message on caught exception. -- diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 430ccee..07abc2d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1944,15 +1944,21 @@ print_variable_and_value (const char *name, struct symbol *var, { struct value *val; struct value_print_options opts; + volatile struct gdb_exception except; if (!name) name = SYMBOL_PRINT_NAME (var); fprintf_filtered (stream, "%s%s = ", n_spaces (2 * indent), name); - - val = read_var_value (var, frame); - get_user_print_options (&opts); - common_val_print (val, stream, indent, &opts, current_language); + TRY_CATCH (except, RETURN_MASK_ERROR) + { + val = read_var_value (var, frame); + get_user_print_options (&opts); + common_val_print (val, stream, indent, &opts, current_language); + } + if (except.reason < 0) + fprintf_filtered(stream, "<error reading variable %s (%s)>", name, + except.message); fprintf_filtered (stream, "\n"); } ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-24 11:33 [patch] PR python/11407 Phil Muldoon @ 2010-06-24 15:10 ` Jan Kratochvil 2010-06-24 18:10 ` Tom Tromey 1 sibling, 0 replies; 16+ messages in thread From: Jan Kratochvil @ 2010-06-24 15:10 UTC (permalink / raw) To: Phil Muldoon; +Cc: gdb-patches On Thu, 24 Jun 2010 13:33:03 +0200, Phil Muldoon wrote: > { > struct value *val; > struct value_print_options opts; nitpick: I would prefer move val and opts to the inner TRY_CATCH block now. [...] > + TRY_CATCH (except, RETURN_MASK_ERROR) > + { > + val = read_var_value (var, frame); > + get_user_print_options (&opts); > + common_val_print (val, stream, indent, &opts, current_language); > + } > + if (except.reason < 0) > + fprintf_filtered(stream, "<error reading variable %s (%s)>", name, > + except.message); Wrong indentation/formatting of the fprintf_filtered line. Thanks, Jan ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-24 11:33 [patch] PR python/11407 Phil Muldoon 2010-06-24 15:10 ` Jan Kratochvil @ 2010-06-24 18:10 ` Tom Tromey 2010-06-24 22:01 ` Phil Muldoon 1 sibling, 1 reply; 16+ messages in thread From: Tom Tromey @ 2010-06-24 18:10 UTC (permalink / raw) To: Phil Muldoon; +Cc: gdb-patches >>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: Phil> This patch is for PR 11407. It also cures the ills in Jan's Phil> test-case from last night: Phil> 2010-06-24 Phil Muldoon <pmuldoon@redhat.com> Phil> PR python/11407 Phil> * printcmd.c (print_variable_and_value): Print error message on Phil> caught exception. This is ok with the changes Jan suggested. I think the MI commands -stack-list-variables and friends will need similar treatment. See mi-cmd-stack.c:list_args_or_locals. Tom ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-24 18:10 ` Tom Tromey @ 2010-06-24 22:01 ` Phil Muldoon 2010-06-25 6:56 ` Phil Muldoon 2010-06-25 18:25 ` Tom Tromey 0 siblings, 2 replies; 16+ messages in thread From: Phil Muldoon @ 2010-06-24 22:01 UTC (permalink / raw) To: tromey; +Cc: gdb-patches On 06/24/2010 07:10 PM, Tom Tromey wrote: >>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: > > Phil> This patch is for PR 11407. It also cures the ills in Jan's > Phil> test-case from last night: > > Phil> 2010-06-24 Phil Muldoon <pmuldoon@redhat.com> > Phil> PR python/11407 > Phil> * printcmd.c (print_variable_and_value): Print error message on > Phil> caught exception. > > This is ok with the changes Jan suggested. > > I think the MI commands -stack-list-variables and friends will need > similar treatment. See mi-cmd-stack.c:list_args_or_locals. Sorry for missing this, I was running 'info locals' in the MI interpreter. The MI -stack-list-locals case (as you noted) takes a different direction from the CLI in printing these cases. I'm not sure what to do in this case. There seems to be no direct equivalent of converting an exception to error output on a stream in MI (or any cases of TRY ... exception handlers). There are many cases of MI raising an error() though, so I thought it appropriate in our case to raise a warning() instead. Because of the peculiarities of the MI cases I just report a warning generically and move on. This is not totally ideal, but it does allow the error/warning preamble followed by the actual locals information. IE in my case: (.. lots and lots of error messages for the Python testcase and ...) ~"RuntimeError: Cannot access memory at address 0x6c756d702f656d57\n" ~"Traceback (most recent call last):\n" ~" File \"/home/pmuldoon/git/stack-list-locals/printers.py\", line 549, in to_string\n" ~" return self.val['_M_dataplus']['_M_p'].lazy_string (length = len)\n" ~"RuntimeError: Cannot access memory at address 0x6c2d6b6361747317\n" &"warning: <error reading variable>\n" &"warning: <error reading variable>\n" ^done,locals=[{name="mappedStrings"},{name="tmp"},{name="coll"},{name="str"},{name="stringV"},{name="derivedSet"},{name="stringVV"}] Which ultimately I think the IDE people want on program initialization (regardless of errors). At any rate, it is an improvement over the direct termination at the first error (and no locals=() data emitted). WDYT? Cheers, Phil -- diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 6797055..fe9fc81 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 }; @@ -335,27 +335,41 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi) && TYPE_CODE (type) != TYPE_CODE_UNION) { struct value_print_options opts; + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + + 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) + warning (_("<error reading variable>")); - 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))); ui_out_field_stream (uiout, "value", stb); } break; case PRINT_ALL_VALUES: { struct value_print_options opts; + volatile struct gdb_exception except; + + TRY_CATCH (except, RETURN_MASK_ERROR) + { + 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) + warning (_("<error reading variable>")); - 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))); - ui_out_field_stream (uiout, "value", stb); } break; } ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-24 22:01 ` Phil Muldoon @ 2010-06-25 6:56 ` Phil Muldoon 2010-06-25 14:27 ` Phil Muldoon 2010-06-25 18:25 ` Tom Tromey 1 sibling, 1 reply; 16+ messages in thread From: Phil Muldoon @ 2010-06-25 6:56 UTC (permalink / raw) To: tromey; +Cc: gdb-patches On 06/24/2010 11:01 PM, Phil Muldoon wrote: > On 06/24/2010 07:10 PM, Tom Tromey wrote: >>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: >> >> Phil> This patch is for PR 11407. It also cures the ills in Jan's >> Phil> test-case from last night: >> >> Phil> 2010-06-24 Phil Muldoon <pmuldoon@redhat.com> >> Phil> PR python/11407 >> Phil> * printcmd.c (print_variable_and_value): Print error message on >> Phil> caught exception. >> >> This is ok with the changes Jan suggested. >> >> I think the MI commands -stack-list-variables and friends will need >> similar treatment. See mi-cmd-stack.c:list_args_or_locals. > > Sorry for missing this, I was running 'info locals' in the MI > interpreter. The MI -stack-list-locals case (as you noted) takes a > different direction from the CLI in printing these cases. > > WDYT? Oops in the last patch, I forgot to include ui_out_field_stream (uiout, "value", stb); in both cases. Here is a corrected patch: -- diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 6797055..e67d085 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 }; @@ -335,26 +335,41 @@ list_args_or_locals (enum what_to_list what, int values, struct frame_info *fi) && 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) + { + + 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) + warning (_("<error reading variable>")); + 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) + { + 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) + warning (_("<error reading variable>")); + ui_out_field_stream (uiout, "value", stb); } break; ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 6:56 ` Phil Muldoon @ 2010-06-25 14:27 ` Phil Muldoon 0 siblings, 0 replies; 16+ messages in thread From: Phil Muldoon @ 2010-06-25 14:27 UTC (permalink / raw) To: tromey; +Cc: gdb-patches On 06/25/2010 07:56 AM, Phil Muldoon wrote: > On 06/24/2010 11:01 PM, Phil Muldoon wrote: >> On 06/24/2010 07:10 PM, Tom Tromey wrote: >>>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: >>> >>> Phil> This patch is for PR 11407. It also cures the ills in Jan's >>> Phil> test-case from last night: >>> >>> Phil> 2010-06-24 Phil Muldoon <pmuldoon@redhat.com> >>> Phil> PR python/11407 >>> Phil> * printcmd.c (print_variable_and_value): Print error message on >>> Phil> caught exception. >>> >>> This is ok with the changes Jan suggested. >>> >>> I think the MI commands -stack-list-variables and friends will need >>> similar treatment. See mi-cmd-stack.c:list_args_or_locals. >> >> Sorry for missing this, I was running 'info locals' in the MI >> interpreter. The MI -stack-list-locals case (as you noted) takes a >> different direction from the CLI in printing these cases. > >> >> WDYT? > > Oops in the last patch, I forgot to include > > ui_out_field_stream (uiout, "value", stb); > > in both cases. Here is a corrected patch: Sorry for yet another reply on top on this. I hope this will be the last. Jan and I were discussing this change on IRC and we decided it probably needed a testcase. I've adapted Jan's test inferiors/case to the MI model. Patch attached. What do you think? Cheers, Phil -- 2010-06-25 Phil Muldoon <pmuldoon@redhat.com> * mi/mi-cmd-stack.c (list_args_or_locals): Catch exceptions from read_var_value and common_val_print and print a warning. 2010-06-23 Jan Kratochvil <jan.kratochvil@redhat.com> Phil Muldoon <pmuldoon@redhat.com> * 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. -- diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 6797055..6d8623b 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,43 @@ 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) + warning (_("<error reading variable>")); + 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) + warning (_("<error reading variable>")); + ui_out_field_stream (uiout, "value", stb); } break; 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 0000000..10ddd81 --- /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 <http://www.gnu.org/licenses/>. */ + +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 0000000..b3ec33a --- /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 <http://www.gnu.org/licenses/>. */ + +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 0000000..a93b3a6 --- /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 <http://www.gnu.org/licenses/>. */ + +/* 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 0000000..355ee34 --- /dev/null +++ b/gdb/testsuite/gdb.mi/dw2-ref-missing-frame.exp @@ -0,0 +1,73 @@ +# 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 <http://www.gnu.org/licenses/>. + +# 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" "&\"warning: <error reading variable>.*&\"warning: <error reading variable>.*300\\^done,locals=\\\[\{name=\"func_nofb_var\",value=\"\"\},\{name=\"func_nofb_var2\",value=\"\"\}\\\]" "func_nofb locals" +} + +# 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" "&\"warning: <error reading variable>.*&\"warning: <error reading variable>.*301\\^done,locals=\\\[\{name=\"func_loopfb_var\",value=\"\"\},\{name=\"func_loopfb_var2\",value=\"\"\}\\\]" "func_loopfb locals" +} ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-24 22:01 ` Phil Muldoon 2010-06-25 6:56 ` Phil Muldoon @ 2010-06-25 18:25 ` Tom Tromey 2010-06-25 21:20 ` Phil Muldoon ` (2 more replies) 1 sibling, 3 replies; 16+ messages in thread From: Tom Tromey @ 2010-06-25 18:25 UTC (permalink / raw) To: Phil Muldoon; +Cc: gdb-patches >>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: Phil> I'm not sure what to do in this case. There seems to be no direct Phil> equivalent of converting an exception to error output on a stream in MI Phil> (or any cases of TRY ... exception handlers). There are many cases of Phil> MI raising an error() though, so I thought it appropriate in our case Phil> to raise a warning() instead. Because of the peculiarities of the MI Phil> cases I just report a warning generically and move on. This is not Phil> totally ideal, but it does allow the error/warning preamble followed Phil> by the actual locals information. I'm not convinced a warning is the best thing. Why not catch the exception and print the text of it as the variable's value? Something like <error reading variable: %s> I think this will work ok with existing front ends. Tom ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 18:25 ` Tom Tromey @ 2010-06-25 21:20 ` Phil Muldoon 2010-07-07 17:02 ` Phil Muldoon 2010-09-08 19:25 ` Tom Tromey 2010-06-26 17:10 ` Doug Evans 2010-06-28 6:26 ` André Pönitz 2 siblings, 2 replies; 16+ messages in thread From: Phil Muldoon @ 2010-06-25 21:20 UTC (permalink / raw) To: tromey; +Cc: gdb-patches On 06/25/2010 07:25 PM, Tom Tromey wrote: >>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: > > Phil> I'm not sure what to do in this case. There seems to be no direct > Phil> equivalent of converting an exception to error output on a stream in MI > Phil> (or any cases of TRY ... exception handlers). There are many cases of > Phil> MI raising an error() though, so I thought it appropriate in our case > Phil> to raise a warning() instead. Because of the peculiarities of the MI > Phil> cases I just report a warning generically and move on. This is not > Phil> totally ideal, but it does allow the error/warning preamble followed > Phil> by the actual locals information. > > I'm not convinced a warning is the best thing. > > Why not catch the exception and print the text of it as the variable's > value? Something like <error reading variable: %s> > I think this will work ok with existing front ends. Here is a patch that does that. What do you think? Cheers, Phil -- diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index 6797055..7ee075c 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, + _("<error reading variable: %s>"), + 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, + _("<error reading variable: %s>"), + except.message); + ui_out_field_stream (uiout, "value", stb); } break; 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 0000000..10ddd81 --- /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 <http://www.gnu.org/licenses/>. */ + +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 0000000..b3ec33a --- /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 <http://www.gnu.org/licenses/>. */ + +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 0000000..a93b3a6 --- /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 <http://www.gnu.org/licenses/>. */ + +/* 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 0000000..cd29de5 --- /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 <http://www.gnu.org/licenses/>. + +# 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=\"\\\<error reading variable: Could not find the frame base for \\\\\"func_nofb\\\\\"\\\.\\\>\"\},\{name=\"func_nofb_var2\",value=\"\\\<error reading variable: Could not find the frame base for \\\\\"func_nofb\\\\\"\\\.\\\>\"\}\\\].*" \ + "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=\"\\\<error reading variable: DWARF-2 expression error: Loop detected.*\"\},\{name=\"func_loopfb_var2\",value=\"\\\<error reading variable: DWARF-2 expression error: Loop detected.*\"\}\\\]" \ + "test func_loopfb_var" +} ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 21:20 ` Phil Muldoon @ 2010-07-07 17:02 ` Phil Muldoon 2010-08-09 19:41 ` Phil Muldoon 2010-09-08 19:25 ` Tom Tromey 1 sibling, 1 reply; 16+ messages in thread From: Phil Muldoon @ 2010-07-07 17:02 UTC (permalink / raw) To: tromey; +Cc: gdb-patches, vladimir On 25/06/10 22:20, Phil Muldoon wrote: > On 06/25/2010 07:25 PM, Tom Tromey wrote: >>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: >> >> Phil> I'm not sure what to do in this case. There seems to be no direct >> Phil> equivalent of converting an exception to error output on a stream in MI >> Phil> (or any cases of TRY ... exception handlers). There are many cases of >> Phil> MI raising an error() though, so I thought it appropriate in our case >> Phil> to raise a warning() instead. Because of the peculiarities of the MI >> Phil> cases I just report a warning generically and move on. This is not >> Phil> totally ideal, but it does allow the error/warning preamble followed >> Phil> by the actual locals information. >> >> I'm not convinced a warning is the best thing. >> >> Why not catch the exception and print the text of it as the variable's >> value? Something like <error reading variable: %s> >> I think this will work ok with existing front ends. > > Here is a patch that does that. > > What do you think? > > Cheers, > > Phil > Tom >> I am curious to hear what Volodya wants. Adding Vladimir Prus to the CC list. Cheers, Phil > -- > > diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c > index 6797055..7ee075c 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, > + _("<error reading variable: %s>"), > + 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, > + _("<error reading variable: %s>"), > + except.message); > + > ui_out_field_stream (uiout, "value", stb); > } > break; > 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 0000000..10ddd81 > --- /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 <http://www.gnu.org/licenses/>. */ > + > +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 0000000..b3ec33a > --- /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 <http://www.gnu.org/licenses/>. */ > + > +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 0000000..a93b3a6 > --- /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 <http://www.gnu.org/licenses/>. */ > + > +/* 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 0000000..cd29de5 > --- /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 <http://www.gnu.org/licenses/>. > + > +# 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=\"\\\<error reading variable: Could not find the frame base for \\\\\"func_nofb\\\\\"\\\.\\\>\"\},\{name=\"func_nofb_var2\",value=\"\\\<error reading variable: Could not find the frame base for \\\\\"func_nofb\\\\\"\\\.\\\>\"\}\\\].*" \ > + "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=\"\\\<error reading variable: DWARF-2 expression error: Loop detected.*\"\},\{name=\"func_loopfb_var2\",value=\"\\\<error reading variable: DWARF-2 expression error: Loop detected.*\"\}\\\]" \ > + "test func_loopfb_var" > +} ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-07-07 17:02 ` Phil Muldoon @ 2010-08-09 19:41 ` Phil Muldoon 2010-08-31 18:42 ` Phil Muldoon 0 siblings, 1 reply; 16+ messages in thread From: Phil Muldoon @ 2010-08-09 19:41 UTC (permalink / raw) To: tromey; +Cc: gdb-patches, vladimir On 07/07/10 18:02, Phil Muldoon wrote: > On 25/06/10 22:20, Phil Muldoon wrote: >> On 06/25/2010 07:25 PM, Tom Tromey wrote: >>>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: >>> >>> Phil> I'm not sure what to do in this case. There seems to be no direct >>> Phil> equivalent of converting an exception to error output on a stream in MI >>> Phil> (or any cases of TRY ... exception handlers). There are many cases of >>> Phil> MI raising an error() though, so I thought it appropriate in our case >>> Phil> to raise a warning() instead. Because of the peculiarities of the MI >>> Phil> cases I just report a warning generically and move on. This is not >>> Phil> totally ideal, but it does allow the error/warning preamble followed >>> Phil> by the actual locals information. >>> >>> I'm not convinced a warning is the best thing. >>> >>> Why not catch the exception and print the text of it as the variable's >>> value? Something like <error reading variable: %s> >>> I think this will work ok with existing front ends. >> >> Here is a patch that does that. >> >> What do you think? >> >> Cheers, >> >> Phil >> > > Tom >> I am curious to hear what Volodya wants. > > > Adding Vladimir Prus to the CC list. > Ping ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-08-09 19:41 ` Phil Muldoon @ 2010-08-31 18:42 ` Phil Muldoon 0 siblings, 0 replies; 16+ messages in thread From: Phil Muldoon @ 2010-08-31 18:42 UTC (permalink / raw) To: tromey; +Cc: gdb-patches, vladimir On 09/08/10 20:41, Phil Muldoon wrote: > On 07/07/10 18:02, Phil Muldoon wrote: >> On 25/06/10 22:20, Phil Muldoon wrote: >>> On 06/25/2010 07:25 PM, Tom Tromey wrote: >>>>>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: >>>> >>>> Phil> I'm not sure what to do in this case. There seems to be no direct >>>> Phil> equivalent of converting an exception to error output on a stream in MI >>>> Phil> (or any cases of TRY ... exception handlers). There are many cases of >>>> Phil> MI raising an error() though, so I thought it appropriate in our case >>>> Phil> to raise a warning() instead. Because of the peculiarities of the MI >>>> Phil> cases I just report a warning generically and move on. This is not >>>> Phil> totally ideal, but it does allow the error/warning preamble followed >>>> Phil> by the actual locals information. >>>> >>>> I'm not convinced a warning is the best thing. >>>> >>>> Why not catch the exception and print the text of it as the variable's >>>> value? Something like <error reading variable: %s> >>>> I think this will work ok with existing front ends. >>> >>> Here is a patch that does that. >>> >>> What do you think? >>> >>> Cheers, >>> >>> Phil >>> >> >> Tom >> I am curious to hear what Volodya wants. >> >> >> Adding Vladimir Prus to the CC list. >> > > Ping Ping ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 21:20 ` Phil Muldoon 2010-07-07 17:02 ` Phil Muldoon @ 2010-09-08 19:25 ` Tom Tromey 1 sibling, 0 replies; 16+ messages in thread From: Tom Tromey @ 2010-09-08 19:25 UTC (permalink / raw) To: Phil Muldoon; +Cc: gdb-patches >>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: Tom> Why not catch the exception and print the text of it as the variable's Tom> value? Something like <error reading variable: %s> Tom> I think this will work ok with existing front ends. Phil> Here is a patch that does that. Phil> What do you think? This patch is ok with a suitable ChangeLog entry. Thanks, and I'm sorry about the delay on this. I probably should have tried harder to get it into 7.2. Tom ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 18:25 ` Tom Tromey 2010-06-25 21:20 ` Phil Muldoon @ 2010-06-26 17:10 ` Doug Evans 2010-06-28 6:26 ` André Pönitz 2 siblings, 0 replies; 16+ messages in thread From: Doug Evans @ 2010-06-26 17:10 UTC (permalink / raw) To: tromey; +Cc: Phil Muldoon, gdb-patches On Fri, Jun 25, 2010 at 11:25 AM, Tom Tromey <tromey@redhat.com> wrote: >>>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: > > Phil> I'm not sure what to do in this case. There seems to be no direct > Phil> equivalent of converting an exception to error output on a stream in MI > Phil> (or any cases of TRY ... exception handlers). There are many cases of > Phil> MI raising an error() though, so I thought it appropriate in our case > Phil> to raise a warning() instead. Because of the peculiarities of the MI > Phil> cases I just report a warning generically and move on. This is not > Phil> totally ideal, but it does allow the error/warning preamble followed > Phil> by the actual locals information. > > I'm not convinced a warning is the best thing. > > Why not catch the exception and print the text of it as the variable's > value? Something like <error reading variable: %s> > I think this will work ok with existing front ends. I like this, fwiw. ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-25 18:25 ` Tom Tromey 2010-06-25 21:20 ` Phil Muldoon 2010-06-26 17:10 ` Doug Evans @ 2010-06-28 6:26 ` André Pönitz 2010-06-28 16:52 ` Tom Tromey 2 siblings, 1 reply; 16+ messages in thread From: André Pönitz @ 2010-06-28 6:26 UTC (permalink / raw) To: gdb-patches On Friday 25 June 2010 20:25:10 Tom Tromey wrote: > >>>>> "Phil" == Phil Muldoon <pmuldoon@redhat.com> writes: > > Phil> I'm not sure what to do in this case. There seems to be no direct > Phil> equivalent of converting an exception to error output on a stream in MI > Phil> (or any cases of TRY ... exception handlers). There are many cases of > Phil> MI raising an error() though, so I thought it appropriate in our case > Phil> to raise a warning() instead. Because of the peculiarities of the MI > Phil> cases I just report a warning generically and move on. This is not > Phil> totally ideal, but it does allow the error/warning preamble followed > Phil> by the actual locals information. > > I'm not convinced a warning is the best thing. > > Why not catch the exception and print the text of it as the variable's > value? Something like <error reading variable: %s> > I think this will work ok with existing front ends. I'd guess it would be nice for a front end to get a hint that something unusual happened in case it wants to have some kind of special handling of such cases (like localizing the error message). A separate field error="...", or perhaps value="<error reading variable: %s>" as suggested with an additional field iserror="1" would be easier to handle than checking the "value" field for well-known strings, especially if such content could be legal output in some cases, too. [But take this with a grain of salt, I/we haven't used MI for data retrieval for a while now, so maybe there are already enough hints in the output nowadays.] Andre' ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-28 6:26 ` André Pönitz @ 2010-06-28 16:52 ` Tom Tromey 2010-06-29 7:43 ` André Pönitz 0 siblings, 1 reply; 16+ messages in thread From: Tom Tromey @ 2010-06-28 16:52 UTC (permalink / raw) To: André Pönitz; +Cc: gdb-patches >>>>> "André" == André Pönitz <andre.poenitz@nokia.com> writes: André> I'd guess it would be nice for a front end to get a hint that André> something unusual happened in case it wants to have some kind of André> special handling of such cases (like localizing the error André> message). André> A separate field error="...", or perhaps value="<error reading André> variable: %s>" as suggested with an additional field iserror="1" André> would be easier to handle than checking the "value" field for André> well-known strings, especially if such content could be legal André> output in some cases, too. That would be fine with me. I am curious to hear what Volodya wants. André> [But take this with a grain of salt, I/we haven't used MI for André> data retrieval for a while now, so maybe there are already enough André> hints in the output nowadays.] What do you use? Tom ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [patch] PR python/11407 2010-06-28 16:52 ` Tom Tromey @ 2010-06-29 7:43 ` André Pönitz 0 siblings, 0 replies; 16+ messages in thread From: André Pönitz @ 2010-06-29 7:43 UTC (permalink / raw) To: gdb-patches On Monday 28 June 2010 18:52:32 you wrote: > >>>>> "André" == André Pönitz <andre.poenitz@nokia.com> writes: > > André> I'd guess it would be nice for a front end to get a hint that > André> something unusual happened in case it wants to have some kind of > André> special handling of such cases (like localizing the error > André> message). > > André> A separate field error="...", or perhaps value="<error reading > André> variable: %s>" as suggested with an additional field iserror="1" > André> would be easier to handle than checking the "value" field for > André> well-known strings, especially if such content could be legal > André> output in some cases, too. > > That would be fine with me. > > I am curious to hear what Volodya wants. > > André> [But take this with a grain of salt, I/we haven't used MI for > André> data retrieval for a while now, so maybe there are already enough > André> hints in the output nowadays.] > > What do you use? I use a rather monolithic python script[1] iterating over the stack variables as well as a few expressions for watched expressions and tooltips, generating all interesting data for the "Locals and Watchers" view in one go. The approach reduces roundtrip count to a minimum, at the price of repeating some unnecessary work each time the inferior stops. It's worthwhile though. As a rule of thumb one can retrieve 50-150 simple data items (say, values from a std::vector<int>) in the time an additional roundtrip would take (~30ms). Apart from that, the script creates exactly those pieces of data that are used in the Gui, and it's easy to generate arbitrary subtrees, including results from inferior calls and such, having individual formats for them, using far less code in the front end than the MI based version (which is still around, but only used on Mac and for older versions of gdb on Linux). It is really nice (and highly appreciated) that gdb allows this degree of flexibility nowadays ;-) Andre' PS: In case you are interested, the main script is here: http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/share/qtcreator/gdbmacros/dumper.py And there are "pretty printers" here: http://qt.gitorious.org/qt-creator/qt-creator/blobs/master/share/qtcreator/gdbmacros/gdbmacros.py ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2010-09-08 18:18 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-06-24 11:33 [patch] PR python/11407 Phil Muldoon 2010-06-24 15:10 ` Jan Kratochvil 2010-06-24 18:10 ` Tom Tromey 2010-06-24 22:01 ` Phil Muldoon 2010-06-25 6:56 ` Phil Muldoon 2010-06-25 14:27 ` Phil Muldoon 2010-06-25 18:25 ` Tom Tromey 2010-06-25 21:20 ` Phil Muldoon 2010-07-07 17:02 ` Phil Muldoon 2010-08-09 19:41 ` Phil Muldoon 2010-08-31 18:42 ` Phil Muldoon 2010-09-08 19:25 ` Tom Tromey 2010-06-26 17:10 ` Doug Evans 2010-06-28 6:26 ` André Pönitz 2010-06-28 16:52 ` Tom Tromey 2010-06-29 7:43 ` André Pönitz
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).