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]

Re: kgdb support for gdb


On Monday 04 Oct 2004 9:25 pm, Andrew Cagney wrote:
> > Index: src/gdb/stack.c
> > ===================================================================
> > --- src.orig/gdb/stack.c	2004-08-03 06:27:26.000000000 +0530
> > +++ src/gdb/stack.c	2004-10-01 12:59:38.000000000 +0530
> > @@ -45,6 +45,7 @@
> >  #include "dictionary.h"
> >  #include "reggroups.h"
> >  #include "regcache.h"
> > +#include "objfiles.h"
>
> See Mark's general comments - I agree, the support should be there on
> all GNU/Linux systems, and not require special customization.
>
> As for details of the lk files, I'll leave that to GNU/Linux patch
> revierws.

Thanks a lot for the detailed reply.

> However, for the frame stuff, I've noticed the below.  Yes it's long.
> But mostly mechanical:
>
> - "gdb doesn't lie"
> This means that if the stack contains a context frame then the context
> frame is included in the backtrace.  Adding a feature to supresses
> certain frames in a back-trace would be interesting but, I think, should
> be added separatly (and needs to be user configurable).

I don't suppress any frames. I insert a fake frame so that the fake frame can 
do the job of reporting correct registers to the previous frame. IT works 
more or less like inline functions. At present inline functions don't insert 
fake frames, but I believe it's being worked on.

Let me state the problem I am trying to solve. You may be able to provide a 
better solution to that.

schedule() function has a call to macro switch_to. The switch_to macro is an 
architecture specific macro. It has hand written assembly code that does a 
part of the context switching job. This code manipulates eip and esp in a 
non-standard way. Present gdb can't produce backtraces correctly if the frame 
0 is inside switch_to. That's obvious since gdb doesn't have dwarf 
information for those instructions.

A few things have been tried to help gdb with this problem. This one is worth 
mentioning: We report the esp as it would be when switch_to is complete. 
Since gdb doesn't look into switch_to code, it starts interpretations where 
switch_to ends. So this works ok for most part. It doesn't solve the problem 
of all registers, though. The switch_to code has been written intelligently 
(read over-engineered) to save only those registers which would be expected 
by gcc to be correct when schedule() function returns. So this task becomes 
unmanageable and error-prone.


> - __sched_text_start
> stack.c should definitly not be directly testing that.  Instead ...

Agreed. I'll make a macro and/or a function switchout.

>
> - frame attributes
> ... the code should start testing for frame attributes: is this a callee
> frame; ......

Didn't understand that.

> - <context switch>
> A things-to-do-today task is modify the stack/frame/... code so that it
> displays something like:
> 	stopped at <signal trampoline>+0x23
> (i.e, the offset into the signal trampoline is displayed - at present it
> isn't) are you interested in trying to [separatly] fix this?

Let me try to understand what's involved in this. I'll get back on this later.

> - dissassemble
> I'm curious, does disassemble work for these context frames?  It
> currently doesn't for signal trampolines.

Will check this too.

> - PC_REGNUM and SP_REGNUM
> I noticed code refering to these - they are definitly on their way out -
> you'll need to find another way of implementing that.  I'm also
> wondering about the lm-tdep code that computes the frame ID, the code
> addr should be the start of that code block and not the current PC - a
> frame ID's code and stack addresses are both constant through out the
> lifetime of a frame.

Implementing these in a different way should be straight forward. Could move 
them into arch dependent files.

> - testing
> As with signal trampolines, we'll need to ensure that this is tested.
> It should be possible to construct testsuite additions that show GDB
> backtracing at least through one of these frames (Past experience has
> taught us that untested code unfortunatly and consistently bitrots).  I
> think it's possible to construct something without requiring a kernel.

Writing tests should be easy if a kernel is available. Without a kernel, ...
I'll think something about this. 
>
> - coding http://www.gnu.org/prep/standards_toc.html
> One querk to check is GDB's comment style.

Will fix this.

-Amit

>
> I think we can wack these out relatively quickly.
>
> Andrew
>
> >  /* Prototypes for exported functions. */
> >
> > @@ -420,9 +421,14 @@
> >    struct symtab_and_line sal;
> >    int source_print;
> >    int location_print;
> > +  CORE_ADDR pc;
> > +  struct frame_id fid;
> > +  struct minimal_symbol *schedbegin;
> > +  struct minimal_symbol *schedend;
> >
> >    if (get_frame_type (fi) == DUMMY_FRAME
> > -      || get_frame_type (fi) == SIGTRAMP_FRAME)
> > +      || get_frame_type (fi) == SIGTRAMP_FRAME
> > +      || (get_frame_type (fi) == CONTEXT_FRAME && print_level != 0))
> >      {
> >        struct cleanup *uiout_cleanup
> >  	= make_cleanup_ui_out_tuple_begin_end (uiout, "frame");
> > @@ -455,12 +461,38 @@
> >  	  annotate_signal_handler_caller ();
> >            ui_out_field_string (uiout, "func", "<signal handler
> > called>"); }
> > +      else if (get_frame_type (fi) == CONTEXT_FRAME)
> > +        {
> > +	  annotate_context_entry ();
> > +          ui_out_field_string (uiout, "func", "<context switch>");
> > +        }
> >        ui_out_text (uiout, "\n");
> >        annotate_frame_end ();
> >
> >        do_cleanups (uiout_cleanup);
> >        return;
> >      }
> > +  /* Don't print context switch and scheduler frames if we are at level
> > 0. */ +  if (get_frame_type (fi) == CONTEXT_FRAME)
> > +    {
> > +      schedbegin = lookup_minimal_symbol("__sched_text_start", NULL,
> > +					 symfile_objfile);
> > +      schedend = lookup_minimal_symbol("__sched_text_end", NULL,
> > +				       symfile_objfile);
> > +      if (schedbegin && schedend)
> > +	while ((fi = get_prev_frame(fi)) != NULL)
> > +	  {
> > +	    fid = get_frame_id(fi);
> > +	    pc = 0;
> > +	    if (!fid.code_addr_p)
> > +	      break;
> > +	    pc = get_frame_id(fi).code_addr;
> > +	    if (SYMBOL_VALUE_ADDRESS(schedbegin) >= pc)
> > +	      break;
> > +	    if (SYMBOL_VALUE_ADDRESS(schedend) <= pc)
> > +	      break;
> > +	  }
> > +    }
> >
> >    /* If fi is not the innermost frame, that normally means that fi->pc
> >       points to *after* the call instruction, and we want to get the


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