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: [RFA]: dwarf2expr.[ch]


Just some questions and statements:
> > +   return ctx->stack[ctx->stack_len - (1+n)];
> > + 
> > + }     
> 
> This should check for underflow, too.  Look at what DW_OP_rot will do
> on an empty stack.
It does.
Look at the lines above it.
(Yours won't have internal_error, just (ctx->error))
if (ctx->stack_len < n)
     internal_error (__FILE__, __LINE__, "Asked for position %d of stack, 
stack only has %d elements on it\n",
                     n, ctx->stack_len);

If you ask for one item, and the stack has 0, this will catch it.


> > + 
> > + 	  switch (op)
> > + 	    {
> > + 	    case DW_OP_deref:
> > + 	      {
> > + 		result = (CORE_ADDR) 
> > + 		  (ctx->read_mem) (ctx->read_mem_baton, 
> > + 				   result, 
> > + 				   TARGET_PTR_BIT / TARGET_CHAR_BIT);
> 
> Since CORE_ADDR may be wider than the target's address,
> I think this
> should mask off and/or sign extend as appropriate, depending on the
> current gdbarch.  Same anywhere we call ctx->read_mem, I think.
Shouldn't the read_mem function do this for us?
read_mem is returning a CORE_ADDR (the cast is pointless, i'll remove 
it) anyway, so it would seem to be *it's* job to make sure the 
CORE_ADDR it gives us is the right thing.


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