亚洲国产精品久久久久久,欧美无乱码久久久免费午夜一区二区三区中文字幕 ,欧美一区二区三区久久综http://www.shnenglu.com/sandy/category/1244.html高性能服務器端計算zh-cnSat, 27 Sep 2008 10:58:16 GMTSat, 27 Sep 2008 10:58:16 GMT60使用Gflags來檢測heap問題http://www.shnenglu.com/sandy/archive/2008/09/27/62877.html小明小明Sat, 27 Sep 2008 02:59:00 GMThttp://www.shnenglu.com/sandy/archive/2008/09/27/62877.htmlhttp://www.shnenglu.com/sandy/comments/62877.htmlhttp://www.shnenglu.com/sandy/archive/2008/09/27/62877.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/62877.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/62877.html閱讀全文

小明 2008-09-27 10:59 發表評論
]]>
LeakDiag使用手記http://www.shnenglu.com/sandy/archive/2008/08/18/59260.html小明小明Mon, 18 Aug 2008 11:12:00 GMThttp://www.shnenglu.com/sandy/archive/2008/08/18/59260.htmlhttp://www.shnenglu.com/sandy/comments/59260.htmlhttp://www.shnenglu.com/sandy/archive/2008/08/18/59260.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/59260.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/59260.html閱讀全文

小明 2008-08-18 19:12 發表評論
]]>
遠程調試技術-使用vs2005http://www.shnenglu.com/sandy/archive/2008/07/28/57351.html小明小明Mon, 28 Jul 2008 07:20:00 GMThttp://www.shnenglu.com/sandy/archive/2008/07/28/57351.htmlhttp://www.shnenglu.com/sandy/comments/57351.htmlhttp://www.shnenglu.com/sandy/archive/2008/07/28/57351.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/57351.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/57351.html閱讀全文

小明 2008-07-28 15:20 發表評論
]]>
VS2005 SP1的編譯兼容性問題http://www.shnenglu.com/sandy/archive/2008/04/18/47519.html小明小明Fri, 18 Apr 2008 10:01:00 GMThttp://www.shnenglu.com/sandy/archive/2008/04/18/47519.htmlhttp://www.shnenglu.com/sandy/comments/47519.htmlhttp://www.shnenglu.com/sandy/archive/2008/04/18/47519.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/47519.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/47519.html閱讀全文

小明 2008-04-18 18:01 發表評論
]]>
C++源文件編碼問題http://www.shnenglu.com/sandy/archive/2007/04/05/21320.html小明小明Thu, 05 Apr 2007 07:30:00 GMThttp://www.shnenglu.com/sandy/archive/2007/04/05/21320.htmlhttp://www.shnenglu.com/sandy/comments/21320.htmlhttp://www.shnenglu.com/sandy/archive/2007/04/05/21320.html#Feedback5http://www.shnenglu.com/sandy/comments/commentRss/21320.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/21320.html閱讀全文

小明 2007-04-05 15:30 發表評論
]]>
UltraEdit的一個Bughttp://www.shnenglu.com/sandy/archive/2007/04/04/21231.html小明小明Wed, 04 Apr 2007 05:51:00 GMThttp://www.shnenglu.com/sandy/archive/2007/04/04/21231.htmlhttp://www.shnenglu.com/sandy/comments/21231.htmlhttp://www.shnenglu.com/sandy/archive/2007/04/04/21231.html#Feedback5http://www.shnenglu.com/sandy/comments/commentRss/21231.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/21231.html閱讀全文

小明 2007-04-04 13:51 發表評論
]]>
WinDBG(CDB)實踐1-新手指南http://www.shnenglu.com/sandy/archive/2007/03/13/19723.html小明小明Tue, 13 Mar 2007 06:39:00 GMThttp://www.shnenglu.com/sandy/archive/2007/03/13/19723.htmlhttp://www.shnenglu.com/sandy/comments/19723.htmlhttp://www.shnenglu.com/sandy/archive/2007/03/13/19723.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/19723.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/19723.html閱讀全文

