lj_debug.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. ** Debugging and introspection.
  3. ** Copyright (C) 2005-2023 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. GCobj **op);
  30. LJ_FUNC const char *lj_debug_slotname(GCproto *pt, const BCIns *pc,
  31. BCReg slot, const char **name);
  32. LJ_FUNC const char *lj_debug_funcname(lua_State *L, cTValue *frame,
  33. const char **name);
  34. LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line);
  35. LJ_FUNC void lj_debug_addloc(lua_State *L, const char *msg,
  36. cTValue *frame, cTValue *nextframe);
  37. LJ_FUNC void lj_debug_pushloc(lua_State *L, GCproto *pt, BCPos pc);
  38. LJ_FUNC int lj_debug_getinfo(lua_State *L, const char *what, lj_Debug *ar,
  39. int ext);
  40. #if LJ_HASPROFILE
  41. LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt,
  42. int depth);
  43. #endif
  44. /* Fixed internal variable names. */
  45. #define VARNAMEDEF(_) \
  46. _(FOR_IDX, "(for index)") \
  47. _(FOR_STOP, "(for limit)") \
  48. _(FOR_STEP, "(for step)") \
  49. _(FOR_GEN, "(for generator)") \
  50. _(FOR_STATE, "(for state)") \
  51. _(FOR_CTL, "(for control)")
  52. enum {
  53. VARNAME_END,
  54. #define VARNAMEENUM(name, str) VARNAME_##name,
  55. VARNAMEDEF(VARNAMEENUM)
  56. #undef VARNAMEENUM
  57. VARNAME__MAX
  58. };
  59. #endif