Did you know…

Have you ever seen the following window before? It was once very popular in the good old days, but has been abandoned in recent years (another good example being the pixel fonts). People just keep getting busier in the blooming new era. Windows 7 Shift + Right Click on a file icon would give you additional…


MACRO Revisited

Macro is powerful, but few people understand how it works. In theory, syntax highlighting for C/C++ is impossible due to the presence of Preprocessing Directives FDIS N3290 16 . Sometimes I do feel that C++ is a mixture of three languages instead of a single language, I have to keep in mind that there are…

2

Pop Quiz – Debug Event Loop and Timeslice Quota

You might have heard of the Popek and Goldberg Virtualization Requirements. In theory, debugger shares a similar set of problems as virtualization, this is especially true for func-eval (Function Evaluation). Here goes a pop quiz about the side effects of the presence of debugger: #define WIN32_LEAN_AND_MEAN #include <Windows.h> #define LOOPCOUNT 10 ULONG g_ulVariableA; ULONG g_ulVariableB; DWORD WINAPI ThreadProcA(LPVOID lpParameter) {   while(true)   {     for(int i = LOOPCOUNT; i; i–)       ++g_ulVariableA;   } // add a breakpoint here (BP1)  return 0; }…


Microsoft Binary Technologies and Debugging

Midway upon the journey of our life I found myself within a forest dark, For the straightforward pathway had been lost. [INFERNO CANTO 1] In the world of debugging, one could easily get lost without sufficient knowledge of the underlying mechanism. While well known examples being DLL (Dynamic-Link Libraries), FPO (Frame-Pointer Omission), LTCG (Link-time Code Generation),…


A Debugging Approach to IFEO

IFEO (Image File Execution Options) is a feature provided by the NT based operating system. It can be helpful when you are trying to debug at the very beginning of an application launch. A few people also taked about IFEO on MSDN Blogs: Image File Execution Options by Junfeng. Inside ‘Image File Execution Options’ debugging…

2

A Debugging Approach to OutputDebugString

Using OutputDebugString is a common debugging technique for user mode debugging. It is easy but quite useful if you are debugging services or trouble shooting loader problem. #define WIN32_LEAN_AND_MEAN #include <Windows.h> int __cdecl main() {   OutputDebugStringA(“Hello, world! (first chance)\n”);   OutputDebugStringW(L”Hello, world! (second chance)\n”); } When you debug this demo application using Visual Studio, you would see the text messages from the Output window: And if you…


Debugging Tips for Multi-Threaded Application

Multi-threaded applications are error-prone and hard to debug, so it’s worth a dedicated topic. I will try to maintain a list of tips for debugging multi-threaded application using Visual Studio and WinDBG. Below is a trivial multi-threaded application which will be used as an example: #define WIN32_LEAN_AND_MEAN #include <Windows.h> DWORD WINAPI ThreadProc(LPVOID lpParameter) {   return 0; // add breakpoint here} int __cdecl main() {   HANDLE hThread = CreateThread(NULL, 4096, ThreadProc, NULL, 0, NULL);   if(hThread)   {…


Visual Studio Debugger or WinDBG?

Microsoft has provided a number of debuggers. Visual Studio Debugger would be the most widely known one, while there is a less known tool set called Debugging Tools for Windows which is available for free. Even inside Microsoft, there were questions around why having so many debuggers, and which one to use. A quick answer is,…


Data Breakpoints

The Visual Studio debugger supports a kind of breakpoint called Data Breakpoint, sometimes it is also called watchpoint. Data breakpoint is architecture dependant, as it requires hardware support provided by CPU. For x86, this will be the DR (Debug Register). The following code demonstrates how to use the x86 debug register by implementing a very simple native debugger. #define WIN32_LEAN_AND_MEAN #include <Windows.h> #include <stdio.h>…

2

Hello, world…

Yet another Hello World… Well, my name is Reiley Yang. I’m a developer working on the Visual Studio debugger. I would like to use this technical blog to share my understanding of debuggers. Previously I have also been working on the C++ libraries (ATL, CRT, MFC, STL) and compiler front-end, so I will probably also…