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 阅读详情

相关推荐

过程挖掘(Process Mining)1——始于颜值

下周开始每周1-2篇的过程挖掘分享 过程挖掘是什么? 过程挖掘与过程管理的关系? 过程挖掘与数据挖掘的关系? 管理学还是计算机科学?

hyhy12580的博客 6242

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

飞鹰技术 1257

长短期记忆网络(LSTM)预测模型及其Python和MATLAB实现

LSTM 通过独特的门控机制解决了传统 RNN 的梯度消失和梯度爆炸问题,使其在处理长序列时具有显著优势。随着技术的不断发展,LSTM 及其变种(如 Bi-directional LSTM、Stacked LSTM 等)有望在更复杂的任务中发挥重要作用。2. **可视化真实值和预测值**:通过绘图来比较真实值和预测值,判断模型的准确性。2. **输入门(Input gate)**:决定当前的输入信息对细胞状态的影响。1. **细胞状态(Cell state)**:保持信息在时间步之间的传递。

qq_45441438的博客 2068

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

翾昱 568

【Creator】cocoscreator 2.4 apk还原为工程 (1)

Cocos Creator 2.4 还原图片 meta文件

jokesuser的博客 2264

ESP-Mesh-Lite vs ESP-Mesh:如何选择适合你的物联网组网方案?

本文深入对比了乐鑫ESP-Mesh-Lite与ESP-Mesh两种物联网组网方案的核心差异。重点解析了ESP-Mesh-Lite分布式协议栈架构的优势,即每个节点拥有独立IP,可直接访问外部网络,极大简化了应用层开发。文章从网络架构、性能、开发体验及适用场景等多维度进行分析,为开发者根据项目需求(如分布式数据采集、智能家居或集中控制网络)选择最合适的方案提供了清晰的决策框架。

pluto的博客 826

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

LVGL开发新选择:深度对比NXP GUI Guider与SquareLine Studio,免费版够用吗?

本文深度对比了LVGL开发中两款主流工具NXP GUI Guider与SquareLine Studio的核心差异,包括功能定位、设计能力、代码生成质量和硬件适配等方面。针对不同项目需求,分析了免费版工具的适用性,帮助开发者根据预算和功能需求做出明智选择。特别关注了GUI设计工具在嵌入式开发中的实际应用效果。

weixin_26976635的博客 441

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的博客 228

[Unity]-[UI]-[Image] 关于UI精灵图资源导入设置的详细解释

如果纹理存储了有特定含义的信息,并且您需要着色器中的确切值(例如,平滑度或金属度),请禁用此属性。此选项允许将纹理编码为特定格式(RGBM 或 dLDR,具体取决于平台)并通过后期处理步骤对纹理数据进行处理(推拉式扩张通道)。使用在3D模型的专业法线贴图。通用的纹理类型,一般在Material上的材质图片参数使用,比如漫反射、法线贴图这些。​​Compression​​:ASTC 6x6(移动端)或DXT5(PC)​​Compression​​:BC5(PC)或ASTC 6x6(移动端)

sky_smile_Allen的博客 2175

【Go语言实战】(2) Gin+Vue 电子商城

618来!!不用纠结去哪里剁手了!直接自己安排一个商场不香吗??

面向生活编程 4835

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

沉底的石头 6966

PyCharm 2024最新版图文安装教程(python环境搭建+PyCharm安装+运行测试+汉化+背景图设置)

PyCharm 2024新版图文安装教程(python环境搭建+PyCharm安装+运行测试+汉化+背景图设置)

Code_流苏:在代码中寻诗意,在实践中觅真知 4万+

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的专栏 1152

NTscan扫描工具

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

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

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的专栏 666

Devexpress16.2.6破解工具

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

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){ ......          

六六哥的博客 3144

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

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     

杨卓荦的技术专栏 3787

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的专栏 2396
上一篇: 经典讨论:"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、付费专栏及课程。

余额充值
⌂ 换网址