How To Debug

how to debug buffer overrun 最近开发一套基于InfiniBand的网络通讯组件,在使用InfiniBand通讯前,我使用socket来进行同步,在服务端开发中遇到这样的一个问题:A buffer overrun has occurred in IBConnection.exe which has corrupted the program's internal state. Press Break to debug th 阅读详情

http://www.latenighthacking.com/projects/howtoDebug.html

How To Debug

These are my debugging notes.

The magic symbol path is SRV*c:/websymbols*http://msdl.microsoft.com/download/symbols

Given a crashed process:

0:001> kb
ChildEBP RetAddr  Args to Child              
44fedb5c 77f7f49f 77e74bd8 00000002 44fedba8 SharedUserData+0x304
44fedb60 77e74bd8 00000002 44fedba8 00000001 ntdll!ZwWaitForMultipleObjects+0xc
44fedbfc 77e74c70 00000002 44fedcd0 00000000 kernel32!WaitForMultipleObjectsEx+0x12c
44fedc14 69455a73 00000002 44fedcd0 00000000 kernel32!WaitForMultipleObjects+0x17
44fee398 69456ba3 44fef96c ffffffff 00008310 faultrep!StartDWException+0x575
44fef400 77eb9d66 44fef96c ffffffff c0000005 faultrep!ReportFault+0x488
44fef924 77c313c8 44fef96c 77c140c8 00000000 kernel32!UnhandledExceptionFilter+0x2e2
44fef940 77c37fde 00000000 44fef96c 77c33efb MSVCRT!_XcptFilter+0x15f
44feffb4 77e802ed 00862e60 0006f96c 77f519f3 MSVCRT!_endthreadex+0xc6
44feffec 00000000 77c37f49 00862e60 00000000 kernel32!BaseThreadStart+0x37

The first param to kernel32!UnhandledExceptionFilter (44fef96c) is a pointer to an EXCEPTION_POINTERS struct.

0:001> dd 44fef96c
44fef96c  44fefa5c 44fefa78 44fef998 77f833a0
44fef97c  44fefa5c 44feffa4 44fefa78 44fefa34
44fef98c  44feffa4 77f833b4 44feffa4 44fefa44

The second pointer in the struct is the pointer to the CONTEXT_RECORD. Use .cxr addr to reset the debuggers context to the thread as it was when it faulted. (Use ~s to return to the thread's current context.)

0:001> .cxr 44fefa78
eax=00000000 ebx=00000001 ecx=00000841 edx=44b9c1d8 esi=493dfad8 edi=44fefde4
eip=6d476a25 esp=44fefd44 ebp=44fefd74 iopl=0         nv up ei pl zr na po nc
cs=001b  ss=0023  ds=0023  es=0023  fs=003b  gs=0000             efl=00010246
jvm!JVM_FindSignal+1ef27:
6d476a25 837cc21400 cmp dword ptr [edx+eax*8+0x14],0x0 ds:0023:44b9c1ec=????????

The first pointer in the struct is the pointer to the EXCEPTION_RECORD. Use .exr addr to dump the struct.

0:001> .exr 44fefa5c
ExceptionAddress: 6d476a25 (jvm!JVM_FindSignal+0x0001ef27)
   ExceptionCode: c0000005
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: 44b9c1ec
Attempt to read from address 44b9c1ec

More useful command examples:

x kernel32!*Ctrl*search for symbol
~*kbdump stack of all threads
bp 77e9658d "r eax=0;g"create breakpoint that executes command when hit
bllist breakpoints
u kernel32!CreateEventAdisassemble

Stack Frame Layout

Push moves the stack pointer backward in memory (ie, esp -= 4) and then writes the given value to location pointed at by the stack pointer.

Stack frame layout (no frame pointer optimization)

this function's ebp
points here ------------/
    ebp-0x8   ebp-0x4   ebp+0x0   ebp+0x4   ebp+0x8   ebp+0xC
                        caller's  return 
    local1    local0    ebp       addr      param0    param1
... 00000000  00000000  00000000  00000000  00000000  00000000 ...

All arguments are widened to 32 bits when they are passed. Return values are also widened to 32 bits and returned in the eax register, except for 8-byte structures, which are returned in the edx:eax register pair. Larger structures are returned in the eax register as pointers to hidden return structures. Parameters are pushed onto the stack from right to left.

The compiler generates prolog and epilog code to save and restore the esi, edi, ebx, and ebp registers, if they are used in the function.

nameargument passingstack cleanupname decorationint func(int a, double b)
cdecl on stack, reverse order / right to left (ebp+0x8 is param0, ebp+0xC is param1 ...)callerprefix: "_"_func
stdcall on stack, reverse order / right to left (ebp+0x8 is param0, ebp+0xC is param1 ...)calleeprefix: "_"; suffix: "@" followed by the number of bytes (in decimal) in the argument list. _func@12
fastcall The first two DWORD or smaller arguments are passed in ecx and edx registers; all other arguments are passed on stack, reverse order / right to left (ebp+0x8 is param2, ebp+0xC is param3 ...)calleeprefix: "@"; suffix: "@" followed by the number of bytes (in decimal) in the argument list.@func@12
thiscall this in ecx; all other arbuments are passed on stack, reverse order / right to left (ebp+0x8 is param0, ebp+0xC is param1 ...); callee(C++ mangling) 

__asm { int 3 }
hardcoded debug breakpoint
#define TEB_OFFSET 4
void ** ppvStackBase;
__asm { mov eax, fs:[TEB_OFFSET] }
__asm { mov ppvStackBase, eax }
stack base from TEB
void ** ppvFrame;
_asm { mov ppvFrame, ebp }
frame pointer

C o m m e n t s :     updated: 2006-01-19 (99 days ago)
This is a great start. Can you point me to some good references - online or offline which can help me getting more info about debugging. Thanks Blake
Edit

How to debug C++ STL vector 标题How to debug C++ STL vector 用GDB 调试C++代码的时候,如果遇到STL vector,map 或者list的时候,想要print 数据的时候发现GDB会打出一堆信息,但是其实对于程序来说关心的只是其中的element数据是什么,那如何只输出我们想要的输入呢? 版本比较低的GDB,比如低于GDB7.0, 其实用以下print命令是可以只打印出element的内容。 print *(Vector._M_impl._M_start)@Vector.size() gdb 7.0 阅读详情

相关推荐

C# OpenCvSharp4实战:5分钟搞定工业视觉模板匹配(附完整代码)

本文为C#开发者提供了基于OpenCvSharp4的工业视觉模板匹配实战指南。通过详细的环境搭建、核心原理解析和完整代码示例,重点介绍了如何使用`matchTemplate`函数,特别是`CCoeffNormed`方法,快速实现高精度、抗光照变化的模板匹配,并分享了多目标匹配、图像预处理等工业级优化技巧。

weixin_29053067的博客 505

How to debug the exception

Introduction No matter you area computer programmer or a user, I think you have seen the dialog to remindyour application is crashed, and remind you to contact application vendor orreport to

飞鹰技术 1253

SAR ADC设计——SAR Logic原理

SAR ADC设计——SAR Logic原理 参考:集成电路设计实践 SAR ADC 清华大学 李福乐 文章目录SAR ADC设计——SAR Logic原理一. Overview二. TSPC(True Single Phase Clock)三. SC_Gen(Sequential Control Generator)四. LATCH_Dynamic五. 时序控制逻辑总结六. SW产生七. DO产生八. GT产生九. SAR Logic模块总结 一. Overview 输入:CKC,CompB,SAMPL

夏风喃喃的博客 1万+

How to debug windows service

1) Add such code to the service's entry, static Main() function, #if DEBUG             System.Diagnostics.Debugger.Launch(); #endif 2) install your windows service appliation with visual studio comman...

eteran的专栏 255

深度学习【46】pix2pixHD

英伟达的pix2pixHD,能够合成高清的2048*1024图片,简直振奋人心。pix2pixHD是我之前介绍过的pix2pix的改进版本,使用多由粗到精的G网络和多尺度D网络(每个D网络都是用了pix2pix中同样的patch技术)。论文一开始用pix2pix尝试合成更高分辨率的图片,但发现效果不好,训练也很不稳定。所以就对pix2pix进行了一顿魔改。我们来看看他们是怎么改进的。由粗到精的G网络

DCD_LIN的博客 1万+

配置 Druid 数据源及密码加密-SpringBoot 实战基础

在SpringBoot中配置 Druid 数据源及密码加密的方法前文集成 MyBatis Plus,实现了一组增删改查接口。在启动服务时,从控制台中可以看出 Spring Boot 默认使用 Hikari 作为数据库连接池,Hikari性能很优秀。在国内使用较多的连接池还属阿里开源的 Druid,中文发音为德鲁伊。Druid 结合了 C3P0、DBCP 等 DB 池的优点,同时还加入了日志监控,可以很好的监控 DB 池连接和 SQL 的执行情况。...

m0_67698950的博客 955

How to Debug

Except using the tools embed in the IDE (like break points), some other ways exist to debug.  1) cout the variable to trace their development 2) extract the small module that need to be debuged and

翾昱 566

primetime如何做voltage scaling

