调试V8中JS对应的汇编代码

栏目: JavaScript · 发布时间: 8年前

内容简介:调试V8中JS对应的汇编代码

1、调试未优化代码

gdb --args ~/v8/out/ia32.debug/d8 --print-code poc.js
bp v8::internal::FullCodeGenerator::MakeCode
run
c
finish   
//跟c命令配对执行多次,直至打印出需要的汇编指令
Run till exit from #0  v8::internal::FullCodeGenerator::MakeCode (info=0xff873eb8) at ../src/full-codegen.cc:283
--- Raw source ---
……

--- Code ---
source_position = 197
kind = FUNCTION
name = evil_object.toJSON
Instructions (size = 128)
0x2b3301a0     0  55             push ebp
0x2b3301a1     1  89e5           mov ebp,esp
……
bp * 0x2b3301a0

2、调试优化代码

gef>  bp v8::internal::Context::AddOptimizedFunctiongef>  run Thread 1 "d8" hit Breakpoint 1, v8::internal::Context::AddOptimizedFunction (this=0x1fe2a1083a79, function=0x1fe2a10ac281) at ../src/contexts.cc:413gef>  job function

0x1fe2a10ac281: [Function]
 - map = 0xe7a59804099 [FastProperties]
 - prototype = 0x1fe2a1084069
 - elements = 0x367f8ed82241 <FixedArray[0]> [FAST_HOLEY_ELEMENTS]
 - initial_map = 
 - shared_info = 0x1fe2a10abdd9 <SharedFunctionInfo Ctor>
 - name = 0x1fe2a10abae9 <String[4]: Ctor>
 - formal_parameter_count = 0
 - context = 0x1fe2a1083a79 <FixedArray[188]>
 - literals = 0x1fe2a10ac551 <FixedArray[1]>
 - 
code = 0x3e4da55066a1 <Code: OPTIMIZED_FUNCTION>
 - properties = {
   #length: 0x367f8edd2709 <AccessorInfo> (accessor constant)
   #name: 0x367f8edd2779 <AccessorInfo> (accessor constant)
   #arguments: 0x367f8edd27e9 <AccessorInfo> (accessor constant)
   #caller: 0x367f8edd2859 <AccessorInfo> (accessor constant)
   #prototype: 0x367f8edd28c9 <AccessorInfo> (accessor constant)
 }

gef> job 0x3e4da55066a1
0x3e4da55066a1: [Code]
kind = OPTIMIZED_FUNCTION
stack_slots = 5
compiler = crankshaft
Instructions (size = 218)
0x3e4da5506700     0  55             push rbp
0x3e4da5506701     1  4889e5         REX.W movq rbp,rsp
0x3e4da5506704     4  56             push rsi
0x3e4da5506705     5  57             push rdi
……
gef> bp *0x3e4da5506700
gef> c

Continuing.

Thread 1 "d8" hit Breakpoint 2, 0x00003e4da5506700 in ?? ()
……
 code:i386:x86-64
0x3e4da5506700    push rbp   $pc
0x3e4da5506701    mov rbp, rsp
0x3e4da5506704    push rsi
0x3e4da5506705    push rdi
0x3e4da5506706    sub rsp, 0x8
0x3e4da550670a    mov rax, QWORD PTR [rbp-0x8]

以上所述就是小编给大家介绍的《调试V8中JS对应的汇编代码》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Linux Device Drivers

Linux Device Drivers

Jonathan Corbet、Alessandro Rubini、Greg Kroah-Hartman / O'Reilly Media / 2005-2-17 / USD 39.95

Device drivers literally drive everything you're interested in--disks, monitors, keyboards, modems--everything outside the computer chip and memory. And writing device drivers is one of the few areas ......一起来看看 《Linux Device Drivers》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具