- 浏览: 1442691 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (691)
- linux (207)
- shell (33)
- java (42)
- 其他 (22)
- javascript (33)
- cloud (16)
- python (33)
- c (48)
- sql (12)
- 工具 (6)
- 缓存 (16)
- ubuntu (7)
- perl (3)
- lua (2)
- 超级有用 (2)
- 服务器 (2)
- mac (22)
- nginx (34)
- php (2)
- 内核 (2)
- gdb (13)
- ICTCLAS (2)
- mac android (0)
- unix (1)
- android (1)
- vim (1)
- epoll (1)
- ios (21)
- mysql (3)
- systemtap (1)
- 算法 (2)
- 汇编 (2)
- arm (3)
- 我的数据结构 (8)
- websocket (12)
- hadoop (5)
- thrift (2)
- hbase (1)
- graphviz (1)
- redis (1)
- raspberry (2)
- qemu (31)
- opencv (4)
- socket (1)
- opengl (1)
- ibeacons (1)
- emacs (6)
- openstack (24)
- docker (1)
- webrtc (11)
- angularjs (2)
- neutron (23)
- jslinux (18)
- 网络 (13)
- tap (9)
- tensorflow (8)
- nlu (4)
- asm.js (5)
- sip (3)
- xl2tp (5)
- conda (1)
- emscripten (6)
- ffmpeg (10)
- srt (1)
- wasm (5)
- bert (3)
- kaldi (4)
- 知识图谱 (1)
最新评论
-
wahahachuang8:
我喜欢代码简洁易读,服务稳定的推送服务,前段时间研究了一下go ...
websocket的helloworld -
q114687576:
http://www.blue-zero.com/WebSoc ...
websocket的helloworld -
zhaoyanzimm:
感谢您的分享,给我提供了很大的帮助,在使用过程中发现了一个问题 ...
nginx的helloworld模块的helloworld -
haoningabc:
leebyte 写道太NB了,期待早日用上Killinux!么 ...
qemu+emacs+gdb调试内核 -
leebyte:
太NB了,期待早日用上Killinux!
qemu+emacs+gdb调试内核
core生成的位置
echo “/data/coredump/core.%e.%p” >/proc/sys/kernel/core_pattern
emacs -nw
1.debug方式编译内核
2.qemu -S启动
3.设置emacs参数 ,启用gdb模式远程调试
环境:
下载linux-2.6.20
http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/
修改Makefile
make defconfig
生成.config文件
这里如果使用这种方式生成的.config文件内核可以编译成功,但是在可能无法进入linux操作系统,尝试使用fabrice bellard的jslinux的配置文件
linuxstart-20120111/config_linux-2.6.20
http://bellard.org/jslinux/tech.html
下载配置文件
http://dl.iteye.com/topics/download/9973ef69-2386-36bb-82f5-1c01a6edabac
把这个保存成.config放到和Makefile同级的目录下
make menuconfig
选择debug模式
vim scripts/mod/sumversion.c
最上面新加一行
vim arch/i386/kernel/Makefile
gcc的版本问题
gcc的参数-m elf_i386改成-m32
ld后的参数不改
改成
vim kernel/mutex.c
开始make
用qemu启动内核
或者使用qemu的官网的test的img:linux-0.2.img
注意:这里加了console=ttyS0 才有很多输出信息,不加没有
注意:这里的hda.bin是fabrice bellard的jslinux中的
注意,这里加了 -serial 才输出到屏幕上,在vnc连进去还是到"ok,booting the kernel"
如果不开-s和-S的调试模式,直接气得弄个qemu的话,append参数里面有console则会在当前命令行进入系统
可以使用qemu官方的linux-0.2.img(不过这个img自带2.6.20的内核,不影响)
如果不适用我们编译的内核,而直接用他自己的内核
vnc连接后
可以去看一下内核的版本
其中-S 是gdb需要的
远程使用vnc 端口3或者5903
进入后应该是一片漆黑
ctl+alt+2
进入qemu调试
然后输入gdbserver回车
默认开启1234端口
指定端口用
(qemu) gdbserver tcp::1233
如果省去gdbserver这步骤
可以启动的时候直接加-s 注意小s是启动server,大S是暂停
可以netstat一下1234端口是否打开
进入linux-2.6.20目录
下面有个vmlinux
如果不使用emacs
直接gdb vmlinux
进入后
target remote localhost:1234
如果使用emacs:
emacs
M-x gdb
Run gdb (like this): gdb -i=mi vmlinux
这里需要设置一下,否则会出现
的错误
设置方法如下
http://stackoverflow.com/questions/15274798/valgrind-vgdb-with-gdb-in-emacs
M-x customize-option
Customize variable: gdb-non-stop-setting
在state上回车
修改成
可以看到在~/.emacs里面多了
回到
M-x gdb
target remote localhost:1234
M-x gdb-many-windows
在gdb下 info source 查看当前文件的名字
开始enjoy吧
另外,linux追代码的时候如果使用vim
编译完内核后到linux-2.6.20目录
make tags
生成ctags文件
这样比自己生成的ctags要准,自己生成的当函数重名的时候会跳错乱
配置~/.vimrc
备注:如果有linux启动不了的问题参考
http://processors.wiki.ti.com/index.php/Kernel_-_Common_Problems_Booting_Linux
http://serverfault.com/questions/471719/how-to-start-qemu-directly-in-the-console-not-in-curses-or-sdl
qemu:http://wiki.qemu.org/Testing
参考:http://blog.chinaunix.net/uid-20729583-id-1884617.html
http://blog.chinaunix.net/uid-26872853-id-3428938.html
这里有版本相关的问题
参考极客范:http://www.geekfan.net/8663/
echo “/data/coredump/core.%e.%p” >/proc/sys/kernel/core_pattern
emacs -nw
1.debug方式编译内核
2.qemu -S启动
3.设置emacs参数 ,启用gdb模式远程调试
环境:
[root@centos140_11 ~]# cat /etc/redhat-release CentOS Linux release 7.1.1503 (Core) [root@centos140_11 ~]# gcc --version gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
下载linux-2.6.20
http://www.linux-mips.org/pub/linux/mips/kernel/v2.6/
修改Makefile
1438 # Modules 1439 %/: prepare scripts FORCE 1440 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \ 1441 $(build)=$(build-dir)
412 %config: scripts_basic outputmakefile FORCE 413 $(Q)mkdir -p include/linux include/config 414 $(Q)$(MAKE) $(build)=scripts/kconfig $@
make defconfig
生成.config文件
这里如果使用这种方式生成的.config文件内核可以编译成功,但是在可能无法进入linux操作系统,尝试使用fabrice bellard的jslinux的配置文件
linuxstart-20120111/config_linux-2.6.20
http://bellard.org/jslinux/tech.html
下载配置文件
http://dl.iteye.com/topics/download/9973ef69-2386-36bb-82f5-1c01a6edabac
把这个保存成.config放到和Makefile同级的目录下
make menuconfig
选择debug模式
vim scripts/mod/sumversion.c
最上面新加一行
#include <limits.h>
vim arch/i386/kernel/Makefile
gcc的版本问题
gcc的参数-m elf_i386改成-m32
ld后的参数不改
57 # The DSO images are built using a special linker script. 58 quiet_cmd_syscall = SYSCALL $@ 59 cmd_syscall = $(CC) -m elf_i386 -nostdlib $(SYSCFLAGS_$(@F)) \ 60 -Wl,-T,$(filter-out FORCE,$^) -o $@ 61
改成
57 # The DSO images are built using a special linker script. 58 quiet_cmd_syscall = SYSCALL $@ 59 cmd_syscall = $(CC) -m32 -nostdlib $(SYSCFLAGS_$(@F)) \ 60 -Wl,-T,$(filter-out FORCE,$^) -o $@ 61
vim kernel/mutex.c
__mutex_lock_slowpath 的两个方法的static去掉 __mutex_unlock_slowpath的两个方法的static去掉
开始make
make ARCH=i386 -j16
用qemu启动内核
/usr/libexec/qemu-kvm -kernel linux-2.6.20.jslinux/arch/i386/boot/bzImage -hda hda.bin -append "root=/dev/hda console=ttyS0" -serial stdio -vnc 0.0.0.0:3
或者使用qemu的官网的test的img:linux-0.2.img
/usr/libexec/qemu-kvm -kernel linux-2.6.20.jslinux/arch/i386/boot/bzImage -hda linux-0.2.img -append "root=/dev/hda console=ttyS0" -serial stdio -vnc 0.0.0.0:3
注意:这里加了console=ttyS0 才有很多输出信息,不加没有
注意:这里的hda.bin是fabrice bellard的jslinux中的
注意,这里加了 -serial 才输出到屏幕上,在vnc连进去还是到"ok,booting the kernel"
如果不开-s和-S的调试模式,直接气得弄个qemu的话,append参数里面有console则会在当前命令行进入系统
可以使用qemu官方的linux-0.2.img(不过这个img自带2.6.20的内核,不影响)
如果不适用我们编译的内核,而直接用他自己的内核
/usr/libexec/qemu-kvm linux-0.2.img -vnc 0.0.0.0:3
vnc连接后
可以去看一下内核的版本
其中-S 是gdb需要的
远程使用vnc 端口3或者5903
进入后应该是一片漆黑
ctl+alt+2
进入qemu调试
然后输入gdbserver回车
默认开启1234端口
指定端口用
(qemu) gdbserver tcp::1233
如果省去gdbserver这步骤
可以启动的时候直接加-s 注意小s是启动server,大S是暂停
/usr/libexec/qemu-kvm -kernel linux-2.6.20.debug/arch/i386/boot/bzImage -hda hda.bin -append "root=/dev/hda" -serial stdio -vnc 0.0.0.0:3 -S -s
可以netstat一下1234端口是否打开
netstat -nltp |grep 1234
进入linux-2.6.20目录
下面有个vmlinux
如果不使用emacs
直接gdb vmlinux
进入后
target remote localhost:1234
如果使用emacs:
emacs
M-x gdb
Run gdb (like this): gdb -i=mi vmlinux
这里需要设置一下,否则会出现
get Non-stop mode requested, but remote does not support non-stop
的错误
设置方法如下
http://stackoverflow.com/questions/15274798/valgrind-vgdb-with-gdb-in-emacs
M-x customize-option
Customize variable: gdb-non-stop-setting
在state上回车
修改成
可以看到在~/.emacs里面多了
(custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(gdb-non-stop-setting nil)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ~
回到
M-x gdb
target remote localhost:1234
M-x gdb-many-windows
在gdb下 info source 查看当前文件的名字
开始enjoy吧
另外,linux追代码的时候如果使用vim
编译完内核后到linux-2.6.20目录
make tags
生成ctags文件
这样比自己生成的ctags要准,自己生成的当函数重名的时候会跳错乱
配置~/.vimrc
syntax on set tabstop=4 set paste set tags=/home/haoning/rtclinux/websocket/web/jslinux/tmp/linux-2.6.20.jslinux/tags
备注:如果有linux启动不了的问题参考
http://processors.wiki.ti.com/index.php/Kernel_-_Common_Problems_Booting_Linux
http://serverfault.com/questions/471719/how-to-start-qemu-directly-in-the-console-not-in-curses-or-sdl
qemu:http://wiki.qemu.org/Testing
参考:http://blog.chinaunix.net/uid-20729583-id-1884617.html
http://blog.chinaunix.net/uid-26872853-id-3428938.html
这里有版本相关的问题
参考极客范:http://www.geekfan.net/8663/
- config_linux-2.6.zip (5.5 KB)
- 下载次数: 1
评论
2 楼
haoningabc
2015-12-17
leebyte 写道
太NB了,期待早日用上Killinux!
么么哒
1 楼
leebyte
2015-12-17
太NB了,期待早日用上Killinux!
发表评论
-
xl2tp 备份
2019-09-24 16:25 5722019年9月24日更新: 注意,需要开启firewall ... -
sdl笔记
2019-01-31 17:19 683sdl教程教程 https://github.com/Twin ... -
tinyemu
2019-01-24 17:59 1394参考https://bellard.org/jslinux/t ... -
aws搭建xl2tp给iphone使用
2018-12-26 21:37 18012019年12月26日 可以参考原来的配置 https:// ... -
spacemacs的国内镜像
2018-07-03 19:36 3186装emacs25以上可以装spacemacs 目前在mac上 ... -
nginx模块开发(二) 使用gdb-dashboard调试
2017-08-11 18:47 1917gdb-dashboard或者 gdbgui 或者gdb自带 ... -
consul的基本使用
2017-06-27 11:13 1349### 安装 [centos7上consul的安装](ht ... -
lvs的helloworld
2017-06-13 20:36 557###################lvs######### ... -
系统调用的helloworld
2017-05-04 16:14 558《2.6内核标准教程》 p293 #include < ... -
bitcoin和cgminer的安装
2017-04-05 22:45 1918参考 http://blog.csdn.net/rion_ch ... -
ceph安装和常用命令
2017-03-21 21:55 910/etc/hosts ssh-keygen ssh-copy- ... -
mobile terminal 笔记
2016-12-02 15:35 544找出旧的iphone4 越狱之后可以变个小操作系统 mobi ... -
spacemacs的安装
2016-09-23 10:06 1301spacemacs http://ftp.gnu.org/g ... -
socket基础和select(python)
2016-06-14 17:21 1756上接 c语言的socket基础ht ... -
socket基础(c语言)
2016-06-14 16:45 937不使用select 普通的基础socket连接,对多个客户端的 ... -
ffmpeg+nginx 的直播(2,直播摄像头和麦克风)
2016-05-28 20:21 4252假设我的服务器是centos7 192.168.139.117 ... -
ffmpeg+nginx 的直播(1,直播播放的视频文件)
2016-05-26 17:11 651564位操作系统centos7 ############ 1.一 ... -
socat和netcat(nc)
2016-04-29 22:36 1670转 原文链接: http://www.wenquan.name ... -
neutron基础九(qemu nat网络)
2016-02-06 17:21 1549接上基础八,kvm透传nested忽略 1.在主机ce ... -
neutron基础八(qemu 桥接网络)
2016-02-06 13:13 1477qemu的桥接和nat的qemu启动命令是一样的,但是后续的脚 ...
相关推荐
QEMU+树莓派3B调试Linux-设备树以及原版内核文件
原版内核
介绍qemu+kvm的使用方法,以及两种之间的关系。
本文档详细介绍了:在windows10主机的vmware软件中安装ubuntu18.04系统,再基于x86架构的ubuntu18.04,搭建openEuler_aarch64架构的qemu虚拟机。
行业分类-物理装置-一种通过nova调用qemu+guest+agent接口的方法
设备树
在linux系统下(包括CentOS、Ubuntu等)编译QEMU和SPICE协议,使其支持USB重定向。
该脚本文件用于使用您的 kernel.img 文件和 kernel.elf 启动 QEMU 和 GDB,以便您可以愉快地调试。 该脚本采用两个参数: $1(强制)- kernel.img 文件的相对路径$2(可选)- kernel.elf 文件的相对路径。 如果没有...
本文将为大家介绍两种Linux中用GDB与QEMU来调试内核分析的方法。
调试linux内核用的虚拟机.把linux内核放在该平台下运行,然后在物理机下调试内核。
本文档介绍了:在树莓派4B中安装openEuler-20.03-LTS-aarch64后,再基于树莓派4B的硬件虚拟化功能,使用libvirt工具与xml配置文件的方式,搭建aarch64架构 openEuler操作系统 的qemu 虚拟机。
使用qemu虚拟机环境实现linux内核源码级的调试
此配置文件.config是针对QEMU模拟器裁剪的linux-5.5.9内核源码配置,以减少编译时间。 https://blog.csdn.net/eidolon_foot/article/details/104905084。
EVE-NG QEMU镜像列表 Update7,pdf repower 6-6.2r fortinet-5.2.rar fortinet-5.4.rar se-2.0.partol.rar ise-2.0. part02rar ise-2.0.part03rar ise-2..parton.rar ise-2.0.parto5rar ise-2.0.parton.rar linux-...
安装QEMU,了解QEMU对multiboot的 支持情况 可以使用其他虚拟机或模拟器 遵守multiboot协议,写multiboot header 直接在VGA的显存中写“helloworld” 使用串口输出“HELLOWORLD” 了解并掌握必要的汇编 了解Makefile...
参考 https://blog.csdn.net/shuaifengyun/article/details/71499619 但是,因为随着github.com代码的更新,导致我做了一大堆的额外的动作。把代码库各个代码返回到2017年5月底。才得以成功运行。 附件写了方法
EclipseCDT+QEMU调试linux内核.pdf
arm, x86 两个平台的qemu 模拟器的安装,gdb 的安装,内核的编译的核调试 ,包括根文件系统的制作,实测的启动参数
Docker-eyeOS 在Docker容器中运行iPhone的xnu-qemu-arm64(iOS) 支持KVM + GDB内核调试! 在Docker中运行armv8-A! 可在任何设备上使用!Docker-eyeOS v1.0.12.1Docker-eyeOS中的功能qemu-system-aarch64引导进入...
这里说明下,本人调试的内核版本是2.6.11.12,为什么去调试这么“古老”的版本?原因不多说了,你手头也许正拿着ULK3,而它针对的内核版本正是2.6.11,有比这更好的理由吗?而且这个版本不算旧,已不算新,我认为还...