⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0,1410,26406,00.html

📁 C++builder学习资料C++builder
💻 HTML
字号:
<HTML>



<HEAD>



<TITLE>What is an AV, and how do I debug them</TITLE>



</HEAD>

<BODY>



<A NAME="top"></A>



<table>

 



<TR>

   <td>





<P>



<SPAN CLASS="title3">What is an AV, and how do I debug them</SPAN> 

 

		- by Borland Developer Support Staff 

<BLOCKQUOTE CLASS="abstract"> 

  <p><B>Abstract:</B>The basic steps to debug Access Violations in a win32 program.</p> 

    </BLOCKQUOTE> 

  

<P>Whenever you get an AV in windows it means that your program tried to access memory that is no longer available to your program.  Notice that I said "no longer" available.  Many times when you get an AV, it is because you either tried to use a pointer whos object had already  been deleted, or a pointer whos object hasn't been created yet.   

  <P>Luckily for us, the win32 memory architecture uses a seperate address space for every process, so we don't have to worry about overwriting the memory of other programs (this was a frequent problem in win16).  This also means that we can actually use the information in the error dialog.   

  <P>When we get an AV dialog, there will be an address (ie AV at address :?????).  Write that address down, rerun the application and open the CPU window.  Right click on it and choose go to address.  When the dialog comes up, enter the address that the AV just occured at.  Now you will be at the instruction that caused the AV.   

  <P>Since everything in the CPU window is written in Assembly it probably won't meant that much to you; however, if you scroll up a bit you should see which function you are currently in.  Now you know what function is causing the AV. Once you know which function caused the AV you can start to set break points within the function.   

  <P>Unfortunately not everything is as easy as that.  Pointer problems can be very hard to debug.  As a general rule, all pointers should be set to NULL after the object that they point to is deleted.  You also might want to check to see if the pointer is NULL before you use it in the offending function, and if it is, the you can output some debug information to help you pinpoint at what point during the program execution the AV is occuring.   

<P>As a last resort you should alse be able to set a data break point on the pointer and check to see when it is set to NULL.   

  </table> 

</BODY> 

  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -