国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 編程 > C++ > 正文

Debugging Tips and Tricks for C++ in Visual Studio

2019-11-06 06:18:43
字體:
來源:轉載
供稿:網友

Visual C++ Team Blog

July 11, 2016 by Andrew B Hall - MSFT // 33 Comments

When we write software our goal is to create correctly functioning applications the first time. Unfortunately, it rarely works that way and we spend a significant amount of time and effort debugging PRoblems in the code rather than adding new value. Fortunately, when issues arise that need investigation Visual Studio ships a world class debugging experience to help find the issue quickly. However, many of us don’t take full advantage of the debugger because we don’t know or simply forget about many of the capabilities it offers to speed up problem solving.

In this post I’ll provide a brief overview the debugging features I showed in a recent C++ Debugging Tips and Tricks video. It certainly doesn’t cover everything but each capability is linked to more detailed information if you want to dive deeper. Additionally, each tip contains a direct link to the exact point in the video I show it.

So go through the following 22 tips and let us know how many of these are new to you – is there anybody that knew all of them? Which one is your favorite?

Finally, before you continue please take a minute to sign up to help us continue to improve the debugger to better meet your needs.

Tips and Tricks

Configuring launch options from project properties (1:25). One common pattern when developing software is to add configuration options to change behavior or test alternate designs based on either command line or environment variable settings. You can configure both command line parameters and set environment variables for the target application on the “Debugging” tab of the Project Properties page (Right click on the project in Solution Explorer and choose “Properties” from the context menu.

Function return values (2:34). When stepping through code in the debugger, the Autos window shows you the values returned by all functions called on the previous line of code.

clip_image002

Set next statement (3:16) enables you to change the next instruction in the application that will execute. This is great for going back and re-running a piece of that that just executed, or can be useful for forcing the application down different code paths to test functionality (e.g. you can move execution inside of a conditional block even if the condition evaluates to false). You can change the next statement by either click and dragging the yellow instruction pointer in the left margin to the desired line, access it through the context menu by right clicking on the desired line and choosing “Set Next Statement” from the context menu, or by using the keyboard shortcut Ctrl+Shift+F10 to set the next statement to line the cursor is on. It is important to note that this simply changes the next instruction that will execute, it does not undo anything that happened previously or run code if you move it forward, for example, if you skip a line of code that initializes a variable using set next statement, the application will crash since the variable will remain initialized.

Step into specific (4:07) allows you to step directly into a function when there are multiple function calls on the same line without the need to navigate to the definition, set a breakpoint, and then continue execution to hit the breakpoint. Step Into Specific can be access from the editor’s context menu by right clicking on the current line, or using the keyboard shortcut Shift+Alt+F11

Run to cursor (5:05) functions as a onetime use breakpoint, by running the debugger to that line and then stopping at that point. Run to cursor can be accessed from both the editor context menu or by using the keyboard shortcut Ctrl+F10 to run to the line the cursor is on. Another useful tip for Run To Cursor is even at design time (when you’re not debugging) the keyboard shortcut Ctrl+F10 will start debugging and run the application to that line of code just like you set a breakpoint and hit F5.

Edit and Continue (6:57) is one of the great productivity time savers when debugging code. If you notice a simple mistake you can correct it while stopped in the debugger without the need to stop debugging, recompile, and run the application back to that location. In Visual Studio 2015 we added support for Edit and Continue into the default C++ debug engine including support for x64 debugging.

Exception Settings (8:31) configure the debugger to stop when specified exceptions are thrown, even if they will later be caught in the application. This is useful when debugging issues where the application is handling the exception but you need to debug why the exception is happening.

Conditional, Hit Count, and Filter Breakpoints (13:44). A Conditional Expression tells the debugger to stop only when a certain condition in the application is met (e.g. when a variable matches a certain string). A Hit Count enables you to break based on the number of times the breakpoint has been hit when equal to an absolute number, equal to or greater, or when the count is a multiple of the number; which is useful if you need to take a sampling based approach to solving an issue (e.g. only show every 100th value). Filter conditions are designed for parallel processing scenarios and enable you to stop when executing on a certain thread, process, or machine.

clip_image004

Pinning DataTips (19:17) when working inside an iterative code path (e.g. for loop) you’re often focused on a single value. Inspecting variables by hovering over them in the editor is great but the DataTips disappear when you move the mouse. By clicking the “pin icon” on the far right side of the DataTip you can “stick” it to the editor so it stays visible on that line of source code until you choose to close it.

clip_image006

Parallel Stacks window (19:42) shows you the call stacks of all of the threads in the process in a concise view. The Parallel Stacks window is opened through the Debug -> Windows menu.

clip_image008

Show External Code (20:30). Visual Studio by default enables a feature we call Just My Code that helps you focus on the code you control by collapsing Operating system and runtime frames on the call stack into a single [External Code] frame. I you want or need to see the complete stack, you can right click in either the Call Stack or Parallel Stacks window to show the complete call stack. If you prefer to debug with this always off, you can permanently disable Just My Code under Debug -> Options

Parallel Watch window (22:00) shows the value of a variable across all threads executing in the current function. It also will show the value of the same variable across stack frames in the case of a recursive method.

clip_image010

Freeze and Thaw threads (23:13) gives you fine grained control over the execution of individual threads. If a particular thread is problematic but you don’t want other threads running while your debugging a single thread you can freeze the threads you don’t want running. When frozen they do not execute any code even when you resume execution of the application.

Flag Threads and Run Flagged Threads to Cursor (24:18) flagging threads enables you to create groups of threads, and then just like Run to Cursor enables you to run the application to a specific line of code, Run Flagged Threads to Cursor enables you to move a group of threads to a specific line. This can be very useful in situations where you need to control the location of certain threads (e.g. to make sure that none of them are holding a lock and then freeze them).

Show Threads in Source (26:13) is a setting that enables you to see what threads are executing with a small glyph in the breakpoint margin. To turn it on, click the “Show Threads in Source” button the debugger toolbar (shown below).

clip_image012

This feature is incredibly powerful when working in code that is running in parallel, but does come at a small performance cost so shouldn’t be left on indefinitely when you’re not using it.

clip_image014

Debug Location toolbar (28:09) is a toolbar that gives you access to the current call stack and the ability to quickly switch between threads among other capabilities. It is visible by default if you use the “General Settings” profile, otherwise you’ll need to manually enable it through View -> Toolbars.

Debugging Heap Corruption with PageHeap (29:43). Heap corruption can be one of the most difficult types of bugs to solve, since the logic error that resulted in the corruption usually occurs long before the application crashes or behaves strangely making it hard to diagnose the location the issue occurs at. PageHeap is a capability in Windows that causes in the operating system to raise an exception if the application either writes to or reads from memory it no longer owns resulting in heap corruption causing the debugger to stop at the location causing the heap corruption. Enabling page heap currently requires using the gflags utility built into the Debugging Tools for Windows as part of the Windows SDK. Once you’ve installed the Debugging Tools for Windows, open an administrative command prompt and run gflags /p /enable [executable name] to enable PageHeap, then debug the application in Visual Studio like normal. A quick Word of caution, PageHeap causes Windows to do more memory tracking, so it slows down the speed of the application it is enabled for, so you shouldn’t leave this on indefinitely if not debugging heap corruption.

clip_image016

PerfTips (33:32) shows you the time your code was executing between stops in the debugger (both when stepping over code and running between breakpoints).

clip_image018

Integrated CPU Profiling (35:53) when writing code, often we do all we can to get it working correctly and it can be difficult or impossible to take the time to profile it separately. To improve the convenience of quickly finding major issues in performance we’ve integrated a CPU profiler into the debugger, that can be access through the Diagnostic Tools window.

Integrated Memory Profiling (38:01) tracking down memory leaks can be hard. To make this easy as possible we’ve integrated memory profiling tools designed to help find and fix leaks directly in to the debugger through the Diagnostic Tools window. By integrating it directly into the debugger, you have fine grained control over where you take snapshots, meaning you look at the memory changes introduced by a single function call or a single line of code.

clip_image020

Natvis (41:03) lets you customize the way Visual Studio displays native types in the debugger. In Visual Studio 2015 we added support for adding project local natvis files, that take effect in the debugger as soon as they are updated, no need to restart debugging.

Showing what source code causes an Access Violation (42:43) frequently a single line of code will deference multiple pointers, which results in hunting for exactly which pointer triggered an access violation. In Visual Studio 2015 Update 1 we added analysis logic into the debugger to show you the exact source expression that triggered the Access Violation.

clip_image022


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
亚洲欧美日韩综合精品网| 国产亚洲精品拍拍拍拍拍| gogogogo高清视频在线| 高潮白浆视频| 中文字幕在线免费看| www在线视频| 日本动漫理论片在线观看网站| 精品女厕厕露p撒尿| 国产不卡在线| 久久亚洲资源| 国产中文字幕在线观看| 国产一卡二卡3卡4卡四卡在线| 天堂在线免费观看| 精品国产一区二区三区四区阿崩| 91免费日韩| 日本黄色免费网址| 国产乱妇乱子| 国产精品入口麻豆完整版| 国产精品视频一区二区免费不卡| 国产区成人精品视频| 91麻豆精品国产91久久| 亚洲国产精华液| 黄色毛片在线看| 91这里只有精品| 国产精品入口麻豆免费| 亚洲精品在线视频免费| 国产在线一区二区视频| 国产精品yjizz视频网一二区| 伊人免费视频| 中文字幕在线观看av| 国产精品国精产品一二| 国产麻豆一区二区三区精品| 美女国产在线| 国产三级在线免费观看| 欧美专区日韩| 国产高清免费av在线| 黄色av免费在线| 中文资源在线网| 国产精品入口麻豆免费| h网站免费在线观看| 国产网友自拍视频导航网站在线观看| 在线观看av资源网| 国产福利在线视频| 国产精选在线视频拍拍拍| jizz国产| 毛片视频免费观看| аⅴ成人天堂中文在线| 亚洲视频网站在线| 国产高清一级片| 国产日产一区二区| 91福利在线免费| 国产在线视频网站| 国产精品一二三区视频| 成人精品福利| 国产在线麻豆精品| 国产主播色在线| 91caoporn在线| 国产在线更新| 国产青草视频在线观看视频| 福利在线国产| 国产二级片在线| av福利在线| 国产视频精选在线| 国产精品一区二区三区视频网站 | 怡红院av在线| 精品一区二区三区在线成人| 国产精品粉嫩av| 国产福利免费观看| 日本亚洲欧美| 国产毛片视频| 国产二级片在线| 久草福利资源在线视频| 天堂中文资源在线| 在线观看中文字幕一区| 老司机精品视频一区二区| 成人无遮挡免费网站视频在线观看| 好看的中文字幕在线播放| 国产亚洲精品一区二区在线观看| 成人精品福利| 一本久中文高清| www.蜜桃av| 国产精品777一区二区| 9999在线视频| 中文字幕2020第一页| 国产精品久久精品牛牛影视| 精品中文字幕不卡在线视频| 国产黄色免费网| 91麻豆精品国产91久久| 国产视频二区| 欧美一级久久久久久久久大| 国产污视频在线| 久草一本av| 非洲黑人最猛性xxxx交| ·天天天天操| 国产免费麻豆视频| 四虎成人欧美精品在永久在线| 国产亚洲依依| 最新国产在线精品91尤物| 中文av在线播放| 日韩av成人| 国产亚洲精品一区二区在线观看| 麻豆电影传媒二区| www.夜夜操| 男女羞羞视频在线观看| 中文岛国精品亚洲一区| 9999在线视频| 国产极品美女到高潮| 最新亚洲精品国自产在线观看| 久久这里精品| 中文字幕第一页在线| 国产伦精品一区二区三区高清版禁| 亚洲高清在线免费| 久久综合精品视频| 国产亚洲精品久久久久久青梅 | 精品中文字幕不卡在线视频| 在线观看中文字幕一区| 中文字幕av网| 午夜av电影| 久久精品视频免费看| 69国产精品视频| 国产精品视频一区二区图片| 国产永久免费高清在线观看| 丁香花视频在线观看| 精品一二三区视频| 中文字幕在线免费看| 国产在线色视频| 中文字幕在线观看日本| 国产香蕉在线| 97最新国自产拍视频在线完整在线看 | 国产区视频在线| 日本三级在线视频| 亚洲电影先锋| 国产精品久久久精品a级小说| 精品欧美不卡一区二区在线观看| 国产又色又爽又黄刺激在线视频| 日本黄色免费网址| 国产亚洲精品一区二区在线观看 | 精品电影在线| 久草视频国产| 永久免费av网站| 欧洲亚洲精品视频| 国产深夜福利| 国产桃色电影在线播放| 国产三级在线| 精品极品三级久久久久| 国产农村av| 在线免费观看污| 中文字幕在线资源| 男人天堂亚洲| 中文字幕4区| 天天操天天操天天色天天要| av在线天堂| 国产激情自拍| 国产鲁鲁视频在线观看特色| 精品日韩av| 国产精品伦一区二区三区视频| 天堂中文字幕在线| 在线视频三级| 精品国产一区二区三区不卡在线 | 超碰国产在线| 午夜在线网站| 亚洲综合天堂网| 国产91大片| 亚洲精品aaaa| 久草视频国产| 国产寡妇树林野战在线播放| 欧美精品se| 国产激情视频在线| 国产一二三区在线视频| www在线观看播放免费视频日本| 国产福利电影在线| 在线观看av网站| 国产一区二区在线|播放| 精品国语对白精品自拍视| 在线伊人免费视频| 国产黄色片在线观看| 在线免费观看黄色av| 国产高清在线观看| 国产在线高清| 高清av中文在线字幕观看1| 国产中文在线观看| 欧美a免费在线| 免费在线观看a| 国产在线黄色片| √天堂8资源中文在线| 精品一区二区三区免费站| 国产视频青青| 免费在线超碰| 热99re久久精品这里都是免费| www黄在线观看| 91激情在线| 精品欧美日韩一区二区| 国产一级免费在线观看| 91xxx在线观看| 波多野结衣中文字幕久久| 青青国产在线| 成人av小说网| 69久久久久| 国产l精品国产亚洲区在线观看| 中文岛国精品亚洲一区|