bianbian coding life

便便代码人生: 关注技术, 翻译文档, 偶尔动动手

[原]Linux下的c/c++ GDB调试

Posted by bianbian on 2007-09-18 10:13


本文Tags: , , ,

还是比较厉害的,比较准。
编译的时候加入 -g -rdynamic 选项,之后就可以跑调试了:
linux $ gcc -g -rdynamic -o error error.c
linux $ gdb error
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type “show copying” to see the conditions.
There is absolutely no warranty for GDB. Type “show warranty” for details.
This GDB was configured as “i686-pc-linux-gnu”…Using host libthread_db library “/lib/libthread_db.so.1″.

(gdb) run
Starting program: /home/linux/error

Program received signal SIGSEGV, Segmentation fault.
错误内容
行数 源码;
(gdb) kill
(gdb) q

linux $

标签: , , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in C/C++, Linux, Technology | 1 Comment »

[原]第一次完整地编译了Linux内核

Posted by bianbian on 2007-09-17 02:10


本文Tags: , , ,

啊,太痛苦了,从下午一直编译到凌晨,终于每个选项都搞清楚了是干嘛的。用的是最新的2.6.22.6内核。
slackware 12.0太好玩了,装好后有几个cpu就会在屏幕上方显示几个LOGO企鹅。一排八个真壮观。。。。

推荐这个文章: http://lamp.linux.gov.cn/Linux/kernel_options.html

共计遇到的主要问题如下:
1)LILO 不能装到MBR,好像做了raid的都不能写MBR。手动写lilo.conf可以解决。(从安装盘引导,mount /dev/cciss/盘 /d1,chroot /d1,然后就可以改 /etc/lilo.conf了,改完直接lilo)
2)make menuconfig报错。类似:
scripts/lxdialog/dialog.h:127: syntax error before “use_colors”
scripts/lxdialog/dialog.h:127: warning: type defaults to `int’ in declaration of `use_colors’
scripts/lxdialog/dialog.h:127: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:128: syntax error before “use_shadow”
scripts/lxdialog/dialog.h:128: warning: type defaults to `int’ in declaration of `use_shadow’
scripts/lxdialog/dialog.h:128: warning: data definition has no type or storage class
scripts/lxdialog/dialog.h:130: syntax error before “attributes”
原因是setup装系统的时候有make menuconfig要用到的开发语言和库没有安装进去。重新安装就可以了。网上其他发行版说的需要手动安装libncurses-dev,在Slackware 12.0并不需要,系统应该自带了。

3)网络不通。检查是驱动选错了。(lspci得到的结果不能全相信,仅供参考!我最后是从安装盘里的默认系统开机自检画面里面发现真实网卡驱动的)
4)VFS: cannot open root device。
可能的原因:A)尽管硬盘全都是SCSI,常规IDE里”INCLUDE IDE/ATA disk Support”这个还是得选上。否则就打不开根设备。。。- -!
B)Enable the block layer(块设备支持,使用硬盘/USB/SCSI设备者必选)-》Support for Large Block Devices(仅在使用大于2TB的块设备时需要)。这个选项我发现必须选上。尽管我只有8*140G,不到2T。但是实际上如果这个选项没有选的话可能起不来。因此我觉得这里是翻译有问题。原文并没有指明是2T。
可能还有其他选项上的问题,可以看看这个网址:http://kerneltrap.org/node/970

期间得到ever的大力帮助,特别感谢。
今天还是嘘嘘生日,真是对不住哦。。。。

标签: , , ,

遵守创作共用协议,转载请链接形式注明来自http://bianbian.org 做人要厚道

相关日志

Posted in Linux, Technology | 1 Comment »