存在这样的情况,标准单元库只有ssgnp0p72vm40c和ssgnp0p9vm40c的libs,但是我们希望它工作在ssgnp0p76vm40c,这样的话就需要用ssgnp0p72vm40c和ssgnp0p9vm40c的libs来scaling出ssgnp0p76vm40c的lib。

qq_34326957的博客 1685

How to debug Python

Getting started—pdb.set_trace() To start, I’ll show you the very simplest way to use the Python debugger. 1. Let’s start with a simple program, epdb1.py. # epdb1.py -- experiment with the Python ...

weixin_30763397的博客 227

Chrome更新出现错误代码3: 0X80070422 -- system level的解决方案

本文主要介绍了Chrome更新出现错误代码3: 0X80070422 – system level的解决方案,希望能对使用Chrome的同学们有所帮助。 文章目录 1. 问题描述 2. 解决方案

weixin_43178406的博客 1万+

【图像拼接】论文精读:Content-Preserving Warps for 3D Video Stabilization(CPW)

论文题目:Content-Preserving Warps for 3D Video Stabilization——用于3D视频稳定的内容保持扭曲GSP、SPW、LPC等warp时多个项最小化问题的思想都是来自于这篇论文——CPW视频防抖。我们描述了一种从手持摄像机转换视频的技术,以便它看起来像是用定向相机运动拍摄的。我们的方法调整视频以出现,就好像它是从附近的视点拍摄的,允许模拟 3D 相机运动。通过仅针对感知合理性,而不是准确的重建,我们能够开发能够有效从单个源视频中重建动态场景的算法。

主要更新底层视觉(去噪、超分等)相关的科研内容,形式为【论文精读】+【论文复现】 2万+

How to debug EXTJS

http://www.sencha.com/forum/showthread.php?46750-How-to-debug-EXTJS http://www.sencha.com/learn/debugging-ext-js-applications This content will be either moved or archived. Please visit th

沉底的石头 6965

华为OD机试双机位C卷-开心消消乐(Py/Java/C/C++/Js/Go)

华为OD机试(机考)双机位C卷 【开心消消乐】,提供Java、C++、Python、Go、JavaScript源码实现,并提供完整思路讲解,以及在线OJ模拟做题。华为od机试 - 开心消消乐。

qq_45776114的博客 1514

How to Debug Programs

http://www.drpaulcarter.com/cs/debug.php#1. 1. How to Start The most common types of mistakes when programming are: Programming without thinkingWriting code in an unstructured manner Let

Rauber_Hotzenplotz的专栏 1150

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

How to debug Windows services

If you want to debug on Vista, please read this post "Debugging a Service on Windows Vista" as well.This article comes from: http://support.microsoft.com/kb/824344SUMMARYThis step-by-step arti

litove的专栏 665

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

How to debug QEMU

STEP 1: add a gloabcontrol variable before main in vl.c. we will stop on main() if the controlvariable is zero   int g_stop_here = 1; int main(int argc, char **argv, char **envp){ ......          

六六哥的博客 3143

How to Debug your Stored Procedure?

How to Debug your Stored Procedure? In many cases, you might want to test your SP on various scenarios and go through each step on how your data gets changed at each step.The below steps shoul...

weixin_34148508的博客 185

how to use the dynamic debug

Introduction ============ This document describes how to use the dynamic debug (ddebug) feature. Dynamic debug is designed to allow you to dynamically enable/disable kernel code to obtain addition

1656

How to debug vbs

how to debug vbs make sure your have install some VS in your OS to support Just-In-Time debugger cscript -d -x ExecuteTP.vbs MyArg1 MyArg2 start to connect debugger set breakpoint and enjoy

贾亮的专栏 352

How to use WinDBG to debug

How to use WinDBG to debug Collecting Memory Dump The easiest way to collect memory dump is to use adplus.vbs script.This script can be used to collect hanging/crashing memory dump, but mo

nathannemo的专栏 764

How to debug a Background job

source:http://learnabapprogramming.blogspot.com/2011/05/how-to-debug-background-job.html Usually,the programs which take long time for execution are scheduled for background job.Again,one need no...

huang850625的专栏 199

How to debug NginX? 如何调试NginX

You need to build nginx with the option: --with-debug. Then in nginx.conf, you should write     error_log  logs/error.log debug; And you should set     master_process  off;     daemon     

杨卓荦的技术专栏 3786

How To Remote Debug

sudo java -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555 -jar ./xxxx.jar >>xxxxx.log

JavaRider的博客 275

how to debug native crash

Just share some debug method for native crash, it’s a very quickway to find out which line cause the crash in logcat,   Generally, if some native service crash, we found crash log inlogcat like th

waterzhou的专栏 2395
上一篇: 经典讨论:"NDIS Hooking" and "NDIS IM Driver"
下一篇: Basic debugging & tips using NTSD
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值