gdb调试(二)
继续研究gdb相关的调试技巧,话不多说进入正题:
![](https://images0.cnblogs.com/i/324374/201408/102158232404074.png)
![](https://images0.cnblogs.com/i/324374/201408/102158451471834.png)
#include <stdio.h>
#include <stdlib.h> long func(int n); int main(int argc, char *argv[])
{
int i;
int x =5;
double z = 2.5;
char ch = 'q'; int arr1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int *arr2 = (int *)malloc(sizeof(int) * 10);
for (i=0; i<10; ++i)
{
arr2[i] = i;
} printf("Entering main ...\n");
for (i=; i<argc; ++i)
{
printf("%s ", argv[i]);
}
printf("\n");
long result = ;
for (i=; i<=; ++i)
{
result += i;
}
printf("result[1-100] = %ld\n", result);
printf("result[1-10] = %ld\n", func()); printf("Exiting main ...\n");
return ;
} long func(int n)
{
long sum = ;
int i;
for (i=; i<=n; ++i)
{
sum += i;
} return sum;
}
![](https://images0.cnblogs.com/i/324374/201408/102159116316924.png)
![](https://images0.cnblogs.com/i/324374/201408/102212485535033.png)
![](https://images0.cnblogs.com/i/324374/201408/102215290224423.png)
![](https://images0.cnblogs.com/i/324374/201408/102159303035097.png)
![](https://images0.cnblogs.com/i/324374/201408/102221379906711.png)
![](https://images0.cnblogs.com/i/324374/201408/102224357097572.png)
![](https://images0.cnblogs.com/i/324374/201408/102226409125622.png)
![](https://images0.cnblogs.com/i/324374/201408/102228586478068.png)
![](https://images0.cnblogs.com/i/324374/201408/102159499127253.png)
![](https://images0.cnblogs.com/i/324374/201408/102234456936826.png)
![](https://images0.cnblogs.com/i/324374/201408/102238205377328.png)
![](https://images0.cnblogs.com/i/324374/201408/102238523342309.png)
#include <stdio.h> int main(void)
{
int i;
char str[] = "hello";
char reverse_str[] = ""; printf("%s\n", str);
for (i=; i<; i++)
reverse_str[-i] = str[i];
printf("%s\n", reverse_str);
return ;
}
先编译运行看下结果:
下面来通过gdb来调试一下该错误:
所以此时问题的原因就被定位了,应该将o放到第一位,目前是放到第二位,然后整体的字符都回退一格,最终应该输出是这样:“olleh\000”,于是程序改装一下:
这时再编译运行:
![](https://images0.cnblogs.com/i/324374/201408/102300017257083.png)
![](https://images0.cnblogs.com/i/324374/201408/102306516006402.png)
![](https://images0.cnblogs.com/i/324374/201408/102307312402245.png)
![](https://images0.cnblogs.com/i/324374/201408/102311058182434.png)
![](https://images0.cnblogs.com/i/324374/201408/102312055066734.png)
![](https://images0.cnblogs.com/i/324374/201408/102314124754058.png)
![](https://images0.cnblogs.com/i/324374/201408/102315000534494.png)
![](https://images0.cnblogs.com/i/324374/201408/102316070539029.png)
![](https://images0.cnblogs.com/i/324374/201408/102318440532061.png)
![](https://images0.cnblogs.com/i/324374/201408/102320123818310.png)
![](https://images0.cnblogs.com/i/324374/201408/112155211234740.png)
![](https://images0.cnblogs.com/i/324374/201408/112155542339220.png)
![](https://images0.cnblogs.com/i/324374/201408/112159105455996.png)
![](https://images0.cnblogs.com/i/324374/201408/112201202025106.png)
![](https://images0.cnblogs.com/i/324374/201408/112202356085077.png)
![](https://images0.cnblogs.com/i/324374/201408/112205098892378.png)
![](https://images0.cnblogs.com/i/324374/201408/112206334204997.png)
![](https://images0.cnblogs.com/i/324374/201408/112156357176595.png)
![](https://images0.cnblogs.com/i/324374/201408/112211237487727.png)
![](https://images0.cnblogs.com/i/324374/201408/112212030308526.png)
gdb调试(二)的更多相关文章
- 一文入门Linux下gdb调试(二)
作者:良知犹存 转载授权以及围观:欢迎添加微信号:Conscience_Remains 总述 今天我们介绍一下core dump文件,Core dump叫做核心转储,它是进程运行时在突然崩溃的 ...
- gcc gdb调试 (二)
GDB的命令概貌——————— 启动gdb后,就你被带入gdb的调试环境中,就可以使用gdb的命令开始调试程序了,gdb的命令可以使用help命令来查看,如下所示: /home/hchen> g ...
- 应用调试(二)GDB
title: 应用调试(二)GDBdate: 2019/1/17 21:00:10 toc: true 应用调试(二)GDB gdb下载工具安装交叉工具链设置GDB介绍编译GDBtarget/host ...
- Linux——【转】gcc编译与gdb调试简要步骤
原文:gcc编译与gdb调试简要步骤 一.Linux程序gcc编译步骤: Gcc编译过程主要的4个阶段: l 预处理阶段,完成宏定义和include文件展开等工作:(.i) l 根据编译参数进行不同程 ...
- gdb 调试
一.gdb 调试-源代码关联 在调试程序的过程中,可以自由地查看相关的源代码(如果有源代码的话)是一项最基本的特性.gdb 当然也提供了这项特性,虽然不如IDE直观,但在一定程度上要比IDE更加灵活和 ...
- gcc编译与gdb调试简要步骤
http://blog.chinaunix.net/uid-24103300-id-108248.html 一.Linux程序gcc编译步骤: Gcc编译过程主要的4个阶段: l 预处理阶段,完成宏定 ...
- core dump gdb调试
core dump又叫核心转储, 当程序运行过程中发生异常, 程序异常退出时, 由操作系统把程序当前的内存状况存储在一个core文件中, 叫core dump. (linux中如果内存越界会收到SIG ...
- gcc编译, gdb调试, makefile写法
//test.c: #include <stdio.h> int main(void) { printf("hello world!"); return 0; } == ...
- 比较全面的gdb调试命令 (转载)
转自http://blog.csdn.net/dadalan/article/details/3758025 用GDB调试程序 GDB是一个强大的命令行调试工具.大家知道命令行的强大就是在于,其可以形 ...
随机推荐
- Java之整数运算
Java的整数运算遵循四则运算规则,可以使用任意嵌套的小括号.四则运算规则和初等数学一致.例如: public class Main { public static void main(String[ ...
- centos7升级openssh
注意: openssl版本(openssl版本要大于1.0.1,zlib版本要大于1.1.4) 一.安装依赖包 yum -y install gcc make perl # zlib zlib-dev ...
- python爬虫3之去哪儿网
学习任务 获取去哪儿网的出发地列表 获取旅游景点列表 获取景点产品列表 存储数据 1 获取出发地站点 (1)访问touch.qunar.com (2)按F12,单击自由行,在自由行页面点击搜索框 (3 ...
- php imagick生成gif动画的方法
>php imagick生成gif动画的方法<pre><?php$image=new Imagick();$animation = new Imagick(); //建立一个对 ...
- spring的面试
IOC IOC(Inversion Of Controll,控制反转)是一种设计思想,将原本在程序中手动创建对象的控制权,交由给Spring框架来管理.IOC容器是Spring用来实现IOC的载体,I ...
- Java开发笔记(一百四十一)JavaFX的列表与表格
下拉框只有在单击时才会弹出所有选项的下拉列表,这固然节省了有限的界面空间,但有时候又需要把所有选项都固定展示到窗口上.像这种平铺的列表控件,Swing给出的控件名称是ListBox,而JavaFX提供 ...
- vue封装一个简单的div框选时间的组件
记录一下我前段时间封装的一个vue组件吧.技术需要积累,有时间我把我之前写的还不错的组件都开源出来.并尝试vue和react 两种方式的组件封装.今天简单写下鼠标框选div选中效果的封装吧. div框 ...
- mongdb基本使用
mongodb创建用户,设置密码 参考:https://www.jianshu.com/p/237a0c5ad9fa MongoDB内置的数据库角色有: 1. 数据库用户角色:read.readWri ...
- Python爬虫b站视频弹幕并生成词云图分析
爬虫:requests,beautifulsoup 词云:wordcloud,jieba 代码加注释: # -*- coding: utf-8 -*- import xlrd#读取excel impo ...
- scope:provided影响子依赖
一.问题 在上一篇<SpringBoot项目启动不走内嵌容器>中发现,provided会影响子依赖. 标记为scope:provided的jar在编译和运行时有作用,表明了运行时depen ...