There are 2 things in the attached patch that should help determine what
is going wrong.

(A) IAR has a problem with 'O' packets larger then 99 bytes
new GDB command to help work around that, see below.

(B) In the "arm7_9" debug section, I added some LOG_DEBUG() messages
It seems there was little to *NONE* in that section of code.
Hence, it is very hard to trace problems.
See attached patch.

There is no reason the attached patch should not be committed.

--Duane.

=========================================

simony> IAR Embeded Workbench for ARM 5.11 doesn't have GDB console output.

I have this initial problem:

IAR kick start (32k version) chokes on large O packets.

I have a fix [see attached patch]

In this new patch, There is a new command:

> gdb configure -max-O-packet 0

Above is -max-(letter-O)-packet, not '-max-(number-ZERO)-packet.

The value 0 (zero) - disables all O (letter Oh) packets.
Default is now '256'

They seem to have a *STUPID* limit of exactly 99 bytes.
This works:
> gdb configure -max-O-packet 99
This fails
> gdb configure -max-O-packet 100

How much you wanna bet somebody @ IAR hard coded 100 somewhere?

======================================
Continuing.... with your original problem.

>> Error: unknown character 0x24 in reply, dropping connection
>> Warning:ignoring character 0x6d
>> Warning:ignoring character 0x31
>> Warning:ignoring character 0x2c
>> Warning:ignoring character 0x31
>> Warning:ignoring character 0x23
>> Warning:ignoring character 0x66
>> Warning:ignoring character 0x62

That translates to: $m1,1#fa

Which means: Read @ address 1, for 1 byte.

Openocd should not have a problem with that command.

However, I can't tell which of the two locations in 'gdb_server.c' this
is coming from. There are two identical error messages :-(

[NOT any more, my attached patch changes that]

I cannot get my instance to fail like you are having it fail. Perhaps it
is something specific to your code, or maybe your target.

Anyway - I suspect - I cannot confirm - that in this exactly place, IAR
has sent a 'm' packet. And OpenOCD is not expecting one... it is
expecting an ACK or NAK only.

My attached patch then tries to "unget" the 0x24 ($) start of packet and
assumes the packet waiting for the ACK is good, and does an "unget" so
the main packet decoder can find the new packet. (The other 'ignoring'
messages are coming from the main packet decoder)

I suspect IAR - gets no reply and dies a horrible death.

======================================
You are talking about BREAKPOINTS and STEPPING - etc.

I don't have an NXP LPC chip, I have atmel stuff.
I don't have problems you are having.

But - perhaps the additional log messages [in the patch] will help
narrow the problem.

======================================
**END**
======================================





Index: src/server/gdb_server.c
===================================================================
--- src/server/gdb_server.c     (revision 986)
+++ src/server/gdb_server.c     (working copy)
@@ -42,9 +42,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 
-#if 0
-#define _DEBUG_GDB_IO_
-#endif
+static int debug_gdb_io;
 
 static int gdb_breakpoint_override;
 static enum breakpoint_type gdb_breakpoint_override_type;
@@ -78,6 +76,15 @@
  * see the code in gdb_read_memory_packet() for further explanations */
 int gdb_report_data_abort = 0;
 
+static int 
+safe_toascii(int c)
+{
+       if( (c < 0x20) || (c > 0x7e) ){
+               c = '.';
+       }
+       return c;
+}
+
 int gdb_last_signal(target_t *target)
 {
        switch (target->debug_reason)
@@ -144,10 +151,9 @@
        gdb_connection_t *gdb_con = connection->priv;
        int retval=ERROR_OK;
 
-#ifdef _DEBUG_GDB_IO_
        char *debug_buffer;
-#endif
 
+
        if (gdb_con->buf_cnt-- > 0)
        {
                *next_char = *(gdb_con->buf_p++);
@@ -156,9 +162,9 @@
                else
                        connection->input_pending = 0;
 
-#ifdef _DEBUG_GDB_IO_
-               LOG_DEBUG("returned char '%c' (0x%2.2x)", *next_char, 
*next_char);
-#endif
+               if( debug_gdb_io ){
+                       LOG_DEBUG("returned char '%c' (0x%2.2x)", *next_char, 
*next_char);
+               }
 
                return ERROR_OK;
        }
@@ -217,13 +223,13 @@
 #endif
        }
 
-#ifdef _DEBUG_GDB_IO_
-       debug_buffer = malloc(gdb_con->buf_cnt + 1);
-       memcpy(debug_buffer, gdb_con->buffer, gdb_con->buf_cnt);
-       debug_buffer[gdb_con->buf_cnt] = 0;
-       LOG_DEBUG("received '%s'", debug_buffer);
-       free(debug_buffer);
-#endif
+       if( debug_gdb_io ){
+               debug_buffer = malloc(gdb_con->buf_cnt + 1);
+               memcpy(debug_buffer, gdb_con->buffer, gdb_con->buf_cnt);
+               debug_buffer[gdb_con->buf_cnt] = 0;
+               LOG_DEBUG("received '%s'", debug_buffer);
+               free(debug_buffer);
+       }
 
        gdb_con->buf_p = gdb_con->buffer;
        gdb_con->buf_cnt--;
@@ -232,9 +238,9 @@
                connection->input_pending = 1;
        else
                connection->input_pending = 0;
-#ifdef _DEBUG_GDB_IO_
-       LOG_DEBUG("returned char '%c' (0x%2.2x)", *next_char, *next_char);
-#endif
+       if( debug_gdb_io ){
+               LOG_DEBUG("returned char '%c' (0x%2.2x)", *next_char, 
*next_char);
+       }
 
        return retval;
 }
