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
{{ message }}
Repository navigation
Commit 79df9d1
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/linux/linux-asan-configuration.md
+27-14Lines changed: 27 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,15 @@
1
1
---
2
2
title: "Configure Linux projects to use Address Sanitizer"
3
3
description: "Describes how to configure C++ Linux projects in Visual Studio to use Address Sanitizer."
4
-
ms.date: "05/29/2019"
4
+
ms.date: "05/31/2019"
5
5
---
6
6
7
7
# Configure Linux projects to use Address Sanitizer
8
8
9
9
In Visual Studio 2019 version 16.1, AddressSanitizer (ASan) support is integrated into Linux projects. You can enable ASan for MSBuild-based Linux projects as well as CMake projects. It works on remote Linux systems and on Windows Subsystem for Linux (WSL).
10
10
11
+
## About ASan
12
+
11
13
ASan is a runtime memory error detector for C/C++ that catches the following errors:
12
14
13
15
- Use after free (dangling pointer reference)
@@ -23,9 +25,31 @@ When ASan detects an error it stops execution immediately. When you run an ASan-
23
25
24
26
You can also view the full ASan output (including where the corrupted memory was allocated/deallocated) in the Debug pane of the output window.
25
27
26
-
## Getting started with ASan in Visual Studio
28
+
## Enable ASan for MSBuild-based Linux projects
29
+
30
+
To enable ASan for MSBuild-based Linux projects,right-click on the project in **Solution Explorer** and select **Properties**. Next, navigate to **Configuration Properties** > **C/C++** > **Sanitizers**. ASan is enabled via compiler and linker flags and requires recompilation in order to work.
31
+
32
+

33
+
34
+
You can pass optional ASan runtime flags by navigating to **Configuration Properties** > **Debugging** > **AddressSanitizer Runtime Flags**. Click the down arrow to add or remove flags.
35
+
36
+

37
+
38
+
## Enable ASan for Visual Studio CMake projects
39
+
40
+
To enable ASan for CMake, right click on the CMakeLists.txt file in **Solution Explorer** and choose open the **CMake Settings for Project**.
41
+
42
+
Make sure you have a Linux configuration (for example **Linux-Debug**) selected in the left pane of the dialog:
To use ASan in Visual Studio, you have to install the debug symbols for ASan (libasan-dbg) on your remote Linux machine or WSL installation. The version of libasan-dbg that you load depends on the version of GCC you have installed on your Linux machine:
46
+
The ASan options are under **General**. Enter the ASan runtime flags in the format "flag=value", separated by semicolons.
To enable the ASan diagnosticsa, you have to install its debug symbols (libasan-dbg) on your remote Linux machine or WSL installation. The version of libasan-dbg that you load depends on the version of GCC you have installed on your Linux machine:
If ASan is enabled, Visual Studio prompts you at the top of the Debug pane of the output window to install the ASan debug symbols.
57
81
58
-
## Enable ASan for MSBuild-based Linux projects
59
-
60
-
To enable ASan for MSBuild-based Linux projects,right-click on the project in **Solution Explorer** and select **Properties**. Next, navigate to **Configuration Properties** > **C/C++** > **Sanitizers**. ASan is enabled via compiler and linker flags and requires recompilation in order to work.
61
-
62
-
[image]
63
-
64
-
You can pass optional ASan runtime flags by navigating to **Configuration Properties** > **Debugging** > **AddressSanitizer Runtime Flags**.
65
-
66
-
## Enable ASan for Visual Studio CMake projects
67
-
68
-
To enable ASan for CMake configurations targeting a remote Linux machine or WSL, Open the **CMake Settings Editor** and go to **General**. Check the option to enable AddressSanizer, and specify the runtime flags.
0 commit comments