久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='rrfVR'></bdo><ul id='rrfVR'></ul>
    1. <legend id='rrfVR'><style id='rrfVR'><dir id='rrfVR'><q id='rrfVR'></q></dir></style></legend>
      <tfoot id='rrfVR'></tfoot>

    2. <small id='rrfVR'></small><noframes id='rrfVR'>

    3. <i id='rrfVR'><tr id='rrfVR'><dt id='rrfVR'><q id='rrfVR'><span id='rrfVR'><b id='rrfVR'><form id='rrfVR'><ins id='rrfVR'></ins><ul id='rrfVR'></ul><sub id='rrfVR'></sub></form><legend id='rrfVR'></legend><bdo id='rrfVR'><pre id='rrfVR'><center id='rrfVR'></center></pre></bdo></b><th id='rrfVR'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rrfVR'><tfoot id='rrfVR'></tfoot><dl id='rrfVR'><fieldset id='rrfVR'></fieldset></dl></div>

      “跨過"在 Visual Studio 中調(diào)試多線程程序時

      quot;Step overquot; when debugging multithreaded programs in Visual Studio(“跨過在 Visual Studio 中調(diào)試多線程程序時)

      <small id='ZiwuF'></small><noframes id='ZiwuF'>

        <bdo id='ZiwuF'></bdo><ul id='ZiwuF'></ul>
              <tbody id='ZiwuF'></tbody>

          • <tfoot id='ZiwuF'></tfoot>

              <legend id='ZiwuF'><style id='ZiwuF'><dir id='ZiwuF'><q id='ZiwuF'></q></dir></style></legend>
              • <i id='ZiwuF'><tr id='ZiwuF'><dt id='ZiwuF'><q id='ZiwuF'><span id='ZiwuF'><b id='ZiwuF'><form id='ZiwuF'><ins id='ZiwuF'></ins><ul id='ZiwuF'></ul><sub id='ZiwuF'></sub></form><legend id='ZiwuF'></legend><bdo id='ZiwuF'><pre id='ZiwuF'><center id='ZiwuF'></center></pre></bdo></b><th id='ZiwuF'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZiwuF'><tfoot id='ZiwuF'></tfoot><dl id='ZiwuF'><fieldset id='ZiwuF'></fieldset></dl></div>
                本文介紹了“跨過"在 Visual Studio 中調(diào)試多線程程序時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                在 Visual Studio(在我的例子中是 2005)中調(diào)試程序時讓我煩惱的一件事是,當我使用step over"(通過按 F10)執(zhí)行到下一行代碼時,我經(jīng)常最終在與我正在查看的線程完全不同的線程中到達特定的代碼行.這意味著我正在做的事情的所有上下文都丟失了.

                我該如何解決這個問題?

                如果這可以在更高版本的 Visual Studio 中實現(xiàn),我也想了解一下.

                在下一行代碼上設置一個斷點,它有條件只為這個線程中斷不是我正在尋找的答案,因為它對我來說太有用了:)

                解決方案

                我認為您的問題只有一個答案,您認為這是工作量太大".但是,我相信這是因為您以錯誤的方式進行操作.讓我介紹在線程 ID 上添加條件斷點的步驟,這些步驟非常簡單,但在您了解它們之前并不明顯.

                1. 在您要繼續(xù)調(diào)試的正確線程中停止調(diào)試器(我猜這通常是到達那里的第一個線程).

                2. 在監(jiān)視窗口中輸入 $TID.

                3. 添加一個斷點,條件為$TID == <觀察窗口中$TID的值>
                  示例:$TID == 0x000016a0

                4. 繼續(xù)執(zhí)行.

                $TID 是 Microsoft 編譯器(至少從 Visual Studio 2003 起)的魔術變量,具有當前線程 ID 的值.它比查看 (FS+0x18)[0x24] 容易得多.=D

                話雖如此,您可以使用一些簡單的宏獲得與調(diào)試器的 One-Shot 斷點相同的行為.當您跳過時,調(diào)試器在后臺設置一個斷點,運行到該斷點,然后將其刪除.保持用戶界面一致的關鍵是在遇到任何斷點時刪除這些斷點.

                以下兩個宏為當前線程提供Step OverRun To Cursor.這是以與調(diào)試器相同的方式完成的,執(zhí)行后斷點將被刪除,無論命中哪個斷點.

                您需要分配一個組合鍵來運行它們.

                <塊引用>

                注意:一個警告——Step Over 宏只有在光標位于您想要跳過的行上時才能正常工作.這是因為它通過光標位置確定當前位置,并簡單地將行號加一.您也許可以用當前執(zhí)行點的信息替換位置計算,但我無法從宏 IDE 中找到該信息.

                他們來了,祝你好運!

                <塊引用>

                要在 Visual Studio 中使用這些宏:
                1. 打開宏 IDE(從菜單中選擇:Tools->Macros->Macro IDE...)
                2. 添加一個新的代碼文件(從菜單中:選擇:Project->Add New Item...,選擇Code File,然后點擊Addem> )
                3. 粘貼此代碼.
                4. 保存文件.

                添加組合鍵以在 Visual Studio 中運行這些宏:
                1. 打開選項(從菜單中選擇:工具->選項)
                2. 展開到Environment->Keyboard
                3. 在 Show commands contains: 中,輸入 Macros. 以查看您的所有宏.
                4. 選擇一個宏,然后點擊按快捷鍵:
                5. 輸入您要使用的組合(退格鍵刪除輸入的組合)
                6. 點擊Assign設置運行所選宏的快捷方式.

                導入系統(tǒng)進口 EnvDTE進口 EnvDTE80導入系統(tǒng).診斷公共模塊 DebugHelperFunctions子 RunToCursorInMyThread()Dim textSelection As EnvDTE.TextSelection將 myThread 調(diào)暗為 EnvDTE.ThreadDim bp As EnvDTE.BreakpointDim bps As EnvDTE.Breakpoints' 對于 Breakpoints.Add()將文件名變暗為字符串Dim LineNumber 作為整數(shù)Dim ThreadID 作為字符串' 獲取本地參考以方便使用myThread = DTE.Debugger.CurrentThreadtextSelection = DTE.ActiveDocument.SelectionLineNumber = textSelection.ActivePoint.Line文件名 = textSelection.DTE.ActiveDocument.FullName線程ID = myThread.ID' 在當前文件的當前行中為當前線程添加一個一次性"斷點bps = DTE.Debugger.Breakpoints.Add("", FileName, LineNumber, 1, "$TID == " & ThreadID)'跑到下一站DTE.Debugger.Go(真)' 刪除我們的一次性"斷點對于每個 bp 在 bpsbp.Delete()下一個結束子子 StepOverInMyThread()Dim textSelection As EnvDTE.TextSelection將 myThread 調(diào)暗為 EnvDTE.ThreadDim bp As EnvDTE.BreakpointDim bps As EnvDTE.Breakpoints' 對于 Breakpoints.Add()將文件名變暗為字符串Dim LineNumber 作為整數(shù)Dim ThreadID 作為字符串' 獲取本地參考以方便使用myThread = DTE.Debugger.CurrentThreadtextSelection = DTE.ActiveDocument.SelectionLineNumber = textSelection.ActivePoint.Line文件名 = textSelection.DTE.ActiveDocument.FullName線程ID = myThread.ID行號 = 行號 + 1' 在當前文件的當前行中為當前線程添加一個一次性"斷點bps = DTE.Debugger.Breakpoints.Add("", FileName, LineNumber, 1, "$TID == " & ThreadID)'跑到下一站DTE.Debugger.Go(真)' 刪除我們的一次性"斷點對于每個 bp 在 bpsbp.Delete()下一個結束子終端模塊

                <塊引用>

                免責聲明:我在 Visual Studio 2005 中編寫了這些宏.您可能可以在 Visual Studio 2008 中很好地使用它們.它們可能需要針對 Visual Studio 2003 及更早版本進行修改.

                One thing that annoys me when debugging programs in Visual Studio (2005 in my case) is that when I use "step over" (by pressing F10) to execute to the next line of code, I often end up reaching that particular line of code in a totally different thread than the one I was looking at. This means that all the context of what I was doing was lost.

                How do I work around this?

                If this is possible to do in later versions of Visual Studio, I'd like to hear about it as well.

                Setting a breakpoint on the next line of code which has a conditional to only break for this thread is not the answer I'm looking for since it is way too much work to be useful for me :)

                解決方案

                I think there is only one answer to your question, which you have discounted as being 'way too much work.' However, I believe that is because you are going about it the wrong way. Let me present steps for adding a conditional breakpoint on Thread ID, which are extremely easy, but not obvious until you know them.

                1. Stop the debugger at a point where you are in the correct thread you want to continue debugging in (which I would guess is usually the first thread that gets there).

                2. Enter $TID into the watch window.

                3. Add a break point with the condition $TID == <value of $TID from Watch Window>,
                  Example: $TID == 0x000016a0

                4. Continue Execution.

                $TID is a magic variable for Microsoft compilers (since at least Visual Studio 2003) that has the value of the current Thread ID. It makes it much easier than looking at (FS+0x18)[0x24]. =D

                That being said, you can get the same behavior as the debugger's One-Shot breakpoints with some simple macros. When you step over, the debugger, behind the scenes, sets a breakpoint, runs to that breakpoint and then removes it. The key to a consistent user interface is removing those breakpoints if ANY breakpoint is hit.

                The following two macros provide Step Over and Run To Cursor for the current thread. This is accomplished in the same manner as the debugger, with the breakpoints being removed after execution, regardless of which breakpoint is hit.

                You will want to assign a key combination to run them.

                NOTE: One caveat -- The Step Over macro only works correctly if the cursor is on the line you want to step over. This is because it determines the current location by the cursor location, and simply adds one to the line number. You may be able to replace the location calculation with information on the current execution point, though I was unable to locate that information from the Macro IDE.

                Here they are and good luck bug hunting!!

                To use these macros in Visual Studio:
                1. Open the Macro IDE ( from the Menu, select: Tools->Macros->Macro IDE... )
                2. Add a new Code File ( from the Menu: select: Project->Add New Item..., choose Code File, and click Add )
                3. Paste in this code.
                4. Save the file.

                To add key combinations for running these macros in Visual Studio:
                1. Open Options (from the Menu, select: Tools->Options )
                2. Expand to Environment->Keyboard
                3. In Show commands containing:, type Macros. to see all your macros.
                4. Select a macro, then click in Press shortcut keys:
                5. Type the combo you want to use (backspace deletes typed combos)
                6. click Assign to set your shortcut to run the selected macro.

                Imports System
                Imports EnvDTE
                Imports EnvDTE80
                Imports System.Diagnostics
                
                Public Module DebugHelperFunctions
                
                    Sub RunToCursorInMyThread()
                        Dim textSelection As EnvDTE.TextSelection
                        Dim myThread As EnvDTE.Thread
                        Dim bp As EnvDTE.Breakpoint
                        Dim bps As EnvDTE.Breakpoints
                
                        ' For Breakpoints.Add()
                        Dim FileName As String
                        Dim LineNumber As Integer
                        Dim ThreadID As String
                
                        ' Get local references for ease of use 
                        myThread = DTE.Debugger.CurrentThread
                        textSelection = DTE.ActiveDocument.Selection
                
                        LineNumber = textSelection.ActivePoint.Line
                        FileName = textSelection.DTE.ActiveDocument.FullName
                        ThreadID = myThread.ID
                
                        ' Add a "One-Shot" Breakpoint in current file on current line for current thread
                        bps = DTE.Debugger.Breakpoints.Add("", FileName, LineNumber, 1, "$TID == " & ThreadID)
                
                        ' Run to the next stop
                        DTE.Debugger.Go(True)
                
                        ' Remove our "One-Shot" Breakpoint
                        For Each bp In bps
                            bp.Delete()
                        Next
                    End Sub
                
                    Sub StepOverInMyThread()
                        Dim textSelection As EnvDTE.TextSelection
                        Dim myThread As EnvDTE.Thread
                        Dim bp As EnvDTE.Breakpoint
                        Dim bps As EnvDTE.Breakpoints
                
                        ' For Breakpoints.Add()
                        Dim FileName As String
                        Dim LineNumber As Integer
                        Dim ThreadID As String
                
                        ' Get local references for ease of use 
                        myThread = DTE.Debugger.CurrentThread
                        textSelection = DTE.ActiveDocument.Selection
                
                        LineNumber = textSelection.ActivePoint.Line
                        FileName = textSelection.DTE.ActiveDocument.FullName
                        ThreadID = myThread.ID
                        LineNumber = LineNumber + 1
                
                        ' Add a "One-Shot" Breakpoint in current file on current line for current thread
                        bps = DTE.Debugger.Breakpoints.Add("", FileName, LineNumber, 1, "$TID == " & ThreadID)
                
                        ' Run to the next stop
                        DTE.Debugger.Go(True)
                
                        ' Remove our "One-Shot" Breakpoint
                        For Each bp In bps
                            bp.Delete()
                        Next
                    End Sub
                
                
                End Module
                

                Disclaimer: I wrote these macros in Visual Studio 2005. You can probably use them fine in Visual Studio 2008. They may require modification for Visual Studio 2003 and before.

                這篇關于“跨過"在 Visual Studio 中調(diào)試多線程程序時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Why do two functions have the same address?(為什么兩個函數(shù)的地址相同?)
                Why the initializer of std::function has to be CopyConstructible?(為什么 std::function 的初始化程序必須是可復制構造的?)
                mixing templates with polymorphism(混合模板與多態(tài)性)
                When should I use the keyword quot;typenamequot; when using templates(我什么時候應該使用關鍵字“typename?使用模板時)
                Dependent name resolution amp; namespace std / Standard Library(依賴名稱解析命名空間 std/標準庫)
                gcc can compile a variadic template while clang cannot(gcc 可以編譯可變參數(shù)模板,而 clang 不能)

                1. <legend id='OOsar'><style id='OOsar'><dir id='OOsar'><q id='OOsar'></q></dir></style></legend>

                      • <small id='OOsar'></small><noframes id='OOsar'>

                          <tbody id='OOsar'></tbody>
                          <bdo id='OOsar'></bdo><ul id='OOsar'></ul>
                          <tfoot id='OOsar'></tfoot>
                          <i id='OOsar'><tr id='OOsar'><dt id='OOsar'><q id='OOsar'><span id='OOsar'><b id='OOsar'><form id='OOsar'><ins id='OOsar'></ins><ul id='OOsar'></ul><sub id='OOsar'></sub></form><legend id='OOsar'></legend><bdo id='OOsar'><pre id='OOsar'><center id='OOsar'></center></pre></bdo></b><th id='OOsar'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OOsar'><tfoot id='OOsar'></tfoot><dl id='OOsar'><fieldset id='OOsar'></fieldset></dl></div>
                          主站蜘蛛池模板: 鲁大师一区影视 | 国产在线1区 | 免费99精品国产自在在线 | 亚洲精品一区二区网址 | 日韩精品一区二区三区中文在线 | 在线播放中文字幕 | 久久国产精品偷 | 午夜天堂精品久久久久 | 欧美成人精品欧美一级 | 在线观看中文字幕 | 日一区二区 | 青青草视频网站 | 国产伦一区二区三区四区 | 国产精品久久久久999 | 国产一区二区精品自拍 | 夜色www国产精品资源站 | 欧美激情第一区 | 日韩成人免费av | 国产精品视频入口 | 免费在线观看一区二区三区 | 拍真实国产伦偷精品 | 久久精品成人热国产成 | 亚洲精品2区 | 亚洲色欲色欲www | 中文字幕第二区 | 成年人精品视频在线观看 | www.久久| 中文字幕免费中文 | 97精品超碰一区二区三区 | 一区二区精品 | 毛片免费看 | 毛片一区二区三区 | 国产视频1 | 一级a性色生活片久久毛片 午夜精品在线观看 | 欧亚av在线| 国产福利二区 | 免费的日批视频 | 婷婷去俺也去 | 91视频在线观看 | 欧美在线激情 | 日韩一区二区在线看 |