windows 调试若干知识
1、 创建map文件
<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:1; mso-generic-font-family:roman; mso-font-format:other; mso-font-pitch:variable; mso-font-signature:0 0 0 0 0 0;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4; mso-font-charset:0; mso-generic-font-family:swiss; mso-font-pitch:variable; mso-font-signature:-520092929 1073786111 9 0 415 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {mso-style-priority:34; mso-style-unhide:no; mso-style-qformat:yes; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; text-indent:21.0pt; mso-char-indent-count:2.0; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:宋体; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} /* List Definitions */ @list l0 {mso-list-id:2075465320; mso-list-type:hybrid; mso-list-template-ids:473879982 2027220046 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;} @list l0:level1 {mso-level-tab-stop:none; mso-level-number-position:left; margin-left:18.0pt; text-indent:-18.0pt;} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} -->
为你的程序创建映射文件,你必须对 VC++ 工程中的相应选项进行适当的设置。第一步是打开映射文件生成功能。你可以在工程设置对话框里进行设置。在 link 标签里的 debug 类里打开 generate mapfile 选项。由于一些奇怪的原因, VC++ 没有把输出程序代码地址和源代码行号的映射作为默认设置。要得到这些信息,还需要在 Project Option 对话框里嵌入 ”/MAPINFO: LINES”. 得到导出序号也许很有用 , 所以你还需要在 project option 里输入 ”/MAPINFO: EXPORTS”.
2. release和debug编译选项。
Debug Build Options:
/Od
/D "WIN32" ## define macros.
/D "_WINDOWS"
/D "_DEBUG"
/D "_AFXDLL"
/D "_UNICODE"
/D "UNICODE"
/Gm ## minimal build
/EHsc ## enable c++ exception
/RTC1 ## basic runtime checks
/MDd ## use multithreaded debug dll
/Yu"stdafx.h" ## use precompiled headers
/Fp"Debug/TestDatabase.pch" ## precompiled header file
/Fo "Debug//" ## object file name
/Fd "Debug/vc90.pdb" ## program database filename
/W3 ## warning level
/nologo
/c ## keep comments
/ZI ## do not include default library names in obj files.
/TP ## compile as c++ source files.
/errorReport:prompt ## error report.
Release Build Options:
/O2 ## maximize speed optimization.
/Oi ## enables intrinsic functions,.this could generate faster but possiblely larger codes.
/GL ## enable cross module optimizations by delaying code generation to link time. Called whole program optimization.
/D "WIN32" ## define WIN32
/D "_WINDOWS"
/D "NDEBUG"
/D "_AFXDLL"
/D "_UNICODE"
/D "UNICODE"
/FD ##
/EHsc ## enable c++ exception
/MD ## use multi threaded dll
/Gy ## enable function-level linking, for edit and continue.
/Yu"stdafx.h" ## precomiled headers
/Fp"Release/TestDatabase.pch" ## pch files
/Fo"Release//" ## object files
/Fd"Release/vc90.pdb" ## program database files.
/W3 ## warning level
/nologo
/c ## keep comments
/Zi ##
/TP ## compiled as c++ source files.
/errorReport:prompt
3. 同调试版的c/c++运行时库
使用调试版本的函数库:
除了有调试符号外, debug 的 c runtime lib 使用了调试堆。下面是调试库一些特点的总结:
1. 对内存分配进行了跟踪,使得用户能够检查内存泄漏。
2. 在刚分配的内存里写上 0xcd 的字节,这有助于发现未初始化数据的错误。
3. 在被释放的内存里写上 0xcd 的字节。有助于发现被释放的内存
4. 在缓冲区的两边各分配了 4 个字节的保护数据,并写入值 0xfd ,用来检查内存的上溢出和下溢出
5. 在每个内存分配的地方对源文件和行号进行了记录,这有助于用户在源代码中对内存分配进行定位。
6. 在调试版本中更能容易发现内存错误。而且调试版本允许对内存的写操作有四个字节的上溢出和下溢出,对程序不会有任何影响。同样的错误在发布版中就会导致内存破坏。
4关于优化。
关闭优化开关:
因为未被优化的汇编代码直接对应于源代码,所以比优化后的代码更容易读懂,所以当你调试代码时,调试器会以 你预想的方式工作,而优化后的代码却可能会四处跳转。和你预想的很不一样。而且一些变量也因为优化去掉了。此外,为被优化的代码编译与链接会更快,从而会有更短的调试周期。
理论上讲,调试版本不会比发布版本更完善,所以一旦你的调试版本通过,基本可以确信你的发布版本可以运行。不幸的是,这个完美的理论因为优化而被打破了。优化代码要求编译器做一些假设,并去除了一些冗余,但有时这些假设不一定正确,并且去掉的冗余有可能隐藏错误。
windows 调试若干知识相关推荐
- Windows Phone 7知识锦分享
写在前面的话 微软全新的手机操作系统Windows Phone 7 已经推出一段时间了,社区中也有不少Windows Phone 7的高手,无论是外国的或者国内的,他们都有提供很多很好的学习资源. i ...
- windows调试器设置
编程中,debug既是技术,又是技巧.熟练的掌握调试工具可以加速软件问题的解决,这对于底层开发和高级开发都是十分必要的.本文就windows调试器的设置问题,根据个人在windbg上的使用经验进行总结 ...
- Windows Phone 7知识锦分享【第二季】
最近的MIX11大会真的令人振奋不已,朋友开玩笑的说,"Mango一出,大家都高潮了".确实,MS很给力,Windows Phone 7 很给力,Silverlight很给力... ...
- Qt安装Windows调试器
Qt安装Windows调试器 问题:Win10下使用Qt无法调试,这是因为没有指定调试器. 解决方法: 1. 打开网址:https://developer.microsoft.com/zh-cn/wi ...
- VS中 本地Windows调试器 与 生成解决方案
① 平时,我们使用VS会直接新建一个项目,然后在使用时,双击.sln的文件便可打开VS工程:因为此时的.sln文件表示,我们创建的是一个解决方案. ② 当出现,VS打开方式为双击.bat文件时,此时需 ...
- sicp计算机应用基础,Windows 7基础知识
理论题 -- Windows 7基础知识 一.单选题 1.Windows 7提供的待机模式中,在_____模式下,系统的状态是保存在内存中的.答案:C A.注销 B.关机 C.睡眠 D.重新启动 2. ...
- windows pwn 基础知识
环境搭建 checksec winchecksec winchecksec 是 windows 版的 checksec ,不过有时候结果不太准确. checksec(x64dbg) x64dbg 的插 ...
- [系统安全] Windows逆向必备知识、逆向分析小实战
本文为笔者从零基础学习系统安全相关内容的笔记,如果您对系统安全.逆向分析等内容感兴趣或者想要了解一些知识,欢迎关注.本系列文章将会随着笔者在未来三年的读研过程中持续更新,由于笔者现阶段还处于初学阶段, ...
- 深度解析windows调试技术之一 [抓取user mode dump文件的几重境界]
抓取user mode dump文件的几重境界 导读 记得去年对一些朋友说过要写一些调试技术相关的文章,但是后来出于种种原因吧,还是没写成.最近终于有些时间,希望可以把这些文章补上.对于软件开发而言, ...
最新文章
- (JAVA)从零开始之--打印流PrintStream记录日志文件
- Linux之vim全选,全部复制,全部删除
- Delphi数据类型及转换(附:源码)
- Parity Alternated Deletions
- linux ucontext 类型,协程:posix::ucontext用户级线程实现原理分析 | WalkerTalking
- 重磅!阿里云发布最新服务等级协议SLA ,多实例可用性升为99.995%
- solr索引创建流程
- 如何配置CentOS或者RedHat5.X、6.X、7.X的网络yum源
- 财务有必要学python吗-一个来自35岁职场高管的忠告:Python为什么不得不学?
- BW作为源系统连接时,激活DSO或其他模型时提示8*数据源不存在,无法激活
- 在centos中如何用yum安装最新的yum源
- 我是游戏设计师——《游戏设计艺术》
- 铁木辛柯matlab,岩石断裂力学(李世愚2006)
- 劳务派遣人员管理办法范文
- matlab检验贝塔分布规律,贝塔分布背后的直觉:概率的概率分布
- AIX 6:新特性概述
- 实对称矩阵的几个性质
- 计算机科学类专升本复习之“C语言结构体”详解(初稿)
- 计算机二级考过律,计算机二级考试考完后的这些事情你知道吗?
- python学习 day51之js续集
热门文章
- 产品学习:智能生产调度管理系统
- 四旋翼自主飞行器设计方案
- STM32实现水下四旋翼(六)传感任务2——姿态解算代码实现(使用角度传感器)
- java 获取est时间_java – 在EST时区获取XMLGregorianCalendar日期
- 重磅!上海出落户新政:双一流应届硕士可直接落户!
- 小程序开发语言python_微信小程序是用什么语言开发的呢
- 论文笔记:图像分割——ExFuse DFN
- web前端期末大作业——基于HTML+CSS+JavaScript实现中国茶文化(30页)
- 我的世界win10java_我的世界java版和win10版的区别
- 英文文章单词自动查找脚本