Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <rth@dot.cygnus.com>
To: Gene McCulley <mcculley@cuspy.com>
Cc: Richard Henderson <rth@cygnus.com>, axp-list@redhat.com
Subject: Re: tracking down unaligned accesses
Date: Mon, 6 Apr 1998 20:38:02 -0700	[thread overview]
Message-ID: <19980406203802.33715@dot.cygnus.com> (raw)
In-Reply-To: <13609.39173.90817.201628@coral.cuspy.com>; from Gene McCulley on Mon, Apr 06, 1998 at 11:15:14PM -0400

[-- Attachment #1: Type: text/plain, Size: 875 bytes --]

[ CC'ed to axp-list because of general interest. ]

On Mon, Apr 06, 1998 at 11:15:14PM -0400, Gene McCulley wrote:
> I am currently porting a large (1.6 million lines of code) application
> to the Alpha.  It has worked previously with the -taso stuff, but now
> I am making it 64-bit clean and eliminating all of the sizeof(void *)
> assumptions.  I am working under Digital Unix, but this step was
> necessary so that we can move to Linux/Alpha.
> 
> I am getting the unaligned access messages:
> Unaligned access pid=5293 <sim> va=0x1420f365c pc=0x1207ac030 ra=0x1207abff4 inst=0xb54c0000
> 
> Is there a way to trap these in the debugger or some other way to
> facilitate finding these?

The following will tell both Digital Unix and Linux (post 2.1.20 or so)
to deliver a SIGBUS rather than fix up the access.  This makes the 
problem significantly easier to debug.


r~

[-- Attachment #2: unaligned.c --]
[-- Type: text/plain, Size: 596 bytes --]

#ifndef __linux__
#include <sys/sysinfo.h>
#else
#include <asm/sysinfo.h>
#include <asm/unistd.h>

static int setsysinfo(unsigned long op, void *buffer, unsigned long size,
		      int *start, void *arg, unsigned long flag)
{
  syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
}
#endif

void trap_unaligned(void)
{
  unsigned int buf[2];
  buf[0] = SSIN_UACPROC;
  buf[1] = UAC_SIGBUS | UAC_NOPRINT;
  setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
}

#ifdef TEST
static int tmp[2];
int main(int ac)
{
  if (ac > 1) 
    trap_unaligned();
  return *(int *)((char *)tmp + 1);
}
#endif

       reply	other threads:[~1998-04-07  3:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <13609.39173.90817.201628@coral.cuspy.com>
1998-04-07  3:38 ` Richard Henderson [this message]
1998-04-07  7:30   ` tracking down unaligned accesses Thomas Leitner
1998-04-07  9:55     ` Richard Henderson
1998-04-07 10:00       ` Thomas Leitner
1998-04-07 12:24   ` Stefan Traby
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox