]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: Remove the old memory file later
authorSimon Glass <sjg@chromium.org>
Mon, 1 Oct 2018 17:55:12 +0000 (11:55 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 9 Oct 2018 10:40:26 +0000 (04:40 -0600)
When debugging sandbox it is sometimes annoying that the memory file is
deleted early on. If sandbox later crashes or we quit (using the
debugger), it is not possible to run it again with the same state since
the memory file is gone.

Remove the old memory file when sandbox exits, instead. Also add debugging
showing the memory filename.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/start.c
arch/sandbox/cpu/state.c

index 85f27829ca423c1baa709b5622d0b62f97cd9863..2ee3b485657c2e9d77d002261b9b2bfaad680a2b 100644 (file)
@@ -177,7 +177,7 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
 
        err = os_read_ram_buf(arg);
        if (err) {
-               printf("Failed to read RAM buffer\n");
+               printf("Failed to read RAM buffer '%s': %d\n", arg, err);
                return err;
        }
 
@@ -314,10 +314,6 @@ int main(int argc, char *argv[])
        if (ret)
                goto err;
 
-       /* Remove old memory file if required */
-       if (state->ram_buf_rm && state->ram_buf_fname)
-               os_unlink(state->ram_buf_fname);
-
        memset(&data, '\0', sizeof(data));
        gd = &data;
 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
index 04a11fed559fb7711a73e32fc8135b35e7a8fcbb..d3b9c0598596585c93593a668d7c4e287234586b 100644 (file)
@@ -393,7 +393,7 @@ int state_uninit(void)
 
        state = &main_state;
 
-       if (state->write_ram_buf && !state->ram_buf_rm) {
+       if (state->write_ram_buf) {
                err = os_write_ram_buf(state->ram_buf_fname);
                if (err) {
                        printf("Failed to write RAM buffer\n");
@@ -408,6 +408,10 @@ int state_uninit(void)
                }
        }
 
+       /* Remove old memory file if required */
+       if (state->ram_buf_rm && state->ram_buf_fname)
+               os_unlink(state->ram_buf_fname);
+
        /* Delete this at the last moment so as not to upset gdb too much */
        if (state->jumped_fname)
                os_unlink(state->jumped_fname);