paip.c++程序崩溃的汇编级别调试-打印堆栈-gcc gdb

如何在进程崩溃后打印堆栈并防止数据丢失 进程在运行过程中遇到逻辑错误, 比如除零, 空指针等等, 系统会触发一个软件中断.  这个中断会以信号的方式通知进程, 这些信号的默认处理方式是结束进程.  发生这种情况, 我们就认为进程崩溃了. 进程崩溃后, 我们会希望知道它是为何崩溃的, 是哪个函数, 哪行代码引起的错误.  另外, 在进程退出前, 我们还希望做一些善后处理, 比如把某些数据存入数据库, 等等. 下面 阅读详情
paip.c++程序崩溃的汇编级别调试-打印堆栈-gcc gdb


作者Attilax ,  EMAIL:1466519819@qq.com 
来源:attilax的专栏
地址:http://blog.csdn.net/attilax


c++程序崩溃直接出来的是个汇编级的指令以及堆栈,无法直接看到c++源码的哪一行出问题了..


要是VC编译的程序崩溃时,取得DMP,然后配合pdb、源代码来分析问题是常用做法


要是GCC编译的,这个方法就不能使用兰..gcc编译根本不会生成pdb文件的...


以下分为有源码以及没有源码两种情况来进行崩溃时的调试..


有源码的情况哈,比较简单的..崩溃后查看堆栈就ok.. qt>debug bar>right>>view >stack..


没有源码的调试就比较复杂了..


1.加-ggdb3  参数,让gcc生成的exe文件加入调试信息..gcc不会单独生成类似的.pdb文件.
//////////////////////////////////////////////////////////////////////////////
D:\Qt\Qt5.1.1\5.1.1\mingw48_32\mkspecs\win32-g++\qmake.conf
line28
QMAKE_CFLAGS            = -pipe -fno-keep-inline-dllexport -w


2.exe文件复制到gdb目录哈..
/////////////////////////////////////////
不个gdb复制出来三不能使用..
D:\Qt\Qt5.1.1\Tools\mingw48_32\bin


3.gdb  *.exe ,运行到崩溃..
4. backtrace  2/3  ,打印堆栈,明确指出c++源文件所在的行...


参考:


GCC编译选项 - 旅途 - C++博客.htm
用GDB调试 GCC 程序 - 猪猪乐园 - 博客频道 - CSDN.NET.htm

qt调试时变量十六进制_GDB调试C++类 Linux上调试常用的工具就是gdb了。借助学习C++虚函数表和内存布局的机会顺便学习下gdb常规调试技巧。一,测试用例1,C++头文件(szyu_test_gdb.h) #ifndef __SZYU_GDB__ #define __SZYU_GDB__ #include <iostream> class Base { public: Base() { }; Bas... 阅读详情

相关推荐

崩溃时打印堆栈调用日志

在GNU/Linux编程中,我们可能会遇到程序因为内存访问错误而崩溃 或类似的问题。一般情况下,我们借助程序崩溃后生成的core文件 来定位引起程序崩溃的位置。 但有时我们无法在现场调试,只能依靠用户传回的一些日志文件的 内容来定位程序错误的位置。如果这时日志中包含程序崩溃时的栈 调用信息,那么对排除错误将会有些帮助。 使用backtrace函数和addr2line程序可以帮助我们

leeshuheng的专栏 4377

Qt断点调试技巧

 课程介绍Qt断点调试窗口介绍无死机堆栈问题分析条件断点如何使用使用编译宏和好用的输出函数死锁问题如何去调查 授课风格

如何快速查看进程/子线程堆栈

如何快速查看进程/子进程堆栈

木简熙的博客 6256

Linux下 gdb 调试-查看函数堆栈-操作说明一

Linux下 gdb 调试-查看函数堆栈

wojiaxiaohuang2014的博客 7372

Qt Release 崩溃测试 demo

Qt Release 版本下 崩溃测试 demo 可以定位到程序崩溃点

Qt程序crash信息的捕捉与跟踪Demo

在用qt编写程序时经常会遇到崩溃问题,如果抓取不到crash堆栈信息就会对崩溃问题束手无策,只能对其进行复现,推断。 该程序展示如何获取crash堆栈信息

Linux GCC捕获当前调用堆栈信息(打印行号、源文件名、函数名、相对函数RVA偏移等信息)

