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