Magic Debug Values(神奇的调试值)
2007-01-10 11:34
316 查看
摘自Azure's Blog
http://www.azure.com.cn/article.asp?id=233
Magic debug values are specific values written to memory during allocation or deallocation, so that it will later be possible to tell whether or not they have become corrupted and to make it obvious when values taken from uninitialized memory are being used.
Memory is usually viewed in hexadecimal, so common values used are often repeated digits or hexspeak.
Famous and common examples include:
0xBAADF00D
0xBAADFEED
0xBADBADBADBAD
Burroughs B6700 "uninitialized" memory (48-bit words)
0xC0EDBABE
0xC001D00D
0xCCCCCCCC
Used by Microsoft's C++ compiler to mark uninitialised stack areas in debug mode.
0xCDCDCDCD
Used by Microsoft's C++ debugging heap to mark uninitialised heap areas.
0xDDDDDDDD
Used by MicroQuill's SmartHeap and Microsoft's C++ debugging heap to mark memory returned to the heap.
0xDEADBEEF
Famously used on IBM systems such as the RS/6000, also in OPENSTEP Enterprise and the Commodore Amiga.
0xEBEBEBEB
From MicroQuill's SmartHeap.
OxFACADE
Used by a number of real-time OS's
0xFD
Used by Microsoft's C++ debugging heap to mark guard bytes in the heap.
0xFEEEFEEE
Used by Microsoft's C++ compiler to mark the storage area of a deleted class in debug mode.
Note that most of these are each 8 nybbles (32 bits) long, as most modern computers are designed to manipulate 32 bits at a time.
The prevalence of these values in Microsoft technology is no coincidence; they are discussed in detail in Steve McGuire's well-known book Writing Solid Code from Microsoft Press. He gives a variety of criteria for these values, such as:
They should not be useful; that is, most algorithms that operate on them should be expected to do something unusual. Numbers like zero don't fit this criterion.
They should be easily recognized by the programmer as invalid values in the debugger.
On machines that don't have byte alignment, they should be odd, so that dereferencing them as addresses causes an exception.
They should cause an exception, or perhaps even a debugger break, if executed as code.
Since they were often used to mark areas of memory that were essentially empty, some of these terms came to be used in phrases meaning "gone, aborted, flushed from memory"; e.g. "Your program is DEADBEEF".
http://www.azure.com.cn/article.asp?id=233
Magic debug values are specific values written to memory during allocation or deallocation, so that it will later be possible to tell whether or not they have become corrupted and to make it obvious when values taken from uninitialized memory are being used.
Memory is usually viewed in hexadecimal, so common values used are often repeated digits or hexspeak.
Famous and common examples include:
0xBAADF00D
0xBAADFEED
0xBADBADBADBAD
Burroughs B6700 "uninitialized" memory (48-bit words)
0xC0EDBABE
0xC001D00D
0xCCCCCCCC
Used by Microsoft's C++ compiler to mark uninitialised stack areas in debug mode.
0xCDCDCDCD
Used by Microsoft's C++ debugging heap to mark uninitialised heap areas.
0xDDDDDDDD
Used by MicroQuill's SmartHeap and Microsoft's C++ debugging heap to mark memory returned to the heap.
0xDEADBEEF
Famously used on IBM systems such as the RS/6000, also in OPENSTEP Enterprise and the Commodore Amiga.
0xEBEBEBEB
From MicroQuill's SmartHeap.
OxFACADE
Used by a number of real-time OS's
0xFD
Used by Microsoft's C++ debugging heap to mark guard bytes in the heap.
0xFEEEFEEE
Used by Microsoft's C++ compiler to mark the storage area of a deleted class in debug mode.
Note that most of these are each 8 nybbles (32 bits) long, as most modern computers are designed to manipulate 32 bits at a time.
The prevalence of these values in Microsoft technology is no coincidence; they are discussed in detail in Steve McGuire's well-known book Writing Solid Code from Microsoft Press. He gives a variety of criteria for these values, such as:
They should not be useful; that is, most algorithms that operate on them should be expected to do something unusual. Numbers like zero don't fit this criterion.
They should be easily recognized by the programmer as invalid values in the debugger.
On machines that don't have byte alignment, they should be odd, so that dereferencing them as addresses causes an exception.
They should cause an exception, or perhaps even a debugger break, if executed as code.
Since they were often used to mark areas of memory that were essentially empty, some of these terms came to be used in phrases meaning "gone, aborted, flushed from memory"; e.g. "Your program is DEADBEEF".
相关文章推荐
- Magic debug values
- 调试手机中数据库的福音:Android-Debug-Database(666)
- Debug和Release下调试的问题
- JS调试必备的5个debug技巧
- CentOS环境下,gdb调试中出现:Missing separate debuginfos, use: debuginfo-install.....的问题
- XE8 & IOS开发之免费证书真机调试:开发证书、AppID、开发授权profile的申请,附Debug真机调试演示
- Swift中Debug和Release两种状态下print()函数调试切换
- debug调试
- 调试函数OutputDebugString 支持变参
- 汇编语言DosBox下在64位上运行实现编译(masm)与调试即debug命令。
- Eclipse的Debug调试技巧
- 远程调试 ERROR: JDWP unable to get necessary JVMTI capabilities. ["debugInit.c",L279]
- Linux下Debug模式启动Tomcat进行远程调试
- tomcat远程eclipse调试debug端口配置在linux环境
- 三步教你实现MyEclipse的debug远程调试
- pycharm 不能单步调试(debug)的原因,或者点击debug不能进入断点。debug区域是灰色的
- MyEclipse使用debug调试程序
- IDEA下使用Jetty进行Debug模式调试
- JAVA游戏编程之一----IDE安装调试(3) --JAD 文件介绍--debug调试
- Eclipse的Debug调试技巧大全