g 或 -g3,并且需求 -rdynamic 编译器选项开关,可以在 Release 下面使用该函数,实现上不支持捕获其它库的详细符号信息(当然你可以改,别人库的符号如非必要必须要搞那么清楚明白)。

liulilittle的博客 686

程序崩溃的时候可生成崩溃堆栈日志的库

以下是调用的方法,在主程序入口函数第一行动态加载异常捕获库,崩溃后可以在运行目录下生成如【进程名称.exception】的文件,可以看到崩溃的堆栈信息 void main() { //Install our crash handler HMODULE hCrashDLL = LoadLibrary("CrashHelper.dll"); if (hCrashDLL == NULL) { printf("Failed to load CrashHelper DLL, Error:%d\n", GetLastError()); return; } else { printf("load CrashHelper DLL ok \n"); } //TODO:开始用户的代码 }

GDB之打印函数堆栈(十二)

本篇目的:GDB之打印函数堆栈。

Android系统攻城狮 651

Python主要智能优化算法库汇总

最近几年简单浏览和对比了一些智能算法的库。现将各种库的主要信息、相关优缺点简单整理如下,各位同学可根据自己的需求和喜好进行选择。 文章目录1、DEAP2、mealpy3、scikit-opt (国产良心)4、Geat2(国产用心)5、pygmo26、pyswarms7、SciPy(想不到吧)小结 1、DEAP 项目地址:https://github.com/DEAP/deap 安装: pip install deap 优点: 起点高,发表在Journal of Machine Learning Rese

半个冯博士 2万+

N5105 PVE UEFI核显直通Windows:从黑屏到HDMI输出的实战调优

本文详细介绍了在N5105处理器上实现PVE UEFI核显直通Windows的实战调优方法。针对黑屏和HDMI音频无法识别等常见问题,提供了系统参数调整、驱动模块加载、虚拟机配置等解决方案,帮助用户成功实现核显直通并优化性能。

weixin_42566424的博客 220

gdb调试——堆栈

gdb命令太多,举一个调试堆栈例子 1 2 #include 3 #include 4 5 void fun(char* input) 6 { 7 int a1 = 11; 8

zhuix7788的专栏 1406

快速上手CH340N电路设计(CH340N USB转串口模块 USB Type-C接口 CH340系列芯片讲解)

一、上模块 二、功能分析 l 芯片:CH340N l 输入接口:USB、TYPE-C l 输出接口:TTL(5V\3.3V\GND\TX\RX) l 指示灯:电源、TX、RX 三、CH340x芯片 l CH340 是一个 USB 总线的转接芯片,实现 USB 转串口 l 全速 USB 设备接口,兼容 USB V2.0 l 硬件全双工串口,内置收发缓冲区,支持通讯波特率 50bps~2Mbps l 支持常用的 MODEM 联络信号 RTS、DTR、DCD、RI、DS...

东小东博客 5万+

paip c++程序崩溃的汇编级别调试-打印堆栈-gcc gdb

paip c++程序崩溃的汇编级别调试-打印堆栈-gcc gdb

sdfhncfw的博客 259

高通Camera AWB跳变问题实战:从夕阳场景到参数调优的完整避坑指南

本文深入解析高通Camera AWB跳变问题,特别是在夕阳场景下的色温突变现象。通过分析灰区统计失效、光源混合干扰等成因,提供从参数调优到诊断工具链的完整解决方案,包括动态灰区扩展算法、色温平滑过渡方案及高通平台特定优化技巧,帮助工程师有效解决AWB跳变问题。

sre5engineer的博客 868

centos7搭建LNMP环境-编译安装&yum安装-超详细

文章目录1. 首先了解编译安装和yum安装的区别。2. yum安装准备工作---切换阿里云yum源3. 编译安装lnmp4.yum安装lnmp5. lnmp一键安装6. 一些报错7. 笔记8. 参考文章 1. 首先了解编译安装和yum安装的区别。 windows下安装centos虚拟机,之前写过。传送门~~ 编译安装: 可以按需安装,想安在哪个目录下就安在哪个目录下。 可以设定参数 可安装自己想要的版本 yum安装: 安装的方便快捷 不需要考虑包的依赖 可以直接使用service nginx st

最美不过下雨天 9363

C++ 崩溃时导出堆栈信息并使用调试工具定位问题 ?

C++ 崩溃时导出堆栈信息并使用调试工具定位问题 ? 1. 生成该程序,运行该程序,非 IDE 调试器运行,会自动在程序目录生成 .dmp 后缀的文件。 2. 使用 使用 winDbg 调试工具打开 .dmp 文件 输入 !analyze –v 指令即可看到详细的分析信息...

驭鲸·环球的博客 1144

AutoSAR EcuM系列01- EcuM模块的功能概述和变体类型

在【ECU的软硬件架构】文章中我们了解ECU的功能和组成,那么ECU具体是怎么启动的呢?我们知道,AutoSAR标准架构有三层,即APPL应用层、RTE层和BSW层。而这些层又被进一步划分为更多单独的组件,如BSW层可能有80多个组件。在ECU启动时,这些组件必须相互交互,有时也必须以某种顺序交互。这些组件的启动顺序由ECU管理器模块或EcuM处理。EcuM负责整个ECU的初始化和去初始化,包括对一些系统模块如。......

1785

嵌入式平台Qt项目使用backtrace函数抓取崩溃堆栈并解析的方法

1. 按照龙骨群中的说法,dragonbone的插件选用3.0

zanglengyu的专栏 3375

仿真学习系列(十五):ADS仿真理解电感的反射特性

在高速电路设计中,电感的反射特性是影响信号质量的重要因素。电感的瞬时阻抗和反射波形直接影响信号的传输效果,尤其在高频应用中更为显著。本篇文章将通过ADS仿真来深入理解电感的反射特性,并探索如何通过调整仿真参数来分析和优化电路设计。

案例文章,高速信号 512

基于混合智能框架的景区边界范围预测与补全系统

摘要 本文提出一种混合智能框架,结合随机森林模型和GIS规则约束,解决景区边界缺失问题。系统基于Python和ArcGIS平台,利用多源地理空间数据训练随机森林分类器预测景区范围,并集成地形、水文、道路等GIS规则进行优化。实验结果表明,该方法能有效预测15000个景区的边界,精度优于单一模型。创新点在于: 1)数据驱动与知识驱动相结合的混合智能范式; 2)面向全国尺度的大规模边界补全; 3)提供完整的Python+ArcGIS实现方案。该系统为景区精细化管理提供了技术支撑,具有实用价值。

