avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Patch for 32 bit breakpoints and program counter


From: Peter Jansen
Subject: [avr-gcc-list] Patch for 32 bit breakpoints and program counter
Date: Fri, 15 Mar 2002 10:56:40 +1100

Hi Ted, Scott,

Attached is a patch for gdb and avarice to get breakpoints and the
program counter to 17 bits for the ATmega128. I can now set a 17 bit
breakpoint and the PC is returned to gdb correctly.

I cannot find where the PC is displayed by the 'info register' command
it is still trucnated to 16 bits in the display.

I'm also working on getting hardware watchpoints working.

Regards,

-- 
Peter Jansen
Smart Container
Level 1, NIC Building
Eveleigh
NSW       1430
AUSTRALIA
diff -urN avarice.1.5/include/avarice.h avarice.1.5-patch/include/avarice.h
--- avarice.1.5/include/avarice.h       Mon Feb 18 07:45:12 2002
+++ avarice.1.5-patch/include/avarice.h Wed Mar 13 15:18:28 2002
@@ -52,7 +52,7 @@
 
     SIG_SPACE_ADDR_OFFSET             = 0x840000,
 
-    BREAKPOINT_SPACE_ADDR_OFFSET      = 0x850000,
+    BREAKPOINT_SPACE_ADDR_OFFSET      = 0x900000,
 
     ADDR_SPACE_MASK = (DATA_SPACE_ADDR_OFFSET   |
                        EEPROM_SPACE_ADDR_OFFSET |
diff -urN avarice.1.5/prog/avarice/jtag.cc 
avarice.1.5-patch/prog/avarice/jtag.cc
--- avarice.1.5/prog/avarice/jtag.cc    Mon Feb 18 07:45:12 2002
+++ avarice.1.5-patch/prog/avarice/jtag.cc      Wed Mar 13 15:19:47 2002
@@ -353,6 +353,8 @@
     unsigned char bpMode = 0x00;
     static bool firstTime = true;
 
+    debugOut("updateBreakpoints\n");
+    
     // OK, I have no idea why this works... ie I don't really know what
     // the 'x' command does. It appears to (as a minimum) clear out BP 1.
     if (firstTime)
@@ -509,7 +511,7 @@
        addr ^= SIG_SPACE_ADDR_OFFSET;
        debugOut("SIG SPACE: 0x%x (0x%x)", addr, whichSpace);
     }
-    else if ((addr & ADDR_SPACE_MASK) == BREAKPOINT_SPACE_ADDR_OFFSET)
+    else if ((addr & 0xf00000) == BREAKPOINT_SPACE_ADDR_OFFSET)
     {
        // breakpoint memory
        whichSpace = ADDR_BREAKPOINT_SPACE;
@@ -643,7 +645,7 @@
        addr ^= SIG_SPACE_ADDR_OFFSET;
        debugOut("SIG SPACE: 0x%x (0x%x)", addr, whichSpace);
     }
