手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux入门教程:Linux内核模块调试

[日期:2011-02-09] 来源:Linux社区  作者:Linux [字体:大 中 小]

  1. 开启虚拟机,虚拟机运行到 kgdb: Waiting for connection from remote gdb

  2. 在Host机上运行: socat tcp-listen:8888 /tmp/vbox2, 其中/tmp/vbox2为管道文件,它是目标机串口的重定向目的文件,socat将这个管道文件又重定向到tcp socket的8888端口。

  3. 开启一个新的虚拟终端,cd path/to/kernel/source/tree, 然后执行gdb ./vmlinux

  输出

  GNU gdb 6.8-debian

  Copyright (C) 2008 Free Software Foundation, Inc.

  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

  This is free software: you are free to change and redistribute it.

  There is NO WARRANTY, to the extent permitted by law.  Type "show copying"

  and "show warranty" for details.

  This GDB was configured as "i486-linux-gnu"...

  (gdb) set-remote

  set remote baud rate to 115200c/s

  set remote target to local tcp socket

  kgdb_breakpoint () at kernel/kgdb.c:1721

  1721        wmb(); /* Sync point after breakpoint */

  (gdb) c

  Continuing.

  目标机会一直启动,直到提示输入用户名密码。

  4. 进入目标机,输入用户名密码(推荐使用字符界面下的root用户),输入g命令,目标机被断下,控制移交到Host机中的gdb中。(目标机root的用户目录中的.bashrc中添加一行alias g='echo g>/proc/sysrq-trigger')

  5. 在Host机中的gdb中

  (gdb) set-mod-break

  set breakpoint in system module init function

  Breakpoint 1 at 0xc014bac5: file kernel/module.c, line 2288.

  (gdb) c

  Continuing.

  6. 在目标机中

  insmod klogger2.ko

  目标机再次断下,控制权移交Host机中的gdb

linux
相关资讯       Linux内核模块调试 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款