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: [patch/rfa] Signal trampoline unwinder for hppa-hpux


> > How can you tell whether a kernel is 32bits or not?
> 
> in the code? In the save_state_t structure returned by the kernel,
> there's a flag, which is checked here:
> 
> +  if (!(flag & 0x40))
> +    {
> +      /* Narrow registers. */
> +      off = scptr + offsetof (save_state_t, ss_narrow);
> +      incr = 4;
> +      szoff = 0;
> +    }
> +  else
> +    {
> +      /* Wide registers. */
> +      off = scptr + offsetof (save_state_t, ss_wide) + 8;
> +      incr = 8;
> +      szoff = (tdep->bytes_per_address == 4 ? 4 : 0);
> +    }
> 
> There are 3 cases, if you have a 32-bit kernel, then it should always
> hit the first if case. If you have a 64-bit kernel and 32-bit userspace,
> you should hit the second case with szoff == 4. For 64-bit kernel and
> 64-bit userspace you will hit the else case with szoff == 0.

Under hpux, I believe that 32-bit PA 2.0 kernels support wide registers
with the 32-bit userspace.  For example, compile the following program
with the HP C compiler with 'cc -Ae +DA2.0 +O2 -S'

long long
foo (long long i)
{
  return i + (-4039);
}

and you get


	.LEVEL	2.0N
	.SPACE	$TEXT$,SORT=8
	.SUBSPA	$CODE$,QUAD=0,ALIGN=4,ACCESS=0x2c,CODE_ONLY,SORT=24
foo
	.PROC
	.CALLINFO FRAME=0,ARGS_SAVED
        .ENTRY
        DEPD    %r25,31,32,%r26 ;offset 0x0
        LDO     -4039(%r26),%r29        ;offset 0x4
        BVE     (%r2)   ;offset 0x8
        .EXIT
        EXTRD,U %r29,31,32,%r28 ;offset 0xc
	.PROCEND	;in=25;out=28,29;fpin=105;
	.EXPORT	foo,ENTRY,PRIV_LEV=3,ARGW0=GR,ARGW1=GR,RTNVAL=GR,LONG_RETURN
	.END

As can be seen, the generated code uses 64-bit registers.  Although
I don't have access to a machine with a narrow PA 2.0 kernel, I believe
that this code should work on it.  Thus, all PA 2.0 kernels running
hpux must save the full 64 bits in each register.  See machine/save_state.h.

The hpux PA 2.0 state treatment differs from parisc-linux.  It appears
to only save the full 64 bits when __LP64__ is defined (64-bit kernel).
See the defines for LDREG and STREG in asm/assembly.h.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)


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