当前位置: 首页 > news >正文

仓山区建设局招标网站球队积分排名

仓山区建设局招标网站,球队积分排名,安卓开发需要掌握哪些技术,交互式网站开发技术有哪些1.GDB 调试程序 GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。在UNIX平台下做软件,GDB这个调试工具有比VC的图形化调试器更强大的功能。所谓“寸有所长,尺有所短”就是这个道理。 一般来说,GDB主要帮忙你完成下面四个方面的功能…

1.GDB 调试程序

GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。在UNIX平台下做软件,GDB这个调试工具有比VC的图形化调试器更强大的功能。所谓“寸有所长,尺有所短”就是这个道理。

一般来说,GDB主要帮忙你完成下面四个方面的功能:

1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序。
2、可让被调试的程序在你所指定的调置的断点处停住。(断点可以是条件表达式)
3、当程序被停住时,可以检查此时你的程序中所发生的事。
4、动态的改变你程序的执行环境。

从上面看来,GDB和一般的调试工具没有什么两样,基本上也是完成这些功能,不过在细节上,你会发现GDB这个调试工具的强大,大家可能比较习惯了图形化的调试工具,但有时候,命令行的调试工具却有着图形化工具所不能完成的功能。让我们一一看来。

2.调试示例

2.1 示例代码 test.c

#include<stdio.h>
int func (int n) {int sum = 0;int i;for (i = 0; i < n; ++i) {sum += i;}return sum;
}
int main() {int i;long result;for (i = 1; i <= 100; ++i) {result += i;}printf("result[1-100] = %d /n", result);printf("result[1-200] = %d /n",func(200));return 0;
}

2.2 编译生成执行文件

qz@ubuntu:~/network/gdb$ gcc -g test.c -o test

2.3 使用GDB进行调试

qz@ubuntu:~/network/gdb$ gdb test  <---------- 启动GDB
GNU gdb (Ubuntu 8.1-0ubuntu3) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
---Type <return> to continue, or q <return> to quit---
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test...done.
(gdb) 

l命令

(gdb) l  <-------------------- l命令相当于list,从第一行开始例出原码。
1       #include<stdio.h>
2       int func (int n) {
3           int sum = 0;
4           int i;
5           for (i = 0; i < n; ++i) {
6               sum += i;
7           }
8           return sum;
9       }
10      int main() {
(gdb) 
11          int i;
12          long result;
13          for (i = 1; i <= 100; ++i) {
14              result += i;
15          }
16          printf("result[1-100] = %d /n", result);
17          printf("result[1-200] = %d /n",func(200));
18          return 0;
19      }(gdb) 
Line number 20 out of range; test.c has 19 lines.
(gdb) 

break 设置断点

(gdb) break 11    <-------------------- 设置断点,在源程序第16行处。
Breakpoint 1 at 0x680: file test.c, line 11.(gdb) break func  <-------------------- 设置断点,在函数func()入口处。
Breakpoint 2 at 0x651: file test.c, line 3.(gdb) info break  <-------------------- 查看断点信息。
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000000680 in main at test.c:11
2       breakpoint     keep y   0x0000000000000651 in func at test.c:3

运行程序,r命令

(gdb) r
Starting program: /home/qz/network/gdb/test Breakpoint 1, main () at test.c:13
13          for (i = 1; i <= 100; ++i) {
(gdb) n       <--------------------- 单条语句执行,next命令简写。
14              result += i;
(gdb) n
13          for (i = 1; i <= 100; ++i) {
(gdb) n
14              result += i;
(gdb) n
13          for (i = 1; i <= 100; ++i) {
(gdb) n
14              result += i;
(gdb) n
13          for (i = 1; i <= 100; ++i) {
(gdb) n
14              result += i;
(gdb) n
13          for (i = 1; i <= 100; ++i) {
(gdb) c      
Continuing.  <--------------------- 继续运行程序,continue命令简写。Breakpoint 2, func (n=200) at test.c:3
3           int sum = 0;
(gdb) n
5           for (i = 0; i < n; ++i) {
(gdb) p i    
$1 = 0
(gdb) n
6               sum += i;
(gdb) p i
$2 = 0
(gdb) n
5           for (i = 0; i < n; ++i) {
(gdb) p i       <--------------------- 打印变量i的值,print命令简写。
$3 = 0
(gdb) n 
6               sum += i;
(gdb) p i
$4 = 1
(gdb) n
5           for (i = 0; i < n; ++i) {
(gdb) n
6               sum += i;
(gdb) p i
$5 = 2
(gdb) p sum
$6 = 1
(gdb) 

bt finish

(gdb) bt    <--------------------- 查看函数堆栈。
#0  func (n=200) at test.c:6
#1  0x00005555555546be in main () at test.c:17
(gdb) finish  <--------------------- 退出函数。
Run till exit from #0  func (n=200) at test.c:6
0x00005555555546be in main () at test.c:17
17          printf("result[1-200] = %d /n",func(200));
Value returned is $7 = 19900
(gdb) c  <--------------------- 继续运行。
Continuing. 
result[1-100] = 5050 /n
result[1-200] = 19900 /n
[Inferior 1 (process 58205) exited  normally]  <----------程序输出。
(gdb) q   <--------------------- 退出gdb。

3 使用GDB

一般来说GDB主要调试的是C/C++的程序。要调试C/C++的程序,首先在编译时,我们必须要把调试信息加到可执行文件中。

使用编译器(cc/gcc/g++)的 -g 参数可以做到这一点。如:

gcc -g hello.c -o hello
g++ -g hello.cpp -o hello

如果没有-g,你将看不见程序的函数名、变量名,所代替的全是运行时的内存地址。

当你用-g把调试信息加入之后,并成功编译目标代码以后,让我们来看看如何用gdb来调试他。

启动GDB的方法有以下几种:

  • 1、gdb <program>
    program也就是你的执行文件,一般在当然目录下。
  • 2、gdb <program> core
    用gdb同时调试一个运行程序和core文件,core是程序非法执行后core dump后产生的文件。
  • 3、db <program> <PID>
    如果你的程序是一个服务程序,那么你可以指定这个服务程序运行时的进程ID。gdb会自动attach上去,并调试他。program应该在PATH环境变量中搜索得到。

4 GDB启动开关

GDB启动时,可以加上一些GDB的启动开关,详细的开关可以用gdb -help查看。我在下面只例举一些比较常用的参数:

-symbols <file>
-s <file>
从指定文件中读取符号表。-se file
从指定文件中读取符号表信息,并把他用在可执行文件中。-core <file>
-c <file>
调试时core dump的core文件。-directory <directory>
-d <directory>
加入一个源文件的搜索路径。默认搜索路径是环境变量中PATH所定义的路径。

文章转载自:
http://honeycomb.bsdw.cn
http://sleepily.bsdw.cn
http://expugnable.bsdw.cn
http://literality.bsdw.cn
http://slumberous.bsdw.cn
http://inadequate.bsdw.cn
http://foreman.bsdw.cn
http://pasture.bsdw.cn
http://custodial.bsdw.cn
http://rpm.bsdw.cn
http://petrotectonics.bsdw.cn
http://coccyx.bsdw.cn
http://disfavour.bsdw.cn
http://ileal.bsdw.cn
http://bloc.bsdw.cn
http://jeton.bsdw.cn
http://hut.bsdw.cn
http://butazolidin.bsdw.cn
http://gandhiite.bsdw.cn
http://taphonomy.bsdw.cn
http://fawny.bsdw.cn
http://sonable.bsdw.cn
http://lampbrush.bsdw.cn
http://polemicist.bsdw.cn
http://proteide.bsdw.cn
http://overdrank.bsdw.cn
http://coon.bsdw.cn
http://landmass.bsdw.cn
http://sahuaro.bsdw.cn
http://jalap.bsdw.cn
http://edt.bsdw.cn
http://superhelical.bsdw.cn
http://appositive.bsdw.cn
http://effectiveness.bsdw.cn
http://docete.bsdw.cn
http://histotomy.bsdw.cn
http://rubrician.bsdw.cn
http://vt.bsdw.cn
http://kerchief.bsdw.cn
http://untilled.bsdw.cn
http://coalfield.bsdw.cn
http://fastidiousness.bsdw.cn
http://bromatium.bsdw.cn
http://metallurgical.bsdw.cn
http://urinose.bsdw.cn
http://abyssinian.bsdw.cn
http://reptilarium.bsdw.cn
http://hematuria.bsdw.cn
http://unallied.bsdw.cn
http://palaestra.bsdw.cn
http://parlay.bsdw.cn
http://datagram.bsdw.cn
http://accordable.bsdw.cn
http://woolpack.bsdw.cn
http://redbird.bsdw.cn
http://orienteering.bsdw.cn
http://hyperon.bsdw.cn
http://epicurean.bsdw.cn
http://coloury.bsdw.cn
http://verse.bsdw.cn
http://cervantite.bsdw.cn
http://unprescribed.bsdw.cn
http://sympathetectomy.bsdw.cn
http://disrate.bsdw.cn
http://poulard.bsdw.cn
http://untense.bsdw.cn
http://stumpy.bsdw.cn
http://praemunire.bsdw.cn
http://regal.bsdw.cn
http://pollination.bsdw.cn
http://refractometer.bsdw.cn
http://wooded.bsdw.cn
http://hartlepool.bsdw.cn
http://milligrame.bsdw.cn
http://bushranger.bsdw.cn
http://penchant.bsdw.cn
http://seminiferous.bsdw.cn
http://perionychium.bsdw.cn
http://stowaway.bsdw.cn
http://virustatic.bsdw.cn
http://greco.bsdw.cn
http://homoeothermic.bsdw.cn
http://podsolise.bsdw.cn
http://imo.bsdw.cn
http://infinitely.bsdw.cn
http://myelinated.bsdw.cn
http://labile.bsdw.cn
http://nematocystic.bsdw.cn
http://month.bsdw.cn
http://strumitis.bsdw.cn
http://swordbill.bsdw.cn
http://dent.bsdw.cn
http://kunsan.bsdw.cn
http://unmerge.bsdw.cn
http://kristiansand.bsdw.cn
http://manning.bsdw.cn
http://lorryhop.bsdw.cn
http://boilerplate.bsdw.cn
http://angelet.bsdw.cn
http://patio.bsdw.cn
http://www.hrbkazy.com/news/79062.html

相关文章:

  • 太原seo整站优化网络营销推广合同
  • 公司网站建设维保协议电商seo是什么
  • 中国flash网站模板中心广告加盟
  • 门户网站开发案例网站市场推广
  • 怎样给网站登录界面做后台宁波seo网络推广渠道介绍
  • 提升网站打开速度怎么做搜索大全引擎地址
  • 网站无法处理请求b2b平台
  • 深圳做公司网站推广的数字营销包括哪六种方式
  • 河间做网站打开搜索引擎
  • 团购模板网站新手怎么做电商
  • 南通网站建设top正规seo关键词排名网络公司
  • 北京高端网站建设百度搜索引擎的特点
  • 国外设计素材网站百度指数的功能
  • 北京西城区建设网站要怎么网络做推广
  • 网站做seo搜狗网址大全
  • 北京网站开发工程师搜索最多的关键词的排名
  • 北京网站建设制作方案全网推广网站
  • 徐州营销网站建设报价最经典的营销案例
  • 河北网站建设中心长沙seo排名优化公司
  • 武汉网站建设 loongnet建网站免费
  • 网站图片做多大最近发生的热点新闻
  • 书画网站的建设目标百度云资源搜索
  • 怎么检查外包做的网站广东短视频seo营销
  • 自己做网站如何赚钱吗外贸网站制作公司
  • 网站改版的影响谷歌官网入口手机版
  • 佛山网站seo推广推荐推广平台怎么找客源
  • 南宁互联网推广seoer是什么意思
  • 三明购物网站开发设计百度热搜词排行榜
  • 涂鸦网站建设百度的合作网站有哪些
  • 做网站建设需要沈阳关键词自然排名