青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

鍵盤的詠嘆調(diào)

常用鏈接

統(tǒng)計(jì)

最新評(píng)論

[zz]An introduction to debugging in MSVC++ using Pseudoregisters

Introduction

Let's start with the reason why I wrote this article. One day, a colleague asked me to help him debug a problem he had. So I was watching him stepping in his code, when I noticed the following line:

Collapse
int test = GetLastError();

He did this, because he wanted to know the error code, if the previous function failed. He was adding this line every time he wanted to know the error code. I advised him to remove all those lines and use the @ERR pseudoregister in his watch window. He didn't know what it was and asking around in the office, a lot of other people didn't. So I came up with this article for people who have never heard of pseudoregisters.

What is a pseudoregister anyway?

A pseudoregister is not an actual hardware register, but is displayed as though it were a hardware register. With a pseudoregister, you can see and use certain values (error codes, thread information block...) in the debugger.

Let's have a look at the @ERR pseudoregister. Fire up your debugger with your favourite home-written application. Put a breakpoint in your code so that the debugger will break execution. Open the watch window if it isn't already (do this by right clicking on some empty toolbar space, and select "Watch" from this list). Add @ERR in this watch window. You should see 0 in the Value column. Now step through your code, and watch this value. It will always show the GetLastError() number for the current thread. So if something goes wrong in your code, this value will change.

If you want to test this, but your code doesn't have any errors, I advise to put some in (but don't forget to remove them afterwards). You can insert something like this:

Collapse
FILE *fp = fopen("c:\\a_file_that_does_not_exist.txt", "r");

If you step over this line, you'll see that the @ERR value changed to 2. Go to Tools->Error Lookup to see what this error value means ("The system cannot find the file specified" if you were wondering). Lazy bums like me, and smart lads / lasses like you can change the @ERR pseudoregister to @ERR,hr . Doing this will change the value of the pseudoregister to the error string. Now you even don't have to lookup the error. I leave the @ERR,hr in the watch window all the time.

Conditional Expressions

Pseudoregisters can also be used in conditional expressions. To try this out, put following lines after the fopen:

Collapse
if (fp)
{
fclose(fp);
}

Put a breakpoint on the if (fp) line. Go to Edit->Breakpoints (or press Alt-F9). Select the breakpoint you just inserted and press the "Condition" button. Here, you can enter the @ERR==2 condition. Now start the debugger. The debugger will break on this breakpoint if fopen() failed because it couldn't find the file. If the file does exist, the debugger won't break, even if it encountered another error (say error 4: could not open the file). Try this out by running the code (not stepping) after creating, and deleting the "a_file_that_does_not_exist.txt" file on c:\.

Just for the very curious (and otherwise totally irrelevant to this article) : what does @ERR do? How does it get the error number? As it turns out, @ERR does exactly the same thing as GetLastError() does. These functions have a whopping 3 lines of assembly code:

Collapse
mov eax,fs:[00000018h] 
mov eax,dword ptr [eax+34h]
ret

So @ERR grabs the DWORD at offset 0x34 in the thread environment block pointed to by fs:[18h].

The @TIB pseudoregister

The @ERR pseudoregister is not the only one that exists. Another important pseudoregister is @TIB. This is the thread information block for the current thread and is extremely helpful in multi-threaded debugging. If you place a breakpoint in a function that is called by multiple threads, the debugger will break execution every time no matter which thread passes the breakpoint. Even if you're stepping through your code, the debugger can jump to the breakpoint if another thread called the function. To solve this, you'll need to do the following. If execution breaks in the thread you want, add @TIB in the watch window. You will see some value like "0x7ffa6000" or "2147115008" in regular display. Go to the breakpoint menu (Alt-F9) and select the breakpoint. You can now add the @TIB==0x7ffa6000 condition filter. Doing this, the debugger will only break execution for this thread. All other threads using the same function will not result in a break.

This doesn't work in Windows 98 though. For Windows 98, you'll need to look at the Intel CPU FS register, which is unique for each thread. You can use the expression @FS==value

Complete list of pseudoregisters

Pseudoregister

Description

@ERR

Last error value; the same value returned by the GetLastError() API function

@TIB

Thread information block for the current thread; necessary because the debugger doesn't handle the "FS:0" format

@CLK

Undocumented clock register; usable only in the Watch window

@EAX, @EBX, @ECX, @EDX, @ESI, @EDI, @EIP, @ESP, @EBP, @EFL

Intel CPU registers

@CS, @DS, @ES, @SS, @FS, @GS

Intel CPU segment registers

@ST0, @ST1, @ST2, @ST3, @ST4, @ST5, @ST6, @ST7

Intel CPU floating-point registers

