From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19870 invoked by alias); 8 Nov 2002 22:22:57 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 19858 invoked from network); 8 Nov 2002 22:22:52 -0000 Received: from unknown (HELO molenda.com) (192.220.74.81) by sources.redhat.com with SMTP; 8 Nov 2002 22:22:52 -0000 Received: (qmail 68130 invoked by uid 19025); 8 Nov 2002 22:22:49 -0000 Date: Fri, 08 Nov 2002 14:22:00 -0000 From: Jason Molenda To: gdb-patches@sources.redhat.com Cc: jjohnstn@redhat.com Subject: PATCH: Fix MI stack frame output for synthetic frames Message-ID: <20021108142248.A65720@molenda.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="SUOF0GtieIMvvwua" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-SW-Source: 2002-11/txt/msg00254.txt.bz2 --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 3466 Hi all, We've recently found a little problem with the current gdb in MI mode with synthesized frames on the stack (a gdb call dummy or a stack handler). Until last month, print_frame_info_base() would print information about these frames to stdout via printf_unfiltered; the reply to -stack-list-frames would have a FRAME tuple for level 0, skip level 1 (assuming that's the synthesized frame), then a FRAME tuple for level 2 and so on. With Jeff's change a month ago - http://sources.redhat.com/ml/gdb-patches/2002-09/msg00777.html a LEVEL field is being output, but no other parts of the FRAME tuple. (the FRAME tuple is a named tuple ("frame") with fields ADDR, FUNC, ARGS, and LINE if those are all available). The output now looks like ~"\n" stack=[frame={level="0",addr=...,func=...},level="1",frame={level="2",addr=...},...] I've attached a patch to emit a TUPLE with a func name of "" or "" and to include the ADDR field. I also took the opportunity to remove some code that'd been #if 0'ed since the original import on to sources.redhat.com in 1999. It's probably easier to read the new code than the patch -- I'll list the new code below and attach the patch. 2002-11-08 Jason Molenda (jmolenda@apple.com) * stack.c (print_frame_info_base): Emit full FRAME tuple for gdb call dummy and signal handler synthetic stack frames; send stack frame name through UI instead of stdout. Jason PS- Jeff, I saw you doing some tuple/list cleanup recently. The one place I fixed on the Apple but the FSF doesn't have correct is the CHILDREN list from -var-list-children; it should be a list, but it's currently output as a tuple. I'd be willing to submit a patch to the code and the testsuite if you're interested. PPS- I should add that this test causes no regressions and doesn't change the CLI output. I wrote a test file to explicitly cover these synthesized frames in CLI and MI modes, but it would take a little reworking to handle the FSF style MI output. static void print_frame_info_base (struct frame_info *fi, int level, int source, int args) { struct symtab_and_line sal; int source_print; int location_print; struct cleanup *uiout_cleanup; if (frame_in_dummy (fi) || fi->signal_handler_caller) { annotate_frame_begin (level == -1 ? 0 : level, fi->pc); uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); /* Do this regardless of SOURCE because we don't have any source to list for this frame. */ if (level >= 0) { ui_out_text (uiout, "#"); ui_out_field_fmt_int (uiout, 2, ui_left, "level", level); } if (ui_out_is_mi_like_p (uiout)) { annotate_frame_address (); ui_out_field_core_addr (uiout, "addr", fi->pc); annotate_frame_address_end (); } } if (frame_in_dummy (fi)) { annotate_function_call (); ui_out_field_string (uiout, "func", ""); ui_out_text (uiout, "\n"); annotate_frame_end (); do_cleanups (uiout_cleanup); return; } if (fi->signal_handler_caller) { annotate_signal_handler_caller (); ui_out_field_string (uiout, "func", ""); ui_out_text (uiout, "\n"); annotate_frame_end (); do_cleanups (uiout_cleanup); return; } --SUOF0GtieIMvvwua Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pa.txt" Content-length: 3102 2002-11-08 Jason Molenda (jmolenda@apple.com) * stack.c (print_frame_info_base): Emit full FRAME tuple for gdb call dummy and signal handler synthetic stack frames; send stack frame name through UI instead of stdout. Index: stack.c =================================================================== RCS file: /cvs/src/src/gdb/stack.c,v retrieving revision 1.46 diff -u -p -r1.46 stack.c --- stack.c 3 Oct 2002 22:34:58 -0000 1.46 +++ stack.c 8 Nov 2002 22:02:49 -0000 @@ -332,28 +332,12 @@ print_frame_info_base (struct frame_info struct symtab_and_line sal; int source_print; int location_print; + struct cleanup *uiout_cleanup; -#if 0 - char buf[MAX_REGISTER_RAW_SIZE]; - CORE_ADDR sp; - - /* On the 68k, this spends too much time in m68k_find_saved_regs. */ - - /* Get the value of SP_REGNUM relative to the frame. */ - get_saved_register (buf, (int *) NULL, (CORE_ADDR *) NULL, - FRAME_INFO_ID (fi), SP_REGNUM, (enum lval_type *) NULL); - sp = extract_address (buf, REGISTER_RAW_SIZE (SP_REGNUM)); - - /* This is not a perfect test, because if a function alloca's some - memory, puts some code there, and then jumps into it, then the test - will succeed even though there is no call dummy. Probably best is - to check for a bp_call_dummy breakpoint. */ - if (PC_IN_CALL_DUMMY (fi->pc, sp, fi->frame)) -#else - if (frame_in_dummy (fi)) -#endif + if (frame_in_dummy (fi) || fi->signal_handler_caller) { annotate_frame_begin (level == -1 ? 0 : level, fi->pc); + uiout_cleanup = make_cleanup_ui_out_tuple_begin_end (uiout, "frame"); /* Do this regardless of SOURCE because we don't have any source to list for this frame. */ @@ -362,25 +346,29 @@ print_frame_info_base (struct frame_info ui_out_text (uiout, "#"); ui_out_field_fmt_int (uiout, 2, ui_left, "level", level); } + if (ui_out_is_mi_like_p (uiout)) + { + annotate_frame_address (); + ui_out_field_core_addr (uiout, "addr", fi->pc); + annotate_frame_address_end (); + } + } + if (frame_in_dummy (fi)) + { annotate_function_call (); - printf_filtered ("\n"); + ui_out_field_string (uiout, "func", ""); + ui_out_text (uiout, "\n"); annotate_frame_end (); + do_cleanups (uiout_cleanup); return; } if (fi->signal_handler_caller) { - annotate_frame_begin (level == -1 ? 0 : level, fi->pc); - - /* Do this regardless of SOURCE because we don't have any source - to list for this frame. */ - if (level >= 0) - { - ui_out_text (uiout, "#"); - ui_out_field_fmt_int (uiout, 2, ui_left, "level", level); - } annotate_signal_handler_caller (); - printf_filtered ("\n"); + ui_out_field_string (uiout, "func", ""); + ui_out_text (uiout, "\n"); annotate_frame_end (); + do_cleanups (uiout_cleanup); return; } --SUOF0GtieIMvvwua--