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/reg.h>
3120c1c355SRod Evans #include <sys/machelf.h>
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate #include "rdb.h"
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate static void
disp_reg_line(struct ps_prochandle * ph,pstatus_t * prst,char * r1,int ind1,char * r2,int ind2)3620c1c355SRod Evans disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
3720c1c355SRod Evans char *r2, int ind2)
387c478bd9Sstevel@tonic-gate {
3920c1c355SRod Evans char str1[MAXPATHLEN], str2[MAXPATHLEN];
407c478bd9Sstevel@tonic-gate
4120c1c355SRod Evans (void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
4220c1c355SRod Evans FLG_PAP_NOHEXNAME));
437c478bd9Sstevel@tonic-gate
4420c1c355SRod Evans (void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
4520c1c355SRod Evans FLG_PAP_NOHEXNAME));
4620c1c355SRod Evans
4720c1c355SRod Evans (void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
4820c1c355SRod Evans EC_WORD(prst->pr_lwp.pr_reg[ind1]), str1, r2,
4920c1c355SRod Evans EC_WORD(prst->pr_lwp.pr_reg[ind2]), str2);
5020c1c355SRod Evans }
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate retc_t
display_all_regs(struct ps_prochandle * ph)537c478bd9Sstevel@tonic-gate display_all_regs(struct ps_prochandle *ph)
547c478bd9Sstevel@tonic-gate {
557c478bd9Sstevel@tonic-gate pstatus_t pstatus;
5620c1c355SRod Evans
577c478bd9Sstevel@tonic-gate if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
587c478bd9Sstevel@tonic-gate 0) == -1) {
597c478bd9Sstevel@tonic-gate perror("dar: reading status");
607c478bd9Sstevel@tonic-gate return (RET_FAILED);
617c478bd9Sstevel@tonic-gate }
6220c1c355SRod Evans (void) printf("registers:\n");
637c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "gs", REG_GS, "fs", REG_FS);
647c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "es", REG_ES, "ds", REG_DS);
657c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rdi", REG_RDI, "rsi", REG_RSI);
667c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rbp", REG_RBP, "rsp", REG_RSP);
677c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rbx", REG_RBX, "rdx", REG_RDX);
687c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rcx", REG_RCX, "rax", REG_RAX);
697c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "trapno", REG_TRAPNO, "err", REG_ERR);
707c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rip", REG_RIP, "cs", REG_CS);
717c478bd9Sstevel@tonic-gate disp_reg_line(ph, &pstatus, "rfl", REG_RFL, "uesp", REG_RSP);
727c478bd9Sstevel@tonic-gate return (RET_OK);
737c478bd9Sstevel@tonic-gate }
74