immunio 0.15.4 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (454) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +0 -27
  3. data/ext/immunio/Rakefile +9 -0
  4. data/lib/immunio/plugins/active_record.rb +1 -1
  5. data/lib/immunio/plugins/active_record_relation.rb +1 -1
  6. data/lib/immunio/plugins/environment_reporter.rb +20 -0
  7. data/lib/immunio/rufus_lua_ext/ref.rb +1 -3
  8. data/lib/immunio/version.rb +1 -1
  9. data/lib/immunio/vm.rb +1 -2
  10. data/lua-hooks/Makefile +97 -0
  11. data/lua-hooks/ext/all.c +41 -52
  12. data/lua-hooks/ext/all.o +0 -0
  13. data/lua-hooks/ext/libinjection/libinjection_html5.o +0 -0
  14. data/lua-hooks/ext/libinjection/libinjection_sqli.o +0 -0
  15. data/lua-hooks/ext/libinjection/libinjection_xss.o +0 -0
  16. data/lua-hooks/ext/libinjection/lualib.c +2 -2
  17. data/lua-hooks/ext/lpeg/lpcap.c +2 -2
  18. data/lua-hooks/ext/lpeg/lpcap.o +0 -0
  19. data/lua-hooks/ext/lpeg/lpcode.c +2 -2
  20. data/lua-hooks/ext/lpeg/lpcode.h +1 -1
  21. data/lua-hooks/ext/lpeg/lpcode.o +0 -0
  22. data/lua-hooks/ext/lpeg/lpprint.o +0 -0
  23. data/lua-hooks/ext/lpeg/lptree.c +2 -2
  24. data/lua-hooks/ext/lpeg/lptypes.h +1 -1
  25. data/lua-hooks/ext/lpeg/lpvm.c +2 -2
  26. data/lua-hooks/ext/lpeg/lpvm.o +0 -0
  27. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +16 -3
  28. data/lua-hooks/ext/lua-snapshot/snapshot.c +14 -7
  29. data/lua-hooks/ext/luajit/COPYRIGHT +56 -0
  30. data/lua-hooks/ext/luajit/Makefile +159 -0
  31. data/lua-hooks/ext/luajit/README +16 -0
  32. data/lua-hooks/ext/luajit/doc/bluequad-print.css +166 -0
  33. data/lua-hooks/ext/luajit/doc/bluequad.css +325 -0
  34. data/lua-hooks/ext/luajit/doc/changes.html +804 -0
  35. data/lua-hooks/ext/luajit/doc/contact.html +104 -0
  36. data/lua-hooks/ext/luajit/doc/ext_c_api.html +189 -0
  37. data/lua-hooks/ext/luajit/doc/ext_ffi.html +332 -0
  38. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +570 -0
  39. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +1261 -0
  40. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +603 -0
  41. data/lua-hooks/ext/luajit/doc/ext_jit.html +201 -0
  42. data/lua-hooks/ext/luajit/doc/ext_profiler.html +365 -0
  43. data/lua-hooks/ext/luajit/doc/extensions.html +448 -0
  44. data/lua-hooks/ext/luajit/doc/faq.html +186 -0
  45. data/lua-hooks/ext/luajit/doc/img/contact.png +0 -0
  46. data/lua-hooks/ext/luajit/doc/install.html +659 -0
  47. data/lua-hooks/ext/luajit/doc/luajit.html +236 -0
  48. data/lua-hooks/ext/luajit/doc/running.html +309 -0
  49. data/lua-hooks/ext/luajit/doc/status.html +118 -0
  50. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +456 -0
  51. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1125 -0
  52. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +518 -0
  53. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1166 -0
  54. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +416 -0
  55. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +953 -0
  56. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +419 -0
  57. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1919 -0
  58. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +83 -0
  59. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +12 -0
  60. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +471 -0
  61. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +1945 -0
  62. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +1094 -0
  63. data/lua-hooks/ext/luajit/etc/luajit.1 +88 -0
  64. data/lua-hooks/ext/luajit/etc/luajit.pc +25 -0
  65. data/lua-hooks/ext/luajit/src/Makefile +697 -0
  66. data/lua-hooks/ext/luajit/src/Makefile.dep +244 -0
  67. data/lua-hooks/ext/luajit/src/host/README +4 -0
  68. data/lua-hooks/ext/luajit/src/host/buildvm +0 -0
  69. data/lua-hooks/ext/luajit/src/host/buildvm.c +518 -0
  70. data/lua-hooks/ext/luajit/src/host/buildvm.h +105 -0
  71. data/lua-hooks/ext/luajit/src/host/buildvm.o +0 -0
  72. data/lua-hooks/ext/luajit/src/host/buildvm_arch.h +7449 -0
  73. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +345 -0
  74. data/lua-hooks/ext/luajit/src/host/buildvm_asm.o +0 -0
  75. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +229 -0
  76. data/lua-hooks/ext/luajit/src/host/buildvm_fold.o +0 -0
  77. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +457 -0
  78. data/lua-hooks/ext/luajit/src/host/buildvm_lib.o +0 -0
  79. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +45 -0
  80. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +368 -0
  81. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.o +0 -0
  82. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +197 -0
  83. data/lua-hooks/ext/luajit/src/host/genminilua.lua +428 -0
  84. data/lua-hooks/ext/luajit/src/host/minilua +0 -0
  85. data/lua-hooks/ext/luajit/src/host/minilua.c +7770 -0
  86. data/lua-hooks/ext/luajit/src/host/minilua.o +0 -0
  87. data/lua-hooks/ext/luajit/src/jit/bc.lua +190 -0
  88. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +661 -0
  89. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +689 -0
  90. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +428 -0
  91. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +17 -0
  92. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +591 -0
  93. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +17 -0
  94. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +838 -0
  95. data/lua-hooks/ext/luajit/src/jit/dump.lua +706 -0
  96. data/lua-hooks/ext/luajit/src/jit/p.lua +310 -0
  97. data/lua-hooks/ext/luajit/src/jit/v.lua +170 -0
  98. data/lua-hooks/ext/luajit/src/jit/vmdef.lua +362 -0
  99. data/lua-hooks/ext/luajit/src/jit/zone.lua +45 -0
  100. data/lua-hooks/ext/{lua → luajit/src}/lauxlib.h +10 -17
  101. data/lua-hooks/ext/luajit/src/lib_aux.c +356 -0
  102. data/lua-hooks/ext/luajit/src/lib_aux.o +0 -0
  103. data/lua-hooks/ext/luajit/src/lib_aux_dyn.o +0 -0
  104. data/lua-hooks/ext/luajit/src/lib_base.c +664 -0
  105. data/lua-hooks/ext/luajit/src/lib_base.o +0 -0
  106. data/lua-hooks/ext/luajit/src/lib_base_dyn.o +0 -0
  107. data/lua-hooks/ext/luajit/src/lib_bit.c +180 -0
  108. data/lua-hooks/ext/luajit/src/lib_bit.o +0 -0
  109. data/lua-hooks/ext/luajit/src/lib_bit_dyn.o +0 -0
  110. data/lua-hooks/ext/luajit/src/lib_debug.c +405 -0
  111. data/lua-hooks/ext/luajit/src/lib_debug.o +0 -0
  112. data/lua-hooks/ext/luajit/src/lib_debug_dyn.o +0 -0
  113. data/lua-hooks/ext/luajit/src/lib_ffi.c +872 -0
  114. data/lua-hooks/ext/luajit/src/lib_ffi.o +0 -0
  115. data/lua-hooks/ext/luajit/src/lib_ffi_dyn.o +0 -0
  116. data/lua-hooks/ext/luajit/src/lib_init.c +55 -0
  117. data/lua-hooks/ext/luajit/src/lib_init.o +0 -0
  118. data/lua-hooks/ext/luajit/src/lib_init_dyn.o +0 -0
  119. data/lua-hooks/ext/luajit/src/lib_io.c +541 -0
  120. data/lua-hooks/ext/luajit/src/lib_io.o +0 -0
  121. data/lua-hooks/ext/luajit/src/lib_io_dyn.o +0 -0
  122. data/lua-hooks/ext/luajit/src/lib_jit.c +767 -0
  123. data/lua-hooks/ext/luajit/src/lib_jit.o +0 -0
  124. data/lua-hooks/ext/luajit/src/lib_jit_dyn.o +0 -0
  125. data/lua-hooks/ext/luajit/src/lib_math.c +230 -0
  126. data/lua-hooks/ext/luajit/src/lib_math.o +0 -0
  127. data/lua-hooks/ext/luajit/src/lib_math_dyn.o +0 -0
  128. data/lua-hooks/ext/luajit/src/lib_os.c +292 -0
  129. data/lua-hooks/ext/luajit/src/lib_os.o +0 -0
  130. data/lua-hooks/ext/luajit/src/lib_os_dyn.o +0 -0
  131. data/lua-hooks/ext/luajit/src/lib_package.c +610 -0
  132. data/lua-hooks/ext/luajit/src/lib_package.o +0 -0
  133. data/lua-hooks/ext/luajit/src/lib_package_dyn.o +0 -0
  134. data/lua-hooks/ext/luajit/src/lib_string.c +752 -0
  135. data/lua-hooks/ext/luajit/src/lib_string.o +0 -0
  136. data/lua-hooks/ext/luajit/src/lib_string_dyn.o +0 -0
  137. data/lua-hooks/ext/luajit/src/lib_table.c +307 -0
  138. data/lua-hooks/ext/luajit/src/lib_table.o +0 -0
  139. data/lua-hooks/ext/luajit/src/lib_table_dyn.o +0 -0
  140. data/lua-hooks/ext/luajit/src/libluajit.a +0 -0
  141. data/lua-hooks/ext/luajit/src/libluajit.so +0 -0
  142. data/lua-hooks/ext/luajit/src/lj.supp +26 -0
  143. data/lua-hooks/ext/luajit/src/lj_alloc.c +1398 -0
  144. data/lua-hooks/ext/luajit/src/lj_alloc.h +17 -0
  145. data/lua-hooks/ext/luajit/src/lj_alloc.o +0 -0
  146. data/lua-hooks/ext/luajit/src/lj_alloc_dyn.o +0 -0
  147. data/lua-hooks/ext/luajit/src/lj_api.c +1210 -0
  148. data/lua-hooks/ext/luajit/src/lj_api.o +0 -0
  149. data/lua-hooks/ext/luajit/src/lj_api_dyn.o +0 -0
  150. data/lua-hooks/ext/luajit/src/lj_arch.h +509 -0
  151. data/lua-hooks/ext/luajit/src/lj_asm.c +2278 -0
  152. data/lua-hooks/ext/luajit/src/lj_asm.h +17 -0
  153. data/lua-hooks/ext/luajit/src/lj_asm.o +0 -0
  154. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +2217 -0
  155. data/lua-hooks/ext/luajit/src/lj_asm_dyn.o +0 -0
  156. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +1833 -0
  157. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2015 -0
  158. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2634 -0
  159. data/lua-hooks/ext/luajit/src/lj_bc.c +14 -0
  160. data/lua-hooks/ext/luajit/src/lj_bc.h +265 -0
  161. data/lua-hooks/ext/luajit/src/lj_bc.o +0 -0
  162. data/lua-hooks/ext/luajit/src/lj_bc_dyn.o +0 -0
  163. data/lua-hooks/ext/luajit/src/lj_bcdef.h +220 -0
  164. data/lua-hooks/ext/luajit/src/lj_bcdump.h +68 -0
  165. data/lua-hooks/ext/luajit/src/lj_bcread.c +457 -0
  166. data/lua-hooks/ext/luajit/src/lj_bcread.o +0 -0
  167. data/lua-hooks/ext/luajit/src/lj_bcread_dyn.o +0 -0
  168. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +361 -0
  169. data/lua-hooks/ext/luajit/src/lj_bcwrite.o +0 -0
  170. data/lua-hooks/ext/luajit/src/lj_bcwrite_dyn.o +0 -0
  171. data/lua-hooks/ext/luajit/src/lj_buf.c +234 -0
  172. data/lua-hooks/ext/luajit/src/lj_buf.h +105 -0
  173. data/lua-hooks/ext/luajit/src/lj_buf.o +0 -0
  174. data/lua-hooks/ext/luajit/src/lj_buf_dyn.o +0 -0
  175. data/lua-hooks/ext/luajit/src/lj_carith.c +429 -0
  176. data/lua-hooks/ext/luajit/src/lj_carith.h +37 -0
  177. data/lua-hooks/ext/luajit/src/lj_carith.o +0 -0
  178. data/lua-hooks/ext/luajit/src/lj_carith_dyn.o +0 -0
  179. data/lua-hooks/ext/luajit/src/lj_ccall.c +984 -0
  180. data/lua-hooks/ext/luajit/src/lj_ccall.h +178 -0
  181. data/lua-hooks/ext/luajit/src/lj_ccall.o +0 -0
  182. data/lua-hooks/ext/luajit/src/lj_ccall_dyn.o +0 -0
  183. data/lua-hooks/ext/luajit/src/lj_ccallback.c +712 -0
  184. data/lua-hooks/ext/luajit/src/lj_ccallback.h +25 -0
  185. data/lua-hooks/ext/luajit/src/lj_ccallback.o +0 -0
  186. data/lua-hooks/ext/luajit/src/lj_ccallback_dyn.o +0 -0
  187. data/lua-hooks/ext/luajit/src/lj_cconv.c +752 -0
  188. data/lua-hooks/ext/luajit/src/lj_cconv.h +70 -0
  189. data/lua-hooks/ext/luajit/src/lj_cconv.o +0 -0
  190. data/lua-hooks/ext/luajit/src/lj_cconv_dyn.o +0 -0
  191. data/lua-hooks/ext/luajit/src/lj_cdata.c +288 -0
  192. data/lua-hooks/ext/luajit/src/lj_cdata.h +76 -0
  193. data/lua-hooks/ext/luajit/src/lj_cdata.o +0 -0
  194. data/lua-hooks/ext/luajit/src/lj_cdata_dyn.o +0 -0
  195. data/lua-hooks/ext/luajit/src/lj_char.c +43 -0
  196. data/lua-hooks/ext/luajit/src/lj_char.h +42 -0
  197. data/lua-hooks/ext/luajit/src/lj_char.o +0 -0
  198. data/lua-hooks/ext/luajit/src/lj_char_dyn.o +0 -0
  199. data/lua-hooks/ext/luajit/src/lj_clib.c +418 -0
  200. data/lua-hooks/ext/luajit/src/lj_clib.h +29 -0
  201. data/lua-hooks/ext/luajit/src/lj_clib.o +0 -0
  202. data/lua-hooks/ext/luajit/src/lj_clib_dyn.o +0 -0
  203. data/lua-hooks/ext/luajit/src/lj_cparse.c +1862 -0
  204. data/lua-hooks/ext/luajit/src/lj_cparse.h +65 -0
  205. data/lua-hooks/ext/luajit/src/lj_cparse.o +0 -0
  206. data/lua-hooks/ext/luajit/src/lj_cparse_dyn.o +0 -0
  207. data/lua-hooks/ext/luajit/src/lj_crecord.c +1834 -0
  208. data/lua-hooks/ext/luajit/src/lj_crecord.h +38 -0
  209. data/lua-hooks/ext/luajit/src/lj_crecord.o +0 -0
  210. data/lua-hooks/ext/luajit/src/lj_crecord_dyn.o +0 -0
  211. data/lua-hooks/ext/luajit/src/lj_ctype.c +635 -0
  212. data/lua-hooks/ext/luajit/src/lj_ctype.h +461 -0
  213. data/lua-hooks/ext/luajit/src/lj_ctype.o +0 -0
  214. data/lua-hooks/ext/luajit/src/lj_ctype_dyn.o +0 -0
  215. data/lua-hooks/ext/luajit/src/lj_debug.c +699 -0
  216. data/lua-hooks/ext/luajit/src/lj_debug.h +65 -0
  217. data/lua-hooks/ext/luajit/src/lj_debug.o +0 -0
  218. data/lua-hooks/ext/luajit/src/lj_debug_dyn.o +0 -0
  219. data/lua-hooks/ext/luajit/src/lj_def.h +365 -0
  220. data/lua-hooks/ext/luajit/src/lj_dispatch.c +557 -0
  221. data/lua-hooks/ext/luajit/src/lj_dispatch.h +138 -0
  222. data/lua-hooks/ext/luajit/src/lj_dispatch.o +0 -0
  223. data/lua-hooks/ext/luajit/src/lj_dispatch_dyn.o +0 -0
  224. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +356 -0
  225. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +211 -0
  226. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +238 -0
  227. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +462 -0
  228. data/lua-hooks/ext/luajit/src/lj_err.c +794 -0
  229. data/lua-hooks/ext/luajit/src/lj_err.h +41 -0
  230. data/lua-hooks/ext/luajit/src/lj_err.o +0 -0
  231. data/lua-hooks/ext/luajit/src/lj_err_dyn.o +0 -0
  232. data/lua-hooks/ext/luajit/src/lj_errmsg.h +190 -0
  233. data/lua-hooks/ext/luajit/src/lj_ff.h +18 -0
  234. data/lua-hooks/ext/luajit/src/lj_ffdef.h +209 -0
  235. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +1247 -0
  236. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +24 -0
  237. data/lua-hooks/ext/luajit/src/lj_ffrecord.o +0 -0
  238. data/lua-hooks/ext/luajit/src/lj_ffrecord_dyn.o +0 -0
  239. data/lua-hooks/ext/luajit/src/lj_folddef.h +1138 -0
  240. data/lua-hooks/ext/luajit/src/lj_frame.h +259 -0
  241. data/lua-hooks/ext/luajit/src/lj_func.c +185 -0
  242. data/lua-hooks/ext/luajit/src/lj_func.h +24 -0
  243. data/lua-hooks/ext/luajit/src/lj_func.o +0 -0
  244. data/lua-hooks/ext/luajit/src/lj_func_dyn.o +0 -0
  245. data/lua-hooks/ext/luajit/src/lj_gc.c +845 -0
  246. data/lua-hooks/ext/luajit/src/lj_gc.h +134 -0
  247. data/lua-hooks/ext/luajit/src/lj_gc.o +0 -0
  248. data/lua-hooks/ext/luajit/src/lj_gc_dyn.o +0 -0
  249. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +787 -0
  250. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +22 -0
  251. data/lua-hooks/ext/luajit/src/lj_gdbjit.o +0 -0
  252. data/lua-hooks/ext/luajit/src/lj_gdbjit_dyn.o +0 -0
  253. data/lua-hooks/ext/luajit/src/lj_ir.c +505 -0
  254. data/lua-hooks/ext/luajit/src/lj_ir.h +577 -0
  255. data/lua-hooks/ext/luajit/src/lj_ir.o +0 -0
  256. data/lua-hooks/ext/luajit/src/lj_ir_dyn.o +0 -0
  257. data/lua-hooks/ext/luajit/src/lj_ircall.h +321 -0
  258. data/lua-hooks/ext/luajit/src/lj_iropt.h +161 -0
  259. data/lua-hooks/ext/luajit/src/lj_jit.h +440 -0
  260. data/lua-hooks/ext/luajit/src/lj_lex.c +482 -0
  261. data/lua-hooks/ext/luajit/src/lj_lex.h +86 -0
  262. data/lua-hooks/ext/luajit/src/lj_lex.o +0 -0
  263. data/lua-hooks/ext/luajit/src/lj_lex_dyn.o +0 -0
  264. data/lua-hooks/ext/luajit/src/lj_lib.c +303 -0
  265. data/lua-hooks/ext/luajit/src/lj_lib.h +115 -0
  266. data/lua-hooks/ext/luajit/src/lj_lib.o +0 -0
  267. data/lua-hooks/ext/luajit/src/lj_lib_dyn.o +0 -0
  268. data/lua-hooks/ext/luajit/src/lj_libdef.h +414 -0
  269. data/lua-hooks/ext/luajit/src/lj_load.c +168 -0
  270. data/lua-hooks/ext/luajit/src/lj_load.o +0 -0
  271. data/lua-hooks/ext/luajit/src/lj_load_dyn.o +0 -0
  272. data/lua-hooks/ext/luajit/src/lj_mcode.c +386 -0
  273. data/lua-hooks/ext/luajit/src/lj_mcode.h +30 -0
  274. data/lua-hooks/ext/luajit/src/lj_mcode.o +0 -0
  275. data/lua-hooks/ext/luajit/src/lj_mcode_dyn.o +0 -0
  276. data/lua-hooks/ext/luajit/src/lj_meta.c +477 -0
  277. data/lua-hooks/ext/luajit/src/lj_meta.h +38 -0
  278. data/lua-hooks/ext/luajit/src/lj_meta.o +0 -0
  279. data/lua-hooks/ext/luajit/src/lj_meta_dyn.o +0 -0
  280. data/lua-hooks/ext/luajit/src/lj_obj.c +50 -0
  281. data/lua-hooks/ext/luajit/src/lj_obj.h +976 -0
  282. data/lua-hooks/ext/luajit/src/lj_obj.o +0 -0
  283. data/lua-hooks/ext/luajit/src/lj_obj_dyn.o +0 -0
  284. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +78 -0
  285. data/lua-hooks/ext/luajit/src/lj_opt_dce.o +0 -0
  286. data/lua-hooks/ext/luajit/src/lj_opt_dce_dyn.o +0 -0
  287. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +2488 -0
  288. data/lua-hooks/ext/luajit/src/lj_opt_fold.o +0 -0
  289. data/lua-hooks/ext/luajit/src/lj_opt_fold_dyn.o +0 -0
  290. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +449 -0
  291. data/lua-hooks/ext/luajit/src/lj_opt_loop.o +0 -0
  292. data/lua-hooks/ext/luajit/src/lj_opt_loop_dyn.o +0 -0
  293. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +935 -0
  294. data/lua-hooks/ext/luajit/src/lj_opt_mem.o +0 -0
  295. data/lua-hooks/ext/luajit/src/lj_opt_mem_dyn.o +0 -0
  296. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +652 -0
  297. data/lua-hooks/ext/luajit/src/lj_opt_narrow.o +0 -0
  298. data/lua-hooks/ext/luajit/src/lj_opt_narrow_dyn.o +0 -0
  299. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +245 -0
  300. data/lua-hooks/ext/luajit/src/lj_opt_sink.o +0 -0
  301. data/lua-hooks/ext/luajit/src/lj_opt_sink_dyn.o +0 -0
  302. data/lua-hooks/ext/luajit/src/lj_opt_split.c +856 -0
  303. data/lua-hooks/ext/luajit/src/lj_opt_split.o +0 -0
  304. data/lua-hooks/ext/luajit/src/lj_opt_split_dyn.o +0 -0
  305. data/lua-hooks/ext/luajit/src/lj_parse.c +2725 -0
  306. data/lua-hooks/ext/luajit/src/lj_parse.h +18 -0
  307. data/lua-hooks/ext/luajit/src/lj_parse.o +0 -0
  308. data/lua-hooks/ext/luajit/src/lj_parse_dyn.o +0 -0
  309. data/lua-hooks/ext/luajit/src/lj_profile.c +368 -0
  310. data/lua-hooks/ext/luajit/src/lj_profile.h +21 -0
  311. data/lua-hooks/ext/luajit/src/lj_profile.o +0 -0
  312. data/lua-hooks/ext/luajit/src/lj_profile_dyn.o +0 -0
  313. data/lua-hooks/ext/luajit/src/lj_recdef.h +270 -0
  314. data/lua-hooks/ext/luajit/src/lj_record.c +2554 -0
  315. data/lua-hooks/ext/luajit/src/lj_record.h +45 -0
  316. data/lua-hooks/ext/luajit/src/lj_record.o +0 -0
  317. data/lua-hooks/ext/luajit/src/lj_record_dyn.o +0 -0
  318. data/lua-hooks/ext/luajit/src/lj_snap.c +870 -0
  319. data/lua-hooks/ext/luajit/src/lj_snap.h +34 -0
  320. data/lua-hooks/ext/luajit/src/lj_snap.o +0 -0
  321. data/lua-hooks/ext/luajit/src/lj_snap_dyn.o +0 -0
  322. data/lua-hooks/ext/luajit/src/lj_state.c +300 -0
  323. data/lua-hooks/ext/luajit/src/lj_state.h +35 -0
  324. data/lua-hooks/ext/luajit/src/lj_state.o +0 -0
  325. data/lua-hooks/ext/luajit/src/lj_state_dyn.o +0 -0
  326. data/lua-hooks/ext/luajit/src/lj_str.c +197 -0
  327. data/lua-hooks/ext/luajit/src/lj_str.h +27 -0
  328. data/lua-hooks/ext/luajit/src/lj_str.o +0 -0
  329. data/lua-hooks/ext/luajit/src/lj_str_dyn.o +0 -0
  330. data/lua-hooks/ext/luajit/src/lj_strfmt.c +554 -0
  331. data/lua-hooks/ext/luajit/src/lj_strfmt.h +125 -0
  332. data/lua-hooks/ext/luajit/src/lj_strfmt.o +0 -0
  333. data/lua-hooks/ext/luajit/src/lj_strfmt_dyn.o +0 -0
  334. data/lua-hooks/ext/luajit/src/lj_strscan.c +547 -0
  335. data/lua-hooks/ext/luajit/src/lj_strscan.h +39 -0
  336. data/lua-hooks/ext/luajit/src/lj_strscan.o +0 -0
  337. data/lua-hooks/ext/luajit/src/lj_strscan_dyn.o +0 -0
  338. data/lua-hooks/ext/luajit/src/lj_tab.c +666 -0
  339. data/lua-hooks/ext/luajit/src/lj_tab.h +73 -0
  340. data/lua-hooks/ext/luajit/src/lj_tab.o +0 -0
  341. data/lua-hooks/ext/luajit/src/lj_tab_dyn.o +0 -0
  342. data/lua-hooks/ext/luajit/src/lj_target.h +164 -0
  343. data/lua-hooks/ext/luajit/src/lj_target_arm.h +270 -0
  344. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +97 -0
  345. data/lua-hooks/ext/luajit/src/lj_target_mips.h +260 -0
  346. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +280 -0
  347. data/lua-hooks/ext/luajit/src/lj_target_x86.h +345 -0
  348. data/lua-hooks/ext/luajit/src/lj_trace.c +859 -0
  349. data/lua-hooks/ext/luajit/src/lj_trace.h +54 -0
  350. data/lua-hooks/ext/luajit/src/lj_trace.o +0 -0
  351. data/lua-hooks/ext/luajit/src/lj_trace_dyn.o +0 -0
  352. data/lua-hooks/ext/luajit/src/lj_traceerr.h +63 -0
  353. data/lua-hooks/ext/luajit/src/lj_udata.c +34 -0
  354. data/lua-hooks/ext/luajit/src/lj_udata.h +14 -0
  355. data/lua-hooks/ext/luajit/src/lj_udata.o +0 -0
  356. data/lua-hooks/ext/luajit/src/lj_udata_dyn.o +0 -0
  357. data/lua-hooks/ext/luajit/src/lj_vm.S +2730 -0
  358. data/lua-hooks/ext/luajit/src/lj_vm.h +114 -0
  359. data/lua-hooks/ext/luajit/src/lj_vm.o +0 -0
  360. data/lua-hooks/ext/luajit/src/lj_vm_dyn.o +0 -0
  361. data/lua-hooks/ext/luajit/src/lj_vmevent.c +58 -0
  362. data/lua-hooks/ext/luajit/src/lj_vmevent.h +59 -0
  363. data/lua-hooks/ext/luajit/src/lj_vmevent.o +0 -0
  364. data/lua-hooks/ext/luajit/src/lj_vmevent_dyn.o +0 -0
  365. data/lua-hooks/ext/luajit/src/lj_vmmath.c +152 -0
  366. data/lua-hooks/ext/luajit/src/lj_vmmath.o +0 -0
  367. data/lua-hooks/ext/luajit/src/lj_vmmath_dyn.o +0 -0
  368. data/lua-hooks/ext/luajit/src/ljamalg.c +96 -0
  369. data/lua-hooks/ext/{lua → luajit/src}/lua.h +12 -7
  370. data/lua-hooks/ext/luajit/src/lua.hpp +9 -0
  371. data/lua-hooks/ext/luajit/src/luaconf.h +156 -0
  372. data/lua-hooks/ext/luajit/src/luajit +0 -0
  373. data/lua-hooks/ext/luajit/src/luajit.c +570 -0
  374. data/lua-hooks/ext/luajit/src/luajit.h +79 -0
  375. data/lua-hooks/ext/luajit/src/luajit.o +0 -0
  376. data/lua-hooks/ext/luajit/src/lualib.h +43 -0
  377. data/lua-hooks/ext/luajit/src/msvcbuild.bat +114 -0
  378. data/lua-hooks/ext/luajit/src/ps4build.bat +103 -0
  379. data/lua-hooks/ext/luajit/src/psvitabuild.bat +93 -0
  380. data/lua-hooks/ext/luajit/src/vm_arm.dasc +4585 -0
  381. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +3764 -0
  382. data/lua-hooks/ext/luajit/src/vm_mips.dasc +4355 -0
  383. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +5252 -0
  384. data/lua-hooks/ext/luajit/src/vm_x64.dasc +4902 -0
  385. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5710 -0
  386. data/lua-hooks/ext/luajit/src/xb1build.bat +101 -0
  387. data/lua-hooks/ext/luajit/src/xedkbuild.bat +92 -0
  388. data/lua-hooks/ext/luautf8/lutf8lib.c +3 -3
  389. data/lua-hooks/lib/boot.lua +37 -2
  390. metadata +372 -69
  391. data/lua-hooks/ext/bitop/README +0 -22
  392. data/lua-hooks/ext/bitop/bit.c +0 -189
  393. data/lua-hooks/ext/extconf.rb +0 -38
  394. data/lua-hooks/ext/lua/COPYRIGHT +0 -34
  395. data/lua-hooks/ext/lua/lapi.c +0 -1087
  396. data/lua-hooks/ext/lua/lapi.h +0 -16
  397. data/lua-hooks/ext/lua/lauxlib.c +0 -652
  398. data/lua-hooks/ext/lua/lbaselib.c +0 -659
  399. data/lua-hooks/ext/lua/lcode.c +0 -831
  400. data/lua-hooks/ext/lua/lcode.h +0 -76
  401. data/lua-hooks/ext/lua/ldblib.c +0 -398
  402. data/lua-hooks/ext/lua/ldebug.c +0 -638
  403. data/lua-hooks/ext/lua/ldebug.h +0 -33
  404. data/lua-hooks/ext/lua/ldo.c +0 -519
  405. data/lua-hooks/ext/lua/ldo.h +0 -57
  406. data/lua-hooks/ext/lua/ldump.c +0 -164
  407. data/lua-hooks/ext/lua/lfunc.c +0 -174
  408. data/lua-hooks/ext/lua/lfunc.h +0 -34
  409. data/lua-hooks/ext/lua/lgc.c +0 -710
  410. data/lua-hooks/ext/lua/lgc.h +0 -110
  411. data/lua-hooks/ext/lua/linit.c +0 -38
  412. data/lua-hooks/ext/lua/liolib.c +0 -556
  413. data/lua-hooks/ext/lua/llex.c +0 -463
  414. data/lua-hooks/ext/lua/llex.h +0 -81
  415. data/lua-hooks/ext/lua/llimits.h +0 -128
  416. data/lua-hooks/ext/lua/lmathlib.c +0 -263
  417. data/lua-hooks/ext/lua/lmem.c +0 -86
  418. data/lua-hooks/ext/lua/lmem.h +0 -49
  419. data/lua-hooks/ext/lua/loadlib.c +0 -705
  420. data/lua-hooks/ext/lua/loadlib_rel.c +0 -760
  421. data/lua-hooks/ext/lua/lobject.c +0 -214
  422. data/lua-hooks/ext/lua/lobject.h +0 -381
  423. data/lua-hooks/ext/lua/lopcodes.c +0 -102
  424. data/lua-hooks/ext/lua/lopcodes.h +0 -268
  425. data/lua-hooks/ext/lua/loslib.c +0 -243
  426. data/lua-hooks/ext/lua/lparser.c +0 -1339
  427. data/lua-hooks/ext/lua/lparser.h +0 -82
  428. data/lua-hooks/ext/lua/lstate.c +0 -214
  429. data/lua-hooks/ext/lua/lstate.h +0 -169
  430. data/lua-hooks/ext/lua/lstring.c +0 -111
  431. data/lua-hooks/ext/lua/lstring.h +0 -31
  432. data/lua-hooks/ext/lua/lstrlib.c +0 -871
  433. data/lua-hooks/ext/lua/ltable.c +0 -588
  434. data/lua-hooks/ext/lua/ltable.h +0 -40
  435. data/lua-hooks/ext/lua/ltablib.c +0 -287
  436. data/lua-hooks/ext/lua/ltm.c +0 -75
  437. data/lua-hooks/ext/lua/ltm.h +0 -54
  438. data/lua-hooks/ext/lua/lua.c +0 -392
  439. data/lua-hooks/ext/lua/lua.def +0 -131
  440. data/lua-hooks/ext/lua/lua.rc +0 -28
  441. data/lua-hooks/ext/lua/lua_dll.rc +0 -26
  442. data/lua-hooks/ext/lua/luac.c +0 -200
  443. data/lua-hooks/ext/lua/luac.rc +0 -1
  444. data/lua-hooks/ext/lua/luaconf.h +0 -763
  445. data/lua-hooks/ext/lua/luaconf.h.in +0 -724
  446. data/lua-hooks/ext/lua/luaconf.h.orig +0 -763
  447. data/lua-hooks/ext/lua/lualib.h +0 -53
  448. data/lua-hooks/ext/lua/lundump.c +0 -227
  449. data/lua-hooks/ext/lua/lundump.h +0 -36
  450. data/lua-hooks/ext/lua/lvm.c +0 -767
  451. data/lua-hooks/ext/lua/lvm.h +0 -36
  452. data/lua-hooks/ext/lua/lzio.c +0 -82
  453. data/lua-hooks/ext/lua/lzio.h +0 -67
  454. data/lua-hooks/ext/lua/print.c +0 -227
