regs.c revision 20c1c3551cb3b3117591ae38463d16aada597c48
2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#include <stdio.h>
2N/A#include <unistd.h>
2N/A#include <string.h>
2N/A#include <sys/param.h>
2N/A#include <sys/reg.h>
2N/A#include <sys/machelf.h>
2N/A
2N/A#include "rdb.h"
2N/A
2N/Astatic void
2N/Adisp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1,
2N/A char *r2, int ind2)
2N/A{
2N/A char str1[MAXPATHLEN], str2[MAXPATHLEN];
(void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1],
FLG_PAP_NOHEXNAME));
(void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2],
FLG_PAP_NOHEXNAME));
(void) printf("%8s: 0x%08x %-16s %8s: 0x%08x %-16s\n", r1,
EC_WORD(prst->pr_lwp.pr_reg[ind1]), str1, r2,
EC_WORD(prst->pr_lwp.pr_reg[ind2]), str2);
}
retc_t
display_all_regs(struct ps_prochandle *ph)
{
pstatus_t pstatus;
if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus),
0) == -1) {
perror("dar: reading status");
return (RET_FAILED);
}
(void) printf("registers:\n");
disp_reg_line(ph, &pstatus, "gs", REG_GS, "fs", REG_FS);
disp_reg_line(ph, &pstatus, "es", REG_ES, "ds", REG_DS);
disp_reg_line(ph, &pstatus, "rdi", REG_RDI, "rsi", REG_RSI);
disp_reg_line(ph, &pstatus, "rbp", REG_RBP, "rsp", REG_RSP);
disp_reg_line(ph, &pstatus, "rbx", REG_RBX, "rdx", REG_RDX);
disp_reg_line(ph, &pstatus, "rcx", REG_RCX, "rax", REG_RAX);
disp_reg_line(ph, &pstatus, "trapno", REG_TRAPNO, "err", REG_ERR);
disp_reg_line(ph, &pstatus, "rip", REG_RIP, "cs", REG_CS);
disp_reg_line(ph, &pstatus, "rfl", REG_RFL, "uesp", REG_RSP);
return (RET_OK);
}