@@ -277,9 +283,7 @@
 {
        int i;
        unsigned char my_checksum = 0;
-#ifdef _DEBUG_GDB_IO_
        char *debug_buffer;
-#endif
        int reply;
        int retval;
        gdb_connection_t *gdb_con = connection->priv;
@@ -287,34 +291,33 @@
        for (i = 0; i < len; i++)
                my_checksum += buffer[i];
 
-#ifdef _DEBUG_GDB_IO_
-       /* 
-        * At this point we should have nothing in the input queue from GDB,
-        * however sometimes '-' is sent even though we've already received
-        * an ACK (+) for everything we've sent off.
-        */
-       int gotdata;
-       for (;;)
-       {
-               if ((retval=check_pending(connection, 0, &gotdata))!=ERROR_OK)
-                       return retval;
-               if (!gotdata)
-                       break;
-               if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
-                       return retval;
-               LOG_WARNING("Discard unexpected char %c", reply);
+       if( debug_gdb_io ){
+               /* 
+                * At this point we should have nothing in the input queue from 
GDB,
+                * however sometimes '-' is sent even though we've already 
received
+                * an ACK (+) for everything we've sent off.
+                */
+               int gotdata;
+               for (;;){
+                       if ((retval=check_pending(connection, 0, 
&gotdata))!=ERROR_OK)
+                               return retval;
+                       if (!gotdata)
+                               break;
+                       if ((retval = gdb_get_char(connection, &reply)) != 
ERROR_OK)
+                               return retval;
+                       LOG_WARNING("Discard unexpected char 0x%02x %c", reply, 
safe_toascii(reply));
+               }
        }
-#endif
 
        while (1)
        {
-#ifdef _DEBUG_GDB_IO_
-               debug_buffer = malloc(len + 1);
-               memcpy(debug_buffer, buffer, len);
-               debug_buffer[len] = 0;
-               LOG_DEBUG("sending packet '$%s#%2.2x'", debug_buffer, 
my_checksum);
-               free(debug_buffer);
-#endif
+               if( debug_gdb_io ){
+                       debug_buffer = malloc(len + 1);
+                       memcpy(debug_buffer, buffer, len);
+                       debug_buffer[len] = 0;
+                       LOG_DEBUG("sending packet '$%s#%2.2x'", debug_buffer, 
my_checksum);
+                       free(debug_buffer);
+               }
 
                char local_buffer[1024];
                local_buffer[0] = '$';
@@ -347,7 +350,14 @@
 
                if (reply == '+')
                        break;
-               else if (reply == '-')
+               else if( reply == '$' ){
+                       // $ starts a new GDB packet.
+                       // Perhaps GDB is sending a *NEW* packet.
+                       // assume the packet was good.
+                       gdb_putback_char( connection, reply );
+                       LOG_WARNING("Got $, expected - Assuming New Packet");
+                       break;
+               } else if (reply == '-')
                {
                        /* Stop sending output packets for now */
                        log_remove_callback(gdb_log_callback, connection);
@@ -368,14 +378,14 @@
                        }
                        else
                        {
-                               LOG_ERROR("unknown character 0x%2.2x in reply, 
dropping connection", reply);
+                               LOG_ERROR("(^C) unknown character 0x%2.2x (%c) 
in reply, dropping connection", reply, safe_toascii(reply));
                                gdb_con->closed=1;
                                return ERROR_SERVER_REMOTE_CLOSED;
                        }
                }
                else
                {
-                       LOG_ERROR("unknown character 0x%2.2x in reply, dropping 
connection", reply);
+                       LOG_ERROR("(?) unknown character 0x%2.2x (%c) in reply, 
dropping connection", reply, safe_toascii(reply));
                        gdb_con->closed=1;
                        return ERROR_SERVER_REMOTE_CLOSED;
                }
@@ -517,9 +527,9 @@
                        if ((retval = gdb_get_char(connection, &character)) != 
ERROR_OK)
                                return retval;
 
-#ifdef _DEBUG_GDB_IO_
-                       LOG_DEBUG("character: '%c'", character);
-#endif
+                       if( debug_gdb_io ){
+                               LOG_DEBUG("character: '%c'", character);
+                       }
 
                        switch (character)
                        {
@@ -538,7 +548,7 @@
                                        *len = 0;
                                        return ERROR_OK;
                                default:
-                                       LOG_WARNING("ignoring character 0x%x", 
character);
+                                       LOG_WARNING("ignoring character 0x%x 
(%c)", character, safe_toascii(character) );
                                        break;
                        }
                } while (character != '$');
@@ -585,25 +595,40 @@
        return retval;
 }
 
+static int gdb_max_o_packet = 256;
 int gdb_output_con(connection_t *connection, const char* line)
 {
        char *hex_buffer;
        int i, bin_size;
+       int n;
 
-       bin_size = strlen(line);
+       if( gdb_max_o_packet > 0 ){
+               hex_buffer = malloc(2+(gdb_max_o_packet*2));
+               if (hex_buffer == NULL)
+                       return ERROR_GDB_BUFFER_TOO_SMALL;
+               
+               bin_size = strlen(line);
+               
+               while( bin_size ){
+                       n = bin_size;
+                       if( n > gdb_max_o_packet ){
+                               n = gdb_max_o_packet;
+                       }
+                       
+                       
+                       hex_buffer[0] = 'O';
+                       for (i=0; i<n; i++)
+                               snprintf(hex_buffer + 1 + i*2, 3, "%2.2x", 
line[i]);
+                       hex_buffer[(n*2)+1] = 0;
+                       
+                       gdb_put_packet(connection, hex_buffer, (n*2) + 1);
+                       line     += n;
+                       bin_size -= n;
+               }
+               
+               free(hex_buffer);               
+       }
 
-       hex_buffer = malloc(bin_size*2 + 2);
-       if (hex_buffer == NULL)
-               return ERROR_GDB_BUFFER_TOO_SMALL;
-
-       hex_buffer[0] = 'O';
-       for (i=0; i<bin_size; i++)
-               snprintf(hex_buffer + 1 + i*2, 3, "%2.2x", line[i]);
-       hex_buffer[bin_size*2+1] = 0;
-
-       gdb_put_packet(connection, hex_buffer, bin_size*2 + 1);
-
-       free(hex_buffer);
        return ERROR_OK;
 }
 
@@ -845,9 +870,9 @@
        char *reg_packet_p;
        int i;
 
-#ifdef _DEBUG_GDB_IO_
-       LOG_DEBUG("-");
-#endif
+       if( debug_gdb_io ){
+               LOG_DEBUG("-");
+       }
 
        if ((retval = target->type->get_gdb_reg_list(target, &reg_list, 
&reg_list_size)) != ERROR_OK)
        {
@@ -868,15 +893,14 @@
                reg_packet_p += CEIL(reg_list[i]->size, 8) * 2;
        }
 
-#ifdef _DEBUG_GDB_IO_
-       {
+       if( debug_gdb_io ){
                char *reg_packet_p;
                reg_packet_p = strndup(reg_packet, CEIL(reg_packet_size, 8) * 
2);
                LOG_DEBUG("reg_packet: %s", reg_packet_p);
                free(reg_packet_p);
        }
-#endif
 
+
        gdb_put_packet(connection, reg_packet, CEIL(reg_packet_size, 8) * 2);
        free(reg_packet);
 
@@ -893,9 +917,9 @@
        int retval;
        char *packet_p;
 
-#ifdef _DEBUG_GDB_IO_
-       LOG_DEBUG("-");
-#endif
+       if( debug_gdb_io ){
+               LOG_DEBUG("-");
+       }
 
        /* skip command character */
        packet++;
@@ -959,9 +983,9 @@
        int reg_list_size;
        int retval;
 
-#ifdef _DEBUG_GDB_IO_
-       LOG_DEBUG("-");
-#endif
+       if( debug_gdb_io ){
+               LOG_DEBUG("-");
+       }
 
        if ((retval = target->type->get_gdb_reg_list(target, &reg_list, 
&reg_list_size)) != ERROR_OK)
        {
@@ -2258,9 +2282,137 @@
        return ERROR_OK;
 }
 
+static int
+gdb_config( Jim_GetOptInfo *goi )
+{
+       jim_wide w;
+       int e;
+       Jim_Nvp *n;
+       enum {
+               GDB_CONFIG_MAX_OPACKET,
+               GDB_DEBUG_IO,
+       };
+       const Jim_Nvp nvp_gdb_config[] = {
+               { .name = "-max-O-packet", .value = GDB_CONFIG_MAX_OPACKET },
+               { .name = "-debug-io"    , .value = GDB_DEBUG_IO },
+               // terminate 
+               { .name = NULL, .value = -1 },
+       };
 
+       while( goi->argc ){
+               e = Jim_GetOpt_Nvp( goi, nvp_gdb_config, &n );
+               if( e != JIM_OK ){
+                       Jim_GetOpt_NvpUnknown( goi, nvp_gdb_config, 1 );
+                       return JIM_ERR;
+               }
+               
+               switch( n->value ){
+               default:
+                       Jim_SetResult_sprintf( goi->interp, "Unknown cfg option 
%d\n", n->value );
+                       return JIM_ERR;
+               case GDB_DEBUG_IO:
+                       if( goi->isconfigure ){
+                               if( goi->argc != 1 ){
+                                       Jim_WrongNumArgs(interp, 2, 
goi->argv-2, "VALUE");
+                                       return JIM_ERR;
+                               }
+                               e = Jim_GetOpt_Wide( goi, &w );
+                               if( e != JIM_OK ){
+                                       return e;
+                               }
+                               if( (w == 0) || (w==1) ){
+                                       // good
+                               } else {
+                                       /* this is a bit excessive... */
+                                       Jim_SetResult_sprintf( goi->interp, 
+                                                                               
   "Expected 0/1, not %d", (int)(w) );
+                                       return JIM_ERR;
+                               }
+                               debug_gdb_io = 1;
+                       }
+                       Jim_SetResult( interp, Jim_NewIntObj( goi->interp, 
debug_gdb_io ));
+                       break;
+
+               case GDB_CONFIG_MAX_OPACKET:
+                       if( goi->isconfigure ){
+                               if( goi->argc != 1 ){
+                                       Jim_WrongNumArgs(interp, 2, 
goi->argv-2, "VALUE");
+                                       return JIM_ERR;
+                               }
+                               e = Jim_GetOpt_Wide( goi, &w );
+                               if( e != JIM_OK ){
+                                       return e;
+                               }
+                               if( (w > 2048) || (w < -1) ){
+                                       /* this is a bit excessive... */
+                                       Jim_SetResult_sprintf( goi->interp, 
"opacket max is 512, 0 or -1 to disable O packets");
+                                       return JIM_ERR;
+                               }
+                               if( w < 0 ){
+                                       w = 0;
+                               }
+                               gdb_max_o_packet = w;
+                       }
+                       Jim_SetResult( interp, Jim_NewIntObj( goi->interp, 
gdb_max_o_packet ) );
+                       break;
+               }
+       }
+       return JIM_OK;
+}                      
+
+static int
+jim_gdb_command( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+{
+       Jim_GetOptInfo goi;
+       Jim_Nvp *n;
+       int e;
+
+       enum {
+               GDB_CMD_CONFIG,
+               GDB_CMD_CGET
+       };
+
+       const Jim_Nvp nvp_gdb_commands[] = {
+               { .name = "configure", .value = GDB_CMD_CONFIG },
+               { .name = "cget", .value = GDB_CMD_CGET },
+               // add more here later
+               { .name = NULL, .value = -1 },
+       };
+       
+       
+       /* go past cmd name */
+       Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
+
+       e = Jim_GetOpt_Nvp( &goi, nvp_gdb_commands, &n );
+       if( e != JIM_OK ){
+               Jim_GetOpt_NvpUnknown( &goi, nvp_gdb_commands, 1 );
+               return JIM_ERR;
+       }
+       Jim_SetEmptyResult( goi.interp );
+       switch(n->value){
+       default:
+               Jim_SetResultString( goi.interp, "(gdb command) unknown 
option",-1);
+               return JIM_ERR;
+               break;
+       case GDB_CMD_CONFIG:
+               goi.isconfigure = 1;
+               return gdb_config( &goi );
+               break;
+       case GDB_CMD_CGET:
+               goi.isconfigure = 0;
+               return gdb_config( &goi );
+               break;
+       }
+}
+
+
 int gdb_register_commands(command_context_t *command_context)
 {
+       register_jim( command_context,
+                                 "gdb",
+                                 jim_gdb_command,
+                                 "(try gdb -help) for details");
+
        register_command(command_context, NULL, "gdb_port", 
handle_gdb_port_command,
                        COMMAND_CONFIG, "");
        register_command(command_context, NULL, "gdb_detach", 
handle_gdb_detach_command,
Index: src/target/arm7_9_common.c
===================================================================
--- src/target/arm7_9_common.c  (revision 986)
+++ src/target/arm7_9_common.c  (working copy)
@@ -62,13 +62,13 @@
 
 static int arm7_9_clear_watchpoints(arm7_9_common_t *arm7_9)
 {
+       LOG_DEBUG("Clearing WPs");
        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 
0x0);
        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_VALUE], 
0x0);
        arm7_9->sw_breakpoints_added = 0;
        arm7_9->wp0_used = 0;
        arm7_9->wp1_used = arm7_9->wp1_used_default;
        arm7_9->wp_available = arm7_9->wp_available_max;
-
        return jtag_execute_queue();
 }
 
@@ -77,6 +77,7 @@
 {
        if (arm7_9->sw_breakpoints_added)
        {
+               LOG_DEBUG("SW already added");
                return ERROR_OK;
        }
        if (arm7_9->wp_available < 1)
@@ -85,6 +86,7 @@
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
        arm7_9->wp_available--;
+       LOG_DEBUG("Now: %d avail",arm7_9->wp_available) ;
        
        /* pick a breakpoint unit */
        if (!arm7_9->wp0_used)
@@ -101,7 +103,7 @@
                LOG_ERROR("BUG: both watchpoints used, but wp_available >= 1");
                return ERROR_FAIL;
        }
-
+       LOG_DEBUG("Using WP: %d",arm7_9->sw_breakpoints_added) ;
        if (arm7_9->sw_breakpoints_added==1)
        {
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_VALUE], 
arm7_9->arm_bkpt);
@@ -177,6 +179,10 @@
        {
                /* either an ARM (4 byte) or Thumb (2 byte) breakpoint */
                u32 mask = (breakpoint->length == 4) ? 0x3u : 0x1u;
+               LOG_DEBUG("Setting HARD BP via wp %d @ address: 0x%08x (as 
%s)", 
+                                 breakpoint->set,
+                                 breakpoint->address,
+                                 (mask == 3 ? "arm" : "thumb"));
                if (breakpoint->set==1)
                {
                        
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_VALUE], 
breakpoint->address);
@@ -203,16 +209,21 @@
        }
        else if (breakpoint->type == BKPT_SOFT)
        {
-               if ((retval=arm7_9_set_software_breakpoints(arm7_9))!=ERROR_OK)
+               if ((retval=arm7_9_set_software_breakpoints(arm7_9))!=ERROR_OK){
+                       LOG_DEBUG("SOFT bp ERR");
                        return retval;
-               
+               }
+
                /* did we already set this breakpoint? */
-               if (breakpoint->set)
+               if (breakpoint->set){
+                       LOG_DEBUG("Already set?");
                        return ERROR_OK;
-               
+               }
+
                if (breakpoint->length == 4)
                {
                        u32 verify = 0xffffffff;
+                       LOG_DEBUG("ARM Soft bp @ 0x%08x", breakpoint->address );
                        /* keep the original instruction in target endianness */
                        target->type->read_memory(target, breakpoint->address, 
4, 1, breakpoint->orig_instr);
                        /* write the breakpoint instruction in target 
endianness (arm7_9->arm_bkpt is host endian) */
@@ -228,6 +239,7 @@
                else
                {
                        u16 verify = 0xffff;
+                       LOG_DEBUG("THUMB Soft bp @ 0x%08x", breakpoint->address 
);
                        /* keep the original instruction in target endianness */
                        target->type->read_memory(target, breakpoint->address, 
2, 1, breakpoint->orig_instr);
                        /* write the breakpoint instruction in target 
endianness (arm7_9->thumb_bkpt is host endian) */
@@ -260,6 +272,10 @@
 
        if (breakpoint->type == BKPT_HARD)
        {
+               LOG_DEBUG("Unset H-BP who=%d,a=0x%08x", 
+                                 breakpoint->set,
+                                 breakpoint->address );
+               
                if (breakpoint->set == 1)
                {
                        
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 0x0);
@@ -279,6 +295,8 @@
                if (breakpoint->length == 4)
                {
                        u32 current_instr;
+                       LOG_DEBUG("Unset S-(arm)-BP a=0x%08x", 
breakpoint->address );
+
                        /* check that user program as not modified breakpoint 
instruction */
                        target->type->read_memory(target, breakpoint->address, 
4, 1, (u8*)&current_instr);
                        if (current_instr==arm7_9->arm_bkpt)
@@ -287,6 +305,7 @@
                else
                {
                        u16 current_instr;
+                       LOG_DEBUG("Unset S-(thumb)-BP a=0x%08x", 
breakpoint->address );
                        /* check that user program as not modified breakpoint 
instruction */
                        target->type->read_memory(target, breakpoint->address, 
2, 1, (u8*)&current_instr);
                        if (current_instr==arm7_9->thumb_bkpt)
@@ -308,7 +327,8 @@
                LOG_WARNING("target not halted");
                return ERROR_TARGET_NOT_HALTED;
        }
-       
+
+       LOG_DEBUG( "BP Add @ 0x%08x", breakpoint->address );
        if (arm7_9->breakpoint_count==0)
        {
                /* make sure we don't have any dangling breakpoints. This is 
vital upon 
@@ -331,6 +351,11 @@
 
        if (breakpoint->type == BKPT_HARD)
        {
+               LOG_DEBUG("Set H bp avail: %d, wp0=%d, wp1=%d",
+                                 arm7_9->wp_available,
+                                 arm7_9->wp0_used,
+                                 arm7_9->wp1_used);
+                               
                arm7_9->wp_available--;
                
                if (!arm7_9->wp0_used)
@@ -351,6 +376,7 @@
        
 
        arm7_9->breakpoint_count++;
+       LOG_DEBUG("BP count now: %d",arm7_9->breakpoint_count );
        
        return arm7_9_set_breakpoint(target, breakpoint);
 }
@@ -360,12 +386,17 @@
        armv4_5_common_t *armv4_5 = target->arch_info;
        arm7_9_common_t *arm7_9 = armv4_5->arch_info;
 
+       LOG_DEBUG("BP remove @ 0x%08x", breakpoint->address );
+
        arm7_9_unset_breakpoint(target, breakpoint);
 
-       if (breakpoint->type == BKPT_HARD)
+       if (breakpoint->type == BKPT_HARD){
                arm7_9->wp_available++;
-       
+               LOG_DEBUG("HW avail: %d", arm7_9->wp_available );
+       }
+
        arm7_9->breakpoint_count--;
+       LOG_DEBUG("BP Count: %d", arm7_9->breakpoint_count );
        if (arm7_9->breakpoint_count==0)
        {
                /* make sure we don't have any dangling breakpoints */
@@ -395,8 +426,11 @@
        else
                rw_mask = 1;
 
+       LOG_DEBUG("Set WP @ 0x%08x, type: %s", watchpoint->address, rw_mask ? 
"wr" : "rd" );
+
        if (!arm7_9->wp0_used)
        {
+               LOG_DEBUG("Using WP0");
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_VALUE], 
watchpoint->address);
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], mask);
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], 
watchpoint->mask);
@@ -411,6 +445,7 @@
        }
        else if (!arm7_9->wp1_used)
        {
+               LOG_DEBUG("Using WP1");
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_ADDR_VALUE], 
watchpoint->address);
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_ADDR_MASK], mask);
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_DATA_MASK], 
watchpoint->mask);
@@ -449,6 +484,7 @@
                return ERROR_OK;
        }
 
