1*d9328cd4SRobert Mustacchi /*
2*d9328cd4SRobert Mustacchi * CDDL HEADER START
3*d9328cd4SRobert Mustacchi *
4*d9328cd4SRobert Mustacchi * The contents of this file are subject to the terms of the
5*d9328cd4SRobert Mustacchi * Common Development and Distribution License (the "License").
6*d9328cd4SRobert Mustacchi * You may not use this file except in compliance with the License.
7*d9328cd4SRobert Mustacchi *
8*d9328cd4SRobert Mustacchi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*d9328cd4SRobert Mustacchi * or http://www.opensolaris.org/os/licensing.
10*d9328cd4SRobert Mustacchi * See the License for the specific language governing permissions
11*d9328cd4SRobert Mustacchi * and limitations under the License.
12*d9328cd4SRobert Mustacchi *
13*d9328cd4SRobert Mustacchi * When distributing Covered Code, include this CDDL HEADER in each
14*d9328cd4SRobert Mustacchi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*d9328cd4SRobert Mustacchi * If applicable, add the following below this CDDL HEADER, with the
16*d9328cd4SRobert Mustacchi * fields enclosed by brackets "[]" replaced with your own identifying
17*d9328cd4SRobert Mustacchi * information: Portions Copyright [yyyy] [name of copyright owner]
18*d9328cd4SRobert Mustacchi *
19*d9328cd4SRobert Mustacchi * CDDL HEADER END
20*d9328cd4SRobert Mustacchi */
21*d9328cd4SRobert Mustacchi
22*d9328cd4SRobert Mustacchi /*
23*d9328cd4SRobert Mustacchi * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
24*d9328cd4SRobert Mustacchi */
25*d9328cd4SRobert Mustacchi
26*d9328cd4SRobert Mustacchi #include <stdio.h>
27*d9328cd4SRobert Mustacchi #include <unistd.h>
28*d9328cd4SRobert Mustacchi #include <string.h>
29*d9328cd4SRobert Mustacchi #include <sys/param.h>
30*d9328cd4SRobert Mustacchi #include <sys/reg.h>
31*d9328cd4SRobert Mustacchi #include <sys/machelf.h>
32*d9328cd4SRobert Mustacchi
33*d9328cd4SRobert Mustacchi #include "rdb.h"
34*d9328cd4SRobert Mustacchi
35*d9328cd4SRobert Mustacchi static void
disp_reg_line(struct ps_prochandle * ph,pstatus_t * prst,char * r1,int ind1,char * r2,int ind2)36*d9328cd4SRobert Mustacchi disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
37*d9328cd4SRobert Mustacchi char *r2, int ind2)
38*d9328cd4SRobert Mustacchi {
39*d9328cd4SRobert Mustacchi char str1[MAXPATHLEN], str2[MAXPATHLEN];
40*d9328cd4SRobert Mustacchi
41*d9328cd4SRobert Mustacchi (void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
42*d9328cd4SRobert Mustacchi FLG_PAP_NOHEXNAME));
43*d9328cd4SRobert Mustacchi
44*d9328cd4SRobert Mustacchi (void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
45*d9328cd4SRobert Mustacchi FLG_PAP_NOHEXNAME));
46*d9328cd4SRobert Mustacchi
47*d9328cd4SRobert Mustacchi (void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
48*d9328cd4SRobert Mustacchi EC_WORD(prst->pr_lwp.pr_reg[ind1]), str1, r2,
49*d9328cd4SRobert Mustacchi EC_WORD(prst->pr_lwp.pr_reg[ind2]), str2);
50*d9328cd4SRobert Mustacchi }
51*d9328cd4SRobert Mustacchi
52*d9328cd4SRobert Mustacchi retc_t
display_all_regs(struct ps_prochandle * ph)53*d9328cd4SRobert Mustacchi display_all_regs(struct ps_prochandle *ph)
54*d9328cd4SRobert Mustacchi {
55*d9328cd4SRobert Mustacchi pstatus_t pstatus;
56*d9328cd4SRobert Mustacchi
57*d9328cd4SRobert Mustacchi if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
58*d9328cd4SRobert Mustacchi 0) == -1) {
59*d9328cd4SRobert Mustacchi perror("dar: reading status");
60*d9328cd4SRobert Mustacchi return (RET_FAILED);
61*d9328cd4SRobert Mustacchi }
62*d9328cd4SRobert Mustacchi (void) printf("registers:\n");
63*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "gs", REG_GS, "fs", REG_FS);
64*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "es", REG_ES, "ds", REG_DS);
65*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rdi", REG_RDI, "rsi", REG_RSI);
66*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rbp", REG_RBP, "rsp", REG_RSP);
67*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rbx", REG_RBX, "rdx", REG_RDX);
68*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rcx", REG_RCX, "rax", REG_RAX);
69*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "trapno", REG_TRAPNO, "err", REG_ERR);
70*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rip", REG_RIP, "cs", REG_CS);
71*d9328cd4SRobert Mustacchi disp_reg_line(ph, &pstatus, "rfl", REG_RFL, "uesp", REG_RSP);
72*d9328cd4SRobert Mustacchi return (RET_OK);
73*d9328cd4SRobert Mustacchi }
74