// File: /workspace/github_c_makefile_star2_O1/zhou-yuxin[P]redis-aof-no-cow/src/scripting.c
// Function: luaLdbLineHook
void luaLdbLineHook(lua_State *lua, lua_Debug *ar) {
    lua_getstack(lua,0,ar);
    lua_getinfo(lua,"Sl",ar);
    ldb.currentline = ar->currentline;

    int bp = ldbIsBreakpoint(ldb.currentline) || ldb.luabp;
    int timeout = 0;

    /* Events outside our script are not interesting. */
    if(strstr(ar->short_src,"user_script") == NULL) return;

    /* Check if a timeout occurred. */
    if (ar->event == LUA_HOOKCOUNT && ldb.step == 0 && bp == 0) {
        mstime_t elapsed = mstime() - server.lua_time_start;
        mstime_t timelimit = server.lua_time_limit ?
                             server.lua_time_limit : 5000;
        if (elapsed >= timelimit) {
            timeout = 1;
            ldb.step = 1;
        } else {
            return; /* No timeout, ignore the COUNT event. */
        }
    }

    if (ldb.step || bp) {
        char *reason = "step over";
        if (bp) reason = ldb.luabp ? "redis.breakpoint() called" :
                                     "break point";
        else if (timeout) reason = "timeout reached, infinite loop?";
        ldb.step = 0;
        ldb.luabp = 0;
        ldbLog(sdscatprintf(sdsempty(),
            "* Stopped at %d, stop reason = %s",
            ldb.currentline, reason));
        ldbLogSourceLine(ldb.currentline);
        ldbSendLogs();
        if (ldbRepl(lua) == C_ERR && timeout) {
            /* If the client closed the connection and we have a timeout
             * connection, let's kill the script otherwise the process
             * will remain blocked indefinitely. */
            lua_pushstring(lua, "timeout during Lua debugging with client closing connection");
            lua_error(lua);
        }
        server.lua_time_start = mstime();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
xorl %ebp, %ebp
xorl %esi, %esi
movq %r14, %rdx
callq 0x8abb9
leaq 0x5914b(%rip), %rsi     # 0xcc8b4
movq %rbx, %rdi
movq %r14, %rdx
callq 0x8ad39
movl 0x28(%r14), %eax
movl %eax, 0xa7bc6(%rip)     # 0x11b344
movslq 0xa7ba3(%rip), %rcx     # 0x11b328
testq %rcx, %rcx
jle 0x737ac
decq %rcx
xorl %edx, %edx
leaq 0xa7a6a(%rip), %rsi     # 0x11b200
cmpl %eax, 0x28(%rsi,%rdx,4)
sete %bpl
je 0x737ac
leaq 0x1(%rdx), %rdi
cmpq %rdx, %rcx
movq %rdi, %rdx
jne 0x73796
cmpl $0x0, 0xa7b7d(%rip)     # 0x11b330
setne %r15b
leaq 0x38(%r14), %rdi
leaq 0x599d5(%rip), %rsi     # 0xcd197
callq 0x266c0
testq %rax, %rax
je 0x738fe
orb %r15b, %bpl
movl (%r14), %eax
xorl $0x3, %eax
orl 0xa7b4d(%rip), %eax     # 0x11b32c
setne %al
orb %bpl, %al
xorl %r15d, %r15d
testb $0x1, %al
jne 0x73833
callq 0x330c8
leaq 0x93060(%rip), %rcx     # 0x106858
subq 0x9e0(%rcx), %rax
movq 0x9d8(%rcx), %rdx
testq %rdx, %rdx
movl $0x1388, %ecx           # imm = 0x1388
cmovneq %rdx, %rcx
xorl %r15d, %r15d
cmpq %rcx, %rax
jl 0x7382a
movl $0x1, 0xa7b08(%rip)     # 0x11b32c
movl $0x1, %r15d
cmpq %rcx, %rax
jl 0x738fe
cmpl $0x0, 0xa7af2(%rip)     # 0x11b32c
setne %al
orb %bpl, %al
testb $0x1, %al
je 0x738fe
testb %bpl, %bpl
je 0x73864
cmpl $0x0, 0xa7adc(%rip)     # 0x11b330
leaq 0x5a7a2(%rip), %rax     # 0xcdffd
leaq 0x5a781(%rip), %r14     # 0xcdfe3
jmp 0x73875
testl %r15d, %r15d
leaq 0x5a76b(%rip), %rax     # 0xcdfd9
leaq 0x5a794(%rip), %r14     # 0xce009
cmoveq %rax, %r14
movq $0x0, 0xa7aa8(%rip) # 0x11b32c
callq 0x39222
movl 0xa7ab5(%rip), %edx     # 0x11b344
leaq 0x5a793(%rip), %rsi     # 0xce029
movq %rax, %rdi
movq %r14, %rcx
xorl %eax, %eax
callq 0x39eb7
movq 0xa7966(%rip), %rdi     # 0x11b210
movq %rax, %rsi
callq 0x2e40f
movl 0xa7a8c(%rip), %edi     # 0x11b344
callq 0x74619
callq 0x73ece
movq %rbx, %rdi
callq 0x7562f
testl %r15d, %r15d
je 0x738eb
cmpl $-0x1, %eax
jne 0x738eb
leaq 0x5a770(%rip), %rsi     # 0xce04b
movq %rbx, %rdi
callq 0x8a02b
movq %rbx, %rdi
callq 0x8a922
callq 0x330c8
leaq 0x92f61(%rip), %rcx     # 0x106858
movq %rax, 0x9e0(%rcx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq