- Added a "User:" debug level. These are messages that are intended for the user...
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 18 Feb 2008 14:32:43 +0000 (14:32 +0000)
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 18 Feb 2008 14:32:43 +0000 (14:32 +0000)
- Faster DEBUG/INFO() when they are disabled
- target_read/write_buffer() now uses 16 and 32 bit access for single word aligned requests. Other requests are serviced as quickly as possible.
- *much* faster read/write GDB packets, removing timeout problems.
- GDB read/write packets w/single word aligned 32/16 bit access now use 32/16 bit word access.
- working area can now be changed on the fly. Provides a way to move working area about as MMU is enabled/disabled.
- cleaned up error messages for verify_image.
Thanks √ėyvind Harboe

git-svn-id: svn://svn.berlios.de/openocd/trunk@302 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/helper/log.c
src/helper/log.h
src/server/gdb_server.c
src/target/target.c

index 4cdcfc8724d68e56a6cfbe921c68e322ed7406c6..fe475130e815d33dc070bad87772fd44b511674f 100644 (file)
@@ -43,12 +43,13 @@ void log_setCallback(logCallback c, void *p)
        privData = p;
 }
 
-static char *log_strings[4] = 
+static char *log_strings[5] = 
 {
+       "User:  ",
        "Error:  ",
        "Warning:",
        "Info:   ",
-       "Debug:  ",
+       "Debug:  "
 };
 
 void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...)
@@ -68,7 +69,7 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f
        if (f != NULL)
                file = f + 1;
 
-       fprintf(log_output, "%s %d %ld %s:%d %s(): %s\n", log_strings[level], count, time(NULL), file, line, function, buffer);
+       fprintf(log_output, "%s %d %ld %s:%d %s(): %s\n", log_strings[level+1], count, time(NULL), file, line, function, buffer);
        fflush(log_output);
        
        va_end(args);
