This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATH, RFA]: Fix UI_OUT related problem in stack.c:print_frame()


Hi Mark,

Thank you for finding this.

Please add a comment before the do_cleanup() to make clear that
the list is being closed there (see below).

Thanks again.

Fernando

P.S.: Maybe someone has anything to say about the make_cleanup_...
function
but we should get it in to stop the bug first.  We make the necessary
adjustments
if someone sugests something different.


Mark Kettenis wrote:
> 
> Hi,
> 
> Right now GDB will report an internal error if you use `q' to quit
> from a long backtrace a couple of time.  Obviously in this case
> ui_out_list_end() isn't called and after calling ui_out_list_begin()
> four times the following message is printed:
> 
>    ui_out: list depth exceeded; only 4 levels of lists can be nested.
> 
> The attached fixes this by adding ui_out_list_end() to the list of
> cleanup actions.  I introduced make_cleanup_ui_out_list_end() to avoid
> compiler warnings and since I expect that there might very well be
> more cases where this sort of thing is needed.
> 
> OK to install?
> 
> 2001-01-27  Mark Kettenis  <kettenis@gnu.org>
> 
>         * ui-out.c (do_list_end): New function.
>         (make_cleanup_ui_out_list_end): New function.
>         * ui-out.h: Provide prototype for make_cleanup_ui_out_list_end.
>         * stack.c (print_frame) [UI_OUT]: Call
>         make_cleanup_ui_out_list_end to make sure we mark the end of the
>         list if we do a non-local exit.  At the end of the function,
>         instead of calling ui_out_list_end directly, let do_cleanups
>         handle it.
> 
> Index: ui-out.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ui-out.c,v
> retrieving revision 1.6
> diff -u -p -r1.6 ui-out.c
> --- ui-out.c 2000/12/15 01:01:50 1.6
> +++ ui-out.c 2001/01/27 11:18:37
> @@ -281,6 +281,18 @@ ui_out_list_end (struct ui_out *uiout)
>    uiout->list_flag--;
>  }
> 
> +static void
> +do_list_end (void *uiout)
> +{
> +  ui_out_list_end (uiout);
> +}
> +
> +struct cleanup *
> +make_cleanup_ui_out_list_end (struct ui_out *uiout)
> +{
> +  return make_cleanup (do_list_end, uiout);
> +}
> +
>  void
>  ui_out_field_int (struct ui_out *uiout, char *fldname, int value)
>  {
> Index: ui-out.h
> ===================================================================
> RCS file: /cvs/src/src/gdb/ui-out.h,v
> retrieving revision 1.2
> diff -u -p -r1.2 ui-out.h
> --- ui-out.h 2000/05/28 01:12:33 1.2
> +++ ui-out.h 2001/01/27 11:18:37
> @@ -81,6 +81,8 @@ extern void ui_out_list_begin (struct ui
> 
>  extern void ui_out_list_end (struct ui_out *uiout);
> 
> +extern struct cleanup *make_cleanup_ui_out_list_end (struct ui_out *uiout);
> +
>  extern void ui_out_field_int (struct ui_out *uiout, char *fldname, int value);
> 
>  extern void ui_out_field_core_addr (struct ui_out *uiout, char *fldname,
> Index: stack.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/stack.c,v
> retrieving revision 1.10
> diff -u -p -r1.10 stack.c
> --- stack.c 2000/12/15 01:01:49 1.10
> +++ stack.c 2001/01/27 11:18:38
> @@ -1,5 +1,6 @@
>  /* Print and select stack frames for GDB, the GNU debugger.
> -   Copyright 1986, 1987, 1989, 1991-1996, 1998-2000 Free Software Foundation, Inc.
> +   Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
> +   1998, 1999, 2000, 2001 Free Software Foundation, Inc.
> 
>     This file is part of GDB.
> 
> @@ -448,6 +449,7 @@ print_frame (struct frame_info *fi,
>  #ifdef UI_OUT
>    struct ui_stream *stb;
>    struct cleanup *old_chain;
> +  struct cleanup *list_chain;
> 
>    stb = ui_out_stream_new (uiout);
>    old_chain = make_cleanup_ui_out_stream_delete (stb);
> @@ -532,6 +534,7 @@ print_frame (struct frame_info *fi,
> 
>  #ifdef UI_OUT
>    ui_out_list_begin (uiout, "frame");
> +  list_chain = make_cleanup_ui_out_list_end (uiout);
>  #endif
> 
>    if (level >= 0)
> @@ -661,7 +664,7 @@ print_frame (struct frame_info *fi,
>  #endif /* PC_SOLIB */
> 
>  #ifdef UI_OUT
> -  ui_out_list_end (uiout);
  +  /* do_cleanups will call ui_out_list_end() for us. */   
<==========
> +  do_cleanups (list_chain);
>    ui_out_text (uiout, "\n");
>    do_cleanups (old_chain);
>  #else

-- 
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]