+       LOG_DEBUG("Un-Set WP @ %d 0x%08x", watchpoint->set, watchpoint->address 
);
        if (watchpoint->set == 1)
        {
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 0x0);
@@ -457,6 +493,7 @@
        }
        else if (watchpoint->set == 2)
        {
+               LOG_DEBUG("Un-Use wp0");
                
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_VALUE], 0x0);
                jtag_execute_queue();
                arm7_9->wp1_used = 0;
@@ -479,15 +516,18 @@
 
        if (arm7_9->wp_available < 1)
        {
+               LOG_DEBUG("WP Not avail!");
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
 
        if ((watchpoint->length != 1) && (watchpoint->length != 2) && 
(watchpoint->length != 4))
        {
+               LOG_DEBUG("WP bad len=%d",watchpoint->length);
                return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
        }
 
        arm7_9->wp_available--;
+       LOG_DEBUG("WP Now avail: %d",arm7_9->wp_available);
 
        return ERROR_OK;
 }
@@ -497,12 +537,15 @@
        armv4_5_common_t *armv4_5 = target->arch_info;
        arm7_9_common_t *arm7_9 = armv4_5->arch_info;
 
+       LOG_DEBUG("WP Unset @ 0x%08x set=%d",watchpoint->address, 
watchpoint->set );
+
        if (watchpoint->set)
        {
                arm7_9_unset_watchpoint(target, watchpoint);
        }
 
        arm7_9->wp_available++;
