D2前端技术论坛

张秋怡 Bringing JavaScript Back to Life

1. Bringing JavaScript Back to Life Joyee Cheung, Igalia
2. About Me • Joyee Cheung / Qiuyi Zhang ( • Based in Hangzhou, China • Compilers team @ Igalia • Node.js TSC & Diagnostics WG • joyeecheung @ GitHub/Twitter )
3. Introduction to Post-Mortem Diagnostics
4. Introduction to Post-Mortem Diagnostics
5. Introduction to Post-Mortem Diagnostics
6. Introduction to Post-Mortem Diagnostics
7. Introduction to Post-Mortem Diagnostics
8. Analysis of a Core Dump
9. Analysis of a Core Dump
10. Analysis of a Core Dump
11. Recovering States from Dynamic Language VMs
12. Recovering States from Dynamic Language VMs
13. A Tour of llnode • https://github.com/nodejs/llnode • Project under the Node.js Diagnostics Working Group • Plugin of the LLDB debugger
14. A Tour of llnode •Can be used to debug • Node.js Core dumps • Live processes of Node.js applications •Also works with • Other programs embedding v8 built with postmortem debugging support • e.g. d8 shell
15. A Tour of llnode
16. A Tour of llnode
17. A Tour of llnode
18. A Tour of llnode
19. A Tour of llnode 1. (Maintainers) read the V8 source code for reverseengineering algorithms
20. A Tour of llnode 1. (Maintainers) read the V8 source code for reverseengineering algorithms 2. Load the exact values of v8dbg_* offsets/constants from an executable embedding V8 e.g. Node.js • If the necessary metadata is not exposed, submit a patch to the upstream
21. A Tour of llnode 1. (Maintainers) read the V8 source code for reverseengineering algorithms 2. Load the exact values of v8dbg_* offsets/constants from an executable embedding V8 e.g. Node.js • If the necessary metadata is not exposed, submit a patch to the upstream 3. Use the algorithm and the metadata to interpret memory blocks in the core dump • Infrastructures and cross-platform support come from the LLDB API
22. Reconstruct JS Values from Raw Memory
23. Reconstruct JS Values from Raw Memory
24. Reconstruct JS Values from Raw Memory
25. Reconstruct JS Values from Raw Memory
26. Reconstruct JS Values from Raw Memory
27. Reconstruct JS Values from Raw Memory
28. Reconstruct JS Values from Raw Memory
29. Reconstruct JS Values from Raw Memory
30. Reconstruct JS Values from Raw Memory
31. Reconstruct JS Values from Raw Memory
32. Reconstruct JS Values from Raw Memory
33. Reconstruct JS Values from Raw Memory
34. Reconstruct JS Values from Raw Memory
35. Reconstruct JS Values from Raw Memory
36. Reconstruct JS Values from Raw Memory
37. Reconstruct JS Values from Raw Memory
38. Reconstruct JS Values from Raw Memory
39. Reconstruct JS Values from Raw Memory
40. Unwinding the Stack: Native
41. Unwinding the Stack: JS Symbols
42. Unwinding the Stack: JS Symbols
43. Unwinding the Stack: JS Symbols
44. Unwinding the Stack: JS Symbols
45. Unwinding the Stack: JS Symbols
46. Unwinding the Stack: JS Symbols
47. Unwinding the Stack: JS Symbols
48. JavaScript API of llnode • As an ordinary Node.js C++ addon (macOS, Linux, FreeBSD) • Restore JavaScript states back into JavaScript • https://github.com/nodejs/llnode/blob/master/JSAPI.md • https://zhuanlan.zhihu.com/p/41178823
49. JavaScript API of llnode
50. JavaScript API of llnode
51. The llnode approach • Highly dependent on the implementation • Easy to break whenever V8 changes its internal object layout • Works well enough with the Node.js LTS schedule • Only need to support very few versions of V8
52. The llnode approach • Minimum effort from the VM’s side • It works! • No overhead during runtime • Fragmentation among llnode, mdb_v8, .etc • Limited to the platform supported by the native debugger
53. Future of Node/JS Post-mortem Diagnostics Node Interactive EU, 2016 https://www.slideshare.net/michaeldaw son3572846/post-mortem-talk-nodeinteractive-eu Get Involved! https://github.com/nodejs/diagnostics
54. Summary •Introduction to post-mortem diagnostics • Analysis of a core dump • Recovering states from dynamic language VMs
55. Summary •Introduction to post-mortem diagnostics • Analysis of a core dump • Recovering states from dynamic language VMs •A tour of llnode • Reconstruct JavaScript values from raw memory • Unwinding the Stack • JavaScript API of llnode
56. Thank you!

相关幻灯片