|
Packit Service |
82fcde |
/* Dump registers.
|
|
Packit Service |
82fcde |
Copyright (C) 1998-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sys/uio.h>
|
|
Packit Service |
82fcde |
#include <_itoa.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* This prints out the information in the following form: */
|
|
Packit Service |
82fcde |
static const char dumpform[] = "\
|
|
Packit Service |
82fcde |
Register dump:\n\
|
|
Packit Service |
82fcde |
fp0-3: 0000030%0000031% 0000032%0000033% 0000034%0000035% 0000036%0000037%\n\
|
|
Packit Service |
82fcde |
fp4-7: 0000038%0000039% 000003a%000003b% 000003c%000003d% 000003e%000003f%\n\
|
|
Packit Service |
82fcde |
fp8-11: 0000040%0000041% 0000042%0000043% 0000044%0000045% 0000046%0000047%\n\
|
|
Packit Service |
82fcde |
fp12-15: 0000048%0000049% 000004a%000004b% 000004c%000004d% 000004e%000004f%\n\
|
|
Packit Service |
82fcde |
fp16-19: 0000050%0000051% 0000052%0000053% 0000054%0000055% 0000056%0000057%\n\
|
|
Packit Service |
82fcde |
fp20-23: 0000058%0000059% 000005a%000005b% 000005c%000005d% 000005e%000005f%\n\
|
|
Packit Service |
82fcde |
fp24-27: 0000060%0000061% 0000062%0000063% 0000064%0000065% 0000066%0000067%\n\
|
|
Packit Service |
82fcde |
fp28-31: 0000068%0000069% 000006a%000006b% 000006c%000006d% 000006e%000006f%\n\
|
|
Packit Service |
82fcde |
r0 =0000000% sp =0000001% r2 =0000002% r3 =0000003% trap=0000028%\n\
|
|
Packit Service |
82fcde |
r4 =0000004% r5 =0000005% r6 =0000006% r7 =0000007% sr0=0000020% sr1=0000021%\n\
|
|
Packit Service |
82fcde |
r8 =0000008% r9 =0000009% r10=000000a% r11=000000b% dar=0000029% dsi=000002a%\n\
|
|
Packit Service |
82fcde |
r12=000000c% r13=000000d% r14=000000e% r15=000000f% r3*=0000022%\n\
|
|
Packit Service |
82fcde |
r16=0000010% r17=0000011% r18=0000012% r19=0000013%\n\
|
|
Packit Service |
82fcde |
r20=0000014% r21=0000015% r22=0000016% r23=0000017% lr=0000024% xer=0000025%\n\
|
|
Packit Service |
82fcde |
r24=0000018% r25=0000019% r26=000001a% r27=000001b% mq=0000027% ctr=0000023%\n\
|
|
Packit Service |
82fcde |
r28=000001c% r29=000001d% r30=000001e% r31=000001f% fscr=0000071% ccr=0000026%\n\
|
|
Packit Service |
82fcde |
";
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Most of the fields are self-explanatory. 'sr0' is the next
|
|
Packit Service |
82fcde |
instruction to execute, from SRR0, which may have some relationship
|
|
Packit Service |
82fcde |
with the instruction that caused the exception. 'r3*' is the value
|
|
Packit Service |
82fcde |
that will be returned in register 3 when the current system call
|
|
Packit Service |
82fcde |
returns. 'sr1' is SRR1, bits 16-31 of which are copied from the MSR:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
16 - External interrupt enable
|
|
Packit Service |
82fcde |
17 - Privilege level (1=user, 0=supervisor)
|
|
Packit Service |
82fcde |
18 - FP available
|
|
Packit Service |
82fcde |
19 - Machine check enable (if clear, processor locks up on machine check)
|
|
Packit Service |
82fcde |
20 - FP exception mode bit 0 (FP exceptions recoverable)
|
|
Packit Service |
82fcde |
21 - Single-step trace enable
|
|
Packit Service |
82fcde |
22 - Branch trace enable
|
|
Packit Service |
82fcde |
23 - FP exception mode bit 1
|
|
Packit Service |
82fcde |
25 - exception prefix (if set, exceptions are taken from 0xFFFnnnnn,
|
|
Packit Service |
82fcde |
otherwise from 0x000nnnnn).
|
|
Packit Service |
82fcde |
26 - Instruction address translation enabled.
|
|
Packit Service |
82fcde |
27 - Data address translation enabled.
|
|
Packit Service |
82fcde |
30 - Exception is recoverable (otherwise, don't try to return).
|
|
Packit Service |
82fcde |
31 - Little-endian mode enable.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
'Trap' is the address of the exception:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
00200 - Machine check exception (memory parity error, for instance)
|
|
Packit Service |
82fcde |
00300 - Data access exception (memory not mapped, see dsisr for why)
|
|
Packit Service |
82fcde |
00400 - Instruction access exception (memory not mapped)
|
|
Packit Service |
82fcde |
00500 - External interrupt
|
|
Packit Service |
82fcde |
00600 - Alignment exception (see dsisr for more information)
|
|
Packit Service |
82fcde |
00700 - Program exception (illegal/trap instruction, FP exception)
|
|
Packit Service |
82fcde |
00800 - FP unavailable (should not be seen by user code)
|
|
Packit Service |
82fcde |
00900 - Decrementer exception (for instance, SIGALRM)
|
|
Packit Service |
82fcde |
00A00 - I/O controller interface exception
|
|
Packit Service |
82fcde |
00C00 - System call exception (for instance, kill(3)).
|
|
Packit Service |
82fcde |
00E00 - FP assist exception (optional FP instructions, etc.)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
'dar' is the memory location, for traps 00300, 00400, 00600, 00A00.
|
|
Packit Service |
82fcde |
'dsisr' has the following bits under trap 00300:
|
|
Packit Service |
82fcde |
0 - direct-store error exception
|
|
Packit Service |
82fcde |
1 - no page table entry for page
|
|
Packit Service |
82fcde |
4 - memory access not permitted
|
|
Packit Service |
82fcde |
5 - trying to access I/O controller space or using lwarx/stwcx on
|
|
Packit Service |
82fcde |
non-write-cached memory
|
|
Packit Service |
82fcde |
6 - access was store
|
|
Packit Service |
82fcde |
9 - data access breakpoint hit
|
|
Packit Service |
82fcde |
10 - segment table search failed to find translation (64-bit ppcs only)
|
|
Packit Service |
82fcde |
11 - I/O controller instruction not permitted
|
|
Packit Service |
82fcde |
For trap 00400, the same bits are set in SRR1 instead.
|
|
Packit Service |
82fcde |
For trap 00600, bits 12-31 of the DSISR set to allow emulation of
|
|
Packit Service |
82fcde |
the instruction without actually having to read it from memory.
|
|
Packit Service |
82fcde |
*/
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define xtoi(x) (x >= 'a' ? x + 10 - 'a' : x - '0')
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static void
|
|
Packit Service |
82fcde |
register_dump (int fd, struct sigcontext *ctx)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
char buffer[sizeof(dumpform)];
|
|
Packit Service |
82fcde |
char *bufferpos;
|
|
Packit Service |
82fcde |
unsigned regno;
|
|
Packit Service |
82fcde |
unsigned *regs = (unsigned *)(ctx->regs);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
memcpy(buffer, dumpform, sizeof(dumpform));
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Generate the output. */
|
|
Packit Service |
82fcde |
while ((bufferpos = memchr (buffer, '%', sizeof(dumpform))))
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
regno = xtoi (bufferpos[-1]) | xtoi (bufferpos[-2]) << 4;
|
|
Packit Service |
82fcde |
memset (bufferpos-2, '0', 3);
|
|
Packit Service |
82fcde |
_itoa_word (regs[regno], bufferpos+1, 16, 0);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Write the output. */
|
|
Packit Service |
82fcde |
write (fd, buffer, sizeof(buffer) - 1);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define REGISTER_DUMP \
|
|
Packit Service |
82fcde |
register_dump (fd, ctx)
|