src/lj_debug.h - luajit-2.0-src

Data types defined

Macros defined

Source code

  1. /*
  2. ** Debugging and introspection.
  3. ** Copyright (C) 2005-2015 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, cTValue *frame,
  32.                                       const char **name);
  33. LJ_FUNC void lj_debug_shortname(char *out, GCstr *str, BCLine line);
  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. #if LJ_HASPROFILE
  40. LJ_FUNC void lj_debug_dumpstack(lua_State *L, SBuf *sb, const char *fmt,
  41.                                 int depth);
  42. #endif

  43. /* Fixed internal variable names. */
  44. #define VARNAMEDEF(_) \
  45.   _(FOR_IDX, "(for index)") \
  46.   _(FOR_STOP, "(for limit)") \
  47.   _(FOR_STEP, "(for step)") \
  48.   _(FOR_GEN, "(for generator)") \
  49.   _(FOR_STATE, "(for state)") \
  50.   _(FOR_CTL, "(for control)")

  51. enum {
  52.   VARNAME_END,
  53. #define VARNAMEENUM(name, str)        VARNAME_##name,
  54.   VARNAMEDEF(VARNAMEENUM)
  55. #undef VARNAMEENUM
  56.   VARNAME__MAX
  57. };

  58. #endif