huanghm88的专栏 318

gdb x命令_详解gdb的使用技巧

点击蓝字,关注我们01概念 GDB是一个由GNU开源组织发布的、UNIX/LINUX操作系统下的、基于命令行的、功能强大的程序调试工具。 在实际应用中,有两种调试方法:在线调试和离线调试。离线调试适用于开发测试环境,可以自由启停进程,设置断点;在线调试一般用于现场问题分析,不能随便启停进程,对于技术要求较高。02前提条件2.1 编译若想执行gdb调试,...

weixin_39682560的博客 2331

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

与GDB调试有关的栈知识

系统中,除了进程的栈大小有限制,实际上每个线程的栈大小也有限制。多线程编程时,各个线程使用的栈的总和不能超过进程许可的栈大小,所以,要注意各个线程的栈大小限制,设计应用程序时一定要注意栈的使用量。

相忘于江湖的专栏 708

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

gdb 个人总结

1.打印好看 set print pretty on 2.常用数据结构打印 3. info locals 4.如何强制转换类型,得加'' 错:p *(Test::A*)pObj2 对:p *('Test::A'*)pObj2 5.打印所有堆栈thread apply all bt 打印堆栈到文件 setloggingfile/tmp/test.txt setloggingon threadapplyallbt 6.指针强转.........

weixin_41848780的博客 1205

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

qt 崩溃处理

配置Symbol file path(符号路径)、Source file path(源文件路径)、 Image File Path(可执行文件路径):可执行文件路径(这个选择具体的exe文件报错,只能选exe文件所在文件夹)release版本是不会自动生成pdb文件的。:把生成的pdb文件所在目录及微软符号服务器加进去。生成exe自带生成pdb文件,所以无需处理。办法是:在pro文件中加入。

baidu_16370559的博客 3837

C++的Linux程序在崩溃(coredump)后,打印调用堆栈的方法,支持x86和ARM

Linux程序如果使用-g编译,若程序发生崩溃(coredump),是可以使用gdb调试生成的dump文件,找到崩溃的位置的。 然后C++有一些组件是提供崩溃堆栈打印的,本文给出boost::stacktrace和Backward-cpp打印方法。.........

Where there is life, there is hope. 9182
上一篇: paip.c++ 宏的展开调试.
下一篇: paip.提升用户体验---控件透明的设置
attilax
博客等级 码龄20年 874粉丝 3260原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值