libv8-sgonyea 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +76 -0
  5. data/Rakefile +113 -0
  6. data/ext/libv8/extconf.rb +28 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +30 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/v8/.gitignore +35 -0
  12. data/lib/libv8/v8/AUTHORS +44 -0
  13. data/lib/libv8/v8/ChangeLog +2839 -0
  14. data/lib/libv8/v8/LICENSE +52 -0
  15. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  16. data/lib/libv8/v8/LICENSE.v8 +26 -0
  17. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  18. data/lib/libv8/v8/SConstruct +1478 -0
  19. data/lib/libv8/v8/build/README.txt +49 -0
  20. data/lib/libv8/v8/build/all.gyp +18 -0
  21. data/lib/libv8/v8/build/armu.gypi +32 -0
  22. data/lib/libv8/v8/build/common.gypi +144 -0
  23. data/lib/libv8/v8/build/gyp_v8 +145 -0
  24. data/lib/libv8/v8/include/v8-debug.h +395 -0
  25. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  26. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  27. data/lib/libv8/v8/include/v8-testing.h +104 -0
  28. data/lib/libv8/v8/include/v8.h +4124 -0
  29. data/lib/libv8/v8/include/v8stdint.h +53 -0
  30. data/lib/libv8/v8/preparser/SConscript +38 -0
  31. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  32. data/lib/libv8/v8/src/SConscript +368 -0
  33. data/lib/libv8/v8/src/accessors.cc +767 -0
  34. data/lib/libv8/v8/src/accessors.h +123 -0
  35. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  36. data/lib/libv8/v8/src/allocation.cc +122 -0
  37. data/lib/libv8/v8/src/allocation.h +143 -0
  38. data/lib/libv8/v8/src/api.cc +5845 -0
  39. data/lib/libv8/v8/src/api.h +574 -0
  40. data/lib/libv8/v8/src/apinatives.js +110 -0
  41. data/lib/libv8/v8/src/apiutils.h +73 -0
  42. data/lib/libv8/v8/src/arguments.h +118 -0
  43. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  44. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  45. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  46. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  47. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  48. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  49. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  50. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  51. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  52. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  53. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  54. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  55. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  56. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  57. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  58. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  59. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  60. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  61. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  62. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  63. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  64. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  65. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  66. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  67. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  68. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  69. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  70. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  71. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  72. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  73. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  74. data/lib/libv8/v8/src/array.js +1366 -0
  75. data/lib/libv8/v8/src/assembler.cc +1207 -0
  76. data/lib/libv8/v8/src/assembler.h +858 -0
  77. data/lib/libv8/v8/src/ast-inl.h +112 -0
  78. data/lib/libv8/v8/src/ast.cc +1146 -0
  79. data/lib/libv8/v8/src/ast.h +2188 -0
  80. data/lib/libv8/v8/src/atomicops.h +167 -0
  81. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  82. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  84. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  85. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  86. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  87. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  88. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  89. data/lib/libv8/v8/src/bignum.cc +768 -0
  90. data/lib/libv8/v8/src/bignum.h +140 -0
  91. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  92. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  93. data/lib/libv8/v8/src/builtins.cc +1707 -0
  94. data/lib/libv8/v8/src/builtins.h +371 -0
  95. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  96. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  97. data/lib/libv8/v8/src/cached-powers.h +65 -0
  98. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  99. data/lib/libv8/v8/src/char-predicates.h +67 -0
  100. data/lib/libv8/v8/src/checks.cc +110 -0
  101. data/lib/libv8/v8/src/checks.h +296 -0
  102. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  103. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  104. data/lib/libv8/v8/src/circular-queue.h +103 -0
  105. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  106. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  107. data/lib/libv8/v8/src/code.h +70 -0
  108. data/lib/libv8/v8/src/codegen.cc +231 -0
  109. data/lib/libv8/v8/src/codegen.h +84 -0
  110. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  111. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  112. data/lib/libv8/v8/src/compiler.cc +786 -0
  113. data/lib/libv8/v8/src/compiler.h +312 -0
  114. data/lib/libv8/v8/src/contexts.cc +347 -0
  115. data/lib/libv8/v8/src/contexts.h +391 -0
  116. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  117. data/lib/libv8/v8/src/conversions.cc +1131 -0
  118. data/lib/libv8/v8/src/conversions.h +135 -0
  119. data/lib/libv8/v8/src/counters.cc +93 -0
  120. data/lib/libv8/v8/src/counters.h +254 -0
  121. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  122. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  123. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  124. data/lib/libv8/v8/src/cpu.h +69 -0
  125. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  126. data/lib/libv8/v8/src/d8-debug.h +158 -0
  127. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  128. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  129. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  130. data/lib/libv8/v8/src/d8.cc +803 -0
  131. data/lib/libv8/v8/src/d8.gyp +91 -0
  132. data/lib/libv8/v8/src/d8.h +235 -0
  133. data/lib/libv8/v8/src/d8.js +2798 -0
  134. data/lib/libv8/v8/src/data-flow.cc +66 -0
  135. data/lib/libv8/v8/src/data-flow.h +205 -0
  136. data/lib/libv8/v8/src/date.js +1103 -0
  137. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  138. data/lib/libv8/v8/src/dateparser.cc +178 -0
  139. data/lib/libv8/v8/src/dateparser.h +266 -0
  140. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  141. data/lib/libv8/v8/src/debug-agent.h +129 -0
  142. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  143. data/lib/libv8/v8/src/debug.cc +3165 -0
  144. data/lib/libv8/v8/src/debug.h +1057 -0
  145. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  146. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  147. data/lib/libv8/v8/src/disasm.h +80 -0
  148. data/lib/libv8/v8/src/disassembler.cc +343 -0
  149. data/lib/libv8/v8/src/disassembler.h +58 -0
  150. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  151. data/lib/libv8/v8/src/diy-fp.h +117 -0
  152. data/lib/libv8/v8/src/double.h +238 -0
  153. data/lib/libv8/v8/src/dtoa.cc +103 -0
  154. data/lib/libv8/v8/src/dtoa.h +85 -0
  155. data/lib/libv8/v8/src/execution.cc +849 -0
  156. data/lib/libv8/v8/src/execution.h +297 -0
  157. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  158. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  159. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  160. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  161. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  162. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  163. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  164. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  165. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  166. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  167. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  168. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  169. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  170. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  171. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  172. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  173. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  174. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  175. data/lib/libv8/v8/src/factory.cc +1222 -0
  176. data/lib/libv8/v8/src/factory.h +442 -0
  177. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  178. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  179. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  180. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  181. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  182. data/lib/libv8/v8/src/flags.cc +551 -0
  183. data/lib/libv8/v8/src/flags.h +79 -0
  184. data/lib/libv8/v8/src/frames-inl.h +247 -0
  185. data/lib/libv8/v8/src/frames.cc +1243 -0
  186. data/lib/libv8/v8/src/frames.h +870 -0
  187. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  188. data/lib/libv8/v8/src/full-codegen.h +771 -0
  189. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  190. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  191. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  192. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  193. data/lib/libv8/v8/src/global-handles.cc +665 -0
  194. data/lib/libv8/v8/src/global-handles.h +284 -0
  195. data/lib/libv8/v8/src/globals.h +325 -0
  196. data/lib/libv8/v8/src/handles-inl.h +177 -0
  197. data/lib/libv8/v8/src/handles.cc +987 -0
  198. data/lib/libv8/v8/src/handles.h +382 -0
  199. data/lib/libv8/v8/src/hashmap.cc +230 -0
  200. data/lib/libv8/v8/src/hashmap.h +123 -0
  201. data/lib/libv8/v8/src/heap-inl.h +704 -0
  202. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  203. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  204. data/lib/libv8/v8/src/heap.cc +5930 -0
  205. data/lib/libv8/v8/src/heap.h +2268 -0
  206. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  207. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  208. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  209. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  210. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  211. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  212. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  213. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  214. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  215. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  216. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  217. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  218. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  219. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  220. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  221. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  222. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  223. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  224. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  225. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  226. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  227. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  228. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  229. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  230. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  231. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  232. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  233. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  234. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  235. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  236. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  237. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  238. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  239. data/lib/libv8/v8/src/ic-inl.h +130 -0
  240. data/lib/libv8/v8/src/ic.cc +2577 -0
  241. data/lib/libv8/v8/src/ic.h +736 -0
  242. data/lib/libv8/v8/src/inspector.cc +63 -0
  243. data/lib/libv8/v8/src/inspector.h +62 -0
  244. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  245. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  246. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  247. data/lib/libv8/v8/src/isolate.cc +1869 -0
  248. data/lib/libv8/v8/src/isolate.h +1382 -0
  249. data/lib/libv8/v8/src/json-parser.cc +504 -0
  250. data/lib/libv8/v8/src/json-parser.h +161 -0
  251. data/lib/libv8/v8/src/json.js +342 -0
  252. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  253. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  254. data/lib/libv8/v8/src/list-inl.h +212 -0
  255. data/lib/libv8/v8/src/list.h +174 -0
  256. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  257. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  258. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  259. data/lib/libv8/v8/src/lithium.cc +190 -0
  260. data/lib/libv8/v8/src/lithium.h +597 -0
  261. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  262. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  263. data/lib/libv8/v8/src/liveedit.h +180 -0
  264. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  265. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  266. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  267. data/lib/libv8/v8/src/log-inl.h +59 -0
  268. data/lib/libv8/v8/src/log-utils.cc +428 -0
  269. data/lib/libv8/v8/src/log-utils.h +231 -0
  270. data/lib/libv8/v8/src/log.cc +1993 -0
  271. data/lib/libv8/v8/src/log.h +476 -0
  272. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  273. data/lib/libv8/v8/src/macros.py +178 -0
  274. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  275. data/lib/libv8/v8/src/mark-compact.h +506 -0
  276. data/lib/libv8/v8/src/math.js +264 -0
  277. data/lib/libv8/v8/src/messages.cc +179 -0
  278. data/lib/libv8/v8/src/messages.h +113 -0
  279. data/lib/libv8/v8/src/messages.js +1096 -0
  280. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  281. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  282. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  283. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  284. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  285. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  286. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  287. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  288. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  289. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  290. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  291. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  292. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  293. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  294. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  295. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  296. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  297. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  298. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  299. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  300. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  301. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  302. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  303. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  304. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  305. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  306. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  307. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  308. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  309. data/lib/libv8/v8/src/natives.h +64 -0
  310. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  311. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  312. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  313. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  314. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  315. data/lib/libv8/v8/src/objects.cc +10585 -0
  316. data/lib/libv8/v8/src/objects.h +6838 -0
  317. data/lib/libv8/v8/src/parser.cc +4997 -0
  318. data/lib/libv8/v8/src/parser.h +765 -0
  319. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  320. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  321. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  322. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  323. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  324. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  325. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  326. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  327. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  328. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  329. data/lib/libv8/v8/src/platform-tls.h +50 -0
  330. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  331. data/lib/libv8/v8/src/platform.h +667 -0
  332. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  333. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  334. data/lib/libv8/v8/src/preparse-data.h +225 -0
  335. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  336. data/lib/libv8/v8/src/preparser.cc +1450 -0
  337. data/lib/libv8/v8/src/preparser.h +493 -0
  338. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  339. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  340. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  341. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  342. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  343. data/lib/libv8/v8/src/property.cc +105 -0
  344. data/lib/libv8/v8/src/property.h +365 -0
  345. data/lib/libv8/v8/src/proxy.js +83 -0
  346. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  347. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  348. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  349. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  350. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  351. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  352. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  353. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  354. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  355. data/lib/libv8/v8/src/regexp.js +483 -0
  356. data/lib/libv8/v8/src/rewriter.cc +360 -0
  357. data/lib/libv8/v8/src/rewriter.h +50 -0
  358. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  359. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  360. data/lib/libv8/v8/src/runtime.cc +12227 -0
  361. data/lib/libv8/v8/src/runtime.h +652 -0
  362. data/lib/libv8/v8/src/runtime.js +649 -0
  363. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  364. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  365. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  366. data/lib/libv8/v8/src/scanner-base.h +670 -0
  367. data/lib/libv8/v8/src/scanner.cc +345 -0
  368. data/lib/libv8/v8/src/scanner.h +146 -0
  369. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  370. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  371. data/lib/libv8/v8/src/scopes.cc +1150 -0
  372. data/lib/libv8/v8/src/scopes.h +507 -0
  373. data/lib/libv8/v8/src/serialize.cc +1574 -0
  374. data/lib/libv8/v8/src/serialize.h +589 -0
  375. data/lib/libv8/v8/src/shell.h +55 -0
  376. data/lib/libv8/v8/src/simulator.h +43 -0
  377. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  378. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  379. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  380. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  381. data/lib/libv8/v8/src/snapshot.h +91 -0
  382. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  383. data/lib/libv8/v8/src/spaces.cc +3145 -0
  384. data/lib/libv8/v8/src/spaces.h +2369 -0
  385. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  386. data/lib/libv8/v8/src/splay-tree.h +205 -0
  387. data/lib/libv8/v8/src/string-search.cc +41 -0
  388. data/lib/libv8/v8/src/string-search.h +568 -0
  389. data/lib/libv8/v8/src/string-stream.cc +592 -0
  390. data/lib/libv8/v8/src/string-stream.h +191 -0
  391. data/lib/libv8/v8/src/string.js +994 -0
  392. data/lib/libv8/v8/src/strtod.cc +440 -0
  393. data/lib/libv8/v8/src/strtod.h +40 -0
  394. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  395. data/lib/libv8/v8/src/stub-cache.h +924 -0
  396. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  397. data/lib/libv8/v8/src/token.cc +63 -0
  398. data/lib/libv8/v8/src/token.h +288 -0
  399. data/lib/libv8/v8/src/type-info.cc +507 -0
  400. data/lib/libv8/v8/src/type-info.h +272 -0
  401. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  402. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  403. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  404. data/lib/libv8/v8/src/unicode.cc +1624 -0
  405. data/lib/libv8/v8/src/unicode.h +280 -0
  406. data/lib/libv8/v8/src/uri.js +408 -0
  407. data/lib/libv8/v8/src/utils-inl.h +48 -0
  408. data/lib/libv8/v8/src/utils.cc +371 -0
  409. data/lib/libv8/v8/src/utils.h +800 -0
  410. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  411. data/lib/libv8/v8/src/v8-counters.h +314 -0
  412. data/lib/libv8/v8/src/v8.cc +213 -0
  413. data/lib/libv8/v8/src/v8.h +131 -0
  414. data/lib/libv8/v8/src/v8checks.h +64 -0
  415. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  416. data/lib/libv8/v8/src/v8globals.h +512 -0
  417. data/lib/libv8/v8/src/v8memory.h +82 -0
  418. data/lib/libv8/v8/src/v8natives.js +1310 -0
  419. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  420. data/lib/libv8/v8/src/v8threads.cc +464 -0
  421. data/lib/libv8/v8/src/v8threads.h +165 -0
  422. data/lib/libv8/v8/src/v8utils.h +319 -0
  423. data/lib/libv8/v8/src/variables.cc +114 -0
  424. data/lib/libv8/v8/src/variables.h +167 -0
  425. data/lib/libv8/v8/src/version.cc +116 -0
  426. data/lib/libv8/v8/src/version.h +68 -0
  427. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  428. data/lib/libv8/v8/src/vm-state.h +71 -0
  429. data/lib/libv8/v8/src/win32-headers.h +96 -0
  430. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  431. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  432. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  433. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  434. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  435. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  436. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  437. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  438. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  439. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  440. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  441. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  442. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  443. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  444. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  445. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  446. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  447. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  448. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  449. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  450. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  451. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  452. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  453. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  454. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  455. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  456. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  457. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  458. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  459. data/lib/libv8/v8/src/zone-inl.h +140 -0
  460. data/lib/libv8/v8/src/zone.cc +196 -0
  461. data/lib/libv8/v8/src/zone.h +240 -0
  462. data/lib/libv8/v8/tools/codemap.js +265 -0
  463. data/lib/libv8/v8/tools/consarray.js +93 -0
  464. data/lib/libv8/v8/tools/csvparser.js +78 -0
  465. data/lib/libv8/v8/tools/disasm.py +92 -0
  466. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  467. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  468. data/lib/libv8/v8/tools/gcmole/README +62 -0
  469. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  470. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  471. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  472. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  473. data/lib/libv8/v8/tools/grokdump.py +841 -0
  474. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  475. data/lib/libv8/v8/tools/js2c.py +364 -0
  476. data/lib/libv8/v8/tools/jsmin.py +280 -0
  477. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  478. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  479. data/lib/libv8/v8/tools/logreader.js +185 -0
  480. data/lib/libv8/v8/tools/mac-nm +18 -0
  481. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  482. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  483. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  484. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  485. data/lib/libv8/v8/tools/presubmit.py +305 -0
  486. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  487. data/lib/libv8/v8/tools/profile.js +751 -0
  488. data/lib/libv8/v8/tools/profile_view.js +219 -0
  489. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  490. data/lib/libv8/v8/tools/splaytree.js +316 -0
  491. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  492. data/lib/libv8/v8/tools/test.py +1510 -0
  493. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  494. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  495. data/lib/libv8/v8/tools/utils.py +96 -0
  496. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  497. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  498. data/lib/libv8/version.rb +5 -0
  499. data/libv8.gemspec +36 -0
  500. metadata +578 -0