index 09bc3a17b218d0a11d5c418f2a5454b70439b7a3..ab32760a96b3c7e2190d8856d7874d76b24deae6 100644 (file)
@@ -26,6 +26,9 @@
 #include <stdarg.h>
 
 /* logging priorities 
+ * LOG_USER - user messages. Could be anything from information 
+ *            to progress messags. These messages do not represent
+ *            incorrect or unexpected behaviour, just normal execution. 
  * LOG_ERROR - fatal errors, that are likely to cause program abort
  * LOG_WARNING - non-fatal errors, that may be resolved later
  * LOG_INFO - state information, etc.
@@ -33,6 +36,7 @@
  */
 enum log_levels
 {
+       LOG_USER = -1,
        LOG_ERROR = 0,
        LOG_WARNING = 1,
        LOG_INFO = 2,
@@ -53,13 +57,16 @@ extern void log_setCallback(logCallback callback, void *priv);
 
 extern int debug_level;
 
+/* Avoid fn call and building parameter list if we're not outputting the information.
+ * Matters on feeble CPUs for DEBUG/INFO statements that are involved frequently */
+
 #define DEBUG(expr ...) \
-       do { \
+       do { if (debug_level >= LOG_DEBUG) \
                log_printf (LOG_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr); \
        } while(0)
 
 #define INFO(expr ...) \
-       do { \
+       do { if (debug_level >= LOG_INFO) \
                log_printf (LOG_INFO, __FILE__, __LINE__, __FUNCTION__, expr); \
        } while(0)
 
@@ -73,6 +80,12 @@ extern int debug_level;
                log_printf (LOG_ERROR, __FILE__, __LINE__, __FUNCTION__, expr); \
        } while(0)
 
+#define USER(expr ...) \
+       do { \
+               log_printf (LOG_USER, __FILE__, __LINE__, __FUNCTION__, expr); \
+       } while(0)
+
+
 /* general failures
  * error codes < 100
  */
index 99c9376d9c13f8ebee78e2e7c3daa2c4fb60084c..d940bc1a5c2f3e0fa08f593458a74a4658ddf393 100644 (file)
@@ -524,7 +524,7 @@ int gdb_output_con(connection_t *connection, char* line)
 int gdb_output(struct command_context_s *context, char* line)
 {
        /* this will be dumped to the log and also sent as an O packet if possible */
-       ERROR(line);
+       USER(line); 
        return ERROR_OK;
 }
 
@@ -1056,35 +1056,18 @@ int gdb_read_memory_packet(connection_t *connection, target_t *target, char *pac
 
        DEBUG("addr: 0x%8.8x, len: 0x%8.8x", addr, len);
 
-       switch (len)
-       {
-               case 4:
-                       if ((addr % 4) == 0)
-                               retval = target->type->read_memory(target, addr, 4, 1, buffer);
-                       else
-                               retval = target->type->read_memory(target, addr, 1, len, buffer);
-                       break;
-               case 2:
-                       if ((addr % 2) == 0)
-                               retval = target->type->read_memory(target, addr, 2, 1, buffer);
-                       else
-                               retval = target->type->read_memory(target, addr, 1, len, buffer);
-                       break;
-               case 3:
-               case 1:
-                       retval = target->type->read_memory(target, addr, 1, len, buffer);
-                       break;
-                       /* handle bulk reads */
-               default:
-                       retval = target_read_buffer(target, addr, len, buffer);
-                       break;
-       }
+       retval = target_read_buffer(target, addr, len, buffer);
 
 #if 0
        if (retval == ERROR_TARGET_DATA_ABORT)
        {
                /* TODO : Here we have to lie and send back all zero's lest stack traces won't work.
                 * At some point this might be fixed in GDB, in which case this code can be removed.
+                * 
+                * OpenOCD developers are acutely aware of this problem, but there is nothing
+                * gained by involving the user in this problem that hopefully will get resolved
+                * eventually
+                * 
                 * http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gdb&pr=2395
                 */
                memset(buffer, 0, len);
@@ -1159,31 +1142,7 @@ int gdb_write_memory_packet(connection_t *connection, target_t *target, char *pa
                buffer[i] = tmp;
        }
 
-       retval = ERROR_OK;
-       switch (len)
-       {
-               /* handle sized writes */
-               case 4:
-                       if ((addr % 4) == 0)
-                               retval = target->type->write_memory(target, addr, 4, 1, buffer);
-                       else
-                               retval = target->type->write_memory(target, addr, 1, len, buffer);
-                       break;
-               case 2:
-                       if ((addr % 2) == 0)
-                               retval = target->type->write_memory(target, addr, 2, 1, buffer);
-                       else
-                               retval = target->type->write_memory(target, addr, 1, len, buffer);
-                       break;
-               case 3:
-               case 1:
-                       retval = target->type->write_memory(target, addr, 1, len, buffer);
-                       break;
-                       /* handle bulk writes */
-               default:
-                       retval = target_write_buffer(target, addr, len, buffer);
-                       break;
-       }
+       retval = target_write_buffer(target, addr, len, buffer);
 
        if (retval == ERROR_OK)
        {
@@ -1206,7 +1165,6 @@ int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, c
        u32 addr = 0;
        u32 len = 0;
 
-       u8 *buffer;
        int retval;
 
        /* skip command character */
@@ -1231,36 +1189,9 @@ int gdb_write_memory_binary_packet(connection_t *connection, target_t *target, c
        retval = ERROR_OK;
        if( len ) {
 
-               buffer = malloc(len);
-
                DEBUG("addr: 0x%8.8x, len: 0x%8.8x", addr, len);
 
-               memcpy( buffer, separator, len );
-
-               switch (len)
-               {
-                       case 4:
-                               if ((addr % 4) == 0)
-                                       retval = target->type->write_memory(target, addr, 4, 1, buffer);
-                               else
-                                       retval = target->type->write_memory(target, addr, 1, len, buffer);
-                               break;
-                       case 2:
-                               if ((addr % 2) == 0)
-                                       retval = target->type->write_memory(target, addr, 2, 1, buffer);
-                               else
-                                       retval = target->type->write_memory(target, addr, 1, len, buffer);
-                               break;
-                       case 3:
-                       case 1:
-                               retval = target->type->write_memory(target, addr, 1, len, buffer);
-                               break;
-                       default:
-                               retval = target_write_buffer(target, addr, len, buffer);
-                               break;
-               }
-
-               free(buffer);
+               retval = target_write_buffer(target, addr, len, separator);
        }
 
        if (retval == ERROR_OK)
index bafbfb0f6d9a55b9cea7bc7ae0f0e749b1227c95..a606376441acc40c45ddf060da6e783428a47a87 100644 (file)
@@ -700,23 +700,24 @@ int target_register_commands(struct command_context_s *cmd_ctx)
        register_command(cmd_ctx, NULL, "daemon_startup", handle_daemon_startup_command, COMMAND_CONFIG, NULL);
        register_command(cmd_ctx, NULL, "target_script", handle_target_script_command, COMMAND_CONFIG, NULL);
        register_command(cmd_ctx, NULL, "run_and_halt_time", handle_run_and_halt_time_command, COMMAND_CONFIG, NULL);
-       register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_CONFIG, NULL);
+       register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, NULL);
 
        return ERROR_OK;
 }
 
+/* Single aligned words are guaranteed to use 16 or 32 bit access 
+ * mode respectively, otherwise data is handled as quickly as 
+ * possible
+ */
 int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer)
 {
        int retval;
        
        DEBUG("writing buffer of %i byte at 0x%8.8x", size, address);
        
-       /* handle writes of less than 4 byte */
-       if (size < 4)
+       if (((address % 2) == 0) && (size == 2))
        {
-               if ((retval = target->type->write_memory(target, address, 1, size, buffer)) != ERROR_OK)
-                       return retval;
-               return ERROR_OK;
+               return target->type->write_memory(target, address, 2, 1, buffer);
        }
        
        /* handle unaligned head bytes */
@@ -764,18 +765,20 @@ int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buff
        return ERROR_OK;
 }
 
+
+/* Single aligned words are guaranteed to use 16 or 32 bit access 
+ * mode respectively, otherwise data is handled as quickly as 
+ * possible
+ */
 int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer)
 {
        int retval;
        
        DEBUG("reading buffer of %i byte at 0x%8.8x", size, address);
        
-       /* handle reads of less than 4 byte */
-       if (size < 4)
+       if (((address % 2) == 0) && (size == 2))
        {
-               if ((retval = target->type->read_memory(target, address, 1, size, buffer)) != ERROR_OK)
-                       return retval;
-               return ERROR_OK;
+               return target->type->read_memory(target, address, 2, 1, buffer);
        }
        
        /* handle unaligned head bytes */
@@ -828,9 +831,14 @@ int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32*
                if (buffer == NULL)
                {
                        ERROR("error allocating buffer for section (%d bytes)", size);
-                       return ERROR_OK;
+                       return ERROR_INVALID_ARGUMENTS;
+               }
+               retval = target_read_buffer(target, address, size, buffer);
+               if (retval != ERROR_OK)
+               {
+                       free(buffer);
+                       return retval;
                }
-               target_read_buffer(target, address, size, buffer);
 
                /* convert to target endianess */
                for (i = 0; i < (size/sizeof(u32)); i++)
@@ -1226,6 +1234,7 @@ int handle_working_area_command(struct command_context_s *cmd_ctx, char *cmd, ch
                ERROR("target number '%s' not defined", args[0]);
                exit(-1);
        }
+       target_free_all_working_areas(target);
        
        target->working_area = strtoul(args[1], NULL, 0);
        target->working_area_size = strtoul(args[2], NULL, 0);
@@ -1450,6 +1459,13 @@ int handle_wait_halt_command(struct command_context_s *cmd_ctx, char *cmd, char
        return wait_state(cmd_ctx, cmd, TARGET_HALTED, ms); 
 }
 
+static void target_process_events(struct command_context_s *cmd_ctx)
+{
+       target_t *target = get_current_target(cmd_ctx);
+       target->type->poll(target);
+       target_call_timer_callbacks();
+}
+
 static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum target_state state, int ms)
 {
        struct timeval timeout, now;
@@ -1634,7 +1650,9 @@ int handle_resume_command(struct command_context_s *cmd_ctx, char *cmd, char **a
                }
        }
 
-       return wait_state(cmd_ctx, cmd, TARGET_RUNNING, 5000);
+       target_process_events(cmd_ctx);
+       
+       return ERROR_OK;
 }
 
 int handle_step_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
@@ -2017,7 +2035,7 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch
                
                if( retval != ERROR_OK )
                {
-                       command_print(cmd_ctx, "image verify failed, verify aborted");
+                       command_print(cmd_ctx, "could not calculate checksum, verify aborted");
                        free(buffer);
                        image_close(&image);
                        return ERROR_OK;
@@ -2028,7 +2046,7 @@ int handle_verify_image_command(struct command_context_s *cmd_ctx, char *cmd, ch
                        /* failed crc checksum, fall back to a binary compare */
                        u8 *data;
                        
-                       command_print(cmd_ctx, "image verify checksum failed - attempting binary compare");
+                       command_print(cmd_ctx, "checksum mismatch - attempting binary compare");
                        
                        data = (u8*)malloc(buf_cnt);
                        

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)