免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 941 | 回复: 0
打印 上一主题 下一主题

硬件无关的硬件课设之GCC、GDB的学习 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-01 19:52 |只看该作者 |倒序浏览

1.查看默认的gcc版本
#gcc –v
gcc
version 3.3.2 20030222

2.编写一个简单的程序进行练习
  #vi hello.c#includestdio.h>
int main(int argc, char* argv[])
{
     printf(“Hello,%s.\n”,argv[1]);
     return 0;
}
# gcc –o
hello –g hello.c
# ./hello “daxi”
Hello,daxi.

3.gcc常用命令选项
-c              只编译并生成目标文件。
-g              生成调试信息。
-o  FILE        生成制定名称的可执行文件。
-Wall           生成所有警告信息。
4.使用gdb
#gdb
hello
(gdb)b
main
(gdb)r
(gdb)n
(gdb)p
argv[0]
$1 =
0xbffffc67 “/root/hello”
(gdb)q

4.gdb常用命令选项
gdb
progname    Start GDB is with an executable program.
r               Start your program
under GDB.
b   LINENUM     Set a breakpoint at line LINENUM in current source file.
b   FUNCTION      Set a breakpoint at entry to function FUNCTION.
s   [COUNT]      Continue running
your program until control reaches a different source line   
n   [COUNT]      Continue to the next source line in current stack
frame.
p   [EXP]       By default value of EXP is printed in a format appropriate to
its data type.
s/n类似VS2005的F11/F10
参考:
http://sources.redhat.com/


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/49865/showart_654355.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP