1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
--- gdb/avr-tdep.c~ Sat Jan 21 23:25:07 2006
+++ gdb/avr-tdep.c Sat Sep 30 22:57:08 2006
@@ -182,8 +182,10 @@
struct gdbarch_tdep
{
- /* FIXME: TRoth: is there anything to put here? */
- int foo;
+ /* Size of the PC on the current AVR target. This is equal 2 for
+ most AVRs except for the ATmega256x devices that have a 3-byte
+ PC. */
+ int pcsize;
};
/* Lookup the name of a register given it's number. */
@@ -1003,22 +1005,29 @@
on the stack is in big endian byte order, even though most
everything else about the avr is little endian. Ick! */
- /* FIXME: number of bytes read here will need updated for the
- mega256 when it is available. */
-
+ struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
ULONGEST pc;
unsigned char tmp;
- unsigned char buf[2];
+ unsigned char buf[3];
- read_memory (info->saved_regs[regnum].addr, buf, 2);
+ read_memory (info->saved_regs[regnum].addr, buf, tdep->pcsize);
/* Convert the PC read from memory as a big-endian to
little-endian order. */
- tmp = buf[0];
- buf[0] = buf[1];
- buf[1] = tmp;
+ if (tdep->pcsize == 2)
+ {
+ tmp = buf[0];
+ buf[0] = buf[1];
+ buf[1] = tmp;
+ }
+ else
+ {
+ tmp = buf[0];
+ buf[0] = buf[2];
+ buf[2] = tmp;
+ }
- pc = (extract_unsigned_integer (buf, 2) * 2);
+ pc = (extract_unsigned_integer (buf, tdep->pcsize) * 2);
store_unsigned_integer (bufferp,
register_size (current_gdbarch, regnum),
pc);
@@ -1253,6 +1262,11 @@
case bfd_mach_avr3:
case bfd_mach_avr4:
case bfd_mach_avr5:
+ tdep->pcsize = 2;
+ break;
+
+ case bfd_mach_avr6:
+ tdep->pcsize = 3;
break;
}
|