
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、linux下gcc的debug和优化,以及编译过程int main(vo) int* p = 0; return a(p); int a(int *p) int y = *p; return y; rootlocalhost debug -c unlimit rootlocalhost debug gcc -wall g null.c rootlocalhost debug ./a.out segmentation fault (core mped) rootlocalhost debug null.c a.out core.21982 rootlocalhost debug yum -y i
2、nstall gdb rootlocalhost debug gdb a.out core.21982 . . . (gdb) print p no symbol table is loaded. use the command. (gdb) print p $1 = (int *) 0x0 (gdb) backace 0 0x08048389 in a (p=0x0) at null.c:10 1 0x08048377 in main () at null.c:6 (gdb) quit (gdb) 其次:优化实例(这里主要采纳的是-o03和no-loops方式) rootlocalhost
3、opm test.c ilude stdio.h double powern(double d, unsigned n) double x = 1.0; unsigned j; for(j=1;j j+) x *=d; return x; int main(void) double m = 0.0; unsigned i; for(i=1;i =100000000;i+ ) sum += powern(i,i%5); printf( sum = %gn ,sum); return 0; rootlocalhost opm gcc -wall -o0 test.c -o o0 /优化等级为0-不
4、优化 rootlocalhost opm ./o0 sum = 5e+30 real 0m2.815s user 0m2.799s sys 0m0.013s rootlocalhost opm gcc -wall -o1 test.c -o o1 /优化等级为1 rootlocalhost opm time ./o1 sum = 5e+30 real 0m1.849s user 0m1.843s sys 0m0.006s rootlocalhost opm gcc -wall -o2 test.c -o o2 /优化等级为2 rootlocalhost opm time ./o2 sum =
5、5e+30 real 0m1.923s user 0m1.910s sys 0m0.011s rootlocalhost opm gcc -wall -o3 test.c -o o3 /优化等级为1 rootlocalhost opm time ./o3 sum = 5e+30 real 0m1.460s user 0m1.453s sys 0m0.006s rootlocalhost opm gcc -wall -o3 -funroll-loops test.c -o o4 /加入noloop优化 rootlocalhost opm time ./o4 sum = 5e+30 real 0m
6、1.322s user 0m1.308s sys 0m0.014s 第三:优化协助发觉debug rootlocalhost o vim uninit.c int sign(int x) int s; if (x 0) s = 1; else if (x 0) s = -1; return s; rootlocalhost o gcc -wall -c uninit.c rootlocalhost o gcc -wall -o1 -c uninit.c uninit.c: in function 'sign': uninit.c:3: warning: 's'
7、may be u uninitialized in this function rootlocalhost o gcc -wall -o2 -c uninit.c uninit.c: in function 'sign': uninit.c:3: warning: 's' may be used uninitialized in this function rootlocalhost o gcc -wall -o3 -c uninit.c uninit.c: in function 'sign': uninit.c:3: warning:
8、9;s' may be used uninitialized in this function 编译过程描述实例 rootlocalhost hello vim hello.c include stdio.h int main(void) printf( hello world!n return 0; 第四:最后列举下编译的过程实例 1、 预处理器阶段(p hello.c hello.i) rootlocalhost hello cpp hello.c hello.i 2、 编译器阶段(gcc -wall -s hello.i) rootlocalhost hello gcc -wal
9、l -s hello.i 3、 汇编器阶段(as hello.s -o hello.o) rootlocalhost hello as hello.s -o hello.o 4、 衔接器阶段(gcc hello.o) rootlocalhost hello gcc hello.o rootlocalhost hello ./a.out hello world! rootlocalhost hello file a.out /检测可执行文件的信息 a.out: elf 32-bit lsb eable, intel 80386, version 1 (sysv), for gnu/linux 2.6.9, dynamically linked (uses shared libs), for gnu/linux 2.6.9, not stripped rootlocalhost hello l a.out /检查用到的库文件 lin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025-2030中国涂层钢板市场经营策略与前景深度评估报告
- 2025-2030中国海洋工程防腐涂料行业市场发展分析及发展前景与风险研究报告
- 2025-2030中国浴帽市场调研及发展策略研究报告
- 2025-2030中国浙江省乡村旅游行业市场发展战略及发展趋势与投资前景研究报告
- 2025-2030中国流感疫苗行业市场发展现状及发展趋势与投资前景研究报告
- 2025-2030中国洗发液行业市场全景调研及投资价值评估咨询报告
- 2025-2030中国注塑桶市场运营现状与重点销售区域分析研究报告
- 2025-2030中国汽车车门把手传感器行业市场发展趋势与前景展望战略研究报告
- 2025-2030中国汽车汽油发动机涡轮增压器行业市场现状供需分析及投资评估规划分析研究报告
- 2025-2030中国汽车可视化市场竞争格局与前景战略分析研究报告
- 污水处理设备安装施工方案
- 审批流程和权限管理制度
- 学校安全风险分级管控清单
- 人教版英语七年级上册阅读理解专项训练16篇(含答案)
- 建筑相关法律法规清单
- 盾构施工关键技术知识考试题库及答案
- DB34T 4708-2024 医疗机构互联网+护理服务工作指南
- 中、小学文件材料分类方案、归档范围、保管期限表(三合一制度)
- 《团队合作共创佳绩》主题班会
- 2024年北京中考地理试卷
- 2021小学教师英语学科业务考试测试卷及答案共三套
评论
0/150
提交评论