小明 2007-03-13 14:39 發表評論
]]>
GDB 和 CDB 基本命令比較http://www.shnenglu.com/sandy/archive/2007/03/08/19425.html小明小明Thu, 08 Mar 2007 06:33:00 GMThttp://www.shnenglu.com/sandy/archive/2007/03/08/19425.htmlhttp://www.shnenglu.com/sandy/comments/19425.htmlhttp://www.shnenglu.com/sandy/archive/2007/03/08/19425.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/19425.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/19425.html也許有人不知道CDB是什么,CDB是windbg的小兄弟,基于command line,對于我這個比較喜歡用command line的人,CDB比windbg更容易上手。

象GDB,CDB這些工具,命令都很多,但是我們只要熟記最常用的"三板斧"就可以工作了。

1.啟動
   1)直接調試:  
      gdb program [core]
      cdb program or cdb -z DumpFile
   2)attach方式
      gdb attach pid
      cdb -pn ExeName or cdb -p pid

2.顯示堆棧
   GDB: bt
   CDB: k

3. 設置斷點
   GDB: b [file:]line
   CDB: bp 'file:line'

4. 運行/繼續運行
   GDB: run [arglist] 
             c   繼續運行 
   CDB: g

5. 單步
   GDB : n (step over) s (step into)
   CDB : p

6. 打印變量的值
    GDB : p expr
    CDB: ? expr

說老實話,CDB過于復雜,學起來比GDB難.

BTW:用CDB之前設置一下symbol的path
set _NT_SYMBOL_PATH=srv*c:\symbols*http://msdl.microsoft.com/download/symbols
   
   



小明 2007-03-08 14:33 發表評論
]]>
[Tips]如何計算utf8下的字節數http://www.shnenglu.com/sandy/archive/2006/11/08/14841.html小明小明Wed, 08 Nov 2006 05:32:00 GMThttp://www.shnenglu.com/sandy/archive/2006/11/08/14841.htmlhttp://www.shnenglu.com/sandy/comments/14841.htmlhttp://www.shnenglu.com/sandy/archive/2006/11/08/14841.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/14841.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/14841.html
<!DOCTYPE?HTML?PUBLIC?"-//W3C//DTD?HTML?4.0?Transitional//EN">
<HTML>
<HEAD>
<TITLE>?An?utf8?count?tool??</TITLE>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf16">
<script>
????
function?utf16to8(str)?{
????????
var?out,?i,?len,?c;

????????out?
=?"";
????????len?
=?str.length;
????????
for(i?=?0;?i?<?len;?i++)?{
????????c?
=?str.charCodeAt(i);
????????
if?((c?>=?0x0001)?&&?(c?<=?0x007F))?{
????????????out?
+=?str.charAt(i);
????????}?
else?if?(c?>?0x07FF)?{
????????????out?
+=?String.fromCharCode(0xE0?|?((c?>>?12)?&?0x0F));
????????????out?
+=?String.fromCharCode(0x80?|?((c?>>??6)?&?0x3F));
????????????out?
+=?String.fromCharCode(0x80?|?((c?>>??0)?&?0x3F));
????????}?
else?{
????????????out?
+=?String.fromCharCode(0xC0?|?((c?>>??6)?&?0x1F));
????????????out?
+=?String.fromCharCode(0x80?|?((c?>>??0)?&?0x3F));
????????}
????????}
????????
return?out;
????}
????
function?count()
????{
????????
var?temp?=?f1.value;
????????temp
=temp.replace(/\\r/g,"\r");
????????temp
=temp.replace(/\\n/g,"\n");
????????result.innerHTML
=utf16to8(temp).length;
????}
</script>
</HEAD>

<BODY>
<TEXTAREA?id="f1"?NAME="f1"?ROWS="10"?COLS="50"></TEXTAREA>
<br/>
<INPUT?TYPE="button"?value="count?length"?onclick="count()">
<div?id="result"></div>
</BODY>
</HTML>


小明 2006-11-08 13:32 發表評論
]]>
Quick Reference -- 工程師必備http://www.shnenglu.com/sandy/archive/2006/09/28/13114.html小明小明Thu, 28 Sep 2006 07:30:00 GMThttp://www.shnenglu.com/sandy/archive/2006/09/28/13114.htmlhttp://www.shnenglu.com/sandy/comments/13114.htmlhttp://www.shnenglu.com/sandy/archive/2006/09/28/13114.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/13114.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/13114.html閱讀全文