@@ -0,0 +1,841 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Copyright 2011 the V8 project authors. All rights reserved.
4
+ # Redistribution and use in source and binary forms, with or without
5
+ # modification, are permitted provided that the following conditions are
6
+ # met:
7
+ #
8
+ # * Redistributions of source code must retain the above copyright
9
+ # notice, this list of conditions and the following disclaimer.
10
+ # * Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following
12
+ # disclaimer in the documentation and/or other materials provided
13
+ # with the distribution.
14
+ # * Neither the name of Google Inc. nor the names of its
15
+ # contributors may be used to endorse or promote products derived
16
+ # from this software without specific prior written permission.
17
+ #
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+
30
+ import ctypes
31
+ import mmap
32
+ import optparse
33
+ import os
34
+ import disasm
35
+ import sys
36
+ import types
37
+ import codecs
38
+ import re
39
+
40
+
41
+ USAGE="""usage: %prog [OPTION]...
42
+
43
+ Minidump analyzer.
44
+
45
+ Shows the processor state at the point of exception including the
46
+ stack of the active thread and the referenced objects in the V8
47
+ heap. Code objects are disassembled and the addresses linked from the
48
+ stack (pushed return addresses) are marked with "=>".
49
+
50
+
51
+ Examples:
52
+ $ %prog 12345678-1234-1234-1234-123456789abcd-full.dmp
53
+ """
54
+
55
+ DEBUG=False
56
+
57
+
58
+ def DebugPrint(s):
59
+ if not DEBUG: return
60
+ print s
61
+
62
+
63
+ class Descriptor(object):
64
+ """Descriptor of a structure in a memory."""
65
+
66
+ def __init__(self, fields):
67
+ self.fields = fields
68
+ self.is_flexible = False
69
+ for _, type_or_func in fields:
70
+ if isinstance(type_or_func, types.FunctionType):
71
+ self.is_flexible = True
72
+ break
73
+ if not self.is_flexible:
74
+ self.ctype = Descriptor._GetCtype(fields)
75
+ self.size = ctypes.sizeof(self.ctype)
76
+
77
+ def Read(self, memory, offset):
78
+ if self.is_flexible:
79
+ fields_copy = self.fields[:]
80
+ last = 0
81
+ for name, type_or_func in fields_copy:
82
+ if isinstance(type_or_func, types.FunctionType):
83
+ partial_ctype = Descriptor._GetCtype(fields_copy[:last])
84
+ partial_object = partial_ctype.from_buffer(memory, offset)
85
+ type = type_or_func(partial_object)
86
+ if type is not None:
87
+ fields_copy[last] = (name, type)
88
+ last += 1
89
+ else:
90
+ last += 1
91
+ complete_ctype = Descriptor._GetCtype(fields_copy[:last])
92
+ else:
93
+ complete_ctype = self.ctype
94
+ return complete_ctype.from_buffer(memory, offset)
95
+
96
+ @staticmethod
97
+ def _GetCtype(fields):
98
+ class Raw(ctypes.Structure):
99
+ _fields_ = fields
100
+ _pack_ = 1
101
+
102
+ def __str__(self):
103
+ return "{" + ", ".join("%s: %s" % (field, self.__getattribute__(field))
104
+ for field, _ in Raw._fields_) + "}"
105
+ return Raw
106
+
107
+
108
+ # Set of structures and constants that describe the layout of minidump
109
+ # files. Based on MSDN and Google Breakpad.
110
+
111
+ MINIDUMP_HEADER = Descriptor([
112
+ ("signature", ctypes.c_uint32),
113
+ ("version", ctypes.c_uint32),
114
+ ("stream_count", ctypes.c_uint32),
115
+ ("stream_directories_rva", ctypes.c_uint32),
116
+ ("checksum", ctypes.c_uint32),
117
+ ("time_date_stampt", ctypes.c_uint32),
118
+ ("flags", ctypes.c_uint64)
119
+ ])
120
+
121
+ MINIDUMP_LOCATION_DESCRIPTOR = Descriptor([
122
+ ("data_size", ctypes.c_uint32),
123
+ ("rva", ctypes.c_uint32)
124
+ ])
125
+
126
+ MINIDUMP_DIRECTORY = Descriptor([
127
+ ("stream_type", ctypes.c_uint32),
128
+ ("location", MINIDUMP_LOCATION_DESCRIPTOR.ctype)
129
+ ])
130
+
131
+ MD_EXCEPTION_MAXIMUM_PARAMETERS = 15
132
+
133
+ MINIDUMP_EXCEPTION = Descriptor([
134
+ ("code", ctypes.c_uint32),
135
+ ("flags", ctypes.c_uint32),
136
+ ("record", ctypes.c_uint64),
137
+ ("address", ctypes.c_uint64),
138
+ ("parameter_count", ctypes.c_uint32),
139
+ ("unused_alignment", ctypes.c_uint32),
140
+ ("information", ctypes.c_uint64 * MD_EXCEPTION_MAXIMUM_PARAMETERS)
141
+ ])
142
+
143
+ MINIDUMP_EXCEPTION_STREAM = Descriptor([
144
+ ("thread_id", ctypes.c_uint32),
145
+ ("unused_alignment", ctypes.c_uint32),
146
+ ("exception", MINIDUMP_EXCEPTION.ctype),
147
+ ("thread_context", MINIDUMP_LOCATION_DESCRIPTOR.ctype)
148
+ ])
149
+
150
+ # Stream types.
151
+ MD_UNUSED_STREAM = 0
152
+ MD_RESERVED_STREAM_0 = 1
153
+ MD_RESERVED_STREAM_1 = 2
154
+ MD_THREAD_LIST_STREAM = 3
155
+ MD_MODULE_LIST_STREAM = 4
156
+ MD_MEMORY_LIST_STREAM = 5
157
+ MD_EXCEPTION_STREAM = 6
158
+ MD_SYSTEM_INFO_STREAM = 7
159
+ MD_THREAD_EX_LIST_STREAM = 8
160
+ MD_MEMORY_64_LIST_STREAM = 9
161
+ MD_COMMENT_STREAM_A = 10
162
+ MD_COMMENT_STREAM_W = 11
163
+ MD_HANDLE_DATA_STREAM = 12
164
+ MD_FUNCTION_TABLE_STREAM = 13
165
+ MD_UNLOADED_MODULE_LIST_STREAM = 14
166
+ MD_MISC_INFO_STREAM = 15
167
+ MD_MEMORY_INFO_LIST_STREAM = 16
168
+ MD_THREAD_INFO_LIST_STREAM = 17
169
+ MD_HANDLE_OPERATION_LIST_STREAM = 18
170
+
171
+ MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE = 80
172
+
173
+ MINIDUMP_FLOATING_SAVE_AREA_X86 = Descriptor([
174
+ ("control_word", ctypes.c_uint32),
175
+ ("status_word", ctypes.c_uint32),
176
+ ("tag_word", ctypes.c_uint32),
177
+ ("error_offset", ctypes.c_uint32),
178
+ ("error_selector", ctypes.c_uint32),
179
+ ("data_offset", ctypes.c_uint32),
180
+ ("data_selector", ctypes.c_uint32),
181
+ ("register_area", ctypes.c_uint8 * MD_FLOATINGSAVEAREA_X86_REGISTERAREA_SIZE),
182
+ ("cr0_npx_state", ctypes.c_uint32)
183
+ ])
184
+
185
+ MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE = 512
186
+
187
+ # Context flags.
188
+ MD_CONTEXT_X86 = 0x00010000
189
+ MD_CONTEXT_X86_CONTROL = (MD_CONTEXT_X86 | 0x00000001)
190
+ MD_CONTEXT_X86_INTEGER = (MD_CONTEXT_X86 | 0x00000002)
191
+ MD_CONTEXT_X86_SEGMENTS = (MD_CONTEXT_X86 | 0x00000004)
192
+ MD_CONTEXT_X86_FLOATING_POINT = (MD_CONTEXT_X86 | 0x00000008)
193
+ MD_CONTEXT_X86_DEBUG_REGISTERS = (MD_CONTEXT_X86 | 0x00000010)
194
+ MD_CONTEXT_X86_EXTENDED_REGISTERS = (MD_CONTEXT_X86 | 0x00000020)
195
+
196
+ def EnableOnFlag(type, flag):
197
+ return lambda o: [None, type][int((o.context_flags & flag) != 0)]
198
+
199
+ MINIDUMP_CONTEXT_X86 = Descriptor([
200
+ ("context_flags", ctypes.c_uint32),
201
+ # MD_CONTEXT_X86_DEBUG_REGISTERS.
202
+ ("dr0", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
203
+ ("dr1", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
204
+ ("dr2", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
205
+ ("dr3", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
206
+ ("dr6", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
207
+ ("dr7", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_DEBUG_REGISTERS)),
208
+ # MD_CONTEXT_X86_FLOATING_POINT.
209
+ ("float_save", EnableOnFlag(MINIDUMP_FLOATING_SAVE_AREA_X86.ctype,
210
+ MD_CONTEXT_X86_FLOATING_POINT)),
211
+ # MD_CONTEXT_X86_SEGMENTS.
212
+ ("gs", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_SEGMENTS)),
213
+ ("fs", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_SEGMENTS)),
214
+ ("es", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_SEGMENTS)),
215
+ ("ds", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_SEGMENTS)),
216
+ # MD_CONTEXT_X86_INTEGER.
217
+ ("edi", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
218
+ ("esi", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
219
+ ("ebx", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
220
+ ("edx", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
221
+ ("ecx", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
222
+ ("eax", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_INTEGER)),
223
+ # MD_CONTEXT_X86_CONTROL.
224
+ ("ebp", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
225
+ ("eip", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
226
+ ("cs", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
227
+ ("eflags", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
228
+ ("esp", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
229
+ ("ss", EnableOnFlag(ctypes.c_uint32, MD_CONTEXT_X86_CONTROL)),
230
+ # MD_CONTEXT_X86_EXTENDED_REGISTERS.
231
+ ("extended_registers",
232
+ EnableOnFlag(ctypes.c_uint8 * MD_CONTEXT_X86_EXTENDED_REGISTERS_SIZE,
233
+ MD_CONTEXT_X86_EXTENDED_REGISTERS))
234
+ ])
235
+
236
+ MINIDUMP_MEMORY_DESCRIPTOR = Descriptor([
237
+ ("start", ctypes.c_uint64),
238
+ ("memory", MINIDUMP_LOCATION_DESCRIPTOR.ctype)
239
+ ])
240
+
241
+ MINIDUMP_MEMORY_DESCRIPTOR64 = Descriptor([
242
+ ("start", ctypes.c_uint64),
243
+ ("size", ctypes.c_uint64)
244
+ ])
245
+
246
+ MINIDUMP_MEMORY_LIST = Descriptor([
247
+ ("range_count", ctypes.c_uint32),
248
+ ("ranges", lambda m: MINIDUMP_MEMORY_DESCRIPTOR.ctype * m.range_count)
249
+ ])
250
+
251
+ MINIDUMP_MEMORY_LIST64 = Descriptor([
252
+ ("range_count", ctypes.c_uint64),
253
+ ("base_rva", ctypes.c_uint64),
254
+ ("ranges", lambda m: MINIDUMP_MEMORY_DESCRIPTOR64.ctype * m.range_count)
255
+ ])
256
+
257
+ MINIDUMP_THREAD = Descriptor([
258
+ ("id", ctypes.c_uint32),
259
+ ("suspend_count", ctypes.c_uint32),
260
+ ("priority_class", ctypes.c_uint32),
261
+ ("priority", ctypes.c_uint32),
262
+ ("ted", ctypes.c_uint64),
263
+ ("stack", MINIDUMP_MEMORY_DESCRIPTOR.ctype),
264
+ ("context", MINIDUMP_LOCATION_DESCRIPTOR.ctype)
265
+ ])
266
+
267
+ MINIDUMP_THREAD_LIST = Descriptor([
268
+ ("thread_count", ctypes.c_uint32),
269
+ ("threads", lambda t: MINIDUMP_THREAD.ctype * t.thread_count)
270
+ ])
271
+
272
+
273
+ class MinidumpReader(object):
274
+ """Minidump (.dmp) reader."""
275
+
276
+ _HEADER_MAGIC = 0x504d444d
277
+
278
+ def __init__(self, options, minidump_name):
279
+ self.minidump_name = minidump_name
280
+ self.minidump_file = open(minidump_name, "r")
281
+ self.minidump = mmap.mmap(self.minidump_file.fileno(), 0, mmap.MAP_PRIVATE)
282
+ self.header = MINIDUMP_HEADER.Read(self.minidump, 0)
283
+ if self.header.signature != MinidumpReader._HEADER_MAGIC:
284
+ print >>sys.stderr, "Warning: unsupported minidump header magic"
285
+ DebugPrint(self.header)
286
+ directories = []
287
+ offset = self.header.stream_directories_rva
288
+ for _ in xrange(self.header.stream_count):
289
+ directories.append(MINIDUMP_DIRECTORY.Read(self.minidump, offset))
290
+ offset += MINIDUMP_DIRECTORY.size
291
+ self.exception = None
292
+ self.exception_context = None
293
+ self.memory_list = None
294
+ self.thread_map = {}
295
+ for d in directories:
296
+ DebugPrint(d)
297
+ # TODO(vitalyr): extract system info including CPU features.
298
+ if d.stream_type == MD_EXCEPTION_STREAM:
299
+ self.exception = MINIDUMP_EXCEPTION_STREAM.Read(
300
+ self.minidump, d.location.rva)
301
+ DebugPrint(self.exception)
302
+ self.exception_context = MINIDUMP_CONTEXT_X86.Read(
303
+ self.minidump, self.exception.thread_context.rva)
304
+ DebugPrint(self.exception_context)
305
+ elif d.stream_type == MD_THREAD_LIST_STREAM:
306
+ thread_list = MINIDUMP_THREAD_LIST.Read(self.minidump, d.location.rva)
307
+ assert ctypes.sizeof(thread_list) == d.location.data_size
308
+ DebugPrint(thread_list)
309
+ for thread in thread_list.threads:
310
+ DebugPrint(thread)
311
+ self.thread_map[thread.id] = thread
312
+ elif d.stream_type == MD_MEMORY_LIST_STREAM:
313
+ print >>sys.stderr, "Warning: not a full minidump"
314
+ ml = MINIDUMP_MEMORY_LIST.Read(self.minidump, d.location.rva)
315
+ DebugPrint(ml)
316
+ for m in ml.ranges:
317
+ DebugPrint(m)
318
+ elif d.stream_type == MD_MEMORY_64_LIST_STREAM:
319
+ assert self.memory_list is None
320
+ self.memory_list = MINIDUMP_MEMORY_LIST64.Read(
321
+ self.minidump, d.location.rva)
322
+ assert ctypes.sizeof(self.memory_list) == d.location.data_size
323
+ DebugPrint(self.memory_list)
324
+
325
+ def IsValidAddress(self, address):
326
+ return self.FindLocation(address) is not None
327
+
328
+ def ReadU8(self, address):
329
+ location = self.FindLocation(address)
330
+ return ctypes.c_uint8.from_buffer(self.minidump, location).value
331
+
332
+ def ReadU32(self, address):
333
+ location = self.FindLocation(address)
334
+ return ctypes.c_uint32.from_buffer(self.minidump, location).value
335
+
336
+ def ReadBytes(self, address, size):
337
+ location = self.FindLocation(address)
338
+ return self.minidump[location:location + size]
339
+
340
+ def FindLocation(self, address):
341
+ # TODO(vitalyr): only works for full minidumps (...64 structure variants).
342
+ offset = 0
343
+ for r in self.memory_list.ranges:
344
+ if r.start <= address < r.start + r.size:
345
+ return self.memory_list.base_rva + offset + address - r.start
346
+ offset += r.size
347
+ return None
348
+
349
+ def GetDisasmLines(self, address, size):
350
+ location = self.FindLocation(address)
351
+ if location is None: return []
352
+ return disasm.GetDisasmLines(self.minidump_name,
353
+ location,
354
+ size,
355
+ "ia32",
356
+ False)
357
+
358
+
359
+ def Dispose(self):
360
+ self.minidump.close()
361
+ self.minidump_file.close()
362
+
363
+
364
+ # List of V8 instance types. Obtained by adding the code below to any .cc file.
365
+ #
366
+ # #define DUMP_TYPE(T) printf("%d: \"%s\",\n", T, #T);
367
+ # struct P {
368
+ # P() {
369
+ # printf("{\n");
370
+ # INSTANCE_TYPE_LIST(DUMP_TYPE)
371
+ # printf("}\n");
372
+ # }
373
+ # };
374
+ # static P p;
375
+ INSTANCE_TYPES = {
376
+ 64: "SYMBOL_TYPE",
377
+ 68: "ASCII_SYMBOL_TYPE",
378
+ 65: "CONS_SYMBOL_TYPE",
379
+ 69: "CONS_ASCII_SYMBOL_TYPE",
380
+ 66: "EXTERNAL_SYMBOL_TYPE",
381
+ 74: "EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE",
382
+ 70: "EXTERNAL_ASCII_SYMBOL_TYPE",
383
+ 0: "STRING_TYPE",
384
+ 4: "ASCII_STRING_TYPE",
385
+ 1: "CONS_STRING_TYPE",
386
+ 5: "CONS_ASCII_STRING_TYPE",
387
+ 2: "EXTERNAL_STRING_TYPE",
388
+ 10: "EXTERNAL_STRING_WITH_ASCII_DATA_TYPE",
389
+ 6: "EXTERNAL_ASCII_STRING_TYPE",
390
+ 6: "PRIVATE_EXTERNAL_ASCII_STRING_TYPE",
391
+ 128: "MAP_TYPE",
392
+ 129: "CODE_TYPE",
393
+ 130: "ODDBALL_TYPE",
394
+ 131: "JS_GLOBAL_PROPERTY_CELL_TYPE",
395
+ 132: "HEAP_NUMBER_TYPE",
396
+ 134: "JS_PROXY_TYPE",
397
+ 133: "FOREIGN_TYPE",
398
+ 135: "BYTE_ARRAY_TYPE",
399
+ 136: "EXTERNAL_BYTE_ARRAY_TYPE",
400
+ 137: "EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE",
401
+ 138: "EXTERNAL_SHORT_ARRAY_TYPE",
402
+ 139: "EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE",
403
+ 140: "EXTERNAL_INT_ARRAY_TYPE",
404
+ 141: "EXTERNAL_UNSIGNED_INT_ARRAY_TYPE",
405
+ 142: "EXTERNAL_FLOAT_ARRAY_TYPE",
406
+ 144: "EXTERNAL_PIXEL_ARRAY_TYPE",
407
+ 145: "FILLER_TYPE",
408
+ 146: "ACCESSOR_INFO_TYPE",
409
+ 147: "ACCESS_CHECK_INFO_TYPE",
410
+ 148: "INTERCEPTOR_INFO_TYPE",
411
+ 149: "CALL_HANDLER_INFO_TYPE",
412
+ 150: "FUNCTION_TEMPLATE_INFO_TYPE",
413
+ 151: "OBJECT_TEMPLATE_INFO_TYPE",
414
+ 152: "SIGNATURE_INFO_TYPE",
415
+ 153: "TYPE_SWITCH_INFO_TYPE",
416
+ 154: "SCRIPT_TYPE",
417
+ 155: "CODE_CACHE_TYPE",
418
+ 158: "FIXED_ARRAY_TYPE",
419
+ 159: "SHARED_FUNCTION_INFO_TYPE",
420
+ 160: "JS_MESSAGE_OBJECT_TYPE",
421
+ 161: "JS_VALUE_TYPE",
422
+ 162: "JS_OBJECT_TYPE",
423
+ 163: "JS_CONTEXT_EXTENSION_OBJECT_TYPE",
424
+ 164: "JS_GLOBAL_OBJECT_TYPE",
425
+ 165: "JS_BUILTINS_OBJECT_TYPE",
426
+ 166: "JS_GLOBAL_PROXY_TYPE",
427
+ 167: "JS_ARRAY_TYPE",
428
+ 168: "JS_REGEXP_TYPE",
429
+ 169: "JS_FUNCTION_TYPE",
430
+ 156: "DEBUG_INFO_TYPE",
431
+ 157: "BREAK_POINT_INFO_TYPE",
432
+ }
433
+
434
+
435
+ class Printer(object):
436
+ """Printer with indentation support."""
437
+
438
+ def __init__(self):
439
+ self.indent = 0
440
+
441
+ def Indent(self):
442
+ self.indent += 2
443
+
444
+ def Dedent(self):
445
+ self.indent -= 2
446
+
447
+ def Print(self, string):
448
+ print "%s%s" % (self._IndentString(), string)
449
+
450
+ def PrintLines(self, lines):
451
+ indent = self._IndentString()
452
+ print "\n".join("%s%s" % (indent, line) for line in lines)
453
+
454
+ def _IndentString(self):
455
+ return self.indent * " "
456
+
457
+
458
+ ADDRESS_RE = re.compile(r"0x[0-9a-fA-F]+")
459
+
460
+
461
+ def FormatDisasmLine(start, heap, line):
462
+ line_address = start + line[0]
463
+ stack_slot = heap.stack_map.get(line_address)
464
+ marker = " "
465
+ if stack_slot:
466
+ marker = "=>"
467
+ code = AnnotateAddresses(heap, line[1])
468
+ return "%s%08x %08x: %s" % (marker, line_address, line[0], code)
469
+
470
+
471
+ def AnnotateAddresses(heap, line):
472
+ extra = []
473
+ for m in ADDRESS_RE.finditer(line):
474
+ maybe_address = int(m.group(0), 16)
475
+ object = heap.FindObject(maybe_address)
476
+ if not object: continue
477
+ extra.append(str(object))
478
+ if len(extra) == 0: return line
479
+ return "%s ;; %s" % (line, ", ".join(extra))
480
+
481
+
482
+ class HeapObject(object):
483
+ def __init__(self, heap, map, address):
484
+ self.heap = heap
485
+ self.map = map
486
+ self.address = address
487
+
488
+ def Is(self, cls):
489
+ return isinstance(self, cls)
490
+
491
+ def Print(self, p):
492
+ p.Print(str(self))
493
+
494
+ def __str__(self):
495
+ return "HeapObject(%08x, %s)" % (self.address,
496
+ INSTANCE_TYPES[self.map.instance_type])
497
+
498
+ def ObjectField(self, offset):
499
+ field_value = self.heap.reader.ReadU32(self.address + offset)
500
+ return self.heap.FindObjectOrSmi(field_value)
501
+
502
+ def SmiField(self, offset):
503
+ field_value = self.heap.reader.ReadU32(self.address + offset)
504
+ assert (field_value & 1) == 0
505
+ return field_value / 2
506
+
507
+
508
+ class Map(HeapObject):
509
+ INSTANCE_TYPE_OFFSET = 8
510
+
511
+ def __init__(self, heap, map, address):
512
+ HeapObject.__init__(self, heap, map, address)
513
+ self.instance_type = \
514
+ heap.reader.ReadU8(self.address + Map.INSTANCE_TYPE_OFFSET)
515
+
516
+
517
+ class String(HeapObject):
518
+ LENGTH_OFFSET = 4
519
+
520
+ def __init__(self, heap, map, address):
521
+ HeapObject.__init__(self, heap, map, address)
522
+ self.length = self.SmiField(String.LENGTH_OFFSET)
523
+
524
+ def GetChars(self):
525
+ return "?string?"
526
+
527
+ def Print(self, p):
528
+ p.Print(str(self))
529
+
530
+ def __str__(self):
531
+ return "\"%s\"" % self.GetChars()
532
+
533
+
534
+ class SeqString(String):
535
+ CHARS_OFFSET = 12
536
+
537
+ def __init__(self, heap, map, address):
538
+ String.__init__(self, heap, map, address)
539
+ self.chars = heap.reader.ReadBytes(self.address + SeqString.CHARS_OFFSET,
540
+ self.length)
541
+
542
+ def GetChars(self):
543
+ return self.chars
544
+
545
+
546
+ class ExternalString(String):
547
+ RESOURCE_OFFSET = 12
548
+
549
+ WEBKIT_RESOUCE_STRING_IMPL_OFFSET = 4
550
+ WEBKIT_STRING_IMPL_CHARS_OFFSET = 8
551
+
552
+ def __init__(self, heap, map, address):
553
+ String.__init__(self, heap, map, address)
554
+ reader = heap.reader
555
+ self.resource = \
556
+ reader.ReadU32(self.address + ExternalString.RESOURCE_OFFSET)
557
+ self.chars = "?external string?"
558
+ if not reader.IsValidAddress(self.resource): return
559
+ string_impl_address = self.resource + \
560
+ ExternalString.WEBKIT_RESOUCE_STRING_IMPL_OFFSET
561
+ if not reader.IsValidAddress(string_impl_address): return
562
+ string_impl = reader.ReadU32(string_impl_address)
563
+ chars_ptr_address = string_impl + \
564
+ ExternalString.WEBKIT_STRING_IMPL_CHARS_OFFSET
565
+ if not reader.IsValidAddress(chars_ptr_address): return
566
+ chars_ptr = reader.ReadU32(chars_ptr_address)
567
+ if not reader.IsValidAddress(chars_ptr): return
568
+ raw_chars = reader.ReadBytes(chars_ptr, 2 * self.length)
569
+ self.chars = codecs.getdecoder("utf16")(raw_chars)[0]
570
+
571
+ def GetChars(self):
572
+ return self.chars
573
+
574
+
575
+ class ConsString(String):
576
+ LEFT_OFFSET = 12
577
+ RIGHT_OFFSET = 16
578
+
579
+ def __init__(self, heap, map, address):
580
+ String.__init__(self, heap, map, address)
581
+ self.left = self.ObjectField(ConsString.LEFT_OFFSET)
582
+ self.right = self.ObjectField(ConsString.RIGHT_OFFSET)
583
+
584
+ def GetChars(self):
585
+ return self.left.GetChars() + self.right.GetChars()
586
+
587
+
588
+ class Oddball(HeapObject):
589
+ TO_STRING_OFFSET = 4
590
+
591
+ def __init__(self, heap, map, address):
592
+ HeapObject.__init__(self, heap, map, address)
593
+ self.to_string = self.ObjectField(Oddball.TO_STRING_OFFSET)
594
+
595
+ def Print(self, p):
596
+ p.Print(str(self))
597
+
598
+ def __str__(self):
599
+ return "<%s>" % self.to_string.GetChars()
600
+
601
+
602
+ class FixedArray(HeapObject):
603
+ LENGTH_OFFSET = 4
604
+ ELEMENTS_OFFSET = 8
605
+
606
+ def __init__(self, heap, map, address):
607
+ HeapObject.__init__(self, heap, map, address)
608
+ self.length = self.SmiField(FixedArray.LENGTH_OFFSET)
609
+
610
+ def Print(self, p):
611
+ p.Print("FixedArray(%08x) {" % self.address)
612
+ p.Indent()
613
+ p.Print("length: %d" % self.length)
614
+ for i in xrange(self.length):
615
+ offset = FixedArray.ELEMENTS_OFFSET + 4 * i
616
+ p.Print("[%08d] = %s" % (i, self.ObjectField(offset)))
617
+ p.Dedent()
618
+ p.Print("}")
619
+
620
+ def __str__(self):
621
+ return "FixedArray(%08x, length=%d)" % (self.address, self.length)
622
+
623
+
624
+ class JSFunction(HeapObject):
625
+ CODE_ENTRY_OFFSET = 12
626
+ SHARED_OFFSET = 20
627
+
628
+ def __init__(self, heap, map, address):
629
+ HeapObject.__init__(self, heap, map, address)
630
+ code_entry = \
631
+ heap.reader.ReadU32(self.address + JSFunction.CODE_ENTRY_OFFSET)
632
+ self.code = heap.FindObject(code_entry - Code.ENTRY_OFFSET + 1)
633
+ self.shared = self.ObjectField(JSFunction.SHARED_OFFSET)
634
+
635
+ def Print(self, p):
636
+ source = "\n".join(" %s" % line for line in self._GetSource().split("\n"))
637
+ p.Print("JSFunction(%08x) {" % self.address)
638
+ p.Indent()
639
+ p.Print("inferred name: %s" % self.shared.inferred_name)
640
+ if self.shared.script.Is(Script) and self.shared.script.name.Is(String):
641
+ p.Print("script name: %s" % self.shared.script.name)
642
+ p.Print("source:")
643
+ p.PrintLines(self._GetSource().split("\n"))
644
+ p.Print("code:")
645
+ self.code.Print(p)
646
+ if self.code != self.shared.code:
647
+ p.Print("unoptimized code:")
648
+ self.shared.code.Print(p)
649
+ p.Dedent()
650
+ p.Print("}")
651
+
652
+ def __str__(self):
653
+ inferred_name = ""
654
+ if self.shared.Is(SharedFunctionInfo):
655
+ inferred_name = self.shared.inferred_name
656
+ return "JSFunction(%08x, %s)" % (self.address, inferred_name)
657
+
658
+ def _GetSource(self):
659
+ source = "?source?"
660
+ start = self.shared.start_position
661
+ end = self.shared.end_position
662
+ if not self.shared.script.Is(Script): return source
663
+ script_source = self.shared.script.source
664
+ if not script_source.Is(String): return source
665
+ return script_source.GetChars()[start:end]
666
+
667
+
668
+ class SharedFunctionInfo(HeapObject):
669
+ CODE_OFFSET = 2 * 4
670
+ SCRIPT_OFFSET = 7 * 4
671
+ INFERRED_NAME_OFFSET = 9 * 4
672
+ START_POSITION_AND_TYPE_OFFSET = 17 * 4
673
+ END_POSITION_OFFSET = 18 * 4
674
+
675
+ def __init__(self, heap, map, address):
676
+ HeapObject.__init__(self, heap, map, address)
677
+ self.code = self.ObjectField(SharedFunctionInfo.CODE_OFFSET)
678
+ self.script = self.ObjectField(SharedFunctionInfo.SCRIPT_OFFSET)
679
+ self.inferred_name = \
680
+ self.ObjectField(SharedFunctionInfo.INFERRED_NAME_OFFSET)
681
+ start_position_and_type = \
682
+ self.SmiField(SharedFunctionInfo.START_POSITION_AND_TYPE_OFFSET)
683
+ self.start_position = start_position_and_type >> 2
684
+ self.end_position = self.SmiField(SharedFunctionInfo.END_POSITION_OFFSET)
685
+
686
+
687
+ class Script(HeapObject):
688
+ SOURCE_OFFSET = 4
689
+ NAME_OFFSET = 8
690
+
691
+ def __init__(self, heap, map, address):
692
+ HeapObject.__init__(self, heap, map, address)
693
+ self.source = self.ObjectField(Script.SOURCE_OFFSET)
694
+ self.name = self.ObjectField(Script.NAME_OFFSET)
695
+
696
+
697
+ class Code(HeapObject):
698
+ INSTRUCTION_SIZE_OFFSET = 4
699
+ ENTRY_OFFSET = 32
700
+
701
+ def __init__(self, heap, map, address):
702
+ HeapObject.__init__(self, heap, map, address)
703
+ self.entry = self.address + Code.ENTRY_OFFSET
704
+ self.instruction_size = \
705
+ heap.reader.ReadU32(self.address + Code.INSTRUCTION_SIZE_OFFSET)
706
+
707
+ def Print(self, p):
708
+ lines = self.heap.reader.GetDisasmLines(self.entry, self.instruction_size)
709
+ p.Print("Code(%08x) {" % self.address)
710
+ p.Indent()
711
+ p.Print("instruction_size: %d" % self.instruction_size)
712
+ p.PrintLines(self._FormatLine(line) for line in lines)
713
+ p.Dedent()
714
+ p.Print("}")
715
+
716
+ def _FormatLine(self, line):
717
+ return FormatDisasmLine(self.entry, self.heap, line)
718
+
719
+
720
+ class V8Heap(object):
721
+ CLASS_MAP = {
722
+ "SYMBOL_TYPE": SeqString,
723
+ "ASCII_SYMBOL_TYPE": SeqString,
724
+ "CONS_SYMBOL_TYPE": ConsString,
725
+ "CONS_ASCII_SYMBOL_TYPE": ConsString,
726
+ "EXTERNAL_SYMBOL_TYPE": ExternalString,
727
+ "EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE": ExternalString,
728
+ "EXTERNAL_ASCII_SYMBOL_TYPE": ExternalString,
729
+ "STRING_TYPE": SeqString,
730
+ "ASCII_STRING_TYPE": SeqString,
731
+ "CONS_STRING_TYPE": ConsString,
732
+ "CONS_ASCII_STRING_TYPE": ConsString,
733
+ "EXTERNAL_STRING_TYPE": ExternalString,
734
+ "EXTERNAL_STRING_WITH_ASCII_DATA_TYPE": ExternalString,
735
+ "EXTERNAL_ASCII_STRING_TYPE": ExternalString,
736
+
737
+ "MAP_TYPE": Map,
738
+ "ODDBALL_TYPE": Oddball,
739
+ "FIXED_ARRAY_TYPE": FixedArray,
740
+ "JS_FUNCTION_TYPE": JSFunction,
741
+ "SHARED_FUNCTION_INFO_TYPE": SharedFunctionInfo,
742
+ "SCRIPT_TYPE": Script,
743
+ "CODE_TYPE": Code
744
+ }
745
+
746
+ def __init__(self, reader, stack_map):
747
+ self.reader = reader
748
+ self.stack_map = stack_map
749
+ self.objects = {}
750
+
751
+ def FindObjectOrSmi(self, tagged_address):
752
+ if (tagged_address & 1) == 0: return tagged_address / 2
753
+ return self.FindObject(tagged_address)
754
+
755
+ def FindObject(self, tagged_address):
756
+ if tagged_address in self.objects:
757
+ return self.objects[tagged_address]
758
+ if (tagged_address & 1) != 1: return None
759
+ address = tagged_address - 1
760
+ if not self.reader.IsValidAddress(address): return None
761
+ map_tagged_address = self.reader.ReadU32(address)
762
+ if tagged_address == map_tagged_address:
763
+ # Meta map?
764
+ meta_map = Map(self, None, address)
765
+ instance_type_name = INSTANCE_TYPES.get(meta_map.instance_type)
766
+ if instance_type_name != "MAP_TYPE": return None
767
+ meta_map.map = meta_map
768
+ object = meta_map
769
+ else:
770
+ map = self.FindObject(map_tagged_address)
771
+ if map is None: return None
772
+ instance_type_name = INSTANCE_TYPES.get(map.instance_type)
773
+ if instance_type_name is None: return None
774
+ cls = V8Heap.CLASS_MAP.get(instance_type_name, HeapObject)
775
+ object = cls(self, map, address)
776
+ self.objects[tagged_address] = object
777
+ return object
778
+
779
+
780
+ EIP_PROXIMITY = 64
781
+
782
+
783
+ def AnalyzeMinidump(options, minidump_name):
784
+ reader = MinidumpReader(options, minidump_name)
785
+ DebugPrint("========================================")
786
+ if reader.exception is None:
787
+ print "Minidump has no exception info"
788
+ return
789
+ print "Exception info:"
790
+ exception_thread = reader.thread_map[reader.exception.thread_id]
791
+ print " thread id: %d" % exception_thread.id
792
+ print " code: %08X" % reader.exception.exception.code
793
+ print " context:"
794
+ print " eax: %08x" % reader.exception_context.eax
795
+ print " ebx: %08x" % reader.exception_context.ebx
796
+ print " ecx: %08x" % reader.exception_context.ecx
797
+ print " edx: %08x" % reader.exception_context.edx
798
+ print " edi: %08x" % reader.exception_context.edi
799
+ print " esi: %08x" % reader.exception_context.esi
800
+ print " ebp: %08x" % reader.exception_context.ebp
801
+ print " esp: %08x" % reader.exception_context.esp
802
+ print " eip: %08x" % reader.exception_context.eip
803
+ # TODO(vitalyr): decode eflags.
804
+ print " eflags: %s" % bin(reader.exception_context.eflags)[2:]
805
+ print
806
+
807
+ stack_bottom = exception_thread.stack.start + \
808
+ exception_thread.stack.memory.data_size
809
+ stack_map = {reader.exception_context.eip: -1}
810
+ for slot in xrange(reader.exception_context.esp, stack_bottom, 4):
811
+ maybe_address = reader.ReadU32(slot)
812
+ if not maybe_address in stack_map:
813
+ stack_map[maybe_address] = slot
814
+ heap = V8Heap(reader, stack_map)
815
+
816
+ print "Disassembly around exception.eip:"
817
+ start = reader.exception_context.eip - EIP_PROXIMITY
818
+ lines = reader.GetDisasmLines(start, 2 * EIP_PROXIMITY)
819
+ for line in lines:
820
+ print FormatDisasmLine(start, heap, line)
821
+ print
822
+
823
+ print "Annotated stack (from exception.esp to bottom):"
824
+ for slot in xrange(reader.exception_context.esp, stack_bottom, 4):
825
+ maybe_address = reader.ReadU32(slot)
826
+ heap_object = heap.FindObject(maybe_address)
827
+ print "%08x: %08x" % (slot, maybe_address)
828
+ if heap_object:
829
+ heap_object.Print(Printer())
830
+ print
831
+
832
+ reader.Dispose()
833
+
834
+
835
+ if __name__ == "__main__":
836
+ parser = optparse.OptionParser(USAGE)
837
+ options, args = parser.parse_args()
838
+ if len(args) != 1:
839
+ parser.print_help()
840
+ sys.exit(1)
841
+ AnalyzeMinidump(options, args[0])