@@ -1,638 +0,0 @@
1
- /*
2
- ** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $
3
- ** Debug Interface
4
- ** See Copyright Notice in lua.h
5
- */
6
-
7
-
8
- #include <stdarg.h>
9
- #include <stddef.h>
10
- #include <string.h>
11
-
12
-
13
- #define ldebug_c
14
- #define LUA_CORE
15
-
16
- #include "lua.h"
17
-
18
- #include "lapi.h"
19
- #include "lcode.h"
20
- #include "ldebug.h"
21
- #include "ldo.h"
22
- #include "lfunc.h"
23
- #include "lobject.h"
24
- #include "lopcodes.h"
25
- #include "lstate.h"
26
- #include "lstring.h"
27
- #include "ltable.h"
28
- #include "ltm.h"
29
- #include "lvm.h"
30
-
31
-
32
-
33
- static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name);
34
-
35
-
36
- static int currentpc (lua_State *L, CallInfo *ci) {
37
- if (!isLua(ci)) return -1; /* function is not a Lua function? */
38
- if (ci == L->ci)
39
- ci->savedpc = L->savedpc;
40
- return pcRel(ci->savedpc, ci_func(ci)->l.p);
41
- }
42
-
43
-
44
- static int currentline (lua_State *L, CallInfo *ci) {
45
- int pc = currentpc(L, ci);
46
- if (pc < 0)
47
- return -1; /* only active lua functions have current-line information */
48
- else
49
- return lgetline(ci_func(ci)->l.p, pc);
50
- }
51
-
52
-
53
- /*
54
- ** this function can be called asynchronous (e.g. during a signal)
55
- */
56
- LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) {
57
- if (func == NULL || mask == 0) { /* turn off hooks? */
58
- mask = 0;
59
- func = NULL;
60
- }
61
- L->hook = func;
62
- L->basehookcount = count;
63
- resethookcount(L);
64
- L->hookmask = cast_byte(mask);
65
- return 1;
66
- }
67
-
68
-
69
- LUA_API lua_Hook lua_gethook (lua_State *L) {
70
- return L->hook;
71
- }
72
-
73
-
74
- LUA_API int lua_gethookmask (lua_State *L) {
75
- return L->hookmask;
76
- }
77
-
78
-
79
- LUA_API int lua_gethookcount (lua_State *L) {
80
- return L->basehookcount;
81
- }
82
-
83
-
84
- LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
85
- int status;
86
- CallInfo *ci;
87
- lua_lock(L);
88
- for (ci = L->ci; level > 0 && ci > L->base_ci; ci--) {
89
- level--;
90
- if (f_isLua(ci)) /* Lua function? */
91
- level -= ci->tailcalls; /* skip lost tail calls */
92
- }
93
- if (level == 0 && ci > L->base_ci) { /* level found? */
94
- status = 1;
95
- ar->i_ci = cast_int(ci - L->base_ci);
96
- }
97
- else if (level < 0) { /* level is of a lost tail call? */
98
- status = 1;
99
- ar->i_ci = 0;
100
- }
101
- else status = 0; /* no such level */
102
- lua_unlock(L);
103
- return status;
104
- }
105
-
106
-
107
- static Proto *getluaproto (CallInfo *ci) {
108
- return (isLua(ci) ? ci_func(ci)->l.p : NULL);
109
- }
110
-
111
-
112
- static const char *findlocal (lua_State *L, CallInfo *ci, int n) {
113
- const char *name;
114
- Proto *fp = getluaproto(ci);
115
- if (fp && (name = luaF_getlocalname(fp, n, currentpc(L, ci))) != NULL)
116
- return name; /* is a local variable in a Lua function */
117
- else {
118
- StkId limit = (ci == L->ci) ? L->top : (ci+1)->func;
119
- if (limit - ci->base >= n && n > 0) /* is 'n' inside 'ci' stack? */
120
- return "(*temporary)";
121
- else
122
- return NULL;
123
- }
124
- }
125
-
126
-
127
- LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) {
128
- CallInfo *ci = L->base_ci + ar->i_ci;
129
- const char *name = findlocal(L, ci, n);
130
- lua_lock(L);
131
- if (name)
132
- luaA_pushobject(L, ci->base + (n - 1));
133
- lua_unlock(L);
134
- return name;
135
- }
136
-
137
-
138
- LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) {
139
- CallInfo *ci = L->base_ci + ar->i_ci;
140
- const char *name = findlocal(L, ci, n);
141
- lua_lock(L);
142
- if (name)
143
- setobjs2s(L, ci->base + (n - 1), L->top - 1);
144
- L->top--; /* pop value */
145
- lua_unlock(L);
146
- return name;
147
- }
148
-
149
-
150
- static void funcinfo (lua_Debug *ar, Closure *cl) {
151
- if (cl->c.isC) {
152
- ar->source = "=[C]";
153
- ar->linedefined = -1;
154
- ar->lastlinedefined = -1;
155
- ar->what = "C";
156
- }
157
- else {
158
- ar->source = getstr(cl->l.p->source);
159
- ar->linedefined = cl->l.p->linedefined;
160
- ar->lastlinedefined = cl->l.p->lastlinedefined;
161
- ar->what = (ar->linedefined == 0) ? "main" : "Lua";
162
- }
163
- luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
164
- }
165
-
166
-
167
- static void info_tailcall (lua_Debug *ar) {
168
- ar->name = ar->namewhat = "";
169
- ar->what = "tail";
170
- ar->lastlinedefined = ar->linedefined = ar->currentline = -1;
171
- ar->source = "=(tail call)";
172
- luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);
173
- ar->nups = 0;
174
- }
175
-
176
-
177
- static void collectvalidlines (lua_State *L, Closure *f) {
178
- if (f == NULL || f->c.isC) {
179
- setnilvalue(L->top);
180
- }
181
- else {
182
- Table *t = luaH_new(L, 0, 0);
183
- int *lineinfo = f->l.p->lineinfo;
184
- int i;
185
- for (i=0; i<f->l.p->sizelineinfo; i++)
186
- setbvalue(luaH_setnum(L, t, lineinfo[i]), 1);
187
- sethvalue(L, L->top, t);
188
- }
189
- incr_top(L);
190
- }
191
-
192
-
193
- static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
194
- Closure *f, CallInfo *ci) {
195
- int status = 1;
196
- if (f == NULL) {
197
- info_tailcall(ar);
198
- return status;
199
- }
200
- for (; *what; what++) {
201
- switch (*what) {
202
- case 'S': {
203
- funcinfo(ar, f);
204
- break;
205
- }
206
- case 'l': {
207
- ar->currentline = (ci) ? currentline(L, ci) : -1;
208
- break;
209
- }
210
- case 'u': {
211
- ar->nups = f->c.nupvalues;
212
- break;
213
- }
214
- case 'n': {
215
- ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL;
216
- if (ar->namewhat == NULL) {
217
- ar->namewhat = ""; /* not found */
218
- ar->name = NULL;
219
- }
220
- break;
221
- }
222
- case 'L':
223
- case 'f': /* handled by lua_getinfo */
224
- break;
225
- default: status = 0; /* invalid option */
226
- }
227
- }
228
- return status;
229
- }
230
-
231
-
232
- LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
233
- int status;
234
- Closure *f = NULL;
235
- CallInfo *ci = NULL;
236
- lua_lock(L);
237
- if (*what == '>') {
238
- StkId func = L->top - 1;
239
- luai_apicheck(L, ttisfunction(func));
240
- what++; /* skip the '>' */
241
- f = clvalue(func);
242
- L->top--; /* pop function */
243
- }
244
- else if (ar->i_ci != 0) { /* no tail call? */
245
- ci = L->base_ci + ar->i_ci;
246
- lua_assert(ttisfunction(ci->func));
247
- f = clvalue(ci->func);
248
- }
249
- status = auxgetinfo(L, what, ar, f, ci);
250
- if (strchr(what, 'f')) {
251
- if (f == NULL) setnilvalue(L->top);
252
- else setclvalue(L, L->top, f);
253
- incr_top(L);
254
- }
255
- if (strchr(what, 'L'))
256
- collectvalidlines(L, f);
257
- lua_unlock(L);
258
- return status;
259
- }
260
-
261
-
262
- /*
263
- ** {======================================================
264
- ** Symbolic Execution and code checker
265
- ** =======================================================
266
- */
267
-
268
- #define check(x) if (!(x)) return 0;
269
-
270
- #define checkjump(pt,pc) check(0 <= pc && pc < pt->sizecode)
271
-
272
- #define checkreg(pt,reg) check((reg) < (pt)->maxstacksize)
273
-
274
-
275
-
276
- static int precheck (const Proto *pt) {
277
- check(pt->maxstacksize <= MAXSTACK);
278
- check(pt->numparams+(pt->is_vararg & VARARG_HASARG) <= pt->maxstacksize);
279
- check(!(pt->is_vararg & VARARG_NEEDSARG) ||
280
- (pt->is_vararg & VARARG_HASARG));
281
- check(pt->sizeupvalues <= pt->nups);
282
- check(pt->sizelineinfo == pt->sizecode || pt->sizelineinfo == 0);
283
- check(pt->sizecode > 0 && GET_OPCODE(pt->code[pt->sizecode-1]) == OP_RETURN);
284
- return 1;
285
- }
286
-
287
-
288
- #define checkopenop(pt,pc) luaG_checkopenop((pt)->code[(pc)+1])
289
-
290
- int luaG_checkopenop (Instruction i) {
291
- switch (GET_OPCODE(i)) {
292
- case OP_CALL:
293
- case OP_TAILCALL:
294
- case OP_RETURN:
295
- case OP_SETLIST: {
296
- check(GETARG_B(i) == 0);
297
- return 1;
298
- }
299
- default: return 0; /* invalid instruction after an open call */
300
- }
301
- }
302
-
303
-
304
- static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
305
- switch (mode) {
306
- case OpArgN: check(r == 0); break;
307
- case OpArgU: break;
308
- case OpArgR: checkreg(pt, r); break;
309
- case OpArgK:
310
- check(ISK(r) ? INDEXK(r) < pt->sizek : r < pt->maxstacksize);
311
- break;
312
- }
313
- return 1;
314
- }
315
-
316
-
317
- static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
318
- int pc;
319
- int last; /* stores position of last instruction that changed `reg' */
320
- last = pt->sizecode-1; /* points to final return (a `neutral' instruction) */
321
- check(precheck(pt));
322
- for (pc = 0; pc < lastpc; pc++) {
323
- Instruction i = pt->code[pc];
324
- OpCode op = GET_OPCODE(i);
325
- int a = GETARG_A(i);
326
- int b = 0;
327
- int c = 0;
328
- check(op < NUM_OPCODES);
329
- checkreg(pt, a);
330
- switch (getOpMode(op)) {
331
- case iABC: {
332
- b = GETARG_B(i);
333
- c = GETARG_C(i);
334
- check(checkArgMode(pt, b, getBMode(op)));
335
- check(checkArgMode(pt, c, getCMode(op)));
336
- break;
337
- }
338
- case iABx: {
339
- b = GETARG_Bx(i);
340
- if (getBMode(op) == OpArgK) check(b < pt->sizek);
341
- break;
342
- }
343
- case iAsBx: {
344
- b = GETARG_sBx(i);
345
- if (getBMode(op) == OpArgR) {
346
- int dest = pc+1+b;
347
- check(0 <= dest && dest < pt->sizecode);
348
- if (dest > 0) {
349
- int j;
350
- /* check that it does not jump to a setlist count; this
351
- is tricky, because the count from a previous setlist may
352
- have the same value of an invalid setlist; so, we must
353
- go all the way back to the first of them (if any) */
354
- for (j = 0; j < dest; j++) {
355
- Instruction d = pt->code[dest-1-j];
356
- if (!(GET_OPCODE(d) == OP_SETLIST && GETARG_C(d) == 0)) break;
357
- }
358
- /* if 'j' is even, previous value is not a setlist (even if
359
- it looks like one) */
360
- check((j&1) == 0);
361
- }
362
- }
363
- break;
364
- }
365
- }
366
- if (testAMode(op)) {
367
- if (a == reg) last = pc; /* change register `a' */
368
- }
369
- if (testTMode(op)) {
370
- check(pc+2 < pt->sizecode); /* check skip */
371
- check(GET_OPCODE(pt->code[pc+1]) == OP_JMP);
372
- }
373
- switch (op) {
374
- case OP_LOADBOOL: {
375
- if (c == 1) { /* does it jump? */
376
- check(pc+2 < pt->sizecode); /* check its jump */
377
- check(GET_OPCODE(pt->code[pc+1]) != OP_SETLIST ||
378
- GETARG_C(pt->code[pc+1]) != 0);
379
- }
380
- break;
381
- }
382
- case OP_LOADNIL: {
383
- if (a <= reg && reg <= b)
384
- last = pc; /* set registers from `a' to `b' */
385
- break;
386
- }
387
- case OP_GETUPVAL:
388
- case OP_SETUPVAL: {
389
- check(b < pt->nups);
390
- break;
391
- }
392
- case OP_GETGLOBAL:
393
- case OP_SETGLOBAL: {
394
- check(ttisstring(&pt->k[b]));
395
- break;
396
- }
397
- case OP_SELF: {
398
- checkreg(pt, a+1);
399
- if (reg == a+1) last = pc;
400
- break;
401
- }
402
- case OP_CONCAT: {
403
- check(b < c); /* at least two operands */
404
- break;
405
- }
406
- case OP_TFORLOOP: {
407
- check(c >= 1); /* at least one result (control variable) */
408
- checkreg(pt, a+2+c); /* space for results */
409
- if (reg >= a+2) last = pc; /* affect all regs above its base */
410
- break;
411
- }
412
- case OP_FORLOOP:
413
- case OP_FORPREP:
414
- checkreg(pt, a+3);
415
- /* go through */
416
- case OP_JMP: {
417
- int dest = pc+1+b;
418
- /* not full check and jump is forward and do not skip `lastpc'? */
419
- if (reg != NO_REG && pc < dest && dest <= lastpc)
420
- pc += b; /* do the jump */
421
- break;
422
- }
423
- case OP_CALL:
424
- case OP_TAILCALL: {
425
- if (b != 0) {
426
- checkreg(pt, a+b-1);
427
- }
428
- c--; /* c = num. returns */
429
- if (c == LUA_MULTRET) {
430
- check(checkopenop(pt, pc));
431
- }
432
- else if (c != 0)
433
- checkreg(pt, a+c-1);
434
- if (reg >= a) last = pc; /* affect all registers above base */
435
- break;
436
- }
437
- case OP_RETURN: {
438
- b--; /* b = num. returns */
439
- if (b > 0) checkreg(pt, a+b-1);
440
- break;
441
- }
442
- case OP_SETLIST: {
443
- if (b > 0) checkreg(pt, a + b);
444
- if (c == 0) {
445
- pc++;
446
- check(pc < pt->sizecode - 1);
447
- }
448
- break;
449
- }
450
- case OP_CLOSURE: {
451
- int nup, j;
452
- check(b < pt->sizep);
453
- nup = pt->p[b]->nups;
454
- check(pc + nup < pt->sizecode);
455
- for (j = 1; j <= nup; j++) {
456
- OpCode op1 = GET_OPCODE(pt->code[pc + j]);
457
- check(op1 == OP_GETUPVAL || op1 == OP_MOVE);
458
- }
459
- if (reg != NO_REG) /* tracing? */
460
- pc += nup; /* do not 'execute' these pseudo-instructions */
461
- break;
462
- }
463
- case OP_VARARG: {
464
- check((pt->is_vararg & VARARG_ISVARARG) &&
465
- !(pt->is_vararg & VARARG_NEEDSARG));
466
- b--;
467
- if (b == LUA_MULTRET) check(checkopenop(pt, pc));
468
- checkreg(pt, a+b-1);
469
- break;
470
- }
471
- default: break;
472
- }
473
- }
474
- return pt->code[last];
475
- }
476
-
477
- #undef check
478
- #undef checkjump
479
- #undef checkreg
480
-
481
- /* }====================================================== */
482
-
483
-
484
- int luaG_checkcode (const Proto *pt) {
485
- return (symbexec(pt, pt->sizecode, NO_REG) != 0);
486
- }
487
-
488
-
489
- static const char *kname (Proto *p, int c) {
490
- if (ISK(c) && ttisstring(&p->k[INDEXK(c)]))
491
- return svalue(&p->k[INDEXK(c)]);
492
- else
493
- return "?";
494
- }
495
-
496
-
497
- static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
498
- const char **name) {
499
- if (isLua(ci)) { /* a Lua function? */
500
- Proto *p = ci_func(ci)->l.p;
501
- int pc = currentpc(L, ci);
502
- Instruction i;
503
- *name = luaF_getlocalname(p, stackpos+1, pc);
504
- if (*name) /* is a local? */
505
- return "local";
506
- i = symbexec(p, pc, stackpos); /* try symbolic execution */
507
- lua_assert(pc != -1);
508
- switch (GET_OPCODE(i)) {
509
- case OP_GETGLOBAL: {
510
- int g = GETARG_Bx(i); /* global index */
511
- lua_assert(ttisstring(&p->k[g]));
512
- *name = svalue(&p->k[g]);
513
- return "global";
514
- }
515
- case OP_MOVE: {
516
- int a = GETARG_A(i);
517
- int b = GETARG_B(i); /* move from `b' to `a' */
518
- if (b < a)
519
- return getobjname(L, ci, b, name); /* get name for `b' */
520
- break;
521
- }
522
- case OP_GETTABLE: {
523
- int k = GETARG_C(i); /* key index */
524
- *name = kname(p, k);
525
- return "field";
526
- }
527
- case OP_GETUPVAL: {
528
- int u = GETARG_B(i); /* upvalue index */
529
- *name = p->upvalues ? getstr(p->upvalues[u]) : "?";
530
- return "upvalue";
531
- }
532
- case OP_SELF: {
533
- int k = GETARG_C(i); /* key index */
534
- *name = kname(p, k);
535
- return "method";
536
- }
537
- default: break;
538
- }
539
- }
540
- return NULL; /* no useful name found */
541
- }
542
-
543
-
544
- static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
545
- Instruction i;
546
- if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
547
- return NULL; /* calling function is not Lua (or is unknown) */
548
- ci--; /* calling function */
549
- i = ci_func(ci)->l.p->code[currentpc(L, ci)];
550
- if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
551
- GET_OPCODE(i) == OP_TFORLOOP)
552
- return getobjname(L, ci, GETARG_A(i), name);
553
- else
554
- return NULL; /* no useful name can be found */
555
- }
556
-
557
-
558
- /* only ANSI way to check whether a pointer points to an array */
559
- static int isinstack (CallInfo *ci, const TValue *o) {
560
- StkId p;
561
- for (p = ci->base; p < ci->top; p++)
562
- if (o == p) return 1;
563
- return 0;
564
- }
565
-
566
-
567
- void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
568
- const char *name = NULL;
569
- const char *t = luaT_typenames[ttype(o)];
570
- const char *kind = (isinstack(L->ci, o)) ?
571
- getobjname(L, L->ci, cast_int(o - L->base), &name) :
572
- NULL;
573
- if (kind)
574
- luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
575
- op, kind, name, t);
576
- else
577
- luaG_runerror(L, "attempt to %s a %s value", op, t);
578
- }
579
-
580
-
581
- void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
582
- if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
583
- lua_assert(!ttisstring(p1) && !ttisnumber(p1));
584
- luaG_typeerror(L, p1, "concatenate");
585
- }
586
-
587
-
588
- void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
589
- TValue temp;
590
- if (luaV_tonumber(p1, &temp) == NULL)
591
- p2 = p1; /* first operand is wrong */
592
- luaG_typeerror(L, p2, "perform arithmetic on");
593
- }
594
-
595
-
596
- int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
597
- const char *t1 = luaT_typenames[ttype(p1)];
598
- const char *t2 = luaT_typenames[ttype(p2)];
599
- if (t1[2] == t2[2])
600
- luaG_runerror(L, "attempt to compare two %s values", t1);
601
- else
602
- luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
603
- return 0;
604
- }
605
-
606
-
607
- static void addinfo (lua_State *L, const char *msg) {
608
- CallInfo *ci = L->ci;
609
- if (isLua(ci)) { /* is Lua code? */
610
- char buff[LUA_IDSIZE]; /* add file:line information */
611
- int line = currentline(L, ci);
612
- luaO_chunkid(buff, getstr(getluaproto(ci)->source), LUA_IDSIZE);
613
- luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
614
- }
615
- }
616
-
617
-
618
- void luaG_errormsg (lua_State *L) {
619
- if (L->errfunc != 0) { /* is there an error handling function? */
620
- StkId errfunc = restorestack(L, L->errfunc);
621
- if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
622
- setobjs2s(L, L->top, L->top - 1); /* move argument */
623
- setobjs2s(L, L->top - 1, errfunc); /* push function */
624
- incr_top(L);
625
- luaD_call(L, L->top - 2, 1); /* call it */
626
- }
627
- luaD_throw(L, LUA_ERRRUN);
628
- }
629
-
630
-
631
- void luaG_runerror (lua_State *L, const char *fmt, ...) {
632
- va_list argp;
633
- va_start(argp, fmt);
634
- addinfo(L, luaO_pushvfstring(L, fmt, argp));
635
- va_end(argp);
636
- luaG_errormsg(L);
637
- }
638
-