2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
34 tic80_index2cr (int index
)
38 case 0x0000: return EPC_CR
;
39 case 0x0001: return EIP_CR
;
40 case 0x0002: return CONFIG_CR
;
41 case 0x0004: return INTPEN_CR
;
42 case 0x0006: return IE_CR
;
43 case 0x0008: return FPST_CR
;
44 case 0x000A: return PPERROR_CR
;
45 case 0x000D: return PKTREQ_CR
;
46 case 0x000E: return TCOUNT_CR
;
47 case 0x000F: return TSCALE_CR
;
48 case 0x0010: return FLTOP_CR
;
49 case 0x0011: return FLTADR_CR
;
50 case 0x0012: return FLTTAG_CR
;
51 case 0x0013: return FLTDLT_CR
;
52 case 0x0014: return FLTDTH_CR
;
53 case 0x0015: return FLT005_CR
;
54 case 0x0016: return FLT006_CR
;
55 case 0x0017: return FLT007_CR
;
56 case 0x0018: return FLT008_CR
;
57 case 0x0019: return FLT009_CR
;
58 case 0x001a: return FLT010_CR
;
59 case 0x001b: return FLT011_CR
;
60 case 0x001c: return FLT012_CR
;
61 case 0x001d: return FLT013_CR
;
62 case 0x001e: return FLT014_CR
;
63 case 0x001f: return FLT015_CR
;
64 case 0x0020: return SYSSTK_CR
;
65 case 0x0021: return SYSTMP_CR
;
66 case 0x0030: return MPC_CR
;
67 case 0x0031: return MIP_CR
;
68 case 0x0033: return ECOMCNTL_CR
;
69 case 0x0034: return ANASTAT_CR
;
70 case 0x0039: return BRK1_CR
;
71 case 0x003A: return BRK2_CR
;
72 case 0x0200: return ITAG0_CR
;
73 case 0x0201: return ITAG1_CR
;
74 case 0x0202: return ITAG2_CR
;
75 case 0x0203: return ITAG3_CR
;
76 case 0x0204: return ITAG4_CR
;
77 case 0x0205: return ITAG5_CR
;
78 case 0x0206: return ITAG6_CR
;
79 case 0x0207: return ITAG7_CR
;
80 case 0x0208: return ITAG8_CR
;
81 case 0x0209: return ITAG9_CR
;
82 case 0x020a: return ITAG10_CR
;
83 case 0x020b: return ITAG11_CR
;
84 case 0x020c: return ITAG12_CR
;
85 case 0x020d: return ITAG13_CR
;
86 case 0x020e: return ITAG14_CR
;
87 case 0x020f: return ITAG15_CR
;
88 case 0x0300: return ILRU_CR
;
89 case 0x0400: return DTAG0_CR
;
90 case 0x0401: return DTAG1_CR
;
91 case 0x0402: return DTAG2_CR
;
92 case 0x0403: return DTAG3_CR
;
93 case 0x0404: return DTAG4_CR
;
94 case 0x0405: return DTAG5_CR
;
95 case 0x0406: return DTAG6_CR
;
96 case 0x0407: return DTAG7_CR
;
97 case 0x0408: return DTAG8_CR
;
98 case 0x0409: return DTAG9_CR
;
99 case 0x040a: return DTAG10_CR
;
100 case 0x040b: return DTAG11_CR
;
101 case 0x040c: return DTAG12_CR
;
102 case 0x040d: return DTAG13_CR
;
103 case 0x040e: return DTAG14_CR
;
104 case 0x040f: return DTAG15_CR
;
105 case 0x0500: return DLRU_CR
;
106 case 0x4000: return IN0P_CR
;
107 case 0x4001: return IN1P_CR
;
108 case 0x4002: return OUTP_CR
;
109 default: return SCRATCH_CR
;
115 #if defined(WITH_TRACE)
116 /* Tracing support routines */
118 static char tic80_trace_buffer
[1024];
119 static int tic80_size_name
;
122 #define SIZE_DECIMAL 11
124 /* Initialize tracing by calculating the maximum name size */
126 tic80_init_trace (void)
129 int len
, max_len
= 0;
131 for (i
= 0; i
< (int)nr_itable_entries
; i
++) {
132 len
= strlen (itable
[i
].name
);
137 tic80_size_name
= max_len
+ sizeof(":m") - 1 + sizeof (":s") - 1;
140 /* Trace the result of an ALU operation with 2 integer inputs and an integer output */
142 tic80_trace_alu3 (int indx
,
147 if (!tic80_size_name
)
150 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld 0x%.*lx/%*ld => 0x%.*lx/%*ld",
151 tic80_size_name
, itable
[indx
].name
,
152 SIZE_HEX
, input1
, SIZE_DECIMAL
, (long)(signed32
)input1
,
153 SIZE_HEX
, input2
, SIZE_DECIMAL
, (long)(signed32
)input2
,
154 SIZE_HEX
, result
, SIZE_DECIMAL
, (long)(signed32
)result
);
156 return tic80_trace_buffer
;
159 /* Trace the result of an ALU operation with 1 integer input and an integer output */
161 tic80_trace_alu2 (int indx
,
165 if (!tic80_size_name
)
168 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld %*s => 0x%.*lx/%*ld",
169 tic80_size_name
, itable
[indx
].name
,
170 SIZE_HEX
, input
, SIZE_DECIMAL
, (long)(signed32
)input
,
171 SIZE_HEX
+ SIZE_DECIMAL
+ 3, "",
172 SIZE_HEX
, result
, SIZE_DECIMAL
, (long)(signed32
)result
);
174 return tic80_trace_buffer
;
177 /* Trace the result of a shift instruction */
179 tic80_trace_shift (int indx
,
188 const char *merge_name
;
192 if (!tic80_size_name
)
197 default: merge_name
= ".??"; break;
198 case 0: merge_name
= ".dz"; break;
199 case 1: merge_name
= ".dm"; break;
200 case 2: merge_name
= ".ds"; break;
201 case 3: merge_name
= ".ez"; break;
202 case 4: merge_name
= ".em"; break;
203 case 5: merge_name
= ".es"; break;
204 case 6: merge_name
= ".iz"; break;
205 case 7: merge_name
= ".im"; break;
208 /* Don't use itable[indx].name, which is just sl {r,i}. Instead reconstruct
209 the name, using the i and n fields. */
210 p
= strchr (itable
[indx
].name
, ' ');
211 sprintf (name
, "s%s%s%s%s",
217 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld %*s%2d,%2d => 0x%.*lx/%*ld",
218 tic80_size_name
, name
,
219 SIZE_HEX
, input
, SIZE_DECIMAL
, (long)(signed32
)input
,
220 SIZE_HEX
+ SIZE_DECIMAL
- 2, "",
222 SIZE_HEX
, result
, SIZE_DECIMAL
, (long)(signed32
)result
);
224 return tic80_trace_buffer
;
227 /* Trace the result of an FPU operation with 2 floating point inputs and a floating point output */
229 tic80_trace_fpu3 (SIM_DESC sd
,
237 if (!tic80_size_name
)
240 trace_one_insn (sd
, cpu
, cia
.ip
, 1,
241 itable
[indx
].file
, itable
[indx
].line_nr
, "fpu",
242 "%-*s %*f %*f => %*f",
243 tic80_size_name
, itable
[indx
].name
,
244 SIZE_HEX
+ SIZE_DECIMAL
+ 1, sim_fpu_2d (input1
),
245 SIZE_HEX
+ SIZE_DECIMAL
+ 1, sim_fpu_2d (input2
),
246 SIZE_HEX
+ SIZE_DECIMAL
+ 1, sim_fpu_2d (result
));
249 /* Trace the result of an FPU operation with 1 floating point input and a floating point output */
251 tic80_trace_fpu2 (SIM_DESC sd
,
258 if (!tic80_size_name
)
261 trace_one_insn (sd
, cpu
, cia
.ip
, 1,
262 itable
[indx
].file
, itable
[indx
].line_nr
, "fpu",
263 "%-*s %*f %-*s => %*f",
264 tic80_size_name
, itable
[indx
].name
,
265 SIZE_HEX
+ SIZE_DECIMAL
+ 1, sim_fpu_2d (input
),
266 SIZE_HEX
+ SIZE_DECIMAL
+ 1, "",
267 SIZE_HEX
+ SIZE_DECIMAL
, sim_fpu_2d (result
));
270 /* Trace the result of an FPU operation with 1 integer input and an integer output */
272 tic80_trace_fpu2i (SIM_DESC sd
,
280 if (!tic80_size_name
)
283 trace_one_insn (sd
, cpu
, cia
.ip
, 1,
284 itable
[indx
].file
, itable
[indx
].line_nr
, "fpu",
285 "%-*s %*f %*f => 0x%.*lx %-*ld",
286 tic80_size_name
, itable
[indx
].name
,
287 SIZE_HEX
+ SIZE_DECIMAL
+ 3, sim_fpu_2d (input1
),
288 SIZE_HEX
+ SIZE_DECIMAL
+ 3, sim_fpu_2d (input2
),
289 SIZE_HEX
, result
, SIZE_DECIMAL
, (long)(signed32
)result
);
292 /* Trace the result of a NOP operation */
294 tic80_trace_nop (int indx
)
296 if (!tic80_size_name
)
299 sprintf (tic80_trace_buffer
, "%s", itable
[indx
].name
);
300 return tic80_trace_buffer
;
303 /* Trace the result of a data sink with one input */
305 tic80_trace_sink1 (int indx
, unsigned32 input
)
307 if (!tic80_size_name
)
310 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld",
311 tic80_size_name
, itable
[indx
].name
,
312 SIZE_HEX
, input
, SIZE_DECIMAL
, (long)(signed32
)input
);
314 return tic80_trace_buffer
;
317 /* Trace the result of a data sink with two inputs */
319 tic80_trace_sink2 (int indx
, unsigned32 input1
, unsigned32 input2
)
321 if (!tic80_size_name
)
324 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld 0x%.*lx/%*ld",
325 tic80_size_name
, itable
[indx
].name
,
326 SIZE_HEX
, input1
, SIZE_DECIMAL
, (long)(signed32
)input1
,
327 SIZE_HEX
, input2
, SIZE_DECIMAL
, (long)(signed32
)input2
);
329 return tic80_trace_buffer
;
332 /* Trace the result of a data sink with three inputs */
334 tic80_trace_sink3 (int indx
, unsigned32 input1
, unsigned32 input2
, unsigned32 input3
)
336 if (!tic80_size_name
)
339 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld 0x%.*lx/%*ld 0x%.*lx/%*ld",
340 tic80_size_name
, itable
[indx
].name
,
341 SIZE_HEX
, input1
, SIZE_DECIMAL
, (long)(signed32
)input1
,
342 SIZE_HEX
, input2
, SIZE_DECIMAL
, (long)(signed32
)input2
,
343 SIZE_HEX
, input3
, SIZE_DECIMAL
, (long)(signed32
)input3
);
345 return tic80_trace_buffer
;
348 /* Trace the result of a conditional branch operation */
350 tic80_trace_cond_br (int indx
,
355 if (!tic80_size_name
)
359 sprintf (tic80_trace_buffer
,
360 "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => 0x%.*lx",
361 tic80_size_name
, itable
[indx
].name
,
362 SIZE_HEX
, target
, SIZE_DECIMAL
, "",
363 SIZE_HEX
, cond
, SIZE_DECIMAL
, (long)(signed32
)cond
,
366 sprintf (tic80_trace_buffer
,
367 "%-*s 0x%.*lx %*s 0x%.*lx/%*ld => [fallthrough]",
368 tic80_size_name
, itable
[indx
].name
,
369 SIZE_HEX
, target
, SIZE_DECIMAL
, "",
370 SIZE_HEX
, cond
, SIZE_DECIMAL
, (long)(signed32
)cond
);
372 return tic80_trace_buffer
;
375 /* Trace the result of a unconditional branch operation */
377 tic80_trace_ucond_br (int indx
,
380 if (!tic80_size_name
)
383 sprintf (tic80_trace_buffer
,
384 "%-*s 0x%.*lx %*s => 0x%.*lx",
385 tic80_size_name
, itable
[indx
].name
,
386 SIZE_HEX
, target
, (SIZE_DECIMAL
*2) + SIZE_HEX
+ 4, "",
389 return tic80_trace_buffer
;
392 /* Trace the result of a load or store operation with 2 integer addresses
393 and an integer output or input */
395 tic80_trace_ldst (int indx
,
405 if (!tic80_size_name
)
408 strcpy (name
, itable
[indx
].name
);
415 sprintf (tic80_trace_buffer
, "%-*s 0x%.*lx/%*ld 0x%.*lx/%*ld %s 0x%.*lx/%*ld",
416 tic80_size_name
, name
,
417 SIZE_HEX
, input1
, SIZE_DECIMAL
, (long)(signed32
)input1
,
418 SIZE_HEX
, input2
, SIZE_DECIMAL
, (long)(signed32
)input2
,
419 (!st_p
) ? "=>" : "<=",
420 SIZE_HEX
, value
, SIZE_DECIMAL
, (long)(signed32
)value
);
422 return tic80_trace_buffer
;
425 #endif /* WITH_TRACE */
This page took 0.038406 seconds and 4 git commands to generate.