欢迎来到天天文库
浏览记录
ID:37847451
大小:106.50 KB
页数:9页
时间:2019-06-01
《linux C- gdb调试、Makefile》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、linuxC-gdb调试、Makefilegcc可以编译c,c++,object-c,java等众多的语言程序g++则是专注于C和C++。gdb调试GDB调试器是一个功能强大的工具,它可以做很多的调试工作,如断点,单步跟踪等。相关命令:下面演示两个例子,追踪快速排序的过程和查看优化后的gcd()算法(方法来自编程之美)观察快速排序:打印数组,查看快速排序中各个元素的位置变化源码:#include#includeusingnamespacestd;intpartion(inta[],intstart
2、,intend){inti=start,j=end;inttemp=a[start];while(i=temp)j--;a[i]=a[j];//iaremorewhile(i3、rt(a,d+1,end);}}intmain(){inta[10]={3,2,7,5,1,0,9,6,4,11};Qsort(a,0,9);for(inti=0;i<10;i++)printf("%d",a[i]);printf("");return0;}指令:edemon@linux:~$g++-g-oexemain.cppedemon@linux:~$gdbexe(gdb)break17Breakpoint1at0x4006f4:filemain.cpp,line17.(gdb)runBreakpoint1,Qsort(a=04、x7fffffffdda0,start=0,end=9)atmain.cpp:1717if(start5、fffdda0,start=0,end=0)atmain.cpp:1717if(start6、7fffffffdda0,start=1,end=2)atmain.cpp:1717if(start7、(a=0x7fffffffdda0,start=2,end=2)atmain.cpp:1717if(start8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
3、rt(a,d+1,end);}}intmain(){inta[10]={3,2,7,5,1,0,9,6,4,11};Qsort(a,0,9);for(inti=0;i<10;i++)printf("%d",a[i]);printf("");return0;}指令:edemon@linux:~$g++-g-oexemain.cppedemon@linux:~$gdbexe(gdb)break17Breakpoint1at0x4006f4:filemain.cpp,line17.(gdb)runBreakpoint1,Qsort(a=0
4、x7fffffffdda0,start=0,end=9)atmain.cpp:1717if(start5、fffdda0,start=0,end=0)atmain.cpp:1717if(start6、7fffffffdda0,start=1,end=2)atmain.cpp:1717if(start7、(a=0x7fffffffdda0,start=2,end=2)atmain.cpp:1717if(start8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
5、fffdda0,start=0,end=0)atmain.cpp:1717if(start6、7fffffffdda0,start=1,end=2)atmain.cpp:1717if(start7、(a=0x7fffffffdda0,start=2,end=2)atmain.cpp:1717if(start8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
6、7fffffffdda0,start=1,end=2)atmain.cpp:1717if(start7、(a=0x7fffffffdda0,start=2,end=2)atmain.cpp:1717if(start8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
7、(a=0x7fffffffdda0,start=2,end=2)atmain.cpp:1717if(start8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
8、Qsort(a=0x7fffffffdda0,start=4,end=9)atmain.cpp:1717if(start
此文档下载收益归作者所有