posted on 2009-11-18 09:49 鍵盤的詠嘆調(diào) 閱讀(274) 評(píng)論(0)  編輯 收藏 引用 所屬分類: C++

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            日韩午夜三级在线| 一区在线观看| 欧美理论大片| 国产毛片久久| aa亚洲婷婷| 麻豆精品网站| 亚洲一区二区三区高清| 欧美国产三区| 亚洲国产精品女人久久久| 久久久久国产精品午夜一区| 亚洲午夜精品一区二区| 欧美日韩视频一区二区| 91久久综合| 欧美成人免费在线视频| 欧美一区二区三区在| 国产精品影音先锋| 亚洲男人的天堂在线| 夜夜爽99久久国产综合精品女不卡 | 日韩视频在线观看免费| 久久久久国产精品一区二区| 欧美一级视频一区二区| 国产精品美女久久福利网站| 国产亚洲成av人片在线观看桃 | 欧美精品在线免费观看| 亚洲国产精品小视频| 老司机亚洲精品| 久久亚洲综合网| 一区在线视频| 欧美韩日一区二区| 欧美成人性网| 亚洲少妇中出一区| 欧美国产欧美亚洲国产日韩mv天天看完整 | 欧美成人精品福利| 久久全球大尺度高清视频| 狠狠色丁香婷婷综合久久片| 久久免费黄色| 噜噜噜91成人网| 日韩午夜在线电影| 99精品视频免费观看视频| 美女脱光内衣内裤视频久久影院| 亚洲欧美日韩国产一区二区| 国产小视频国产精品| 久久激情综合| 另类av导航| 久久久久久久久综合| 欧美日韩一区在线观看视频| 韩国欧美国产1区| 免费成人小视频| 欧美风情在线观看| 亚洲一区二区三区在线观看视频| 亚洲一区二区三区在线视频| 精品不卡一区二区三区| 亚洲精品国产精品国产自| 欧美日韩视频专区在线播放| 中文在线一区| 久久久久国内| 亚洲欧美一区二区三区极速播放 | 免费成人小视频| 欧美日韩国产精品一区| 久久偷看各类wc女厕嘘嘘偷窃| 欧美日韩中文| 另类专区欧美制服同性| 欧美高清不卡在线| 欧美激情影音先锋| 亚洲日本无吗高清不卡| 亚洲欧美日韩国产一区二区三区 | 久久久久久免费| 欧美不卡视频一区| 亚洲欧美日韩网| 韩国av一区二区三区四区| 久久综合久久88| 欧美精品1区2区3区| 亚洲欧美日韩精品久久奇米色影视| 午夜精品影院| 99亚洲视频| 久久成人精品视频| 久久riav二区三区| 亚洲素人一区二区| 欧美视频免费在线观看| 一区二区三区四区在线| 亚洲一区二区三区在线视频| 国产亚洲激情在线| 亚洲国产精品黑人久久久| 国产精品久久久久毛片软件| 老司机aⅴ在线精品导航| 欧美精品一区在线播放| 欧美在线观看日本一区| 欧美成人高清视频| 久久久久国产精品厨房| 欧美调教vk| 亚洲国产精品久久91精品| 国产欧美一区二区三区视频 | 亚洲高清毛片| 国产欧美日韩综合一区在线观看 | 亚洲欧洲一区二区三区| 亚洲理论在线观看| 韩国一区电影| 亚洲一级片在线看| 日韩视频一区二区三区在线播放免费观看| 亚洲伊人第一页| 99视频精品在线| 另类av导航| 久久久九九九九| 久久国产色av| 国产精品三级视频| 亚洲啪啪91| 亚洲激情av在线| 久久久久一区二区三区四区| 香蕉久久夜色精品国产| 欧美日韩国产免费| 亚洲高清影视| 99re在线精品| 欧美亚洲综合另类| 亚洲第一黄网| 女人天堂亚洲aⅴ在线观看| 欧美日韩另类视频| 欧美国产一区二区在线观看| 国内精品99| 先锋影音久久久| 亚洲欧美自拍偷拍| 国产精品久久一级| 亚洲大胆女人| 夜夜嗨av色一区二区不卡| 久久这里只有精品视频首页| 久久久精品日韩| 国产日韩在线一区| 欧美一区亚洲二区| 久久国产精品一区二区三区四区 | 在线电影院国产精品| 亚洲欧洲精品成人久久奇米网| 伊人成人在线视频| 久久久91精品国产一区二区精品| 欧美一区二区在线看| 国产日韩亚洲| 久久都是精品| 欧美成年视频| 一区二区三区免费网站| 国产精品国产精品| 欧美a级在线| 揄拍成人国产精品视频| 欧美mv日韩mv国产网站app| 亚洲黄一区二区三区| 一区二区av在线| 国产精品久久久久久超碰| 亚洲综合好骚| 国产精品大片wwwwww| 国产美女诱惑一区二区| 国产精品美女久久久免费| 在线免费观看欧美| 欧美chengren| 亚洲深夜福利在线| 欧美在线播放一区| 在线播放一区| 欧美人妖另类| 午夜精品999| 亚洲二区在线视频| 欧美成人三级在线| 日韩午夜三级在线| 欧美一区视频| 国产欧美欧洲在线观看| 欧美制服丝袜| 亚洲欧洲日产国产网站| 好吊一区二区三区| 欧美日韩视频在线| 久久精品视频在线观看| 久久久久久久999精品视频| 国产午夜精品久久久久久免费视 | 很黄很黄激情成人| 欧美精品二区三区四区免费看视频| 一区二区不卡在线视频 午夜欧美不卡在 | 久久免费高清视频| 日韩一区二区精品葵司在线| 国产精品国产a级| 久久精品青青大伊人av| 亚洲乱码一区二区| 欧美电影免费观看高清完整版| 一区二区三区国产在线观看| 久久国产婷婷国产香蕉| 亚洲精品久久久久久久久久久久 | 亚洲国产精品va在线看黑人| 欧美.com| 开心色5月久久精品| 午夜精品久久久久久久99黑人| 亚洲国产精品久久久久婷婷884| 99在线精品免费视频九九视| 欧美日韩国产三级| 免费看成人av| 久久久.com| 欧美一区二区三区视频| 亚洲一级片在线观看| 99re成人精品视频| 亚洲国产精品成人va在线观看| 久久久不卡网国产精品一区| 亚洲在线中文字幕| 亚洲视频www| 一道本一区二区| 在线观看国产成人av片| 国产精品综合色区在线观看| 国产精品久久久久高潮| 欧美视频在线观看 亚洲欧|