How can I get the lua stack trace from a core file using gdb

后端 未结 4 951
北海茫月
北海茫月 2021-02-01 18:07

I have a C++ application (for OS X) that calls lua as a scripting language. I\'m running a large number of these applications (100s) and they can run for a very long time (days

4条回答
  •  逝去的感伤
    2021-02-01 18:17

    This is a small variation to Michael Anderson's GDB script: I had to use this because I was getting Cannot access memory at address 0x656d errors with his script, due to L->base_ci being invalid in my core dump. This starts from the top frame (L->ci) and goes down, in the opposite direction, avoiding the invalid L->base_ci pointer.

    set $p = L->ci
    while ($p > L->base_ci )
      if ( $p->func->value.gc->cl.c.isC == 1 )
        printf "0x%x   C FUNCTION ", $p
        output $p->func->value.gc->cl.c.f
        printf "\n"
      else
        if ($p->func.tt==6)
          set $proto = $p->func->value.gc->cl.l.p
          set $filename = (char*)(&($proto->source->tsv) + 1)
          set $lineno = $proto->lineinfo[ $p->savedpc - $proto->code -1 ]
          printf "0x%x LUA FUNCTION : %d %s\n", $p, $lineno, $filename
        else
          printf "0x%x LUA BASE\n", $p
        end
      end
      set $p = $p - 1
    end
    

提交回复
热议问题