// File: /workspace/github_c_makefile_star2_O0/erikdubbelboer[P]discnt/src/debug.c
// Function: sigsegvHandler
void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
    ucontext_t *uc = (ucontext_t*) secret;
    sds infostring, clients;
    struct sigaction act;
    UNUSED(info);

    bugReportStart();
    serverLog(LL_WARNING,
        "    Discnt %s crashed by signal: %d", DISCNT_VERSION, sig);
    if (sig == SIGSEGV) {
        serverLog(LL_WARNING,
         "    SIGSEGV caused by address: %p", (void*)info->si_addr);
    }
    serverLog(LL_WARNING,
        "    Failed assertion: %s (%s:%d)", server.assert_failed,
                        server.assert_file, server.assert_line);

    /* Log the stack trace */
    serverLog(LL_WARNING, "--- STACK TRACE");
    logStackTrace(uc);

    /* Log INFO and CLIENT LIST */
    serverLog(LL_WARNING, "--- INFO OUTPUT");
    infostring = genDiscntInfoString("all");
    infostring = sdscatprintf(infostring, "hash_init_value: %u\n",
        dictGetHashFunctionSeed());
    serverLogRaw(LL_WARNING, infostring);
    serverLog(LL_WARNING, "--- CLIENT LIST OUTPUT");
    clients = getAllClientsInfoString();
    serverLogRaw(LL_WARNING, clients);
    sdsfree(infostring);
    sdsfree(clients);

    /* Log the current client */
    logCurrentClient();

    /* Log dump of processor registers */
    logRegisters(uc);

#if defined(HAVE_PROC_MAPS)
    /* Test memory */
    serverLog(LL_WARNING, "--- FAST MEMORY TEST");
    bioKillThreads();
    if (memtest_test_linux_anonymous_maps()) {
        serverLog(LL_WARNING,
            "!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!");
    } else {
        serverLog(LL_WARNING,
            "Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.");
    }
#endif

    serverLog(LL_WARNING,
"\n=== DISCNT BUG REPORT END. Make sure to include from START to END. ===\n\n"
"       Please report the crash by opening an issue on github:\n\n"
"           http://github.com/erikdubbelboer/discnt/issues\n\n"
"  Suspect RAM error? Use discnt-server --test-memory to verify it.\n\n"
);
    /* free(messages); Don't call free() with possibly corrupted memory. */
    if (server.daemonize && server.supervised == 0) unlink(server.pidfile);

    /* Make sure we exit with the right signal at the end. So for instance
     * the core will be dumped if enabled. */
    sigemptyset (&act.sa_mask);
    act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND;
    act.sa_handler = SIG_DFL;
    sigaction (sig, &act, NULL);
    kill(getpid(),sig);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
callq 0x30150
movl -0x4(%rbp), %ecx
movl $0x3, %edi
leaq 0x76039(%rip), %rsi     # 0xa6f3b
leaq 0x741e4(%rip), %rdx     # 0xa50ed
movb $0x0, %al
callq 0x18b10
cmpl $0xb, -0x4(%rbp)
jne 0x30f31
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x3, %edi
leaq 0x76035(%rip), %rsi     # 0xa6f5f
movb $0x0, %al
callq 0x18b10
leaq 0x8e1b0(%rip), %rax     # 0xbf0e8
movq 0x680(%rax), %rdx
leaq 0x8e1a2(%rip), %rax     # 0xbf0e8
movq 0x688(%rax), %rcx
leaq 0x8e194(%rip), %rax     # 0xbf0e8
movl 0x690(%rax), %r8d
movl $0x3, %edi
leaq 0x7601a(%rip), %rsi     # 0xa6f81
movb $0x0, %al
callq 0x18b10
movl $0x3, %edi
leaq 0x76028(%rip), %rsi     # 0xa6fa2
movb $0x0, %al
callq 0x18b10
movq -0x20(%rbp), %rdi
callq 0x30750
movl $0x3, %edi
leaq 0x7601c(%rip), %rsi     # 0xa6fb2
movb $0x0, %al
callq 0x18b10
leaq 0x75f79(%rip), %rdi     # 0xa6f1d
callq 0x1c5a0
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0xd0(%rbp)
callq 0x15fa0
movq -0xd0(%rbp), %rdi
movl %eax, %edx
leaq 0x75ff5(%rip), %rsi     # 0xa6fc2
movb $0x0, %al
callq 0x1f350
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rsi
movl $0x3, %edi
callq 0x18900
movl $0x3, %edi
leaq 0x75fe5(%rip), %rsi     # 0xa6fd7
movb $0x0, %al
callq 0x18b10
callq 0x26c90
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movl $0x3, %edi
callq 0x18900
movq -0x28(%rbp), %rdi
callq 0x1e3c0
movq -0x30(%rbp), %rdi
callq 0x1e3c0
callq 0x30870
movq -0x20(%rbp), %rdi
callq 0x305b0
movl $0x3, %edi
leaq 0x75fb2(%rip), %rsi     # 0xa6fee
movb $0x0, %al
callq 0x18b10
callq 0x36910
callq 0x30950
cmpl $0x0, %eax
je 0x31067
movl $0x3, %edi
leaq 0x75fa5(%rip), %rsi     # 0xa7003
movb $0x0, %al
callq 0x18b10
jmp 0x3107a
movl $0x3, %edi
leaq 0x75fc6(%rip), %rsi     # 0xa7039
movb $0x0, %al
callq 0x18b10
movl $0x3, %edi
leaq 0x7602d(%rip), %rsi     # 0xa70b3
movb $0x0, %al
callq 0x18b10
leaq 0x8e054(%rip), %rax     # 0xbf0e8
cmpl $0x0, 0x5b8(%rax)
je 0x310bd
leaq 0x8e044(%rip), %rax     # 0xbf0e8
cmpl $0x0, 0x5b0(%rax)
jne 0x310bd
leaq 0x8e034(%rip), %rax     # 0xbf0e8
movq 0x50(%rax), %rdi
callq 0x120d0
leaq -0xc8(%rbp), %rdi
addq $0x8, %rdi
callq 0x124d0
movl $0xc8000000, -0x40(%rbp) # imm = 0xC8000000
movq $0x0, -0xc8(%rbp)
movl -0x4(%rbp), %edi
leaq -0xc8(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x12150
callq 0x121d0
movl %eax, %edi
movl -0x4(%rbp), %esi
callq 0x12520
addq $0xd0, %rsp
popq %rbp
retq
nopw (%rax,%rax)