小明 2006-09-28 15:30 發表評論
]]>
[Tips]如何識別字符編碼http://www.shnenglu.com/sandy/archive/2006/09/27/13014.html小明小明Wed, 27 Sep 2006 02:00:00 GMThttp://www.shnenglu.com/sandy/archive/2006/09/27/13014.htmlhttp://www.shnenglu.com/sandy/comments/13014.htmlhttp://www.shnenglu.com/sandy/archive/2006/09/27/13014.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/13014.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/13014.html閱讀全文

小明 2006-09-27 10:00 發表評論
]]>
代碼格式化工具http://www.shnenglu.com/sandy/archive/2006/07/14/9855.html小明小明Fri, 14 Jul 2006 08:32:00 GMThttp://www.shnenglu.com/sandy/archive/2006/07/14/9855.htmlhttp://www.shnenglu.com/sandy/comments/9855.htmlhttp://www.shnenglu.com/sandy/archive/2006/07/14/9855.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/9855.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/9855.html閱讀全文

小明 2006-07-14 16:32 發表評論
]]>
C++代碼靜態分析工具-Prefasthttp://www.shnenglu.com/sandy/archive/2006/03/28/4689.html小明小明Tue, 28 Mar 2006 05:59:00 GMThttp://www.shnenglu.com/sandy/archive/2006/03/28/4689.htmlhttp://www.shnenglu.com/sandy/comments/4689.htmlhttp://www.shnenglu.com/sandy/archive/2006/03/28/4689.html#Feedback5http://www.shnenglu.com/sandy/comments/commentRss/4689.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/4689.html 1. 什么是Prefast

Prefast是一種代碼分析工具,它能夠幫助你找到編譯器不能找到的錯誤或者缺陷。Prefast首次被微軟集成到Visual Studio 2005 Team Suite中去,使用起來非常方便。

2.怎么使用Prefast
在vs2005 Team Suite中,使用Prefast非常簡單。修改你的工程屬性,設置Enable Code Analysis For C/C++為Yes.

prefast1.jpg

效果:
prefast2.jpg

注意到有可能錯誤的地方以淺灰色顯示在編輯器中了。

3.Prefast能幫你找到哪些錯誤

1)沒有初始化

// no?initial
void ?defect1()
{
????????
int ?a;
????????
int ?b;

????????b?
= ?a;
}

會報: d:\test\testcode\testcode.cpp(18) : warning C6001: Using uninitialized memory 'a': Lines: 15, 16, 18

2)空指針取值

// one?path?dereference?NULL
void ?defect4( int ?b,? int ?c)
{
????????
int ? * p? = ?NULL;
????????
int ?a? = ? 1 ;

????????
if ?(b? == ? 1 )?{
????????????????
if ?(c? == ? 1 )?{
????????????????????????p?
= ? & a;
????????????????}
????????????????
else ?{
????????????????????????????????????????????????
????????????????}
????????}
????????
else ?{
????????????????
if ?(c? == ? 1 )?{

????????????????}
????????????????
else ?{
????????????????????????p?
= ? & a;
????????????????}
????????}

????????
* p;

????????
return ;
}????

會報:d:\test\testcode\testcode.cpp(65) : warning C6011: Dereferencing NULL pointer 'p': Lines: 45, 46, 48, 57, 65

3)可能錯誤的運算符優先級

void ?defect5()
{
????????
int ?a? = ? 1 ;
????????
int ?b? = ? 1 ;
????????
int ?c? = ? 1 ;

????????
if ?(a? & ?b? == ?c)
????????????????
return ;
}

會報: d:\test\testcode\testcode.cpp(76) : warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators

4)可能的buffer overrun

void ?defect8()
{
????????
char ?buf[ 100 ];
????????
char ?buf2[ 200 ];
????????
int ?i? = ? 100 ;

????????sprintf(buf,?
" hello?world?%d " ,?i);
????????strcpy(buf,?buf2);
}

會報: d:\test\testcode\testcode.cpp(133) : warning C6202: Buffer overrun for 'buf', which is possibly stack allocated, in call to 'strcpy': length '200' exceeds buffer size '100'

