Commit 1c5a81d8036966875dd96c5700f8c9a7121c237d

Authored by Simon Glass
1 parent 2b1dc29a12

sandbox: Remove the old memory file later

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>

Showing 2 changed files with 6 additions and 6 deletions Side-by-side Diff

arch/sandbox/cpu/start.c
... ... @@ -177,7 +177,7 @@
177 177  
178 178 err = os_read_ram_buf(arg);
179 179 if (err) {
180   - printf("Failed to read RAM buffer\n");
  180 + printf("Failed to read RAM buffer '%s': %d\n", arg, err);
181 181 return err;
182 182 }
183 183  
... ... @@ -313,10 +313,6 @@
313 313 ret = sandbox_read_state(state, state->state_fname);
314 314 if (ret)
315 315 goto err;
316   -
317   - /* Remove old memory file if required */
318   - if (state->ram_buf_rm && state->ram_buf_fname)
319   - os_unlink(state->ram_buf_fname);
320 316  
321 317 memset(&data, '\0', sizeof(data));
322 318 gd = &data;
arch/sandbox/cpu/state.c
... ... @@ -393,7 +393,7 @@
393 393  
394 394 state = &main_state;
395 395  
396   - if (state->write_ram_buf && !state->ram_buf_rm) {
  396 + if (state->write_ram_buf) {
397 397 err = os_write_ram_buf(state->ram_buf_fname);
398 398 if (err) {
399 399 printf("Failed to write RAM buffer\n");
... ... @@ -407,6 +407,10 @@
407 407 return -1;
408 408 }
409 409 }
  410 +
  411 + /* Remove old memory file if required */
  412 + if (state->ram_buf_rm && state->ram_buf_fname)
  413 + os_unlink(state->ram_buf_fname);
410 414  
411 415 /* Delete this at the last moment so as not to upset gdb too much */
412 416 if (state->jumped_fname)