]> git.baikalelectronics.ru Git - uboot.git/commitdiff
sandbox: Support signal handling only when requested
authorSimon Glass <sjg@chromium.org>
Mon, 22 Mar 2021 05:21:01 +0000 (18:21 +1300)
committerSimon Glass <sjg@chromium.org>
Tue, 6 Jul 2021 16:38:03 +0000 (10:38 -0600)
At present if sandbox crashes it prints a message and tries to exit. But
with the recently introduced signal handler, it often seems to get stuck
in a loop until the stack overflows:

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation

Segmentation violation
...

The signal handler is only useful for a few tests, as I understand it.
Make it optional.

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

index 6bb94473f195b70f6a37752f6f97f91673148984..63b086dff801c7bafb7c37db8f2b2121a617905c 100644 (file)
@@ -390,6 +390,16 @@ static int sandbox_cmdline_cb_select_unittests(struct sandbox_state *state,
 }
 SANDBOX_CMDLINE_OPT_SHORT(select_unittests, 'k', 1, "Select unit tests to run");
 
+static int sandbox_cmdline_cb_signals(struct sandbox_state *state,
+                                     const char *arg)
+{
+       state->handle_signals = true;
+
+       return 0;
+}
+SANDBOX_CMDLINE_OPT_SHORT(signals, 'S', 0,
+                         "Handle signals (such as SIGSEGV) in sandbox");
+
 static void setup_ram_buf(struct sandbox_state *state)
 {
        /* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
@@ -476,9 +486,11 @@ int main(int argc, char *argv[])
        if (ret)
                goto err;
 
-       ret = os_setup_signal_handlers();
-       if (ret)
-               goto err;
+       if (state->handle_signals) {
+               ret = os_setup_signal_handlers();
+               if (ret)
+                       goto err;
+       }
 
 #if CONFIG_VAL(SYS_MALLOC_F_LEN)
        gd->malloc_base = CONFIG_MALLOC_F_ADDR;
index bca13069824461aaa4525fd4c0edf567e08eea7b..1c4c571e28d3e629f93b5f11b6d806ed454b391a 100644 (file)
@@ -93,6 +93,7 @@ struct sandbox_state {
        bool ram_buf_read;              /* true if we read the RAM buffer */
        bool run_unittests;             /* Run unit tests */
        const char *select_unittests;   /* Unit test to run */
+       bool handle_signals;            /* Handle signals within sandbox */
 
        /* Pointer to information for each SPI bus/cs */
        struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS]