This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: dwarf2-frame.c question for maintainers
On Thu, 2004-07-15 at 10:58, Andrew Cagney wrote:
> > On Wed, 2004-07-14 at 12:28, Andrew Cagney wrote:
> >
> >>>>>> >>> How come extract_typed_address, in read_reg, doesn't sign extend?
> >>>
> >>>> >
> >>>> >
> >>>> > I should have explained that. It does. However extract_typed_address is
> >>>> > incorrect because it makes the invalid assumption that sizeof(address)
> >>>> > == sizeof(register). So that has to go and be replaced with something
> >>>> > like
> >>>> > extract_signed_integer (buf, register_size (current_gdbarch, regnum));
> >>
> >>>
> >>> You mean the builtin_type_void_data_ptr parameter to
> >>> extract_typed_address? Ah.
> >>>
> >>> I see builtin_type_void_data_ptr dates back to 1.1 (Mark?). It could
> >>> instead use the register's type?
> >
> >
> > extract_typed_address calls extract_[un]signed_integer with size =
> > TYPE_LENGTH of builtin_type_void_data_ptr.
> >
> > Here's exactly what I am seeing. Maybe you can tell me if read_reg is
> > the problem.
> >
> > For example big-endian Mips, with o64 or (eabi and mlong32):
> > (registers are 64 bits and pointers are 32 bits)
> >
> > read_reg calls frame_unwind_register (next_frame, regnum, buf)
> > after that, buf has something like ffffffff801fffb8
> >
> > Now if you do extract_typed_address(), it knows addresses are 4 bytes
> > and returns 0xffffffff sign extended to 0xfffffffffffffff
>
> Right, as it stands, that call is just wrong.
>
> > If instead, you call extract_[un]signed_integer((buf, register_size
> > (current_gdbarch, regnum)), it returns 0xffffffff801fffb8
> >
> > The real problem here is the the size. AFAICT, sign-extension here is
> > unimportant; I get the same test results calling
> > extract_unsigned_integer in read_reg() for mips, because, as you can
> > see, nothing needs extending, just the whole register needs read.
> > However, I can't prove that is always the case because I am not familiar
> > enough with the code.
>
> Consider o32. Both the ABI and ISA are 32-bits, but GDB's CORE_ADDR may
> be 64-bits. Even if it doesn't appear to make a difference, the MIPS
> needs to always sign extend addresses/registers - that's the dogma :-)
Right. And so back to the original question. What is the best way to
have read_reg detect if it should sign-extend? We agreed that passing a
pointer to the CU was out, as was using a global. Do I need to add
something to gdbarch?
--
Martin M. Hunt <hunt@redhat.com>
Red Hat Inc.