5)可能的無窮循環

// infinite?loop
void ?defect14()
{
????????signed?
char ?i;

????????
for ?(i? = ? 100 ;?i? >= ? 0 ;?i ++ )?{
????????????????;?
????????}
}

會報: d:\test\testcode\testcode.cpp(198) : warning C6292: Ill-defined for-loop: counts up from maximum

6)格式字符串錯誤

// Format?string?mismatch
void ?defect21()
{
????????
char ?buff[ 5 ];
????????sprintf(buff,?
" %s?%s " ,? " a " );
}

會報: d:\test\testcode\testcode.cpp(277) : warning C6063: Missing string argument to 'sprintf' that corresponds to conversion specifier '2'

7)安全問題

void ?defect27()
{
????????CreateProcess(NULL,
???????????????
" c:\\program?files\\Project.exe?arg1 " ,? // correct?"\"c:\\program?files\\Project.exe\"?arg1",
???????????????NULL,
???????????????NULL,
???????????????
false ,
???????????????
0 ,
???????????????NULL,
???????????????NULL,
???????????????NULL,
???????????????NULL);???????????????
}

會報: d:\test\testcode\testcode.cpp(327) : warning C6277: NULL application name with an unquoted path in call to 'CreateProcessA': results in a security vulnerability if the path contains spaces

8)=和==誤用

void ?defect32()
{
????????
int ?a? = ? 1 ;

????????
if ?(a? = ? 2 )
????????????????
return ;
}

會報: d:\test\testcode\testcode.cpp(405) : warning C6282: Incorrect operator: assignment of constant in Boolean context. Consider using '==' instead

9)邏輯運算問題

// always?false
void ?defect45()
{
????????
int ?x;

????????
if ?( 0 ? && ?x ++ )?{
????????????????;
????????}
}

會報: d:\test\testcode\testcode.cpp(564) : warning C6237: (<zero> && <expression>) is always zero. <expression> is never evaluated and might have side effects

10)其他







小明 2006-03-28 13:59 發表評論
]]>
C++跨平臺開發方法/工具http://www.shnenglu.com/sandy/archive/2006/03/24/4544.html小明小明Fri, 24 Mar 2006 08:45:00 GMThttp://www.shnenglu.com/sandy/archive/2006/03/24/4544.htmlhttp://www.shnenglu.com/sandy/comments/4544.htmlhttp://www.shnenglu.com/sandy/archive/2006/03/24/4544.html#Feedback15http://www.shnenglu.com/sandy/comments/commentRss/4544.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/4544.html  閱讀全文

小明 2006-03-24 16:45 發表評論
]]>
日本欧美国产精品第一页久久| 国产国产成人精品久久| 久久精品无码一区二区三区日韩| 久久久久久久人妻无码中文字幕爆| 久久久久人妻一区精品色| 66精品综合久久久久久久| 欧美国产成人久久精品| 欧美黑人激情性久久| 大美女久久久久久j久久| 久久人人爽人人爽人人爽 | 97精品依人久久久大香线蕉97| 亚洲精品无码久久千人斩| 国产精品久久久久一区二区三区| 一级a性色生活片久久无 | 国产精品99久久不卡| 亚洲精品乱码久久久久久蜜桃图片| 欧美精品一区二区精品久久| 99久久99久久精品国产片果冻| 国产精品免费看久久久香蕉| 午夜天堂精品久久久久| 日韩欧美亚洲综合久久影院Ds| 久久精品成人免费看| 久久久无码精品亚洲日韩蜜臀浪潮| 久久久久无码专区亚洲av| 97久久精品人人澡人人爽| 色综合久久综合中文综合网| 一级女性全黄久久生活片免费| 久久99精品久久久久久水蜜桃| 久久99热狠狠色精品一区| 国产婷婷成人久久Av免费高清| 亚洲国产精品无码久久一区二区| 亚洲精品tv久久久久| 中文成人久久久久影院免费观看| 精品无码久久久久久国产| 久久精品国产黑森林| 99精品伊人久久久大香线蕉| 精品多毛少妇人妻AV免费久久| 超级碰久久免费公开视频| 久久激情亚洲精品无码?V| 久久这里有精品视频| 波多野结衣久久精品|