mxz297 / dyninst

DyninstAPI: Tools for binary instrumentation, analysis, and modification.
http://www.dyninst.org
GNU Lesser General Public License v2.1
2 stars 4 forks source link

Generating go function call for running process #7

Closed ManojKumarChauhan closed 3 years ago

ManojKumarChauhan commented 3 years ago

Create a go binary. Create a function with arguments in go library. Instrument library function at entry point of some binary function. Using code coverage, attach to a process, instrument the function . codecoverage application will either crash or hang.

ManojKumarChauhan commented 3 years ago

Hi @mxz297, After moving isGoBinary in address space and using isGo = gen.addrSpace()->isGoBinary(); There is no crash for running process case but the instrumented method did not work. When the instrumented method was called, following error came due to address 0x7fa436fffed0 panic: runtime error: invalid memory address or nil pointer dereference

If method testforchi.Getlibsymbol is instrumented at the entry point of Show function then the code inside Show function did not execute because the error came in testforchi.Getlibsymbol.

0x7fa436fffebb <DYNINSTstaticHeap_16M_anyHeap_1+3723>: outsb %ds:(%rsi),(%dx) 0x7fa436fffebc <DYNINSTstaticHeap_16M_anyHeap_1+3724>: je 0x7fa436ffff30 <DYNINSTstaticHeap_16M_anyHeap_1+3840> 0x7fa436fffebe <DYNINSTstaticHeap_16M_anyHeap_1+3726>: outsl %ds:(%rsi),(%dx) 0x7fa436fffebf <DYNINSTstaticHeap_16M_anyHeap_1+3727>: insb (%dx),%es:(%rdi) 0x7fa436fffec0 <DYNINSTstaticHeap_16M_anyHeap_1+3728>: insb (%dx),%es:(%rdi) 0x7fa436fffec1 <DYNINSTstaticHeap_16M_anyHeap_1+3729>: gs jb 0x7fa436fffef2 <DYNINSTstaticHeap_16M_anyHeap_1+3778> 0x7fa436fffec4 <DYNINSTstaticHeap_16M_anyHeap_1+3732>: push %rbx 0x7fa436fffec5 <DYNINSTstaticHeap_16M_anyHeap_1+3733>: pushq $0x776f 0x7fa436fffeca <DYNINSTstaticHeap_16M_anyHeap_1+3738>: add %al,(%rax) 0x7fa436fffecc <DYNINSTstaticHeap_16M_anyHeap_1+3740>: add %al,(%rax) 0x7fa436fffece <DYNINSTstaticHeap_16M_anyHeap_1+3742>: add %al,(%rax) 0x7fa436fffed0 <DYNINSTstaticHeap_16M_anyHeap_1+3744>: mov %rdi,%gs:0x38 0x7fa436fffed9 <DYNINSTstaticHeap_16M_anyHeap_1+3753>: mov %rsi,%gs:0x30 0x7fa436fffee2 <DYNINSTstaticHeap_16M_anyHeap_1+3762>: movabs $0x7fa436fff548,%rsi 0x7fa436fffeec <DYNINSTstaticHeap_16M_anyHeap_1+3772>: push %rsi 0x7fa436fffeed <DYNINSTstaticHeap_16M_anyHeap_1+3773>: movabs $0x7fa436fff550,%rsi 0x7fa436fffef7 <DYNINSTstaticHeap_16M_anyHeap_1+3783>: push %rsi 0x7fa436fffef8 <DYNINSTstaticHeap_16M_anyHeap_1+3784>: callq 0x7fa440c40500

ManojKumarChauhan commented 3 years ago

Closing this issue as I have solved it.