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 #include <sys/regset.h>
317c478bd9Sstevel@tonic-gate
327c478bd9Sstevel@tonic-gate #include "rdb.h"
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate static void
disp_reg_line(struct ps_prochandle * ph,pstatus_t * prst,char * r1,int ind1,char * r2,int ind2)3520c1c355SRod Evans disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
3620c1c355SRod Evans char *r2, int ind2)
377c478bd9Sstevel@tonic-gate {
3820c1c355SRod Evans char str1[MAXPATHLEN], str2[MAXPATHLEN];
397c478bd9Sstevel@tonic-gate
4020c1c355SRod Evans (void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
4120c1c355SRod Evans FLG_PAP_NOHEXNAME));
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);
4820c1c355SRod Evans }
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate retc_t
display_all_regs(struct ps_prochandle * ph)517c478bd9Sstevel@tonic-gate display_all_regs(struct ps_prochandle *ph)
527c478bd9Sstevel@tonic-gate {
537c478bd9Sstevel@tonic-gate pstatus_t pstatus;
5420c1c355SRod Evans
557c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
567c478bd9Sstevel@tonic-gate 0) == -1) {
577c478bd9Sstevel@tonic-gate perror("dar: reading status");
587c478bd9Sstevel@tonic-gate return (RET_FAILED);
597c478bd9Sstevel@tonic-gate }
6020c1c355SRod Evans (void) printf("registers:\n");
617c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "gs", GS, "fs", FS);
627c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "es", ES, "ds", DS);
637c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "edi", EDI, "esi", ESI);
647c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "ebp", EBP, "esp", ESP);
657c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "ebx", EBX, "edx", EDX);
667c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "ecx", ECX, "eax", EAX);
677c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "trapno", TRAPNO, "err", ERR);
687c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "eip", EIP, "cs", CS);
697c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "efl", EFL, "uesp", UESP);
707c478bd9Sstevel@tonic-gate return (RET_OK);
717c478bd9Sstevel@tonic-gate }
72