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]
Other format: [Raw text]

PATCH: Fix MI stack frame output for synthetic frames


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

~"<signal handler called>\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 "<signal
handler called>" or "<function called from gdb>" 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", "<function called from gdb>");
      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", "<signal handler called>");
      ui_out_text (uiout, "\n");
      annotate_frame_end ();
      do_cleanups (uiout_cleanup);
      return;
    }




Attachment: pa.txt
Description: Text document


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