public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* Unwinding through multiple stacks
@ 2015-03-25  0:00 Doug Evans
  2015-03-25  7:35 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Doug Evans @ 2015-03-25  0:00 UTC (permalink / raw)
  To: Andy Wingo; +Cc: Alexander Smundak, gdb-patches

Hi.

A topic came up on #gdb that the current patches don't cover.
What if the frame we're trying to unwind through has a different stack?
If the different stack is below the "normal" stack gdb will complain:
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The code to catch this is in frame.c:

  /* Check that this frame's ID isn't inner to (younger, below, next)
     the next frame.  This happens when a frame unwind goes backwards.
     This check is valid only if this frame and the next frame are
NORMAL.
     See the comment at frame_id_inner for details.  */
  if (get_frame_type (this_frame) == NORMAL_FRAME
      && this_frame->next->unwind->type == NORMAL_FRAME
      && frame_id_inner (get_frame_arch (this_frame->next),
                         get_frame_id (this_frame),
                         get_frame_id (this_frame->next)))
    {
      CORE_ADDR this_pc_in_block;
      struct minimal_symbol *morestack_msym;
      const char *morestack_name = NULL;

      /* gcc -fsplit-stack __morestack can continue the stack anywhere.  */
      this_pc_in_block = get_frame_address_in_block (this_frame);
      morestack_msym = lookup_minimal_symbol_by_pc (this_pc_in_block).minsym;
      if (morestack_msym)
        morestack_name = MSYMBOL_LINKAGE_NAME (morestack_msym);
      if (!morestack_name || strcmp (morestack_name, "__morestack") != 0)
        {
          if (frame_debug)
            {
              fprintf_unfiltered (gdb_stdlog, "-> ");
              fprint_frame (gdb_stdlog, NULL);
              fprintf_unfiltered (gdb_stdlog,
                                  " // this frame ID is inner }\n");
            }
          this_frame->stop_reason = UNWIND_INNER_ID;
          return NULL;
        }
    }

We need to generalize the __morestack solution
and provide it through the unwinders.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Unwinding through multiple stacks
  2015-03-25  0:00 Unwinding through multiple stacks Doug Evans
@ 2015-03-25  7:35 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2015-03-25  7:35 UTC (permalink / raw)
  To: Doug Evans; +Cc: Alexander Smundak, gdb-patches

Hi,

On Wed 25 Mar 2015 01:00, Doug Evans <dje@google.com> writes:

> A topic came up on #gdb that the current patches don't cover.
> What if the frame we're trying to unwind through has a different
> stack?

I was wondering about this too.  IIUC this check from GDB isn't a
fundamental limitation -- it's just a convenience for the user, that we
don't keep trying to compute outer frames for what looks to be a corrupt
stack.

In these cases I would have the unwinder mark the frame as not needing
an UNWIND_INNER_ID check.  Having the check by default is still useful
IMO.  How about

  (unwind-info-set-discontiguous! unwind-info #t)

or something.  That would eventually cause the frame_id to have a
"discontiguous" bitfield marked as 1.

To me it seems appropriate for a followup patch.  WDYT?

Andy

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-25  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25  0:00 Unwinding through multiple stacks Doug Evans
2015-03-25  7:35 ` Andy Wingo

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).