zoukankan      html  css  js  c++  java
  • SystemTap

    安装
    sudo apt-get install build-essential
    sudo apt-get install elfutils
    sudo apt-get install libdw-dev
    wget wget https://sourceware.org/systemtap/ftp/releases/systemtap-2.4.tar.gz
    tar -xzvf systemtap-2.4.tar.gz
    cd systemtap-2.4
    ./configure
    sudo make
    sudo make install

    測试语句
    sudo stap --all-modules -ve 'probe begin { log("hello world") exit () }'
    sudo stap -ve 'probe begin { log("hello world") exit () }'
    sudo stap -ve 'probe kernel.function("sys_open") {log("hello world") exit()}'
    sudo stap -ve 'probe module("libiscsi").function("iscsi_queuecommand") {log("hello world") exit()}'
    打印堆栈
    print_backtrace
    --all-modules载入全部模块,显示堆栈信息

    在Ubuntu上使用SystemTap
    http://www.ningoo.net/html/2010/use_systemtap_on_ubuntu.html

    ubuntu+systemtap进行Linux内核和用户空间开发測试
    http://blog.csdn.net/sailor_8318/article/details/25076745

    SystemTap在Ubuntu 12.04上的安装 Build-id mismatch
    http://www.it165.net/os/html/201310/6486.html

    使用systemtap调试linux内核
    http://blog.csdn.net/heli007/article/details/7187748

    利用systemtap定位ifconfig dropped数据包的原因
    http://www.it165.net/os/html/201308/5944.html

    范例
    https://sourceware.org/systemtap/wiki

    System语言具体解释
    http://blog.csdn.net/linyt/article/details/5204841

    #! /usr/bin/env stap 
    
    global host_no = 17
    global channel = 0
    global targetid = 0
    global lunid = 15
    
    # 推断io是否下发到iscsi
    probe module("libiscsi").function("iscsi_queuecommand")
    {
        if ( $host!=0 && $sc!=0 )
        {
            if ( $host->host_no==host_no && $sc->device->channel==channel && $sc->device->id==targetid && $sc->device->lun==lunid )
            {
                printf("====================send scsi=======================
    ")
                printf("tag = %d
    ", $sc->tag)
                printf("serial_number = %lu
    ", $sc->serial_number)
                printf("jiffies_at_alloc = %lu
    ", $sc->jiffies_at_alloc)
                print_backtrace()        
                printf("
    ")
            }
        }
    }
    
    
    probe kernel.function("do_sync_read")
    {
        if ($filp!=0)
        {
            if ($filp->f_inode!=0)
            {
                if ($filp->f_inode->i_ino == 3978543828)
                {
                    printf("===========================================do_sync_read
    
    ")
                }
            }
        }
    }
    
    # 推断IO在iscsi被正确下发
    probe module("libiscsi").statement("iscsi_queuecommand@libiscsi.c:1690")
    {
        if ( $host!=0 && $sc!=0 )
        {
            if ( $host->host_no==host_no && $sc->device->channel==channel && $sc->device->id==targetid && $sc->device->lun==lunid )
            {
                printf("====================cmd sended=======================
    ")
                printf("reason=%d
    ", $reason)
                printf("
    ")
            }
        }
    }
    
    # 推断IO是否返回
    probe module("libiscsi").function("__iscsi_put_task")
    {
        if ($task != 0)
        {
    
            if ($task->sc != 0)
            {
                if ( $task->sc->device->host->host_no==host_no && $task->sc->device->channel==channel && $task->sc->device->id==targetid && $task->sc->device->lun==lunid )
                {
                    printf("*************************recv scsi********************
    ")
                    printf("tag = %d
    ", $task->sc->tag)
                    printf("serial_number = %lu
    ", $task->sc->serial_number)
                    printf("jiffies_at_alloc = %lu
    ", $task->sc->jiffies_at_alloc)
                    print_backtrace()
                    printf("
    ")
               }
            }
        }
    }


  • 相关阅读:
    守护线程
    接口中的方法重写
    jvm内存结构
    浅拷贝,深拷贝
    队列
    12月4号荒度了一天
    同步条件
    条件变量
    信号量Semaphore
    sql练习
  • 原文地址:https://www.cnblogs.com/tlnshuju/p/7259927.html
Copyright © 2011-2022 走看看