I've committed the fix for "<memory> is missing"  problem.

>    /* a gdb session just attached, try to put the target in halt mode.
>     *
>     * DANGER!!!!
>     *
>     * If the halt fails(e.g. target needs a reset, JTAG communication not
>     * working, etc.), then the GDB connect will succeed as
>     * the get_gdb_reg_list() will lie and return a register list with
>     * dummy values.
>     *
>     * This allows GDB monitor commands to be run from a GDB init script to
>     * initialize the target
>     *
>     * Also, since the halt() is asynchronous target connect will be
>     * instantaneous and thus avoiding annoying timeout problems during
>     * connect.
>     */
>
> The above comment means that OpenOCD knowingly replies with stale data, even
> if there's absolutely no reason for doing so...

could you explain what you mean by "absolutely no reason"?

Do you specifically mean that the target should be halted, if possible,
before replying to the register packet?


There are a couple of things that need to line up just right:

- we need to allow GDB connections to dead or unresponsive targets. This
is to allow users to have monitor commands in the GDB init script to set
things up.
- we need to respond immediately to the connect, or we get weird error
messages that are pretty much impossible to deduce anything from, it
just looks like  OpenOCD or GDB is broken)

You didn't include a -d3 log, so I don't know much about what happened
in your debug session.


Perhaps we can get rid of the white lie upon connect, but for
now it seems like the best option.

Perhaps waiting 500ms for the halted state will do the trick?

If this fails, then I'd like to see the -d3 log.

-- 
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer
Index: C:/workspace/trunk/src/server/gdb_server.c
===================================================================
--- C:/workspace/trunk/src/server/gdb_server.c  (revision 861)
+++ C:/workspace/trunk/src/server/gdb_server.c  (working copy)
@@ -679,6 +679,10 @@
         * connect. 
         */
        target_halt(gdb_service->target);
+       /* wait a tiny bit for halted state or we just continue. The
+        * GDB register packet will then contain garbage 
+        */
+       target_wait_state(gdb_service->target, TARGET_HALTED, 500);
        
        /* remove the initial ACK from the incoming buffer */
        if ((retval = gdb_get_char(connection, &initial_ack)) != ERROR_OK)
Index: C:/workspace/trunk/src/target/target.c
===================================================================
--- C:/workspace/trunk/src/target/target.c      (revision 860)
+++ C:/workspace/trunk/src/target/target.c      (working copy)
@@ -1683,7 +1683,6 @@
        return ERROR_OK;
 }
 
-static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum 
target_state state, int ms);
 
 int handle_poll_command(struct command_context_s *cmd_ctx, char *cmd, char 
**args, int argc)
 {
@@ -1729,11 +1728,12 @@
                        return ERROR_OK;
                }
        }
+       target_t *target = get_current_target(cmd_ctx);
 
-       return wait_state(cmd_ctx, cmd, TARGET_HALTED, ms); 
+       return target_wait_state(target, TARGET_HALTED, ms); 
 }
 
-static int wait_state(struct command_context_s *cmd_ctx, char *cmd, enum 
target_state state, int ms)
+int target_wait_state(target_t *target, enum target_state state, int ms)
 {
        int retval;
        struct timeval timeout, now;
@@ -1741,7 +1741,6 @@
        gettimeofday(&timeout, NULL);
        timeval_add_time(&timeout, 0, ms * 1000);
        
-       target_t *target = get_current_target(cmd_ctx);
        for (;;)
        {
                if ((retval=target_poll(target))!=ERROR_OK)
@@ -1754,7 +1753,7 @@
                if (once)
                {
                        once=0;
-                       command_print(cmd_ctx, "waiting for target %s...", 
target_state_strings[state]);
+                       LOG_USER("waiting for target %s...", 
target_state_strings[state]);
                }
                
                gettimeofday(&now, NULL);
Index: C:/workspace/trunk/src/target/target.h
===================================================================
--- C:/workspace/trunk/src/target/target.h      (revision 860)
+++ C:/workspace/trunk/src/target/target.h      (working copy)
@@ -280,6 +280,7 @@
 extern int target_read_buffer(struct target_s *target, u32 address, u32 size, 
u8 *buffer);
 extern int target_checksum_memory(struct target_s *target, u32 address, u32 
size, u32* crc);
 extern int target_blank_check_memory(struct target_s *target, u32 address, u32 
size, u32* blank);
+extern int target_wait_state(target_t *target, enum target_state state, int 
ms);
 
 /* DANGER!!!!!
  * 
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to