lj_debug.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. ** Debugging and introspection.
  3. ** Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
  4. */
  5. #ifndef _LJ_DEBUG_H
  6. #define _LJ_DEBUG_H
  7. #include "lj_obj.h"
  8. typedef struct lj_Debug {
  9. /* Common fields. Must be in the same order as in lua.h. */
  10. int event;
  11. const char *name;
  12. const char *namewhat;
  13. const char *what;
  14. const char *source;
  15. int currentline;
  16. int nups;
  17. int linedefined;
  18. int lastlinedefined;
  19. char short_src[LUA_IDSIZE];
  20. int i_ci;
  21. /* Extended fields. Only valid if lj_debug_getinfo() is called with ext = 1.*/
  22. int nparams;
  23. int isvararg;
  24. } lj_Debug;
  25. LJ_FUNC cTValue *lj_debug_frame(lua_State *L, int level, int *size);
  26. LJ_FUNC BCLine LJ_FASTCALL lj_debug_line(GCproto *pt, BCPos pc);
  27. LJ_FUNC const char *lj_debug_uvname(GCproto *pt, uint32_t idx);
  28. LJ_FUNC const char *lj_debug_uvnamev(cTValue *o, uint32_t idx, TValue **tvp);
  29. LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc,
  30. BCReg slot, const char **name);
  31. LJ_FUNC const char *lj_debug_funcname(lua_State *L, TValue *frame,
  32. const char **name);
  33. LJ_FUNC void lj_debug_shortname(char *out, GCstr *str);
  34. LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg,
  35. cTValue *frame, cTValue *nextframe);
  36. LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc);
  37. LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar,
  38. int ext);
  39. /* Fixed internal variable names. */
  40. #define VARNAMEDEF(_) \
  41. _(FOR_IDX, "(for index)") \
  42. _(FOR_STOP, "(for limit)") \
  43. _(FOR_STEP, "(for step)") \
  44. _(FOR_GEN, "(for generator)") \
  45. _(FOR_STATE, "(for state)") \
  46. _(FOR_CTL, "(for control)")
  47. enum {
  48. VARNAME_END,
  49. #define VARNAMEENUM(name, str) VARNAME_##name,
  50. VARNAMEDEF(VARNAMEENUM)
  51. #undef VARNAMEENUM
  52. VARNAME__MAX
  53. };
  54. #endif