zoukankan      html  css  js  c++  java
  • 用户态函数跟踪 (无调试符号)

    [root@localhost ~]# cat test.c

    #include <stdio.h>

    int main( void) {

    int a=0; a=fun(10,20);

    printf("%d ",a);

    }

    int fun(int  a,int b)

    {   return a+b; }

    [root@localhost ~]# stap -e 'probe process("a.out").function("*"){printf("%s %s (0x%x 0x%x 0x%x 0x%x 0x%x ) ",execname(),probefunc(),u64_arg(1),u64_arg(2),u64_arg(3),u64_arg(4),u64_arg(5))}' -d /lib64/libc-2.5.so

     (由上至下调用)
    a.out _start (0x7fe92a54a000 0x346841863f 0x346840d880 0x7ffff01e76d8 0x1000 )
    a.out __libc_csu_init (0x1 0x7ffff01e76c8 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out _init (0x1 0x7ffff01e76c8 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out call_gmon_start (0x1 0x7ffff01e76c8 0x7ffff01e76d8  0x400500 0x3468b542d0 )
    a.out frame_dummy (0x1 0x7ffff01e76c8 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out __do_global_ctors_aux (0x1 0x7ffff01e76c8 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out main (0x1 0x7ffff01e76c8 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out fun (0xa 0x14 0x7ffff01e76d8 0x400500 0x3468b542d0 )
    a.out _fini (0x346861d480 0x0 0x600718 0x7ffff01e7530 0x4 )
    a.out __do_global_dtors_aux (0x346861d480 0x0 0x600718 0x7ffff01e7530 0x4 )

    [root@localhost ~]# stap -e 'probe process("a.out").function("*"){printf("%s %s ( rdi:0x%x rsi:0x%x rdx:0x%x rcx:0x%x r8:0x%x 
    ",execname(),probefunc(),register("rdi"),register("rsi"),register("rdx"),register("rcx"),register("r8"))}' -d /lib64/libc-2.5.so  
    
    a.out _start ( rdi:0x7f78ce3c3000 rsi:0x346841863f rdx:0x346840d880 rcx:0x7fff9788b298 r8:0x1000 
    a.out __libc_csu_init ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out _init ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out call_gmon_start ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out frame_dummy ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out __do_global_ctors_aux ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out main ( rdi:0x1 rsi:0x7fff9788b288 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out fun ( rdi:0xa rsi:0x14 rdx:0x7fff9788b298 rcx:0x400500 r8:0x3468b542d0 
    a.out _fini ( rdi:0x346861d480 rsi:0x0 rdx:0x600718 rcx:0x7fff9788b0f0 r8:0x4 
    a.out __do_global_dtors_aux ( rdi:0x346861d480 rsi:0x0 rdx:0x600718 rcx:0x7fff9788b0f0 r8:0x4 

     [root@localhost ~]# stap -e 'probe process("a.out").function("*"){printf("%d, %d, %d ", pid(), cpu(), print_regs()); exit()}'
    WARNING: Eliding side-effect-free expression : identifier 'asmlinkage' at <input>:1:38
     source: probe process("a.out").function("*"){asmlinkage(); printf("%d, %d, %d ", pid(), cpu(), print_regs()); exit()}
                                                  ^
    RIP: 00000000004003c0
    RSP: 00007fff55b5ae30  EFLAGS: 00000202
    RAX: 0000000000000000 RBX: 0000000000000000 RCX: 00007fff55b5ae48
    RDX: 000000346840d880 RSI: 000000346841863f RDI: 00007ff1cbc71000
    RBP: 0000000000000000 R08: 0000000000001000 R09: 0000000000200000
    R10: 0000000000000002 R11: 0000000000000203 R12: 00000000004003c0
    R13: 00007fff55b5ae30 R14: 0000000000000000 R15: 0000000000000000
    FS:  00007ff1cbc5d6e0(0000) GS:ffff880003420000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 000000346891d000 CR3: 0000000057238000 CR4: 00000000000406e0
    17378, 1, 0

     http://blog.163.com/digoal@126/blog/static/163877040201382914152385/

  • 相关阅读:
    【转】CUDA5/CentOS6.4
    【转】centos 6.4 samba 安装配置
    【转】Install MATLAB 2013a on CentOS 6.4 x64 with mode silent
    【转】Getting xrdp to work on CentOS 6.4
    【VLFeat】使用matlab版本计算HOG
    Unofficial Windows Binaries for Python Extension Packages
    March 06th, 2018 Week 10th Tuesday
    March 05th, 2018 Week 10th Monday
    March 04th, 2018 Week 10th Sunday
    March 03rd, 2018 Week 9th Saturday
  • 原文地址:https://www.cnblogs.com/zengkefu/p/4934339.html
Copyright © 2011-2022 走看看