-    else if ((addr & ADDR_SPACE_MASK) == BREAKPOINT_SPACE_ADDR_OFFSET)
+    else if ((addr & 0xf00000) == BREAKPOINT_SPACE_ADDR_OFFSET)
     {
        // breakpoint memory
        whichSpace = ADDR_BREAKPOINT_SPACE;
diff -urN avarice.1.5/prog/avarice/remote.cc 
avarice.1.5-patch/prog/avarice/remote.cc
--- avarice.1.5/prog/avarice/remote.cc  Mon Feb 18 07:45:12 2002
+++ avarice.1.5-patch/prog/avarice/remote.cc    Thu Mar 14 15:15:19 2002
@@ -196,9 +196,11 @@
        newPC = getProgramCounter();
        jtagBuffer[35] = (unsigned char)(newPC & 0xff);
        jtagBuffer[36] = (unsigned char)((newPC & 0xff00) >> 8);
+       jtagBuffer[37] = (unsigned char)((newPC & 0xff0000) >> 16);
+       jtagBuffer[38] = (unsigned char)((newPC & 0xff000000) >> 24);
        debugOut("PC = %x\n", newPC);
 
-       mem2hex(jtagBuffer, remcomOutBuffer, 32 + 2 + 2 + 1);
+       mem2hex(jtagBuffer, remcomOutBuffer, 32 + 2 + 4 + 1);
 
        free(jtagBuffer);
        jtagBuffer = 0;
diff -urN gdb+dejagnu-20020312/gdb/avr-tdep.c 
gdb-20020312-patch-0.1/gdb/avr-tdep.c
--- gdb+dejagnu-20020312/gdb/avr-tdep.c Fri Mar 15 10:10:33 2002
+++ gdb-20020312-patch-0.1/gdb/avr-tdep.c       Fri Mar 15 10:47:10 2002
@@ -91,7 +91,7 @@
     AVR_PC_REGNUM     = 34,
 
     AVR_NUM_REGS      = 32 + 1 /*SREG*/ + 1 /*SP*/ + 1 /*PC*/,
-    AVR_NUM_REG_BYTES = 32 + 1 /*SREG*/ + 2 /*SP*/ + 2 /*PC*/,
+    AVR_NUM_REG_BYTES = 32 + 1 /*SREG*/ + 2 /*SP*/ + 4 /*PC*/,
 
     AVR_PC_REG_INDEX  = 35,       /* index into array of registers */
 
@@ -180,8 +180,9 @@
 {
   switch (reg_nr)
     {
-    case AVR_SP_REGNUM:
     case AVR_PC_REGNUM:
+      return 4;
+    case AVR_SP_REGNUM:
     case AVR_FP_REGNUM:
       return 2;
     default:
@@ -206,8 +207,9 @@
 {
   switch (reg_nr)
     {
-    case AVR_SP_REGNUM:
     case AVR_PC_REGNUM:
+      return builtin_type_unsigned_int;
+    case AVR_SP_REGNUM:
       return builtin_type_unsigned_short;
     default:
       return builtin_type_unsigned_char;
@@ -227,7 +229,7 @@
 avr_iaddr_p (CORE_ADDR x)
 {
 /*    fprintf_unfiltered (gdb_stderr, "---->> iaddr_p: addr = 0x%x\n", x); */
-  return (((x) & AVR_MEM_MASK) == AVR_IMEM_START);
+  return (((x) & 0x000800000) == AVR_IMEM_START);
 }
 
 /* FIXME: Really need to use a larger mask for instructions. Some devices are
@@ -1213,7 +1215,7 @@
   set_gdbarch_register_bytes (gdbarch, AVR_NUM_REG_BYTES);
   set_gdbarch_register_byte (gdbarch, avr_register_byte);
   set_gdbarch_register_raw_size (gdbarch, avr_register_raw_size);
-  set_gdbarch_max_register_raw_size (gdbarch, 2);
+  set_gdbarch_max_register_raw_size (gdbarch, 4);
   set_gdbarch_register_virtual_size (gdbarch, avr_register_virtual_size);
   set_gdbarch_max_register_virtual_size (gdbarch, 4);
   set_gdbarch_register_virtual_type (gdbarch, avr_register_virtual_type);
@@ -1281,9 +1283,9 @@
 /*    set_gdbarch_prologue_frameless_p (gdbarch, avr_prologue_frameless_p); */
   set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
 
-/*    set_gdbarch_breakpoint_from_pc             n/a */
-/*    set_gdbarch_memory_insert_breakpoint       n/a */
-/*    set_gdbarch_memory_remove_breakpoint       n/a */
+/*  set_gdbarch_breakpoint_from_pc (gdbarch, avr_breakpoint_from_pc);  */
+/*  set_gdbarch_memory_insert_breakpoint (gdbarch, 
avr_memory_insert_breakpoint); */
+/*  set_gdbarch_memory_remove_breakpoint (gdbarch, 
avr_memory_remove_breakpoint); */
   set_gdbarch_decr_pc_after_break (gdbarch, 0);
 
 /*    set_gdbarch_prepare_to_proceed             n/a (only for threading) */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]