17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
520c1c355SRod Evans * Common Development and Distribution License (the "License").
620c1c355SRod Evans * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
2120c1c355SRod Evans
227c478bd9Sstevel@tonic-gate /*
2320c1c355SRod Evans * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <stdio.h>
277c478bd9Sstevel@tonic-gate #include <unistd.h>
287c478bd9Sstevel@tonic-gate #include <string.h>
297c478bd9Sstevel@tonic-gate #include <sys/param.h>
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate #include "rdb.h"
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate static void
disp_reg_line(struct ps_prochandle * ph,pstatus_t * prst,char * r1,int ind1,char * r2,int ind2)3420c1c355SRod Evans disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
3520c1c355SRod Evans char *r2, int ind2)
367c478bd9Sstevel@tonic-gate {
3720c1c355SRod Evans char str1[MAXPATHLEN], str2[MAXPATHLEN];
387c478bd9Sstevel@tonic-gate
3920c1c355SRod Evans (void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
4020c1c355SRod Evans FLG_PAP_NOHEXNAME));
417c478bd9Sstevel@tonic-gate
4220c1c355SRod Evans (void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
4320c1c355SRod Evans FLG_PAP_NOHEXNAME));
447c478bd9Sstevel@tonic-gate
4520c1c355SRod Evans (void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
4620c1c355SRod Evans prst->pr_lwp.pr_reg[ind1], str1, r2, prst->pr_lwp.pr_reg[ind2],
4720c1c355SRod Evans str2);
487c478bd9Sstevel@tonic-gate }
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate void
display_local_regs(struct ps_prochandle * ph,pstatus_t * prst)5120c1c355SRod Evans display_local_regs(struct ps_prochandle *ph, pstatus_t *prst)
527c478bd9Sstevel@tonic-gate {
537c478bd9Sstevel@tonic-gate pstatus_t pstatus;
547c478bd9Sstevel@tonic-gate
5520c1c355SRod Evans if (prst == NULL) {
567c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
577c478bd9Sstevel@tonic-gate 0) == -1) {
587c478bd9Sstevel@tonic-gate perror("dlr: reading status");
597c478bd9Sstevel@tonic-gate return;
607c478bd9Sstevel@tonic-gate }
617c478bd9Sstevel@tonic-gate prst = &pstatus;
627c478bd9Sstevel@tonic-gate }
6320c1c355SRod Evans (void) printf("locals:\n");
647c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4);
657c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5);
667c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6);
677c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7);
687c478bd9Sstevel@tonic-gate }
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate void
display_out_regs(struct ps_prochandle * ph,pstatus_t * prst)7120c1c355SRod Evans display_out_regs(struct ps_prochandle *ph, pstatus_t *prst)
727c478bd9Sstevel@tonic-gate {
737c478bd9Sstevel@tonic-gate pstatus_t pstatus;
747c478bd9Sstevel@tonic-gate
7520c1c355SRod Evans if (prst == NULL) {
767c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
777c478bd9Sstevel@tonic-gate 0) == -1) {
787c478bd9Sstevel@tonic-gate perror("dor: reading status");
797c478bd9Sstevel@tonic-gate return;
807c478bd9Sstevel@tonic-gate }
817c478bd9Sstevel@tonic-gate prst = &pstatus;
827c478bd9Sstevel@tonic-gate }
8320c1c355SRod Evans (void) printf("outs:\n");
847c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4);
857c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5);
867c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6);
877c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7);
887c478bd9Sstevel@tonic-gate }
897c478bd9Sstevel@tonic-gate
907c478bd9Sstevel@tonic-gate void
display_special_regs(struct ps_prochandle * ph,pstatus_t * prst)9120c1c355SRod Evans display_special_regs(struct ps_prochandle *ph, pstatus_t *prst)
927c478bd9Sstevel@tonic-gate {
937c478bd9Sstevel@tonic-gate pstatus_t pstatus;
947c478bd9Sstevel@tonic-gate
9520c1c355SRod Evans if (prst == NULL) {
967c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
977c478bd9Sstevel@tonic-gate 0) == -1) {
987c478bd9Sstevel@tonic-gate perror("dsr: reading status");
997c478bd9Sstevel@tonic-gate return;
1007c478bd9Sstevel@tonic-gate }
1017c478bd9Sstevel@tonic-gate prst = &pstatus;
1027c478bd9Sstevel@tonic-gate }
10320c1c355SRod Evans (void) printf("specials:\n");
1047c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC);
1057c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y);
1067c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR);
1077c478bd9Sstevel@tonic-gate }
1087c478bd9Sstevel@tonic-gate
1097c478bd9Sstevel@tonic-gate void
display_global_regs(struct ps_prochandle * ph,pstatus_t * prst)11020c1c355SRod Evans display_global_regs(struct ps_prochandle *ph, pstatus_t *prst)
1117c478bd9Sstevel@tonic-gate {
1127c478bd9Sstevel@tonic-gate pstatus_t pstatus;
1137c478bd9Sstevel@tonic-gate
11420c1c355SRod Evans if (prst == NULL) {
1157c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
1167c478bd9Sstevel@tonic-gate 0) == -1) {
1177c478bd9Sstevel@tonic-gate perror("dgr: reading status");
1187c478bd9Sstevel@tonic-gate return;
1197c478bd9Sstevel@tonic-gate }
1207c478bd9Sstevel@tonic-gate prst = &pstatus;
1217c478bd9Sstevel@tonic-gate }
12220c1c355SRod Evans (void) printf("globals:\n");
1237c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4);
1247c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5);
1257c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6);
1267c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7);
1277c478bd9Sstevel@tonic-gate }
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gate void
display_in_regs(struct ps_prochandle * ph,pstatus_t * prst)13020c1c355SRod Evans display_in_regs(struct ps_prochandle *ph, pstatus_t *prst)
1317c478bd9Sstevel@tonic-gate {
1327c478bd9Sstevel@tonic-gate pstatus_t pstatus;
1337c478bd9Sstevel@tonic-gate
13420c1c355SRod Evans if (prst == NULL) {
1357c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
1367c478bd9Sstevel@tonic-gate 0) == -1) {
1377c478bd9Sstevel@tonic-gate perror("dir: reading status");
1387c478bd9Sstevel@tonic-gate return;
1397c478bd9Sstevel@tonic-gate }
1407c478bd9Sstevel@tonic-gate prst = &pstatus;
1417c478bd9Sstevel@tonic-gate }
14220c1c355SRod Evans (void) printf("ins:\n");
1437c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4);
1447c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5);
1457c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6);
1467c478bd9Sstevel@tonic-gate disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7);
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate }
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate retc_t
display_all_regs(struct ps_prochandle * ph)15120c1c355SRod Evans display_all_regs(struct ps_prochandle *ph)
1527c478bd9Sstevel@tonic-gate {
1537c478bd9Sstevel@tonic-gate pstatus_t pstatus;
1547c478bd9Sstevel@tonic-gate
1557c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
1567c478bd9Sstevel@tonic-gate 0) == -1) {
1577c478bd9Sstevel@tonic-gate perror("dar: reading status");
1587c478bd9Sstevel@tonic-gate return (RET_FAILED);
1597c478bd9Sstevel@tonic-gate }
1607c478bd9Sstevel@tonic-gate display_global_regs(ph, &pstatus);
1617c478bd9Sstevel@tonic-gate display_in_regs(ph, &pstatus);
1627c478bd9Sstevel@tonic-gate display_local_regs(ph, &pstatus);
1637c478bd9Sstevel@tonic-gate display_out_regs(ph, &pstatus);
1647c478bd9Sstevel@tonic-gate display_special_regs(ph, &pstatus);
1657c478bd9Sstevel@tonic-gate
1667c478bd9Sstevel@tonic-gate return (RET_OK);
1677c478bd9Sstevel@tonic-gate }
168