]>
Commit | Line | Data |
---|---|---|
7a292a7a SS |
1 | /* Target-dependent code for the Acorn Risc Machine (ARM). |
2 | Copyright (C) 1988, 1989, 1991, 1992, 1993, 1995-1999 | |
c906108c SS |
3 | Free Software Foundation, Inc. |
4 | ||
5 | This file is part of GDB. | |
6 | ||
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 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
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. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |
20 | ||
21 | #include "defs.h" | |
22 | #include "frame.h" | |
23 | #include "inferior.h" | |
24 | #include "gdbcmd.h" | |
25 | #include "gdbcore.h" | |
26 | #include "symfile.h" | |
27 | #include "gdb_string.h" | |
28 | #include "coff/internal.h" /* Internal format of COFF symbols in BFD */ | |
29 | ||
30 | /* | |
31 | The following macros are actually wrong. Neither arm nor thumb can | |
32 | or should set the lsb on addr. | |
33 | The thumb addresses are mod 2, so (addr & 2) would be a good heuristic | |
34 | to use when checking for thumb (see arm_pc_is_thumb() below). | |
35 | Unfortunately, something else depends on these (incorrect) macros, so | |
36 | fixing them actually breaks gdb. I didn't have time to investigate. Z.R. | |
37 | */ | |
38 | /* Thumb function addresses are odd (bit 0 is set). Here are some | |
39 | macros to test, set, or clear bit 0 of addresses. */ | |
40 | #define IS_THUMB_ADDR(addr) ((addr) & 1) | |
41 | #define MAKE_THUMB_ADDR(addr) ((addr) | 1) | |
42 | #define UNMAKE_THUMB_ADDR(addr) ((addr) & ~1) | |
43 | ||
44 | /* Macros to round N up or down to the next A boundary; A must be | |
45 | a power of two. */ | |
46 | #define ROUND_DOWN(n,a) ((n) & ~((a) - 1)) | |
47 | #define ROUND_UP(n,a) (((n) + (a) - 1) & ~((a) - 1)) | |
085dd6e6 JM |
48 | |
49 | static char *APCS_register_names[] = | |
50 | { "a1", "a2", "a3", "a4", /* 0 1 2 3 */ | |
51 | "v1", "v2", "v3", "v4", /* 4 5 6 7 */ | |
52 | "v5", "v6", "sl", "fp", /* 8 9 10 11 */ | |
53 | "ip", "sp", "lr", "pc", /* 12 13 14 15 */ | |
54 | "f0", "f1", "f2", "f3", /* 16 17 18 19 */ | |
55 | "f4", "f5", "f6", "f7", /* 20 21 22 23 */ | |
56 | "fps","ps" } /* 24 25 */; | |
57 | ||
58 | /* These names are the ones which gcc emits, and | |
59 | I find them less confusing. Toggle between them | |
60 | using the `othernames' command. */ | |
61 | static char *additional_register_names[] = | |
62 | { "r0", "r1", "r2", "r3", /* 0 1 2 3 */ | |
63 | "r4", "r5", "r6", "r7", /* 4 5 6 7 */ | |
64 | "r8", "r9", "r10", "r11", /* 8 9 10 11 */ | |
65 | "r12", "r13", "r14", "pc", /* 12 13 14 15 */ | |
66 | "f0", "f1", "f2", "f3", /* 16 17 18 19 */ | |
67 | "f4", "f5", "f6", "f7", /* 20 21 22 23 */ | |
68 | "fps","ps" } /* 24 25 */; | |
69 | ||
70 | /* By default use the APCS registers names */ | |
71 | ||
72 | char **arm_register_names = APCS_register_names; | |
73 | ||
c906108c SS |
74 | /* Should call_function allocate stack space for a struct return? */ |
75 | /* The system C compiler uses a similar structure return convention to gcc */ | |
76 | int | |
77 | arm_use_struct_convention (gcc_p, type) | |
78 | int gcc_p; | |
79 | struct type *type; | |
80 | { | |
81 | return (TYPE_LENGTH (type) > 4); | |
82 | } | |
83 | ||
84 | int | |
85 | arm_frame_chain_valid (chain, thisframe) | |
86 | CORE_ADDR chain; | |
87 | struct frame_info *thisframe; | |
88 | { | |
89 | #define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */ | |
90 | return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC)); | |
91 | } | |
92 | ||
93 | /* Set to true if the 32-bit mode is in use. */ | |
94 | ||
95 | int arm_apcs_32 = 1; | |
96 | ||
97 | /* Flag set by arm_fix_call_dummy that tells whether the target function | |
98 | is a Thumb function. This flag is checked by arm_push_arguments. | |
99 | FIXME: Change the PUSH_ARGUMENTS macro (and its use in valops.c) to | |
100 | pass the function address as an additional parameter. */ | |
101 | ||
102 | static int target_is_thumb; | |
103 | ||
104 | /* Flag set by arm_fix_call_dummy that tells whether the calling function | |
105 | is a Thumb function. This flag is checked by arm_pc_is_thumb | |
106 | and arm_call_dummy_breakpoint_offset. */ | |
107 | ||
108 | static int caller_is_thumb; | |
109 | ||
110 | /* Tell if the program counter value in MEMADDR is in a Thumb function. */ | |
111 | ||
112 | int | |
113 | arm_pc_is_thumb (memaddr) | |
114 | bfd_vma memaddr; | |
115 | { | |
116 | struct minimal_symbol * sym; | |
117 | CORE_ADDR sp; | |
118 | ||
119 | /* If bit 0 of the address is set, assume this is a Thumb address. */ | |
120 | if (IS_THUMB_ADDR (memaddr)) | |
121 | return 1; | |
122 | ||
123 | /* Thumb function have a "special" bit set in minimal symbols */ | |
124 | sym = lookup_minimal_symbol_by_pc (memaddr); | |
125 | if (sym) | |
126 | { | |
127 | return (MSYMBOL_IS_SPECIAL(sym)); | |
128 | } | |
129 | else | |
130 | return 0; | |
131 | } | |
132 | ||
133 | /* Tell if the program counter value in MEMADDR is in a call dummy that | |
134 | is being called from a Thumb function. */ | |
135 | ||
136 | int | |
137 | arm_pc_is_thumb_dummy (memaddr) | |
138 | bfd_vma memaddr; | |
139 | { | |
140 | CORE_ADDR sp = read_sp(); | |
141 | ||
142 | if (PC_IN_CALL_DUMMY (memaddr, sp, sp+64)) | |
143 | return caller_is_thumb; | |
144 | else | |
145 | return 0; | |
146 | } | |
147 | ||
148 | CORE_ADDR | |
149 | arm_addr_bits_remove (val) | |
150 | CORE_ADDR val; | |
151 | { | |
152 | if (arm_pc_is_thumb (val)) | |
153 | return (val & (arm_apcs_32 ? 0xfffffffe : 0x03fffffe)); | |
154 | else | |
155 | return (val & (arm_apcs_32 ? 0xfffffffc : 0x03fffffc)); | |
156 | } | |
157 | ||
158 | CORE_ADDR | |
159 | arm_saved_pc_after_call (frame) | |
160 | struct frame_info *frame; | |
161 | { | |
162 | return ADDR_BITS_REMOVE (read_register (LR_REGNUM)); | |
163 | } | |
164 | ||
392a587b JM |
165 | int |
166 | arm_frameless_function_invocation (fi) | |
167 | struct frame_info *fi; | |
168 | { | |
169 | int frameless; | |
170 | CORE_ADDR func_start, after_prologue; | |
171 | func_start = (get_pc_function_start ((fi)->pc) + FUNCTION_START_OFFSET); | |
172 | after_prologue = func_start; | |
173 | SKIP_PROLOGUE (after_prologue); | |
174 | frameless = (after_prologue == func_start); | |
175 | return frameless; | |
176 | } | |
177 | ||
c906108c SS |
178 | /* A typical Thumb prologue looks like this: |
179 | push {r7, lr} | |
180 | add sp, sp, #-28 | |
181 | add r7, sp, #12 | |
182 | Sometimes the latter instruction may be replaced by: | |
183 | mov r7, sp | |
184 | */ | |
185 | ||
186 | static CORE_ADDR | |
187 | thumb_skip_prologue (pc) | |
188 | CORE_ADDR pc; | |
189 | { | |
190 | CORE_ADDR current_pc; | |
191 | ||
192 | for (current_pc = pc; current_pc < pc + 20; current_pc += 2) | |
193 | { | |
194 | unsigned short insn = read_memory_unsigned_integer (current_pc, 2); | |
195 | ||
196 | if ( (insn & 0xfe00) != 0xb400 /* push {..., r7, lr} */ | |
197 | && (insn & 0xff00) != 0xb000 /* add sp, #simm */ | |
198 | && (insn & 0xff00) != 0xaf00 /* add r7, sp, #imm */ | |
199 | && insn != 0x466f /* mov r7, sp */ | |
200 | && (insn & 0xffc0) != 0x4640) /* mov r0-r7, r8-r15 */ | |
201 | break; | |
202 | } | |
203 | ||
204 | return current_pc; | |
205 | } | |
206 | ||
207 | /* APCS (ARM procedure call standard) defines the following prologue: | |
208 | ||
209 | mov ip, sp | |
210 | [stmfd sp!, {a1,a2,a3,a4}] | |
211 | stmfd sp!, {...,fp,ip,lr,pc} | |
212 | [stfe f7, [sp, #-12]!] | |
213 | [stfe f6, [sp, #-12]!] | |
214 | [stfe f5, [sp, #-12]!] | |
215 | [stfe f4, [sp, #-12]!] | |
216 | sub fp, ip, #nn // nn == 20 or 4 depending on second ins | |
217 | */ | |
218 | ||
219 | CORE_ADDR | |
220 | arm_skip_prologue (pc) | |
221 | CORE_ADDR pc; | |
222 | { | |
223 | unsigned long inst; | |
224 | CORE_ADDR skip_pc; | |
225 | CORE_ADDR func_addr, func_end; | |
226 | struct symtab_and_line sal; | |
227 | ||
228 | /* See what the symbol table says. */ | |
229 | if (find_pc_partial_function (pc, NULL, & func_addr, & func_end)) | |
230 | { | |
231 | sal = find_pc_line (func_addr, 0); | |
232 | if (sal.line != 0 && sal.end < func_end) | |
233 | return sal.end; | |
234 | } | |
235 | ||
236 | /* Check if this is Thumb code. */ | |
237 | if (arm_pc_is_thumb (pc)) | |
238 | return thumb_skip_prologue (pc); | |
239 | ||
240 | /* Can't find the prologue end in the symbol table, try it the hard way | |
241 | by disassembling the instructions. */ | |
242 | skip_pc = pc; | |
243 | inst = read_memory_integer (skip_pc, 4); | |
244 | if (inst != 0xe1a0c00d) /* mov ip, sp */ | |
245 | return pc; | |
246 | ||
247 | skip_pc += 4; | |
248 | inst = read_memory_integer (skip_pc, 4); | |
249 | if ((inst & 0xfffffff0) == 0xe92d0000) /* stmfd sp!,{a1,a2,a3,a4} */ | |
250 | { | |
251 | skip_pc += 4; | |
252 | inst = read_memory_integer (skip_pc, 4); | |
253 | } | |
254 | ||
255 | if ((inst & 0xfffff800) != 0xe92dd800) /* stmfd sp!,{...,fp,ip,lr,pc} */ | |
256 | return pc; | |
257 | ||
258 | skip_pc += 4; | |
259 | inst = read_memory_integer (skip_pc, 4); | |
260 | ||
261 | /* Any insns after this point may float into the code, if it makes | |
262 | for better instruction scheduling, so we skip them only if | |
263 | we find them, but still consdier the function to be frame-ful */ | |
264 | ||
265 | /* We may have either one sfmfd instruction here, or several stfe insns, | |
266 | depending on the version of floating point code we support. */ | |
267 | if ((inst & 0xffbf0fff) == 0xec2d0200) /* sfmfd fn, <cnt>, [sp]! */ | |
268 | { | |
269 | skip_pc += 4; | |
270 | inst = read_memory_integer (skip_pc, 4); | |
271 | } | |
272 | else | |
273 | { | |
274 | while ((inst & 0xffff8fff) == 0xed6d0103) /* stfe fn, [sp, #-12]! */ | |
275 | { | |
276 | skip_pc += 4; | |
277 | inst = read_memory_integer (skip_pc, 4); | |
278 | } | |
279 | } | |
280 | ||
281 | if ((inst & 0xfffff000) == 0xe24cb000) /* sub fp, ip, #nn */ | |
282 | skip_pc += 4; | |
283 | ||
284 | return skip_pc; | |
285 | } | |
286 | ||
287 | ||
288 | ||
289 | /* Function: thumb_scan_prologue (helper function for arm_scan_prologue) | |
290 | This function decodes a Thumb function prologue to determine: | |
291 | 1) the size of the stack frame | |
292 | 2) which registers are saved on it | |
293 | 3) the offsets of saved regs | |
294 | 4) the offset from the stack pointer to the frame pointer | |
295 | This information is stored in the "extra" fields of the frame_info. | |
296 | ||
297 | A typical Thumb function prologue might look like this: | |
298 | push {r7, lr} | |
299 | sub sp, #28, | |
300 | add r7, sp, #12 | |
301 | Which would create this stack frame (offsets relative to FP) | |
302 | old SP -> 24 stack parameters | |
303 | 20 LR | |
304 | 16 R7 | |
305 | R7 -> 0 local variables (16 bytes) | |
306 | SP -> -12 additional stack space (12 bytes) | |
307 | The frame size would thus be 36 bytes, and the frame offset would be | |
308 | 12 bytes. The frame register is R7. */ | |
309 | ||
310 | static void | |
311 | thumb_scan_prologue (fi) | |
312 | struct frame_info * fi; | |
313 | { | |
314 | CORE_ADDR prologue_start; | |
315 | CORE_ADDR prologue_end; | |
316 | CORE_ADDR current_pc; | |
317 | int saved_reg[16]; /* which register has been copied to register n? */ | |
318 | int i; | |
319 | ||
320 | if (find_pc_partial_function (fi->pc, NULL, & prologue_start, & prologue_end)) | |
321 | { | |
322 | struct symtab_and_line sal = find_pc_line (prologue_start, 0); | |
323 | ||
324 | if (sal.line == 0) /* no line info, use current PC */ | |
325 | prologue_end = fi->pc; | |
326 | else if (sal.end < prologue_end) /* next line begins after fn end */ | |
327 | prologue_end = sal.end; /* (probably means no prologue) */ | |
328 | } | |
329 | else | |
330 | prologue_end = prologue_start + 40; /* We're in the boondocks: allow for */ | |
331 | /* 16 pushes, an add, and "mv fp,sp" */ | |
332 | ||
333 | prologue_end = min (prologue_end, fi->pc); | |
334 | ||
335 | /* Initialize the saved register map. When register H is copied to | |
336 | register L, we will put H in saved_reg[L]. */ | |
337 | for (i = 0; i < 16; i++) | |
338 | saved_reg[i] = i; | |
339 | ||
340 | /* Search the prologue looking for instructions that set up the | |
341 | frame pointer, adjust the stack pointer, and save registers. */ | |
342 | ||
343 | fi->framesize = 0; | |
344 | for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 2) | |
345 | { | |
346 | unsigned short insn; | |
347 | int regno; | |
348 | int offset; | |
349 | ||
350 | insn = read_memory_unsigned_integer (current_pc, 2); | |
351 | ||
352 | if ((insn & 0xfe00) == 0xb400) /* push { rlist } */ | |
353 | { | |
354 | /* Bits 0-7 contain a mask for registers R0-R7. Bit 8 says | |
355 | whether to save LR (R14). */ | |
356 | int mask = (insn & 0xff) | ((insn & 0x100) << 6); | |
357 | ||
358 | /* Calculate offsets of saved R0-R7 and LR. */ | |
359 | for (regno = LR_REGNUM; regno >= 0; regno--) | |
360 | if (mask & (1 << regno)) | |
361 | { | |
362 | fi->framesize += 4; | |
363 | fi->fsr.regs[saved_reg[regno]] = -(fi->framesize); | |
364 | saved_reg[regno] = regno; /* reset saved register map */ | |
365 | } | |
366 | } | |
367 | else if ((insn & 0xff00) == 0xb000) /* add sp, #simm */ | |
368 | { | |
369 | offset = (insn & 0x7f) << 2; /* get scaled offset */ | |
370 | if (insn & 0x80) /* is it signed? */ | |
371 | offset = -offset; | |
372 | fi->framesize -= offset; | |
373 | } | |
374 | else if ((insn & 0xff00) == 0xaf00) /* add r7, sp, #imm */ | |
375 | { | |
376 | fi->framereg = THUMB_FP_REGNUM; | |
377 | fi->frameoffset = (insn & 0xff) << 2; /* get scaled offset */ | |
378 | } | |
379 | else if (insn == 0x466f) /* mov r7, sp */ | |
380 | { | |
381 | fi->framereg = THUMB_FP_REGNUM; | |
382 | fi->frameoffset = 0; | |
383 | saved_reg[THUMB_FP_REGNUM] = SP_REGNUM; | |
384 | } | |
385 | else if ((insn & 0xffc0) == 0x4640) /* mov r0-r7, r8-r15 */ | |
386 | { | |
387 | int lo_reg = insn & 7; /* dest. register (r0-r7) */ | |
388 | int hi_reg = ((insn >> 3) & 7) + 8; /* source register (r8-15) */ | |
389 | saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */ | |
390 | } | |
391 | else | |
392 | break; /* anything else isn't prologue */ | |
393 | } | |
394 | } | |
395 | ||
396 | /* Function: check_prologue_cache | |
397 | Check if prologue for this frame's PC has already been scanned. | |
398 | If it has, copy the relevant information about that prologue and | |
399 | return non-zero. Otherwise do not copy anything and return zero. | |
400 | ||
401 | The information saved in the cache includes: | |
402 | * the frame register number; | |
403 | * the size of the stack frame; | |
404 | * the offsets of saved regs (relative to the old SP); and | |
405 | * the offset from the stack pointer to the frame pointer | |
406 | ||
407 | The cache contains only one entry, since this is adequate | |
408 | for the typical sequence of prologue scan requests we get. | |
409 | When performing a backtrace, GDB will usually ask to scan | |
410 | the same function twice in a row (once to get the frame chain, | |
411 | and once to fill in the extra frame information). | |
412 | */ | |
413 | ||
414 | static struct frame_info prologue_cache; | |
415 | ||
416 | static int | |
417 | check_prologue_cache (fi) | |
418 | struct frame_info * fi; | |
419 | { | |
420 | int i; | |
421 | ||
422 | if (fi->pc == prologue_cache.pc) | |
423 | { | |
424 | fi->framereg = prologue_cache.framereg; | |
425 | fi->framesize = prologue_cache.framesize; | |
426 | fi->frameoffset = prologue_cache.frameoffset; | |
427 | for (i = 0; i <= NUM_REGS; i++) | |
428 | fi->fsr.regs[i] = prologue_cache.fsr.regs[i]; | |
429 | return 1; | |
430 | } | |
431 | else | |
432 | return 0; | |
433 | } | |
434 | ||
435 | ||
436 | /* Function: save_prologue_cache | |
437 | Copy the prologue information from fi to the prologue cache. | |
438 | */ | |
439 | ||
440 | static void | |
441 | save_prologue_cache (fi) | |
442 | struct frame_info * fi; | |
443 | { | |
444 | int i; | |
445 | ||
446 | prologue_cache.pc = fi->pc; | |
447 | prologue_cache.framereg = fi->framereg; | |
448 | prologue_cache.framesize = fi->framesize; | |
449 | prologue_cache.frameoffset = fi->frameoffset; | |
450 | ||
451 | for (i = 0; i <= NUM_REGS; i++) | |
452 | prologue_cache.fsr.regs[i] = fi->fsr.regs[i]; | |
453 | } | |
454 | ||
455 | ||
456 | /* Function: arm_scan_prologue | |
457 | This function decodes an ARM function prologue to determine: | |
458 | 1) the size of the stack frame | |
459 | 2) which registers are saved on it | |
460 | 3) the offsets of saved regs | |
461 | 4) the offset from the stack pointer to the frame pointer | |
462 | This information is stored in the "extra" fields of the frame_info. | |
463 | ||
464 | A typical Arm function prologue might look like this: | |
465 | mov ip, sp | |
466 | stmfd sp!, {fp, ip, lr, pc} | |
467 | sub fp, ip, #4 | |
468 | sub sp, sp, #16 | |
469 | Which would create this stack frame (offsets relative to FP): | |
470 | IP -> 4 (caller's stack) | |
471 | FP -> 0 PC (points to address of stmfd instruction + 12 in callee) | |
472 | -4 LR (return address in caller) | |
473 | -8 IP (copy of caller's SP) | |
474 | -12 FP (caller's FP) | |
475 | SP -> -28 Local variables | |
476 | The frame size would thus be 32 bytes, and the frame offset would be | |
477 | 28 bytes. */ | |
478 | ||
479 | static void | |
480 | arm_scan_prologue (fi) | |
481 | struct frame_info * fi; | |
482 | { | |
483 | int regno, sp_offset, fp_offset; | |
484 | CORE_ADDR prologue_start, prologue_end, current_pc; | |
485 | ||
486 | /* Check if this function is already in the cache of frame information. */ | |
487 | if (check_prologue_cache (fi)) | |
488 | return; | |
489 | ||
490 | /* Assume there is no frame until proven otherwise. */ | |
491 | fi->framereg = SP_REGNUM; | |
492 | fi->framesize = 0; | |
493 | fi->frameoffset = 0; | |
494 | ||
495 | /* Check for Thumb prologue. */ | |
496 | if (arm_pc_is_thumb (fi->pc)) | |
497 | { | |
498 | thumb_scan_prologue (fi); | |
499 | save_prologue_cache (fi); | |
500 | return; | |
501 | } | |
502 | ||
503 | /* Find the function prologue. If we can't find the function in | |
504 | the symbol table, peek in the stack frame to find the PC. */ | |
505 | if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end)) | |
506 | { | |
507 | /* Assume the prologue is everything between the first instruction | |
508 | in the function and the first source line. */ | |
509 | struct symtab_and_line sal = find_pc_line (prologue_start, 0); | |
510 | ||
511 | if (sal.line == 0) /* no line info, use current PC */ | |
512 | prologue_end = fi->pc; | |
513 | else if (sal.end < prologue_end) /* next line begins after fn end */ | |
514 | prologue_end = sal.end; /* (probably means no prologue) */ | |
515 | } | |
516 | else | |
517 | { | |
518 | /* Get address of the stmfd in the prologue of the callee; the saved | |
519 | PC is the address of the stmfd + 12. */ | |
7a292a7a | 520 | prologue_start = ADDR_BITS_REMOVE(read_memory_integer (fi->frame, 4)) - 12; |
c906108c SS |
521 | prologue_end = prologue_start + 40; /* FIXME: should be big enough */ |
522 | } | |
523 | ||
524 | /* Now search the prologue looking for instructions that set up the | |
525 | frame pointer, adjust the stack pointer, and save registers. */ | |
526 | ||
527 | sp_offset = fp_offset = 0; | |
528 | for (current_pc = prologue_start; current_pc < prologue_end; current_pc += 4) | |
529 | { | |
530 | unsigned int insn = read_memory_unsigned_integer (current_pc, 4); | |
531 | ||
532 | if ((insn & 0xffff0000) == 0xe92d0000) /* stmfd sp!, {..., r7, lr} */ | |
533 | { | |
534 | int mask = insn & 0xffff; | |
535 | ||
536 | /* Calculate offsets of saved registers. */ | |
537 | for (regno = PC_REGNUM; regno >= 0; regno--) | |
538 | if (mask & (1 << regno)) | |
539 | { | |
540 | sp_offset -= 4; | |
541 | fi->fsr.regs[regno] = sp_offset; | |
542 | } | |
543 | } | |
544 | else if ((insn & 0xfffff000) == 0xe24cb000) /* sub fp, ip #n */ | |
545 | { | |
546 | unsigned imm = insn & 0xff; /* immediate value */ | |
547 | unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ | |
548 | imm = (imm >> rot) | (imm << (32-rot)); | |
549 | fp_offset = -imm; | |
550 | fi->framereg = FP_REGNUM; | |
551 | } | |
552 | else if ((insn & 0xfffff000) == 0xe24dd000) /* sub sp, sp #n */ | |
553 | { | |
554 | unsigned imm = insn & 0xff; /* immediate value */ | |
555 | unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ | |
556 | imm = (imm >> rot) | (imm << (32-rot)); | |
557 | sp_offset -= imm; | |
558 | } | |
559 | else if ((insn & 0xffff7fff) == 0xed6d0103) /* stfe f?, [sp, -#c]! */ | |
560 | { | |
561 | sp_offset -= 12; | |
562 | regno = F0_REGNUM + ((insn >> 12) & 0x07); | |
563 | fi->fsr.regs[regno] = sp_offset; | |
564 | } | |
565 | else if (insn == 0xe1a0c00d) /* mov ip, sp */ | |
566 | continue; | |
567 | else | |
568 | break; /* not a recognized prologue instruction */ | |
569 | } | |
570 | ||
571 | /* The frame size is just the negative of the offset (from the original SP) | |
572 | of the last thing thing we pushed on the stack. The frame offset is | |
573 | [new FP] - [new SP]. */ | |
574 | fi->framesize = -sp_offset; | |
575 | fi->frameoffset = fp_offset - sp_offset; | |
576 | ||
577 | save_prologue_cache (fi); | |
578 | } | |
579 | ||
580 | ||
581 | /* Function: find_callers_reg | |
582 | Find REGNUM on the stack. Otherwise, it's in an active register. One thing | |
583 | we might want to do here is to check REGNUM against the clobber mask, and | |
584 | somehow flag it as invalid if it isn't saved on the stack somewhere. This | |
585 | would provide a graceful failure mode when trying to get the value of | |
586 | caller-saves registers for an inner frame. */ | |
587 | ||
588 | static CORE_ADDR | |
589 | arm_find_callers_reg (fi, regnum) | |
590 | struct frame_info * fi; | |
591 | int regnum; | |
592 | { | |
593 | for (; fi; fi = fi->next) | |
594 | ||
595 | #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ | |
596 | if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) | |
597 | return generic_read_register_dummy (fi->pc, fi->frame, regnum); | |
598 | else | |
599 | #endif | |
600 | if (fi->fsr.regs[regnum] != 0) | |
601 | return read_memory_integer (fi->fsr.regs[regnum], | |
602 | REGISTER_RAW_SIZE(regnum)); | |
603 | return read_register (regnum); | |
604 | } | |
605 | ||
606 | ||
607 | /* Function: frame_chain | |
608 | Given a GDB frame, determine the address of the calling function's frame. | |
609 | This will be used to create a new GDB frame struct, and then | |
610 | INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC will be called for the new frame. | |
611 | For ARM, we save the frame size when we initialize the frame_info. | |
612 | ||
613 | The original definition of this function was a macro in tm-arm.h: | |
614 | { In the case of the ARM, the frame's nominal address is the FP value, | |
615 | and 12 bytes before comes the saved previous FP value as a 4-byte word. } | |
616 | ||
617 | #define FRAME_CHAIN(thisframe) \ | |
618 | ((thisframe)->pc >= LOWEST_PC ? \ | |
619 | read_memory_integer ((thisframe)->frame - 12, 4) :\ | |
620 | 0) | |
621 | */ | |
622 | ||
623 | CORE_ADDR | |
624 | arm_frame_chain (fi) | |
625 | struct frame_info * fi; | |
626 | { | |
627 | #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ | |
628 | CORE_ADDR fn_start, callers_pc, fp; | |
629 | ||
630 | /* is this a dummy frame? */ | |
631 | if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) | |
632 | return fi->frame; /* dummy frame same as caller's frame */ | |
633 | ||
634 | /* is caller-of-this a dummy frame? */ | |
635 | callers_pc = FRAME_SAVED_PC(fi); /* find out who called us: */ | |
636 | fp = arm_find_callers_reg (fi, FP_REGNUM); | |
637 | if (PC_IN_CALL_DUMMY (callers_pc, fp, fp)) | |
638 | return fp; /* dummy frame's frame may bear no relation to ours */ | |
639 | ||
640 | if (find_pc_partial_function (fi->pc, 0, &fn_start, 0)) | |
641 | if (fn_start == entry_point_address ()) | |
642 | return 0; /* in _start fn, don't chain further */ | |
643 | #endif | |
644 | CORE_ADDR caller_pc, fn_start; | |
645 | struct frame_info caller_fi; | |
646 | int framereg = fi->framereg; | |
647 | ||
648 | if (fi->pc < LOWEST_PC) | |
649 | return 0; | |
650 | ||
651 | /* If the caller is the startup code, we're at the end of the chain. */ | |
652 | caller_pc = FRAME_SAVED_PC (fi); | |
653 | if (find_pc_partial_function (caller_pc, 0, &fn_start, 0)) | |
654 | if (fn_start == entry_point_address ()) | |
655 | return 0; | |
656 | ||
657 | /* If the caller is Thumb and the caller is ARM, or vice versa, | |
658 | the frame register of the caller is different from ours. | |
659 | So we must scan the prologue of the caller to determine its | |
660 | frame register number. */ | |
661 | if (arm_pc_is_thumb (caller_pc) != arm_pc_is_thumb (fi->pc)) | |
662 | { | |
663 | memset (& caller_fi, 0, sizeof (caller_fi)); | |
664 | caller_fi.pc = caller_pc; | |
665 | arm_scan_prologue (& caller_fi); | |
666 | framereg = caller_fi.framereg; | |
667 | } | |
668 | ||
669 | /* If the caller used a frame register, return its value. | |
670 | Otherwise, return the caller's stack pointer. */ | |
671 | if (framereg == FP_REGNUM || framereg == THUMB_FP_REGNUM) | |
672 | return arm_find_callers_reg (fi, framereg); | |
673 | else | |
674 | return fi->frame + fi->framesize; | |
675 | } | |
676 | ||
677 | /* Function: init_extra_frame_info | |
678 | This function actually figures out the frame address for a given pc and | |
679 | sp. This is tricky because we sometimes don't use an explicit | |
680 | frame pointer, and the previous stack pointer isn't necessarily recorded | |
681 | on the stack. The only reliable way to get this info is to | |
682 | examine the prologue. */ | |
683 | ||
684 | void | |
685 | arm_init_extra_frame_info (fi) | |
686 | struct frame_info * fi; | |
687 | { | |
688 | int reg; | |
689 | ||
690 | if (fi->next) | |
691 | fi->pc = FRAME_SAVED_PC (fi->next); | |
692 | ||
693 | memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs); | |
694 | ||
695 | #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ | |
696 | if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) | |
697 | { | |
698 | /* We need to setup fi->frame here because run_stack_dummy gets it wrong | |
699 | by assuming it's always FP. */ | |
700 | fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM); | |
701 | fi->framesize = 0; | |
702 | fi->frameoffset = 0; | |
703 | return; | |
704 | } | |
705 | else | |
706 | #endif | |
707 | { | |
708 | arm_scan_prologue (fi); | |
709 | ||
710 | if (!fi->next) /* this is the innermost frame? */ | |
711 | fi->frame = read_register (fi->framereg); | |
712 | else /* not the innermost frame */ | |
713 | /* If we have an FP, the callee saved it. */ | |
714 | if (fi->framereg == FP_REGNUM || fi->framereg == THUMB_FP_REGNUM) | |
715 | if (fi->next->fsr.regs[fi->framereg] != 0) | |
716 | fi->frame = read_memory_integer (fi->next->fsr.regs[fi->framereg], | |
717 | 4); | |
718 | ||
719 | /* Calculate actual addresses of saved registers using offsets determined | |
720 | by arm_scan_prologue. */ | |
721 | for (reg = 0; reg < NUM_REGS; reg++) | |
722 | if (fi->fsr.regs[reg] != 0) | |
723 | fi->fsr.regs[reg] += fi->frame + fi->framesize - fi->frameoffset; | |
724 | } | |
725 | } | |
726 | ||
727 | ||
728 | /* Function: frame_saved_pc | |
729 | Find the caller of this frame. We do this by seeing if LR_REGNUM is saved | |
730 | in the stack anywhere, otherwise we get it from the registers. | |
731 | ||
732 | The old definition of this function was a macro: | |
733 | #define FRAME_SAVED_PC(FRAME) \ | |
734 | ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4)) | |
735 | */ | |
736 | ||
737 | CORE_ADDR | |
738 | arm_frame_saved_pc (fi) | |
739 | struct frame_info * fi; | |
740 | { | |
741 | #if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ | |
742 | if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) | |
743 | return generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM); | |
744 | else | |
745 | #endif | |
746 | { | |
747 | CORE_ADDR pc = arm_find_callers_reg (fi, LR_REGNUM); | |
748 | return IS_THUMB_ADDR (pc) ? UNMAKE_THUMB_ADDR (pc) : pc; | |
749 | } | |
750 | } | |
751 | ||
752 | ||
753 | /* Return the frame address. On ARM, it is R11; on Thumb it is R7. | |
754 | Examine the Program Status Register to decide which state we're in. */ | |
755 | ||
756 | CORE_ADDR | |
757 | arm_target_read_fp () | |
758 | { | |
759 | if (read_register (PS_REGNUM) & 0x20) /* Bit 5 is Thumb state bit */ | |
760 | return read_register (THUMB_FP_REGNUM); /* R7 if Thumb */ | |
761 | else | |
762 | return read_register (FP_REGNUM); /* R11 if ARM */ | |
763 | } | |
764 | ||
765 | ||
766 | /* Calculate the frame offsets of the saved registers (ARM version). */ | |
767 | void | |
768 | arm_frame_find_saved_regs (fi, regaddr) | |
769 | struct frame_info *fi; | |
770 | struct frame_saved_regs *regaddr; | |
771 | { | |
772 | memcpy (regaddr, &fi->fsr, sizeof (struct frame_saved_regs)); | |
773 | } | |
774 | ||
775 | ||
776 | void | |
777 | arm_push_dummy_frame () | |
778 | { | |
779 | CORE_ADDR old_sp = read_register (SP_REGNUM); | |
780 | CORE_ADDR sp = old_sp; | |
781 | CORE_ADDR fp, prologue_start; | |
782 | int regnum; | |
783 | ||
784 | /* Push the two dummy prologue instructions in reverse order, | |
785 | so that they'll be in the correct low-to-high order in memory. */ | |
786 | /* sub fp, ip, #4 */ | |
787 | sp = push_word (sp, 0xe24cb004); | |
788 | /* stmdb sp!, {r0-r10, fp, ip, lr, pc} */ | |
789 | prologue_start = sp = push_word (sp, 0xe92ddfff); | |
790 | ||
791 | /* push a pointer to the dummy prologue + 12, because when | |
792 | stm instruction stores the PC, it stores the address of the stm | |
793 | instruction itself plus 12. */ | |
794 | fp = sp = push_word (sp, prologue_start + 12); | |
795 | sp = push_word (sp, read_register (PC_REGNUM)); /* FIXME: was PS_REGNUM */ | |
796 | sp = push_word (sp, old_sp); | |
797 | sp = push_word (sp, read_register (FP_REGNUM)); | |
798 | ||
799 | for (regnum = 10; regnum >= 0; regnum --) | |
800 | sp = push_word (sp, read_register (regnum)); | |
801 | ||
802 | write_register (FP_REGNUM, fp); | |
803 | write_register (THUMB_FP_REGNUM, fp); | |
804 | write_register (SP_REGNUM, sp); | |
805 | } | |
806 | ||
807 | /* Fix up the call dummy, based on whether the processor is currently | |
808 | in Thumb or ARM mode, and whether the target function is Thumb | |
809 | or ARM. There are three different situations requiring three | |
810 | different dummies: | |
811 | ||
812 | * ARM calling ARM: uses the call dummy in tm-arm.h, which has already | |
813 | been copied into the dummy parameter to this function. | |
814 | * ARM calling Thumb: uses the call dummy in tm-arm.h, but with the | |
815 | "mov pc,r4" instruction patched to be a "bx r4" instead. | |
816 | * Thumb calling anything: uses the Thumb dummy defined below, which | |
817 | works for calling both ARM and Thumb functions. | |
818 | ||
819 | All three call dummies expect to receive the target function address | |
820 | in R4, with the low bit set if it's a Thumb function. | |
821 | */ | |
822 | ||
823 | void | |
824 | arm_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p) | |
825 | char * dummy; | |
826 | CORE_ADDR pc; | |
827 | CORE_ADDR fun; | |
828 | int nargs; | |
829 | value_ptr * args; | |
830 | struct type * type; | |
831 | int gcc_p; | |
832 | { | |
833 | static short thumb_dummy[4] = | |
834 | { | |
835 | 0xf000, 0xf801, /* bl label */ | |
836 | 0xdf18, /* swi 24 */ | |
837 | 0x4720, /* label: bx r4 */ | |
838 | }; | |
839 | static unsigned long arm_bx_r4 = 0xe12fff14; /* bx r4 instruction */ | |
840 | ||
841 | /* Set flag indicating whether the current PC is in a Thumb function. */ | |
842 | caller_is_thumb = arm_pc_is_thumb (read_pc()); | |
843 | ||
844 | /* If the target function is Thumb, set the low bit of the function address. | |
845 | And if the CPU is currently in ARM mode, patch the second instruction | |
846 | of call dummy to use a BX instruction to switch to Thumb mode. */ | |
847 | target_is_thumb = arm_pc_is_thumb (fun); | |
848 | if (target_is_thumb) | |
849 | { | |
850 | fun |= 1; | |
851 | if (!caller_is_thumb) | |
852 | store_unsigned_integer (dummy + 4, sizeof (arm_bx_r4), arm_bx_r4); | |
853 | } | |
854 | ||
855 | /* If the CPU is currently in Thumb mode, use the Thumb call dummy | |
856 | instead of the ARM one that's already been copied. This will | |
857 | work for both Thumb and ARM target functions. */ | |
858 | if (caller_is_thumb) | |
859 | { | |
860 | int i; | |
861 | char *p = dummy; | |
862 | int len = sizeof (thumb_dummy) / sizeof (thumb_dummy[0]); | |
863 | ||
864 | for (i = 0; i < len; i++) | |
865 | { | |
866 | store_unsigned_integer (p, sizeof (thumb_dummy[0]), thumb_dummy[i]); | |
867 | p += sizeof (thumb_dummy[0]); | |
868 | } | |
869 | } | |
870 | ||
871 | /* Put the target address in r4; the call dummy will copy this to the PC. */ | |
872 | write_register (4, fun); | |
873 | } | |
874 | ||
875 | ||
876 | /* Return the offset in the call dummy of the instruction that needs | |
877 | to have a breakpoint placed on it. This is the offset of the 'swi 24' | |
878 | instruction, which is no longer actually used, but simply acts | |
879 | as a place-holder now. | |
880 | ||
881 | This implements the CALL_DUMMY_BREAK_OFFSET macro. | |
882 | */ | |
883 | ||
884 | int | |
885 | arm_call_dummy_breakpoint_offset () | |
886 | { | |
887 | if (caller_is_thumb) | |
888 | return 4; | |
889 | else | |
890 | return 8; | |
891 | } | |
892 | ||
893 | ||
894 | CORE_ADDR | |
895 | arm_push_arguments(nargs, args, sp, struct_return, struct_addr) | |
896 | int nargs; | |
897 | value_ptr * args; | |
898 | CORE_ADDR sp; | |
899 | int struct_return; | |
900 | CORE_ADDR struct_addr; | |
901 | { | |
902 | int argreg; | |
903 | int float_argreg; | |
904 | int argnum; | |
905 | int stack_offset; | |
906 | struct stack_arg { | |
907 | char *val; | |
908 | int len; | |
909 | int offset; | |
910 | }; | |
911 | struct stack_arg *stack_args = | |
912 | (struct stack_arg*)alloca (nargs * sizeof (struct stack_arg)); | |
913 | int nstack_args = 0; | |
914 | ||
915 | ||
916 | /* Initialize the integer and float register pointers. */ | |
917 | argreg = A1_REGNUM; | |
918 | float_argreg = F0_REGNUM; | |
919 | ||
920 | /* the struct_return pointer occupies the first parameter-passing reg */ | |
921 | if (struct_return) | |
922 | write_register (argreg++, struct_addr); | |
923 | ||
924 | /* The offset onto the stack at which we will start copying parameters | |
925 | (after the registers are used up) begins at 16 in the old ABI. | |
926 | This leaves room for the "home" area for register parameters. */ | |
927 | stack_offset = REGISTER_SIZE * 4; | |
928 | ||
929 | /* Process args from left to right. Store as many as allowed in | |
930 | registers, save the rest to be pushed on the stack */ | |
931 | for(argnum = 0; argnum < nargs; argnum++) | |
932 | { | |
933 | char * val; | |
934 | value_ptr arg = args[argnum]; | |
935 | struct type * arg_type = check_typedef (VALUE_TYPE (arg)); | |
936 | struct type * target_type = TYPE_TARGET_TYPE (arg_type); | |
937 | int len = TYPE_LENGTH (arg_type); | |
938 | enum type_code typecode = TYPE_CODE (arg_type); | |
939 | CORE_ADDR regval; | |
940 | int newarg; | |
941 | ||
942 | val = (char *) VALUE_CONTENTS (arg); | |
943 | ||
944 | /* If the argument is a pointer to a function, and it's a Thumb | |
945 | function, set the low bit of the pointer. */ | |
946 | if (typecode == TYPE_CODE_PTR | |
947 | && target_type != NULL | |
948 | && TYPE_CODE (target_type) == TYPE_CODE_FUNC) | |
949 | { | |
950 | regval = extract_address (val, len); | |
951 | if (arm_pc_is_thumb (regval)) | |
952 | store_address (val, len, MAKE_THUMB_ADDR (regval)); | |
953 | } | |
954 | ||
955 | #define MAPCS_FLOAT 0 /* --mapcs-float not implemented by the compiler yet */ | |
956 | #if MAPCS_FLOAT | |
957 | /* Up to four floating point arguments can be passed in floating | |
958 | point registers on ARM (not on Thumb). */ | |
959 | if (typecode == TYPE_CODE_FLT | |
960 | && float_argreg <= ARM_LAST_FP_ARG_REGNUM | |
961 | && !target_is_thumb) | |
962 | { | |
963 | /* This is a floating point value that fits entirely | |
964 | in a single register. */ | |
965 | regval = extract_address (val, len); | |
966 | write_register (float_argreg++, regval); | |
967 | } | |
968 | else | |
969 | #endif | |
970 | { | |
971 | /* Copy the argument to general registers or the stack in | |
972 | register-sized pieces. Large arguments are split between | |
973 | registers and stack. */ | |
974 | while (len > 0) | |
975 | { | |
976 | if (argreg <= ARM_LAST_ARG_REGNUM) | |
977 | { | |
978 | int partial_len = len < REGISTER_SIZE ? len : REGISTER_SIZE; | |
979 | regval = extract_address (val, partial_len); | |
980 | ||
981 | /* It's a simple argument being passed in a general | |
982 | register. */ | |
983 | write_register (argreg, regval); | |
984 | argreg++; | |
985 | len -= partial_len; | |
986 | val += partial_len; | |
987 | } | |
988 | else | |
989 | { | |
990 | /* keep for later pushing */ | |
991 | stack_args[nstack_args].val = val; | |
992 | stack_args[nstack_args++].len = len; | |
993 | break; | |
994 | } | |
995 | } | |
996 | } | |
997 | } | |
998 | /* now do the real stack pushing, process args right to left */ | |
999 | while(nstack_args--) | |
1000 | { | |
1001 | sp -= stack_args[nstack_args].len; | |
1002 | write_memory(sp, stack_args[nstack_args].val, | |
1003 | stack_args[nstack_args].len); | |
1004 | } | |
1005 | ||
1006 | /* Return adjusted stack pointer. */ | |
1007 | return sp; | |
1008 | } | |
1009 | ||
1010 | void | |
1011 | arm_pop_frame () | |
1012 | { | |
1013 | struct frame_info *frame = get_current_frame(); | |
1014 | int regnum; | |
7a292a7a | 1015 | CORE_ADDR old_SP; |
c906108c | 1016 | |
7a292a7a | 1017 | old_SP = read_register (frame->framereg); |
c906108c SS |
1018 | for (regnum = 0; regnum < NUM_REGS; regnum++) |
1019 | if (frame->fsr.regs[regnum] != 0) | |
1020 | write_register (regnum, | |
1021 | read_memory_integer (frame->fsr.regs[regnum], 4)); | |
1022 | ||
1023 | write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); | |
7a292a7a | 1024 | write_register (SP_REGNUM, old_SP); |
c906108c SS |
1025 | |
1026 | flush_cached_frames (); | |
1027 | } | |
1028 | ||
1029 | static void | |
1030 | print_fpu_flags (flags) | |
1031 | int flags; | |
1032 | { | |
1033 | if (flags & (1 << 0)) fputs ("IVO ", stdout); | |
1034 | if (flags & (1 << 1)) fputs ("DVZ ", stdout); | |
1035 | if (flags & (1 << 2)) fputs ("OFL ", stdout); | |
1036 | if (flags & (1 << 3)) fputs ("UFL ", stdout); | |
1037 | if (flags & (1 << 4)) fputs ("INX ", stdout); | |
1038 | putchar ('\n'); | |
1039 | } | |
1040 | ||
1041 | void | |
1042 | arm_float_info () | |
1043 | { | |
1044 | register unsigned long status = read_register (FPS_REGNUM); | |
1045 | int type; | |
1046 | ||
1047 | type = (status >> 24) & 127; | |
1048 | printf ("%s FPU type %d\n", | |
1049 | (status & (1<<31)) ? "Hardware" : "Software", | |
1050 | type); | |
1051 | fputs ("mask: ", stdout); | |
1052 | print_fpu_flags (status >> 16); | |
1053 | fputs ("flags: ", stdout); | |
1054 | print_fpu_flags (status); | |
1055 | } | |
1056 | ||
c906108c SS |
1057 | static void |
1058 | arm_othernames () | |
1059 | { | |
085dd6e6 JM |
1060 | |
1061 | if (arm_register_names == APCS_register_names) { | |
1062 | arm_register_names = additional_register_names; | |
1063 | arm_toggle_regnames (); | |
1064 | } else { | |
1065 | arm_register_names = APCS_register_names; | |
1066 | arm_toggle_regnames (); | |
1067 | } | |
1068 | ||
c906108c SS |
1069 | } |
1070 | ||
1071 | /* FIXME: Fill in with the 'right thing', see asm | |
1072 | template in arm-convert.s */ | |
1073 | ||
1074 | void | |
1075 | convert_from_extended (ptr, dbl) | |
1076 | void * ptr; | |
1077 | double * dbl; | |
1078 | { | |
1079 | *dbl = *(double*)ptr; | |
1080 | } | |
1081 | ||
1082 | void | |
1083 | convert_to_extended (dbl, ptr) | |
1084 | void * ptr; | |
1085 | double * dbl; | |
1086 | { | |
1087 | *(double*)ptr = *dbl; | |
1088 | } | |
1089 | ||
1090 | static int | |
1091 | condition_true (cond, status_reg) | |
1092 | unsigned long cond; | |
1093 | unsigned long status_reg; | |
1094 | { | |
1095 | if (cond == INST_AL || cond == INST_NV) | |
1096 | return 1; | |
1097 | ||
1098 | switch (cond) | |
1099 | { | |
1100 | case INST_EQ: | |
1101 | return ((status_reg & FLAG_Z) != 0); | |
1102 | case INST_NE: | |
1103 | return ((status_reg & FLAG_Z) == 0); | |
1104 | case INST_CS: | |
1105 | return ((status_reg & FLAG_C) != 0); | |
1106 | case INST_CC: | |
1107 | return ((status_reg & FLAG_C) == 0); | |
1108 | case INST_MI: | |
1109 | return ((status_reg & FLAG_N) != 0); | |
1110 | case INST_PL: | |
1111 | return ((status_reg & FLAG_N) == 0); | |
1112 | case INST_VS: | |
1113 | return ((status_reg & FLAG_V) != 0); | |
1114 | case INST_VC: | |
1115 | return ((status_reg & FLAG_V) == 0); | |
1116 | case INST_HI: | |
1117 | return ((status_reg & (FLAG_C | FLAG_Z)) == FLAG_C); | |
1118 | case INST_LS: | |
1119 | return ((status_reg & (FLAG_C | FLAG_Z)) != FLAG_C); | |
1120 | case INST_GE: | |
1121 | return (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0)); | |
1122 | case INST_LT: | |
1123 | return (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0)); | |
1124 | case INST_GT: | |
1125 | return (((status_reg & FLAG_Z) == 0) && | |
1126 | (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0))); | |
1127 | case INST_LE: | |
1128 | return (((status_reg & FLAG_Z) != 0) || | |
1129 | (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0))); | |
1130 | } | |
1131 | return 1; | |
1132 | } | |
1133 | ||
1134 | #define submask(x) ((1L << ((x) + 1)) - 1) | |
1135 | #define bit(obj,st) (((obj) >> (st)) & 1) | |
1136 | #define bits(obj,st,fn) (((obj) >> (st)) & submask ((fn) - (st))) | |
1137 | #define sbits(obj,st,fn) \ | |
1138 | ((long) (bits(obj,st,fn) | ((long) bit(obj,fn) * ~ submask (fn - st)))) | |
1139 | #define BranchDest(addr,instr) \ | |
1140 | ((CORE_ADDR) (((long) (addr)) + 8 + (sbits (instr, 0, 23) << 2))) | |
1141 | #define ARM_PC_32 1 | |
1142 | ||
1143 | static unsigned long | |
1144 | shifted_reg_val (inst, carry, pc_val, status_reg) | |
1145 | unsigned long inst; | |
1146 | int carry; | |
1147 | unsigned long pc_val; | |
1148 | unsigned long status_reg; | |
1149 | { | |
1150 | unsigned long res, shift; | |
1151 | int rm = bits (inst, 0, 3); | |
1152 | unsigned long shifttype = bits (inst, 5, 6); | |
1153 | ||
1154 | if (bit(inst, 4)) | |
1155 | { | |
1156 | int rs = bits (inst, 8, 11); | |
1157 | shift = (rs == 15 ? pc_val + 8 : read_register (rs)) & 0xFF; | |
1158 | } | |
1159 | else | |
1160 | shift = bits (inst, 7, 11); | |
1161 | ||
1162 | res = (rm == 15 | |
1163 | ? ((pc_val | (ARM_PC_32 ? 0 : status_reg)) | |
1164 | + (bit (inst, 4) ? 12 : 8)) | |
1165 | : read_register (rm)); | |
1166 | ||
1167 | switch (shifttype) | |
1168 | { | |
1169 | case 0: /* LSL */ | |
1170 | res = shift >= 32 ? 0 : res << shift; | |
1171 | break; | |
1172 | ||
1173 | case 1: /* LSR */ | |
1174 | res = shift >= 32 ? 0 : res >> shift; | |
1175 | break; | |
1176 | ||
1177 | case 2: /* ASR */ | |
1178 | if (shift >= 32) shift = 31; | |
1179 | res = ((res & 0x80000000L) | |
1180 | ? ~((~res) >> shift) : res >> shift); | |
1181 | break; | |
1182 | ||
1183 | case 3: /* ROR/RRX */ | |
1184 | shift &= 31; | |
1185 | if (shift == 0) | |
1186 | res = (res >> 1) | (carry ? 0x80000000L : 0); | |
1187 | else | |
1188 | res = (res >> shift) | (res << (32-shift)); | |
1189 | break; | |
1190 | } | |
1191 | ||
1192 | return res & 0xffffffff; | |
1193 | } | |
1194 | ||
1195 | ||
1196 | /* Return number of 1-bits in VAL. */ | |
1197 | ||
1198 | static int | |
1199 | bitcount (val) | |
1200 | unsigned long val; | |
1201 | { | |
1202 | int nbits; | |
1203 | for (nbits = 0; val != 0; nbits++) | |
1204 | val &= val - 1; /* delete rightmost 1-bit in val */ | |
1205 | return nbits; | |
1206 | } | |
1207 | ||
1208 | ||
1209 | static CORE_ADDR | |
1210 | thumb_get_next_pc (pc) | |
1211 | CORE_ADDR pc; | |
1212 | { | |
1213 | unsigned long pc_val = ((unsigned long)pc) + 4; /* PC after prefetch */ | |
1214 | unsigned short inst1 = read_memory_integer (pc, 2); | |
1215 | CORE_ADDR nextpc = pc + 2; /* default is next instruction */ | |
1216 | unsigned long offset; | |
1217 | ||
1218 | if ((inst1 & 0xff00) == 0xbd00) /* pop {rlist, pc} */ | |
1219 | { | |
1220 | CORE_ADDR sp; | |
1221 | ||
1222 | /* Fetch the saved PC from the stack. It's stored above | |
1223 | all of the other registers. */ | |
1224 | offset = bitcount (bits (inst1, 0, 7)) * REGISTER_SIZE; | |
1225 | sp = read_register (SP_REGNUM); | |
1226 | nextpc = (CORE_ADDR) read_memory_integer (sp + offset, 4); | |
1227 | nextpc = ADDR_BITS_REMOVE (nextpc); | |
1228 | if (nextpc == pc) | |
1229 | error ("Infinite loop detected"); | |
1230 | } | |
1231 | else if ((inst1 & 0xf000) == 0xd000) /* conditional branch */ | |
1232 | { | |
1233 | unsigned long status = read_register (PS_REGNUM); | |
1234 | unsigned long cond = bits (inst1, 8, 11); | |
1235 | if (cond != 0x0f && condition_true (cond, status)) /* 0x0f = SWI */ | |
1236 | nextpc = pc_val + (sbits (inst1, 0, 7) << 1); | |
1237 | } | |
1238 | else if ((inst1 & 0xf800) == 0xe000) /* unconditional branch */ | |
1239 | { | |
1240 | nextpc = pc_val + (sbits (inst1, 0, 10) << 1); | |
1241 | } | |
1242 | else if ((inst1 & 0xf800) == 0xf000) /* long branch with link */ | |
1243 | { | |
1244 | unsigned short inst2 = read_memory_integer (pc + 2, 2); | |
1245 | offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1); | |
1246 | nextpc = pc_val + offset; | |
1247 | } | |
1248 | ||
1249 | return nextpc; | |
1250 | } | |
1251 | ||
1252 | ||
1253 | CORE_ADDR | |
1254 | arm_get_next_pc (pc) | |
1255 | CORE_ADDR pc; | |
1256 | { | |
1257 | unsigned long pc_val; | |
1258 | unsigned long this_instr; | |
1259 | unsigned long status; | |
1260 | CORE_ADDR nextpc; | |
1261 | ||
1262 | if (arm_pc_is_thumb (pc)) | |
1263 | return thumb_get_next_pc (pc); | |
1264 | ||
1265 | pc_val = (unsigned long) pc; | |
1266 | this_instr = read_memory_integer (pc, 4); | |
1267 | status = read_register (PS_REGNUM); | |
1268 | nextpc = (CORE_ADDR) (pc_val + 4); /* Default case */ | |
1269 | ||
1270 | if (condition_true (bits (this_instr, 28, 31), status)) | |
1271 | { | |
1272 | switch (bits (this_instr, 24, 27)) | |
1273 | { | |
1274 | case 0x0: case 0x1: /* data processing */ | |
1275 | case 0x2: case 0x3: | |
1276 | { | |
1277 | unsigned long operand1, operand2, result = 0; | |
1278 | unsigned long rn; | |
1279 | int c; | |
1280 | ||
1281 | if (bits (this_instr, 12, 15) != 15) | |
1282 | break; | |
1283 | ||
1284 | if (bits (this_instr, 22, 25) == 0 | |
1285 | && bits (this_instr, 4, 7) == 9) /* multiply */ | |
1286 | error ("Illegal update to pc in instruction"); | |
1287 | ||
1288 | /* Multiply into PC */ | |
1289 | c = (status & FLAG_C) ? 1 : 0; | |
1290 | rn = bits (this_instr, 16, 19); | |
1291 | operand1 = (rn == 15) ? pc_val + 8 : read_register (rn); | |
1292 | ||
1293 | if (bit (this_instr, 25)) | |
1294 | { | |
1295 | unsigned long immval = bits (this_instr, 0, 7); | |
1296 | unsigned long rotate = 2 * bits (this_instr, 8, 11); | |
1297 | operand2 = ((immval >> rotate) | (immval << (32-rotate))) | |
1298 | & 0xffffffff; | |
1299 | } | |
1300 | else /* operand 2 is a shifted register */ | |
1301 | operand2 = shifted_reg_val (this_instr, c, pc_val, status); | |
1302 | ||
1303 | switch (bits (this_instr, 21, 24)) | |
1304 | { | |
1305 | case 0x0: /*and*/ | |
1306 | result = operand1 & operand2; | |
1307 | break; | |
1308 | ||
1309 | case 0x1: /*eor*/ | |
1310 | result = operand1 ^ operand2; | |
1311 | break; | |
1312 | ||
1313 | case 0x2: /*sub*/ | |
1314 | result = operand1 - operand2; | |
1315 | break; | |
1316 | ||
1317 | case 0x3: /*rsb*/ | |
1318 | result = operand2 - operand1; | |
1319 | break; | |
1320 | ||
1321 | case 0x4: /*add*/ | |
1322 | result = operand1 + operand2; | |
1323 | break; | |
1324 | ||
1325 | case 0x5: /*adc*/ | |
1326 | result = operand1 + operand2 + c; | |
1327 | break; | |
1328 | ||
1329 | case 0x6: /*sbc*/ | |
1330 | result = operand1 - operand2 + c; | |
1331 | break; | |
1332 | ||
1333 | case 0x7: /*rsc*/ | |
1334 | result = operand2 - operand1 + c; | |
1335 | break; | |
1336 | ||
1337 | case 0x8: case 0x9: case 0xa: case 0xb: /* tst, teq, cmp, cmn */ | |
1338 | result = (unsigned long) nextpc; | |
1339 | break; | |
1340 | ||
1341 | case 0xc: /*orr*/ | |
1342 | result = operand1 | operand2; | |
1343 | break; | |
1344 | ||
1345 | case 0xd: /*mov*/ | |
1346 | /* Always step into a function. */ | |
1347 | result = operand2; | |
1348 | break; | |
1349 | ||
1350 | case 0xe: /*bic*/ | |
1351 | result = operand1 & ~operand2; | |
1352 | break; | |
1353 | ||
1354 | case 0xf: /*mvn*/ | |
1355 | result = ~operand2; | |
1356 | break; | |
1357 | } | |
1358 | nextpc = (CORE_ADDR) ADDR_BITS_REMOVE (result); | |
1359 | ||
1360 | if (nextpc == pc) | |
1361 | error ("Infinite loop detected"); | |
1362 | break; | |
1363 | } | |
1364 | ||
1365 | case 0x4: case 0x5: /* data transfer */ | |
1366 | case 0x6: case 0x7: | |
1367 | if (bit (this_instr, 20)) | |
1368 | { | |
1369 | /* load */ | |
1370 | if (bits (this_instr, 12, 15) == 15) | |
1371 | { | |
1372 | /* rd == pc */ | |
1373 | unsigned long rn; | |
1374 | unsigned long base; | |
1375 | ||
1376 | if (bit (this_instr, 22)) | |
1377 | error ("Illegal update to pc in instruction"); | |
1378 | ||
1379 | /* byte write to PC */ | |
1380 | rn = bits (this_instr, 16, 19); | |
1381 | base = (rn == 15) ? pc_val + 8 : read_register (rn); | |
1382 | if (bit (this_instr, 24)) | |
1383 | { | |
1384 | /* pre-indexed */ | |
1385 | int c = (status & FLAG_C) ? 1 : 0; | |
1386 | unsigned long offset = | |
1387 | (bit (this_instr, 25) | |
1388 | ? shifted_reg_val (this_instr, c, pc_val) | |
1389 | : bits (this_instr, 0, 11)); | |
1390 | ||
1391 | if (bit (this_instr, 23)) | |
1392 | base += offset; | |
1393 | else | |
1394 | base -= offset; | |
1395 | } | |
1396 | nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base, | |
1397 | 4); | |
1398 | ||
1399 | nextpc = ADDR_BITS_REMOVE (nextpc); | |
1400 | ||
1401 | if (nextpc == pc) | |
1402 | error ("Infinite loop detected"); | |
1403 | } | |
1404 | } | |
1405 | break; | |
1406 | ||
1407 | case 0x8: case 0x9: /* block transfer */ | |
1408 | if (bit (this_instr, 20)) | |
1409 | { | |
1410 | /* LDM */ | |
1411 | if (bit (this_instr, 15)) | |
1412 | { | |
1413 | /* loading pc */ | |
1414 | int offset = 0; | |
1415 | ||
1416 | if (bit (this_instr, 23)) | |
1417 | { | |
1418 | /* up */ | |
1419 | unsigned long reglist = bits (this_instr, 0, 14); | |
1420 | offset = bitcount (reglist) * 4; | |
1421 | if (bit (this_instr, 24)) /* pre */ | |
1422 | offset += 4; | |
1423 | } | |
1424 | else if (bit (this_instr, 24)) | |
1425 | offset = -4; | |
1426 | ||
1427 | { | |
1428 | unsigned long rn_val = | |
1429 | read_register (bits (this_instr, 16, 19)); | |
1430 | nextpc = | |
1431 | (CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val | |
1432 | + offset), | |
1433 | 4); | |
1434 | } | |
1435 | nextpc = ADDR_BITS_REMOVE (nextpc); | |
1436 | if (nextpc == pc) | |
1437 | error ("Infinite loop detected"); | |
1438 | } | |
1439 | } | |
1440 | break; | |
1441 | ||
1442 | case 0xb: /* branch & link */ | |
1443 | case 0xa: /* branch */ | |
1444 | { | |
1445 | nextpc = BranchDest (pc, this_instr); | |
1446 | ||
1447 | nextpc = ADDR_BITS_REMOVE (nextpc); | |
1448 | if (nextpc == pc) | |
1449 | error ("Infinite loop detected"); | |
1450 | break; | |
1451 | } | |
1452 | ||
1453 | case 0xc: case 0xd: | |
1454 | case 0xe: /* coproc ops */ | |
1455 | case 0xf: /* SWI */ | |
1456 | break; | |
1457 | ||
1458 | default: | |
1459 | fprintf (stderr, "Bad bit-field extraction\n"); | |
1460 | return (pc); | |
1461 | } | |
1462 | } | |
1463 | ||
1464 | return nextpc; | |
1465 | } | |
1466 | ||
1467 | #include "bfd-in2.h" | |
1468 | #include "libcoff.h" | |
1469 | ||
1470 | static int | |
1471 | gdb_print_insn_arm (memaddr, info) | |
1472 | bfd_vma memaddr; | |
1473 | disassemble_info * info; | |
1474 | { | |
1475 | if (arm_pc_is_thumb (memaddr)) | |
1476 | { | |
1477 | static asymbol * asym; | |
1478 | static combined_entry_type ce; | |
1479 | static struct coff_symbol_struct csym; | |
1480 | static struct _bfd fake_bfd; | |
1481 | static bfd_target fake_target; | |
1482 | ||
1483 | if (csym.native == NULL) | |
1484 | { | |
1485 | /* Create a fake symbol vector containing a Thumb symbol. This is | |
1486 | solely so that the code in print_insn_little_arm() and | |
1487 | print_insn_big_arm() in opcodes/arm-dis.c will detect the presence | |
1488 | of a Thumb symbol and switch to decoding Thumb instructions. */ | |
1489 | ||
1490 | fake_target.flavour = bfd_target_coff_flavour; | |
1491 | fake_bfd.xvec = & fake_target; | |
1492 | ce.u.syment.n_sclass = C_THUMBEXTFUNC; | |
1493 | csym.native = & ce; | |
1494 | csym.symbol.the_bfd = & fake_bfd; | |
1495 | csym.symbol.name = "fake"; | |
1496 | asym = (asymbol *) & csym; | |
1497 | } | |
1498 | ||
1499 | memaddr = UNMAKE_THUMB_ADDR (memaddr); | |
1500 | info->symbols = & asym; | |
1501 | } | |
1502 | else | |
1503 | info->symbols = NULL; | |
1504 | ||
1505 | if (TARGET_BYTE_ORDER == BIG_ENDIAN) | |
1506 | return print_insn_big_arm (memaddr, info); | |
1507 | else | |
1508 | return print_insn_little_arm (memaddr, info); | |
1509 | } | |
1510 | ||
1511 | /* Sequence of bytes for breakpoint instruction. */ | |
1512 | #define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */ | |
1513 | #define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE} | |
1514 | #define THUMB_LE_BREAKPOINT {0xfe,0xdf} | |
1515 | #define THUMB_BE_BREAKPOINT {0xdf,0xfe} | |
1516 | ||
1517 | /* The following has been superseded by BREAKPOINT_FOR_PC, but | |
1518 | is defined merely to keep mem-break.c happy. */ | |
1519 | #define LITTLE_BREAKPOINT ARM_LE_BREAKPOINT | |
1520 | #define BIG_BREAKPOINT ARM_BE_BREAKPOINT | |
1521 | ||
1522 | /* This function implements the BREAKPOINT_FROM_PC macro. It uses the program | |
1523 | counter value to determine whether a 16- or 32-bit breakpoint should be | |
1524 | used. It returns a pointer to a string of bytes that encode a breakpoint | |
1525 | instruction, stores the length of the string to *lenptr, and adjusts pc | |
1526 | (if necessary) to point to the actual memory location where the | |
1527 | breakpoint should be inserted. */ | |
1528 | ||
1529 | unsigned char * | |
1530 | arm_breakpoint_from_pc (pcptr, lenptr) | |
1531 | CORE_ADDR * pcptr; | |
1532 | int * lenptr; | |
1533 | { | |
1534 | if (arm_pc_is_thumb (*pcptr) || arm_pc_is_thumb_dummy (*pcptr)) | |
1535 | { | |
1536 | if (TARGET_BYTE_ORDER == BIG_ENDIAN) | |
1537 | { | |
1538 | static char thumb_breakpoint[] = THUMB_BE_BREAKPOINT; | |
1539 | *pcptr = UNMAKE_THUMB_ADDR (*pcptr); | |
1540 | *lenptr = sizeof (thumb_breakpoint); | |
1541 | return thumb_breakpoint; | |
1542 | } | |
1543 | else | |
1544 | { | |
1545 | static char thumb_breakpoint[] = THUMB_LE_BREAKPOINT; | |
1546 | *pcptr = UNMAKE_THUMB_ADDR (*pcptr); | |
1547 | *lenptr = sizeof (thumb_breakpoint); | |
1548 | return thumb_breakpoint; | |
1549 | } | |
1550 | } | |
1551 | else | |
1552 | { | |
1553 | if (TARGET_BYTE_ORDER == BIG_ENDIAN) | |
1554 | { | |
1555 | static char arm_breakpoint[] = ARM_BE_BREAKPOINT; | |
1556 | *lenptr = sizeof (arm_breakpoint); | |
1557 | return arm_breakpoint; | |
1558 | } | |
1559 | else | |
1560 | { | |
1561 | static char arm_breakpoint[] = ARM_LE_BREAKPOINT; | |
1562 | *lenptr = sizeof (arm_breakpoint); | |
1563 | return arm_breakpoint; | |
1564 | } | |
1565 | } | |
1566 | } | |
1567 | /* Return non-zero if the PC is inside a call thunk (aka stub or trampoline). | |
1568 | This implements the IN_SOLIB_CALL_TRAMPOLINE macro. */ | |
1569 | ||
1570 | int | |
1571 | arm_in_call_stub (pc, name) | |
1572 | CORE_ADDR pc; | |
1573 | char * name; | |
1574 | { | |
1575 | CORE_ADDR start_addr; | |
1576 | ||
1577 | /* Find the starting address of the function containing the PC. If the | |
1578 | caller didn't give us a name, look it up at the same time. */ | |
1579 | if (find_pc_partial_function (pc, name ? NULL : &name, &start_addr, NULL) == 0) | |
1580 | return 0; | |
1581 | ||
1582 | return strncmp (name, "_call_via_r", 11) == 0; | |
1583 | } | |
1584 | ||
1585 | ||
1586 | /* If PC is in a Thumb call or return stub, return the address of the target | |
1587 | PC, which is in a register. The thunk functions are called _called_via_xx, | |
1588 | where x is the register name. The possible names are r0-r9, sl, fp, ip, | |
1589 | sp, and lr. */ | |
1590 | ||
1591 | CORE_ADDR | |
1592 | arm_skip_stub (pc) | |
1593 | CORE_ADDR pc; | |
1594 | { | |
1595 | char * name; | |
1596 | CORE_ADDR start_addr; | |
1597 | ||
1598 | /* Find the starting address and name of the function containing the PC. */ | |
1599 | if (find_pc_partial_function (pc, &name, &start_addr, NULL) == 0) | |
1600 | return 0; | |
1601 | ||
1602 | /* Call thunks always start with "_call_via_". */ | |
1603 | if (strncmp (name, "_call_via_", 10) == 0) | |
1604 | { | |
1605 | /* Use the name suffix to determine which register contains | |
1606 | the target PC. */ | |
1607 | static char *table[15] = | |
1608 | { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | |
1609 | "r8", "r9", "sl", "fp", "ip", "sp", "lr" | |
1610 | }; | |
1611 | int regno; | |
1612 | ||
1613 | for (regno = 0; regno <= 14; regno++) | |
1614 | if (strcmp (&name[10], table[regno]) == 0) | |
1615 | return read_register (regno); | |
1616 | } | |
1617 | return 0; /* not a stub */ | |
1618 | } | |
1619 | ||
1620 | ||
1621 | void | |
1622 | _initialize_arm_tdep () | |
1623 | { | |
085dd6e6 JM |
1624 | int regname_is_APCS = (arm_register_names == APCS_register_names); |
1625 | ||
c906108c | 1626 | tm_print_insn = gdb_print_insn_arm; |
085dd6e6 JM |
1627 | |
1628 | /* Sync the opcode insn printer with our register viewer: */ | |
c906108c | 1629 | |
085dd6e6 JM |
1630 | if (arm_toggle_regnames () != regname_is_APCS) |
1631 | arm_toggle_regnames (); | |
1632 | ||
c906108c SS |
1633 | add_com ("othernames", class_obscure, arm_othernames, |
1634 | "Switch to the other set of register names."); | |
1635 | ||
1636 | /* ??? Maybe this should be a boolean. */ | |
1637 | add_show_from_set (add_set_cmd ("apcs32", no_class, | |
1638 | var_zinteger, (char *)&arm_apcs_32, | |
1639 | "Set usage of ARM 32-bit mode.\n", &setlist), | |
1640 | & showlist); | |
1641 | ||
1642 | } | |
1643 | ||
1644 | /* Test whether the coff symbol specific value corresponds to a Thumb function */ | |
1645 | int | |
1646 | coff_sym_is_thumb(int val) | |
1647 | { | |
1648 | return (val == C_THUMBEXT || | |
1649 | val == C_THUMBSTAT || | |
1650 | val == C_THUMBEXTFUNC || | |
1651 | val == C_THUMBSTATFUNC || | |
1652 | val == C_THUMBLABEL); | |
1653 | } |