+       LOG_DEBUG("WP Now avail: %d",arm7_9->wp_available);
 
        return ERROR_OK;
 }
@@ -755,11 +798,13 @@
                if (arm7_9->has_vector_catch)
                {
                        /* program vector catch register to catch reset vector 
*/
+                       LOG_DEBUG("ResetHalt Set VEC-Catch");
                        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_VEC_CATCH], 0x1);
                }
                else
                {
                        /* program watchpoint unit to match on reset vector 
address */
+                       LOG_DEBUG("ResetHalt Via WP0");
                        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_VALUE], 0x0);
                        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], 0x3);
                        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], 
0xffffffff);
@@ -846,12 +891,14 @@
                         * vector catch to enter debug state
                         * restore the register in that case
                         */
+                       LOG_DEBUG("Restore VEC");
                        
embeddedice_store_reg(&arm7_9->eice_cache->reg_list[EICE_VEC_CATCH]);
                }
                else
                {
                        /* restore registers if watchpoint unit 0 was in use
                         */
+                       LOG_DEBUG("wp0_used: %d,reset=%d", arm7_9->wp0_used, 
arm7_9->debug_entry_from_reset);
                        if (arm7_9->wp0_used)
                        {
                                if (arm7_9->debug_entry_from_reset)
@@ -990,6 +1037,7 @@
        {
                /* program EmbeddedICE Debug Control Register to assert DBGRQ
                 */
+               LOG_DEBUG("ResetHalt via DBGRQ (%c)", arm7_9->set_special_dbgrq 
? 't' : 'f');
                if (arm7_9->set_special_dbgrq) {
                        arm7_9->set_special_dbgrq(target);
                } else {
@@ -1001,6 +1049,7 @@
        {
                /* program watchpoint unit to match on any address
                 */
+               LOG_DEBUG("ResetHalt via WP0");
                
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], 
0xffffffff);
                
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], 
0xffffffff);
                
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 
EICE_W_CTRL_ENABLE);
@@ -1565,6 +1614,7 @@
        * - comparator 1 matches the current address
        * - rangeout from comparator 1 is connected to comparator 0 rangein
        * - comparator 0 matches any address, as long as rangein is low */
+       LOG_DEBUG("ICE Step Enable");
        embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], 
0xffffffff);
        embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], 
0xffffffff);
        
embeddedice_write_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 
EICE_W_CTRL_ENABLE);
@@ -1581,6 +1631,7 @@
        armv4_5_common_t *armv4_5 = target->arch_info;
        arm7_9_common_t *arm7_9 = armv4_5->arch_info;
 
+       LOG_DEBUG("ICE Step Disable");
        embeddedice_store_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK]);
        embeddedice_store_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK]);
        
embeddedice_store_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE]);
@@ -2645,3 +2696,11 @@
 
        return ERROR_OK;
 }
+
+
+/*
+ * Local Variables: ***
+ * c-basic-offset: 4 ***
+ * tab-width: 4 ***
+ * End: ***
+ */
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to