You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/sanitizers/asan.md
+59-59Lines changed: 59 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -144,82 +144,82 @@ To build and run the debugger, press **F5**. An **Exception Thrown** window appe
144
144
145
145
## <aname="ide-cmake"></a> Use AddressSanitizer from Visual Studio: CMake
146
146
147
-
To enable AddressSanitizer for a [CMake project created to target Windows](../build/cmake-projects-in-visual-studio.md), take these steps:
147
+
To enable AddressSanitizer for a [CMake project created to target Windows](../build/cmake-projects-in-visual-studio.md), follow these steps:
148
148
149
149
1. Open the **Configurations** dropdown in the toolbar at the top of the IDE and select **Manage Configurations**.
150
150
151
-
:::image type="content" source="media/asan-cmake-configuration-dropdown.png" alt-text="Screenshot of the CMake configuration dropdown.":::
151
+
:::image type="content" source="media/asan-cmake-configuration-dropdown.png" alt-text="Screenshot of the CMake configuration dropdown. It displays options like x64 Debug, x64 Release, and so on. At the bottom of the list, Manage Configurations... is highlighted.":::
152
152
153
-
That selection opens the CMake Project Settings editor, which reflects the contents of the `CMakeSettings.json` file in your project.
153
+
That opens the CMake Project Settings editor, which reflects the contents of your project's `CMakeSettings.json` file.
154
154
155
155
1. Choose the **Edit JSON** link in the editor. This selection switches the view to raw JSON.
156
156
157
157
1. Add the following snippet to the `"windows-base"` preset, inside `"configurePresets":` to turn on Address Sanitizer:
1. Address sanitizer doesn't work if edit-and-continue is specified (`/ZI`), which is enabled by default for new CMake projects. In `CMakeLists.txt`, comment out (prefix with `#`) the line that starts with `set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT"`. That line looks something like this, afterwards:
1. Clear your CMake cache directory and reconfigure: choose **Project** > **Delete cache and Reconfigure**. Choose **Yes** when the prompt appears to clear your cache directory and reconfigure.
200
-
1. Replace the contents of the cpp file (for example, `CMakeProject1.cpp`) with the following:
201
-
202
-
```cpp
203
-
// CMakeProject1.cpp : Defines the entry point for the application
204
-
205
-
#include <stdio.h>
206
-
207
-
int x[100];
208
-
209
-
int main()
210
-
{
211
-
printf("Hello!\n");
212
-
x[100] = 5; // Boom!
213
-
return 0;
214
-
}
215
-
```
199
+
1. Clear your CMake cache directory and reconfigure by choosing from the Visual Studio menu: **Project** > **Delete cache and Reconfigure**. Choose **Yes** when the prompt appears to clear your cache directory and reconfigure.
200
+
1. Replace the contents of the source file (for example, `CMakeProject1.cpp`) with the following:
201
+
202
+
```cpp
203
+
// CMakeProject1.cpp : Defines the entry point for the application
204
+
205
+
#include <stdio.h>
206
+
207
+
int x[100];
208
+
209
+
int main()
210
+
{
211
+
printf("Hello!\n");
212
+
x[100] = 5; // Boom!
213
+
return 0;
214
+
}
215
+
```
216
216
217
217
1. Choose **F5** to recompile and run under the debugger.
218
218
219
-
This screenshot captures the error from the CMake build.
220
-
221
-
:::image type="content" source="media/asan-cmake-error-f5.png" alt-text="Screenshot of an exception that says: Address Sanitizer Error: Global buffer overflow. In the background, address sanitizer output is visible in command window":::
222
-
219
+
This screenshot captures the error from the CMake build.
220
+
221
+
:::image type="content" source="media/asan-cmake-error-f5.png" alt-text="Screenshot of an exception that says: Address Sanitizer Error: Global buffer overflow. In the background, address sanitizer output is visible in command window":::
We introduced new functionality in AddressSanitizer for use with cloud and distributed workflows. This functionality allows offline viewing of an AddressSanitizer error in the IDE. The error gets overlaid on top of your source, just as you would experience in a live debug session.
0 commit comments