if (frame_debug) fprintf_unfiltered (gdb_stdlog, "-> NULL
frame_debug_got_null_frame (gdb_stdlog, this_frame, "inside main func");
get_prev_frame (struct frame_info *this_frame){  struct frame_info *prev_frame;  struct frame_id this_id;  if (frame_debug)    {      fprintf_unfiltered (gdb_stdlog, "{ get_prev_frame (this_frame=");      if (this_frame != NULL)	fprintf_unfiltered (gdb_stdlog, "%d", this_frame->level);      else	fprintf_unfiltered (gdb_stdlog, "<NULL>");      fprintf_unfiltered (gdb_stdlog, ") ");    }  /* Return the inner-most frame, when the caller passes in NULL.  */  /* NOTE: cagney/2002-11-09: Not sure how this would happen.  The     caller should have previously obtained a valid frame using     get_selected_frame() and then called this code - only possibility     I can think of is code behaving badly.     NOTE: cagney/2003-01-10: Talk about code behaving badly.  Check     block_innermost_frame().  It does the sequence: frame = NULL;     while (1) { frame = get_prev_frame (frame); .... }.  Ulgh!  Why     it couldn't be written better, I don't know.     NOTE: cagney/2003-01-11: I suspect what is happening is     block_innermost_frame() is, when the target has no state     (registers, memory, ...), still calling this function.  The     assumption being that this function will return NULL indicating     that a frame isn't possible, rather than checking that the target     has state and then calling get_current_frame() and     get_prev_frame().  This is a guess mind.  */  if (this_frame == NULL)    {      /* NOTE: cagney/2002-11-09: There was a code segment here that	 would error out when CURRENT_FRAME was NULL.  The comment	 that went with it made the claim ...	 ``This screws value_of_variable, which just wants a nice	 clean NULL return from block_innermost_frame if there are no	 frames.  I don't think I've ever seen this message happen	 otherwise.  And returning NULL here is a perfectly legitimate	 thing to do.''         Per the above, this code shouldn't even be called with a NULL         THIS_FRAME.  */      return current_frame;    }  /* There is always a frame.  If this assertion fails, suspect that     something should be calling get_selected_frame() or     get_current_frame().  */  gdb_assert (this_frame != NULL);  /* Make sure we pass an address within THIS_FRAME's code block to     inside_main_func.  Otherwise, we might stop unwinding at a     function which has a call instruction as its last instruction if     that function immediately precedes main().  */  if (this_frame->level >= 0      && !backtrace_past_main      && inside_main_func (get_frame_address_in_block (this_frame)))    /* Don't unwind past main(), bug always unwind the sentinel frame.       Note, this is done _before_ the frame has been marked as       previously unwound.  That way if the user later decides to       allow unwinds past main(), that just happens.  */    {      if (frame_debug)	fprintf_unfiltered (gdb_stdlog, "-> NULL // inside main func }\n");      return NULL;    }  if (this_frame->level > backtrace_limit)    {      error ("Backtrace limit of %d exceeded", backtrace_limit);    }  /* If we're already inside the entry function for the main objfile,     then it isn't valid.  Don't apply this test to a dummy frame -     dummy frame PC's typically land in the entry func.  Don't apply     this test to the sentinel frame.  Sentinel frames should always     be allowed to unwind.  */  /* NOTE: cagney/2003-02-25: Don't enable until someone has found     hard evidence that this is needed.  */  /* NOTE: cagney/2003-07-07: Fixed a bug in inside_main_func - wasn't     checking for "main" in the minimal symbols.  With that fixed     asm-source tests now stop in "main" instead of halting the     backtrace in wierd and wonderful ways somewhere inside the entry     file.  Suspect that deprecated_inside_entry_file and     inside_entry_func tests were added to work around that (now     fixed) case.  */  /* NOTE: cagney/2003-07-15: danielj (if I'm reading it right)     suggested having the inside_entry_func test use the     inside_main_func msymbol trick (along with entry_point_address I     guess) to determine the address range of the start function.     That should provide a far better stopper than the current     heuristics.  */  /* NOTE: cagney/2003-07-15: Need to add a "set backtrace     beyond-entry-func" command so that this can be selectively     disabled.  */  if (0#if 0      && backtrace_beyond_entry_func#endif      && this_frame->type != DUMMY_FRAME && this_frame->level >= 0      && inside_entry_func (this_frame))    {      if (frame_debug)	{	  fprintf_unfiltered (gdb_stdlog, "-> ");	  fprint_frame (gdb_stdlog, NULL);	  fprintf_unfiltered (gdb_stdlog, "// inside entry func }\n");	}      return NULL;    }  /* Only try to do the unwind once.  */  if (this_frame->prev_p)    {      if (frame_debug)	{	  fprintf_unfiltered (gdb_stdlog, "-> ");	  fprint_frame (gdb_stdlog, this_frame->prev);	  fprintf_unfiltered (gdb_stdlog, " // cached \n");	}      return this_frame->prev;    }  this_frame->prev_p = 1;  /* If we're inside the entry file, it isn't valid.  Don't apply this     test to a dummy frame - dummy frame PC's typically land in the     entry file.  Don't apply this test to the sentinel frame.     Sentinel frames should always be allowed to unwind.  */  /* NOTE: drow/2002-12-25: should there be a way to disable this     check?  It assumes a single small entry file, and the way some     debug readers (e.g.  dbxread) figure out which object is the     entry file is somewhat hokey.  */  /* NOTE: cagney/2003-01-10: If there is a way of disabling this test     then it should probably be moved to before the ->prev_p test,     above.  */  /* NOTE: vinschen/2003-04-01: Disabled.  It turns out that the call     to deprecated_inside_entry_file destroys a meaningful backtrace     under some conditions.  E. g. the backtrace tests in the     asm-source testcase are broken for some targets.  In this test     the functions are all implemented as part of one file and the     testcase is not necessarily linked with a start file (depending     on the target).  What happens is, that the first frame is printed     normaly and following frames are treated as being inside the     enttry file then.  This way, only the #0 frame is printed in the     backtrace output.  */  if (0      && this_frame->type != DUMMY_FRAME && this_frame->level >= 0      && deprecated_inside_entry_file (get_frame_pc (this_frame)))    {      if (frame_debug)	{	  fprintf_unfiltered (gdb_stdlog, "-> ");	  fprint_frame (gdb_stdlog, NULL);	  fprintf_unfiltered (gdb_stdlog, " // inside entry file }\n");	}      return NULL;    }  /* If any of the old frame initialization methods are around, use     the legacy get_prev_frame method.  */  if (legacy_frame_p (current_gdbarch))    {      prev_frame = legacy_get_prev_frame (this_frame);      return prev_frame;    }  /* Check that this frame's ID was valid.  If it wasn't, don't try to     unwind to the prev frame.  Be careful to not apply this test to     the sentinel frame.  */  this_id = get_frame_id (this_frame);  if (this_frame->level >= 0 && !frame_id_p (this_id))    {      if (frame_debug)	{	  fprintf_unfiltered (gdb_stdlog, "-> ");	  fprint_frame (gdb_stdlog, NULL);	  fprintf_unfiltered (gdb_stdlog, " // this ID is NULL }\n");	}      return NULL;    }  /* Check that this frame's ID isn't inner to (younger, below, next)     the next frame.  This happens when a frame unwind goes backwards.     Since the sentinel frame doesn't really exist, don't compare the     inner-most against that sentinel.  */  if (this_frame->level > 0      && frame_id_inner (this_id, get_frame_id (this_frame->next)))    error ("Previous frame inner to this frame (corrupt stack?)");  /* Check that this and the next frame are not identical.  If they     are, there is most likely a stack cycle.  As with the inner-than     test above, avoid comparing the inner-most and sentinel frames.  */  if (this_frame->level > 0      && frame_id_eq (this_id, get_frame_id (this_frame->next)))    error ("Previous frame identical to this frame (corrupt stack?)");  /* Allocate the new frame but do not wire it in to the frame chain.     Some (bad) code in INIT_FRAME_EXTRA_INFO tries to look along     frame->next to pull some fancy tricks (of course such code is, by     definition, recursive).  Try to prevent it.     There is no reason to worry about memory leaks, should the     remainder of the function fail.  The allocated memory will be     quickly reclaimed when the frame cache is flushed, and the `we've     been here before' check above will stop repeated memory     allocation calls.  */  prev_frame = FRAME_OBSTACK_ZALLOC (struct frame_info);  prev_frame->level = this_frame->level + 1;  /* Don't yet compute ->unwind (and hence ->type).  It is computed     on-demand in get_frame_type, frame_register_unwind, and     get_frame_id.  */  /* Don't yet compute the frame's ID.  It is computed on-demand by     get_frame_id().  */  /* The unwound frame ID is validate at the start of this function,     as part of the logic to decide if that frame should be further     unwound, and not here while the prev frame is being created.     Doing this makes it possible for the user to examine a frame that     has an invalid frame ID.     Some very old VAX code noted: [...]  For the sake of argument,     suppose that the stack is somewhat trashed (which is one reason     that "info frame" exists).  So, return 0 (indicating we don't     know the address of the arglist) if we don't know what frame this     frame calls.  */  /* Link it in.  */  this_frame->prev = prev_frame;  prev_frame->next = this_frame;  if (frame_debug)    {      fprintf_unfiltered (gdb_stdlog, "-> ");      fprint_frame (gdb_stdlog, prev_frame);      fprintf_unfiltered (gdb_stdlog, " }\n");    }  return prev_frame;}