Debugging Notes
Unaligned access on Alpha
These problems are recognized by kernel messages which look something like this:
... <program>(<process-id>): unaligned trap at <addr1>: <addr2> ...
There is a small utility available called unalign.c
which runs
the offending program in GDB and breaks execution when the unaligned access
occurred. However, if this doesn't work then you can attempt to manually find
the point where the unaligned access occurred:
- Start GDB and load the offending program.
- Run the program and terminate it.
- Check the process ID of your program as it was in GDB and check the kernel messages for unaligned traps of that process.
- Use
addr1
of the "unaligned trap" message to find the source line:
This will print the file and line number where the unaligned access occurred as well as a piece of the related source code.list *0x<addr1>
Alternatively, you can use GDB's disassemble
command combined with
its /m
switch:
This will output assembly code interspersed with source code of the program. It
will output all code of the function where the unaligned access occurred, so
you need check which instruction/statement corresponds to
disassemble /m 0x<addr1>
addr1
.
More information on unaligned access can be found in Gentoo's Porting Guide.