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

    bugReportStart();
    serverLog(LL_WARNING,
        "Redis %s crashed by signal: %d", REDIS_VERSION, sig);
    if (eip != NULL) {
        serverLog(LL_WARNING,
        "Crashed running the instuction at: %p", eip);
    }
    if (sig == SIGSEGV || sig == SIGBUS) {
        serverLog(LL_WARNING,
        "Accessing 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 */
    serverLogRaw(LL_WARNING|LL_RAW, "\n------ STACK TRACE ------\n");
    logStackTrace(uc);

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

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

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

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

    if (eip != NULL) {
        Dl_info info;
        if (dladdr(eip, &info) != 0) {
            serverLog(LL_WARNING|LL_RAW,
                "\n------ DUMPING CODE AROUND EIP ------\n"
                "Symbol: %s (base: %p)\n"
                "Module: %s (base %p)\n"
                "$ xxd -r -p /tmp/dump.hex /tmp/dump.bin\n"
                "$ objdump --adjust-vma=%p -D -b binary -m i386:x86-64 /tmp/dump.bin\n"
                "------\n",
                info.dli_sname, info.dli_saddr, info.dli_fname, info.dli_fbase,
                info.dli_saddr);
            size_t len = (long)eip - (long)info.dli_saddr;
            unsigned long sz = sysconf(_SC_PAGESIZE);
            if (len < 1<<13) { /* we don't have functions over 8k (verified) */
                /* Find the address of the next page, which is our "safety"
                 * limit when dumping. Then try to dump just 128 bytes more
                 * than EIP if there is room, or stop sooner. */
                unsigned long next = ((unsigned long)eip + sz) & ~(sz-1);
                unsigned long end = (unsigned long)eip + 128;
                if (end > next) end = next;
                len = end - (unsigned long)info.dli_saddr;
                serverLogHexDump(LL_WARNING, "dump of function",
                    info.dli_saddr ,len);
                dumpX86Calls(info.dli_saddr,len);
            }
        }
    }

    serverLogRaw(LL_WARNING|LL_RAW,
"\n=== REDIS 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/antirez/redis/issues\n\n"
"  Suspect RAM error? Use redis-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 $0x120, %rsp            # imm = 0x120
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x78d20
movq %rax, -0x28(%rbp)
callq 0x784b0
movl -0x4(%rbp), %ecx
movl $0x3, %edi
leaq 0xc7dbd(%rip), %rsi     # 0x1411ac
leaq 0xc0e6c(%rip), %rdx     # 0x13a262
movb $0x0, %al
callq 0x2fc60
cmpq $0x0, -0x28(%rbp)
je 0x7941b
movq -0x28(%rbp), %rdx
movl $0x3, %edi
leaq 0xc7db7(%rip), %rsi     # 0x1411cb
movb $0x0, %al
callq 0x2fc60
cmpl $0xb, -0x4(%rbp)
je 0x79427
cmpl $0x7, -0x4(%rbp)
jne 0x79442
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x3, %edi
leaq 0xc7db6(%rip), %rsi     # 0x1411f1
movb $0x0, %al
callq 0x2fc60
leaq 0xfed8f(%rip), %rax     # 0x1781d8
movq 0xa28(%rax), %rdx
leaq 0xfed81(%rip), %rax     # 0x1781d8
movq 0xa30(%rax), %rcx
leaq 0xfed73(%rip), %rax     # 0x1781d8
movl 0xa38(%rax), %r8d
movl $0x3, %edi
leaq 0xc7d8f(%rip), %rsi     # 0x141207
movb $0x0, %al
callq 0x2fc60
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d99(%rip), %rsi     # 0x141224
callq 0x2fa20
movq -0x20(%rbp), %rdi
callq 0x78bc0
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d9b(%rip), %rsi     # 0x141240
callq 0x2fa20
leaq 0xd26bd(%rip), %rdi     # 0x14bb6e
callq 0x35820
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x118(%rbp)
callq 0x2d1b0
movq -0x118(%rbp), %rdi
movl %eax, %edx
leaq 0xc7d82(%rip), %rsi     # 0x14125c
movb $0x0, %al
callq 0x395b0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rsi
movl $0x403, %edi            # imm = 0x403
callq 0x2fa20
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d72(%rip), %rsi     # 0x141271
callq 0x2fa20
callq 0x45d90
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rsi
movl $0x403, %edi            # imm = 0x403
callq 0x2fa20
movq -0x30(%rbp), %rdi
callq 0x38620
movq -0x38(%rbp), %rdi
callq 0x38620
callq 0x78d40
movq -0x20(%rbp), %rdi
callq 0x78970
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d4d(%rip), %rsi     # 0x141294
callq 0x2fa20
callq 0x8e520
callq 0x78ea0
cmpl $0x0, %eax
je 0x7956e
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d4e(%rip), %rsi     # 0x1412b5
callq 0x2fa20
jmp 0x7957f
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d72(%rip), %rsi     # 0x1412ec
callq 0x2fa20
cmpq $0x0, -0x28(%rbp)
je 0x796b5
movq -0x28(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x26860
cmpl $0x0, %eax
je 0x796b3
movq -0xe0(%rbp), %rdx
movq -0xd8(%rbp), %rcx
movq -0xf0(%rbp), %r8
movq -0xe8(%rbp), %r9
movq -0xd8(%rbp), %rax
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d95(%rip), %rsi     # 0x141367
movq %rax, (%rsp)
movb $0x0, %al
callq 0x2fc60
movq -0x28(%rbp), %rax
movq -0xd8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xf8(%rbp)
movl $0x1e, %edi
callq 0x26410
movq %rax, -0x100(%rbp)
cmpq $0x2000, -0xf8(%rbp) # imm = 0x2000
jae 0x796b1
movq -0x28(%rbp), %rax
addq -0x100(%rbp), %rax
movq -0x100(%rbp), %rcx
subq $0x1, %rcx
xorq $-0x1, %rcx
andq %rcx, %rax
movq %rax, -0x108(%rbp)
movq -0x28(%rbp), %rax
addq $0x80, %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
cmpq -0x108(%rbp), %rax
jbe 0x79667
movq -0x108(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rax
movq -0xd8(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0xf8(%rbp)
movq -0xd8(%rbp), %rdx
movq -0xf8(%rbp), %rcx
movl $0x3, %edi
leaq 0xc7d94(%rip), %rsi     # 0x14142d
callq 0x79750
movq -0xd8(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0x79270
jmp 0x796b3
jmp 0x796b5
movl $0x403, %edi            # imm = 0x403
leaq 0xc7d7d(%rip), %rsi     # 0x14143e
callq 0x2fa20
leaq 0xfeb0b(%rip), %rax     # 0x1781d8
cmpl $0x0, 0x61c(%rax)
je 0x796f6
leaq 0xfeafb(%rip), %rax     # 0x1781d8
cmpl $0x0, 0x614(%rax)
jne 0x796f6
leaq 0xfeaeb(%rip), %rax     # 0x1781d8
movq 0x60(%rax), %rdi
callq 0x263b0
leaq -0xd0(%rbp), %rdi
addq $0x8, %rdi
callq 0x26ac0
movl $0xc8000000, -0x48(%rbp) # imm = 0xC8000000
movq $0x0, -0xd0(%rbp)
movl -0x4(%rbp), %edi
leaq -0xd0(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
callq 0x266d0
callq 0x26420
movl %eax, %edi
movl -0x4(%rbp), %esi
callq 0x26670
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)