Mercurial > illumos > illumos-gate
annotate usr/src/cmd/sgs/librtld_db/demo/sparcv9/regs.c @ 12939:a27c46eb192b
6972234 sgs demo's could use some cleanup
author | Rod Evans <Rod.Evans@Sun.COM> |
---|---|
date | Tue, 27 Jul 2010 22:49:34 -0700 |
parents | usr/src/cmd/sgs/librtld_db/rdb_demo/sparcv9/regs.c@68f95e015346 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 * CDDL HEADER START | |
3 * | |
4 * The contents of this file are subject to the terms of the | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
5 * Common Development and Distribution License (the "License"). |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
6 * You may not use this file except in compliance with the License. |
0 | 7 * |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
9 * or http://www.opensolaris.org/os/licensing. | |
10 * See the License for the specific language governing permissions | |
11 * and limitations under the License. | |
12 * | |
13 * When distributing Covered Code, include this CDDL HEADER in each | |
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
15 * If applicable, add the following below this CDDL HEADER, with the | |
16 * fields enclosed by brackets "[]" replaced with your own identifying | |
17 * information: Portions Copyright [yyyy] [name of copyright owner] | |
18 * | |
19 * CDDL HEADER END | |
20 */ | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
21 |
0 | 22 /* |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
23 * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 24 */ |
25 | |
26 #include <stdio.h> | |
27 #include <unistd.h> | |
28 #include <string.h> | |
29 #include <sys/param.h> | |
30 | |
31 #include "rdb.h" | |
32 | |
33 static void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
34 disp_reg_line(struct ps_prochandle *ph, pstatus_t *prst, char *r1, int ind1, |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
35 char *r2, int ind2) |
0 | 36 { |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
37 char str1[MAXPATHLEN], str2[MAXPATHLEN]; |
0 | 38 |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
39 (void) strcpy(str1, print_address_ps(ph, prst->pr_lwp.pr_reg[ind1], |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
40 FLG_PAP_NOHEXNAME)); |
0 | 41 |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
42 (void) strcpy(str2, print_address_ps(ph, prst->pr_lwp.pr_reg[ind2], |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
43 FLG_PAP_NOHEXNAME)); |
0 | 44 |
45 if (ph->pp_dmodel == PR_MODEL_LP64) { | |
46 /* | |
47 * In 64-bits, the display gets too wide when | |
48 * you have both a 64-bit address and a symbol | |
49 * name, e.g. _GLOBAL_OFFSET_TABLE; therefore, | |
50 * each is put on a separate line. This isn't | |
51 * as convenient as the 32-bit display. | |
52 */ | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
53 (void) printf("%8s: 0x%08lx %-16s\n", r1, |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
54 prst->pr_lwp.pr_reg[ind1], str1); |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
55 (void) printf("%8s: 0x%08lx %-16s\n", r2, |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
56 prst->pr_lwp.pr_reg[ind2], str2); |
0 | 57 } else |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
58 (void) printf("%8s: 0x%08lx %-16s %8s: 0x%08lx %-16s\n", r1, |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
59 prst->pr_lwp.pr_reg[ind1], str1, r2, |
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
60 prst->pr_lwp.pr_reg[ind2], str2); |
0 | 61 } |
62 | |
63 void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
64 display_local_regs(struct ps_prochandle *ph, pstatus_t *prst) |
0 | 65 { |
66 pstatus_t pstatus; | |
67 | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
68 if (prst == NULL) { |
0 | 69 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), |
70 0) == -1) { | |
71 perror("dar: reading status"); | |
72 return; | |
73 } | |
74 prst = &pstatus; | |
75 } | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
76 (void) printf("locals:\n"); |
0 | 77 disp_reg_line(ph, prst, "l0", R_L0, "l4", R_L4); |
78 disp_reg_line(ph, prst, "l1", R_L1, "l5", R_L5); | |
79 disp_reg_line(ph, prst, "l2", R_L2, "l6", R_L6); | |
80 disp_reg_line(ph, prst, "l3", R_L3, "l7", R_L7); | |
81 } | |
82 | |
83 void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
84 display_out_regs(struct ps_prochandle *ph, pstatus_t *prst) |
0 | 85 { |
86 pstatus_t pstatus; | |
87 | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
88 if (prst == NULL) { |
0 | 89 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), |
90 0) == -1) { | |
91 perror("dar: reading status"); | |
92 return; | |
93 } | |
94 prst = &pstatus; | |
95 } | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
96 (void) printf("outs:\n"); |
0 | 97 disp_reg_line(ph, prst, "o0", R_O0, "o4", R_O4); |
98 disp_reg_line(ph, prst, "o1", R_O1, "o5", R_O5); | |
99 disp_reg_line(ph, prst, "o2", R_O2, "o6(sp)", R_O6); | |
100 disp_reg_line(ph, prst, "o3", R_O3, "o7", R_O7); | |
101 } | |
102 | |
103 void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
104 display_special_regs(struct ps_prochandle *ph, pstatus_t *prst) |
0 | 105 { |
106 pstatus_t pstatus; | |
107 | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
108 if (prst == NULL) { |
0 | 109 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), |
110 0) == -1) { | |
111 perror("dar: reading status"); | |
112 return; | |
113 } | |
114 prst = &pstatus; | |
115 } | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
116 (void) printf("specials:\n"); |
0 | 117 if (ph->pp_dmodel == PR_MODEL_LP64) { |
118 disp_reg_line(ph, prst, "ccr", R_CCR, "pc", R_PC); | |
119 disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y); | |
120 disp_reg_line(ph, prst, "asi", R_ASI, "FPRS", R_FPRS); | |
121 } else { | |
122 disp_reg_line(ph, prst, "psr", R_PSR, "pc", R_PC); | |
123 disp_reg_line(ph, prst, "npc", R_nPC, "Y", R_Y); | |
124 disp_reg_line(ph, prst, "wim", R_WIM, "TBR", R_TBR); | |
125 } | |
126 } | |
127 | |
128 void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
129 display_global_regs(struct ps_prochandle *ph, pstatus_t *prst) |
0 | 130 { |
131 pstatus_t pstatus; | |
132 | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
133 if (prst == NULL) { |
0 | 134 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), |
135 0) == -1) { | |
136 perror("dar: reading status"); | |
137 return; | |
138 } | |
139 prst = &pstatus; | |
140 } | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
141 (void) printf("globals:\n"); |
0 | 142 disp_reg_line(ph, prst, "g0", R_G0, "g4", R_G4); |
143 disp_reg_line(ph, prst, "g1", R_G1, "g5", R_G5); | |
144 disp_reg_line(ph, prst, "g2", R_G2, "g6", R_G6); | |
145 disp_reg_line(ph, prst, "g3", R_G3, "g7", R_G7); | |
146 } | |
147 | |
148 void | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
149 display_in_regs(struct ps_prochandle *ph, pstatus_t *prst) |
0 | 150 { |
151 pstatus_t pstatus; | |
152 | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
153 if (prst == NULL) { |
0 | 154 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), |
155 0) == -1) { | |
156 perror("dar: reading status"); | |
157 return; | |
158 } | |
159 prst = &pstatus; | |
160 } | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
161 (void) printf("ins:\n"); |
0 | 162 disp_reg_line(ph, prst, "i0", R_I0, "i4", R_I4); |
163 disp_reg_line(ph, prst, "i1", R_I1, "i5", R_I5); | |
164 disp_reg_line(ph, prst, "i2", R_I2, "i6(fp)", R_I6); | |
165 disp_reg_line(ph, prst, "i3", R_I3, "i7", R_I7); | |
166 | |
167 } | |
168 | |
169 retc_t | |
12939
a27c46eb192b
6972234 sgs demo's could use some cleanup
Rod Evans <Rod.Evans@Sun.COM>
parents:
0
diff
changeset
|
170 display_all_regs(struct ps_prochandle *ph) |
0 | 171 { |
172 pstatus_t pstatus; | |
173 | |
174 if (pread(ph->pp_statusfd, &pstatus, sizeof (pstatus), | |
175 0) == -1) { | |
176 perror("dar: reading status"); | |
177 return (RET_FAILED); | |
178 } | |
179 display_global_regs(ph, &pstatus); | |
180 display_in_regs(ph, &pstatus); | |
181 display_local_regs(ph, &pstatus); | |
182 display_out_regs(ph, &pstatus); | |
183 display_special_regs(ph, &pstatus); | |
184 | |
185 return (RET_OK); | |
186 } |