kernel_debug

这篇博客介绍了如何在Linux系统中进行kernel调试,包括安装和使用oprofile进行性能分析。此外,还讨论了常见的系统服务,如端口分配和shell的使用。文章探讨了Linux下的网络技术,如socket编程可能遇到的问题以及高性能网络I/O框架netmap。同时,提到了针对Windows和Linux的抓包工具以及Linux下bin文件的安装方法。
摘要由CSDN通过智能技术生成
1.使用gdb调试
    *  /proc/kcore文件是系统内核运行情况的内存映像
    * 如果编译内核的时候增加-g选项,即会在生成的二进制代码vmlinuz或vmlinux中,添加调试相关的数据。
    * 以root身份运行
    #gdb /usr/src/linux/vmlinux /proc/kcore
    * 因为core-file命令是静态的,如果需要查看内核最近的运行情况,需要再次运行core-file将新的/proc/kcore导入,否则就只能是上次使用core-file的情况
# gdb vmlinux
# (gdb) core-file /proc/kcore
# #0  0x0 in ?? ()
# (gdb) p jiffies
# $1 = 29119787
# (gdb) p jiffies  
# $2 = 29119787
# (gdb) core-file /proc/kcore
# #0  0x0 in ?? ()
# (gdb) p jiffies
# $3 = 29122291
# (gdb)

2.Core Dump
1>开启系统的Core Dump功能
    ulimit -c core_file_size_in_kb
    如果要关闭该功能core_file_size_in_kb为0就行了。
    ulimit -c 1000

2>设置Core Dump的核心转储文件目录和命名规则
    文件的命名规则放在
    /proc/sys/kernel/core_name_format文件中
    使用sysctl -w "kernel.core_name_format=/coredump/%n.core"
    上例的core文件放在/coredump目录下,文件名是进程名+.core
    以下是一些命名的格式说明
    %P   The Process ID (current->pid)
    %U   The UID of the process (current->uid)
    %N   The command name of the process (current->comm)
    %H   The nodename of the system (system_utsname.nodename)
    %%   A "%"

3.UML调试内核
1>直接使用gdb运行UML内核
root@wangyao-desktop:/usr/src/linux-2.6.24# gdb -q ./linux ubd0=/uml/Debian-4.0-x86-root_fs mem=128M eth0=tuntap,,,192.168.1.11 umid=ubuntu
Excess command line arguments ignored. (mem=128M ...)
Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
/usr/src/linux-2.6.24/ubd0=/uml/Debian-4.0-x86-root_fs: No such file or directory.
(gdb) b start_kernel
Breakpoint 1 at 0x80493a7: file init/main.c, line 512.
(gdb) r
Starting program: /usr/src/linux-2.6.24/linux
Core dump limits :
        soft - 0
        hard - NONE
Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking for tmpfs mo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值