CentOS 7 开发环境搭建

本文主要是给自己看的,以便日后查阅。



yum grouplist
yum groupinstall "GNOME Desktop"
yum groupinstall "Development Tools"
yum install cscope
yum install ctags
yum install screen
yum install grub-customizer
yum install ncurses-devel
yum install openssl-devel
yum install gcc
yum install gcc-c++

yum install tmux cscope ctags screen grub-customizer ncurses-devel openssl-devel gcc gcc-c++ patch *lzo* *elf* vim-enhanced git bison readline-devel snappy-devel wget tcl tcl-devel tk tk-devel git-email autoconf automake

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.1.tar.xz
xz -dk llinux-4.10.1.tar.xz (decompress and keep)
tar xf linux-4.10.1.tar
cd linux-4.10.1
cp /boot/config-3.10.0-514.el7.x86_64 .config

make menuconfig (load, save, exit)
CONFIG_STRICT_DEVMEM=n # for crash
CONFIG_MODVERSIONS=n
CONFIG_UPROBE_EVENTS=y
CONFIG_ARCH_SUPPORTS_UPROBES=y
CONFIG_UPROBES=y
make
make modules_install
make install

# for crash
http://people.redhat.com/anderson/
yum install patch
yum install *lzo*
yum install bison
yum install  readline-devel snappy-devel

CONFIG_STRICT_DEVMEM=n
crash> mod -s e1000e
crash> net
   NET_DEVICE     NAME   IP ADDRESS(ES)
ffff88017e9da000  lo     127.0.0.1
ffff880207b98000  enp0s25 192.168.31.190
ffff88020a918000  wlp3s0 192.168.31.245
ffff880214aea000  virbr0 192.168.122.1
ffff88020c730000  virbr0-nic 
crash> net_device
...
SIZE: 2304
crash> px 2304
$4 = 0x900
crash> e1000_adapter.napi ffff880207b98900
  napi = {
    poll_list = {
      next = 0xffff880207b98c90, 
      prev = 0xffff880207b98c90
    }, 
    state = 8, 
    weight = 64, 
    gro_count = 0, 
    poll = 0xffffffffa01d94d0 , 
    poll_owner = -1, 
    dev = 0xffff880207b98000, 
    gro_list = 0x0, 
    skb = 0x0, 
    timer = {
      node = {
        node = {
          __rb_parent_color = 18446612141033753816, 
          rb_right = 0x0, 
          rb_left = 0x0
        }, 
        expires = 0
      }, 
      _softexpires = 0, 
      function = 0xffffffff816155a0 , 
      base = 0xffff88021e2525c0, 
      state = 0 '\000', 
      is_rel = 0 '\000', 
      start_pid = -1, 
      start_site = 0x0, 
      start_comm = "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
    }, 
    dev_list = {
      next = 0xffff880207b98060, 
      prev = 0xffff880207b98060
    }, 
    napi_hash_node = {
      next = 0x0, 
      pprev = 0xffffffff81d7e288 
    }, 
    napi_id = 8193
  }


# for systemtap
https://sourceware.org/systemtap/getinvolved.html
yum install *elf*

stap -ve 'probe begin { log("hello world") exit () }'
stap -c df -e 'probe syscall.* { if (target()==pid()) log(name." ".argstr) }'


function stm
{
        if [[ $# == 1 ]]; then
                module=mlx5_core
                function=$1
                file=$dir/$1.stp
        elif [[ $# == 2 ]]; then
                module=$1
                function=$2
                file=$dir/$2.stp
        else
                return
        fi


        dir=/root/stap


        mkdir -p $dir


        cat << EOF > $file
#!/usr/local/bin/stap -v
global start
function timestamp:long() { return gettimeofday_us() - start }
probe begin { start = gettimeofday_us() }


global i=0;
probe module("$module").function("$function")
{
        print_backtrace()
        printf("parms: %s\n", \$\$parms);
        printf("execname: %s\n", execname());
        printf("ts: %d\n", timestamp() / 1000000);
        print_ubacktrace()
        printf("%d\n", i++);
}
EOF


set -x
        cat $file
        cd $dir
        chmod +x $file
        stap -v -k -d act_gact -d cls_flower -d act_mirred -d /usr/sbin/ethtool -d cls_flower -d udp_tunnel -d sch_ingress -d /home1/chrism/iproute2/tc/tc -d 8021q -d /usr/sbin/ip -d /usr/sbin/ifconfig -d /usr/sbin/tc -d devlink -d mlx5_core -d /usr/sbin/devlink  -d vhost -d vhost_net -d tun -d kernel -d openvswitch -d vport_vxlan -d vxlan -d /usr/lib64/libpthread-2.17.so -d /usr/sbin/ovs-vswitchd -d /usr/lib64/libc-2.17.so $file
set +x
}
function str
{
        [[ $# != 1 ]] && return


        dir=/root/stap
        file=$dir/$1.stp


        mkdir -p $dir


        mod=$(grep -w $1 /proc/kallsyms | awk '{print $4}' | tr -d ] | tr -d [)
        echo $mod


        if [[ "$mod" == "" ]]; then
                cat << EOF > $file
#!/usr/local/bin/stap


global start
function timestamp:long() { return gettimeofday_us() - start }
probe begin { start = gettimeofday_us() }


probe kernel.function("$1").return
{
/*      print_backtrace() */
        printf("%x\t%d\n", \$return, \$return);
        printf("ts: %d\n", timestamp()/1000000);
}
EOF
        else
                cat << EOF > $file
#!/usr/local/bin/stap


global start
function timestamp:long() { return gettimeofday_us() - start }
probe begin { start = gettimeofday_us() }


probe module("$mod").function("$1").return
{
/*      print_backtrace() */
        printf("%x\t%d\n", \$return, \$return);
        printf("ts: %d\n", timestamp()/1000000);
}
EOF
        fi


set -x
        cat $file
        cd $dir
        chmod +x $file
        stap -v -k -d vhost -d vhost_net -d tun -d kernel -d openvswitch -d vport_vxlan -d vxlan -d /usr/lib64/libpthread-2.17.so -d /usr/local/sbin/ovs-vswitchd -d /usr/lib64/libc-2.17.so $file
set +x
}

mybuild () 
{
set -x; 
        ver=4.10.1
        module=e1000e;
        linux_dir=/home/mishuang/linux-$ver;
        src_dir=$linux_dir/drivers/net/ethernet/intel/$module;
        cd $dir_dir;
        sudo make CONFIG_E1000E=m -C $linux_dir M=$src_dir modules;
        sudo cp $src_dir/$module.ko /lib/modules/$ver/kernel/drivers/net/ethernet/intel/$module;
        sudo rmmod $module;
        sudo modprobe $module;
set +x
}

$ yum provides /etc/passwd
$ rpm -qf /etc/passwd


你可能感兴趣的:(linux)