Posted on February 24th, 2015
Posted on February 23rd, 2015
Posted on January 26th, 2015
Posted on January 15th, 2015
Visual Studio builds 32-bit applications by default, so no action is required on that front.
/Ziflag to the Visual Studio compiler. From the IDE, Press Alt-F7 to bring up the configuration properties of your build target. Under "Configuration Properties | C/C++ | General", the "Debug Information Format" entry should either say "Program Database (/Zi)" or "Program Database for Edit and Continue (/ZI)". Additionally, under "Configuration Properties | Linker | Debugging", the "Generate Debug Info" entry should say "Yes (/DEBUG)".
/Ob0parameter. In the Visual Studio IDE, press Alt-F7 and then under "Configuration Properties | C/C++ | Optimization" ensure "Inline Function Expansion" says "Disabled (/Ob0)".
Oy-parameter. In the Visual Studio IDE, press Alt-F7 and then under "Configuration Properties | C/C++ | Optimization" ensure "Omit Frame Pointers" says "No (/Oy-)".
All combinations of the debug or release C library, linked statically or dynamically, are supported. When using static versions of msvcrt (the
/MT flags), if your application does not have symbols then Dr. Memory will not be able to identify memory allocation calls, which may lead to false positives and/or false negatives. Be sure to build with debugging information included using the instructions above.
The debug C library (specified with the
/MTd flags) contains its own redzone and heap error checks. Dr. Memory completely replaces these checks with its own, more complete checks.
The Visual Studio compiler's
/RTC1 flag can prevent Dr. Memory from reporting uninitialized reads of local variables, and the
/RTC1 checks for uninitialized reads themselves may not catch everything that Dr. Memory finds. However,
/RTC1 does perform additional stack checks that Dr. Memory does not, so for best results, your application should be run under Dr. Memory without
/RTC1, and run natively with
In the Visual Studio IDE, press Alt-F7 and then under "Configuration Properties | C/C++ | Code Generation" ensure "Basic Runtime Checks" says "Default".
Here is a sample command line for Visual Studio:
cl /Zi /MT /EHsc /Oy- /Ob0 /Femyapp.exe *.cpp
Dr. Memory has support for running within the Visual Studio IDE as an External Tool. The Windows installer automatically creates a new Tools menu entry for launching Dr. Memory for each version of Visual Studio detected at install time. If you are using a local install, or if you installed Visual Studio after installing Dr. Memory, or if you are using Visual Studio Express 2010 and it was in Basic mode at the time you installed Dr. Memory, you will need to follow the following instructions in order to add Dr. Memory as an External Tool.
If using Visual Studio Express 2010, first enable the full menu system by selecting
Tools | Settings | Expert Settings (this step is not necessary for Visual Studio Professional or later versions of Visual Studio Express).
Next, for Visual Studio 2005 through 2012, select the
Tools | External Tools... menu option to open the External Tools dialog box. Click Add and fill in the fields as follows (adjusting the path to
drmemory.exe if you installed it somewhere else):
Title: Dr. Memory Command: C:\Program Files (x86)\Dr. Memory\bin\drmemory.exe Arguments: -visual_studio -- $(TargetPath) Initial Directory: $(TargetDir)
Use Output window checkbox. Click OK.
For Visual Studio 6, select
Tools | Customize, then the
Tools tab, and then click the
New button. Fill in the fields as above, though the
Title field is instead the input box in the main list. Also, you'll want quotes around the TargetPath variable (but you do not want quotes for any later Visual Studio version):
Command: C:\Program Files\Dr. Memory\bin\drmemory.exe Arguments: -visual_studio -- "$(TargetPath)" Initial Directory: $(TargetDir)
Now you can select
Tools | Dr. Memory and Visual Studio will run your application. The output of Dr. Memory (along with your program) will be printed to the Output Window. You can double-click on a source file on any callstack frame in order to automatically open up that file to the line number indicated.
To pass arguments to your application, in the External Tools dialog box entry for Dr. Memory, either directly add them for all runs, or check the "Prompt for arguments" checkbox to be prompted for arguments on each invocation. Add application arguments at the end, after the pre-filled-in string:
-visual_studio -- $(TargetPath) ADD ARGUMENTS HERE
Posted on January 14th, 2015
길게 쓰진 못하지만 sns에 남기긴 좀 그런 글을 정리하는 곳.