Skip to content

Commit 79df9d1

Browse files
author
mikeblome
committed
intermediate checkin
1 parent d33e3ff commit 79df9d1

5 files changed

Lines changed: 27 additions & 14 deletions

‎docs/linux/linux-asan-configuration.md‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
title: "Configure Linux projects to use Address Sanitizer"
33
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"
55
---
66

77
# Configure Linux projects to use Address Sanitizer
88

99
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).
1010

11+
## About ASan
12+
1113
ASan is a runtime memory error detector for C/C++ that catches the following errors:
1214

1315
- Use after free (dangling pointer reference)
@@ -23,9 +25,31 @@ When ASan detects an error it stops execution immediately. When you run an ASan-
2325

2426
You can also view the full ASan output (including where the corrupted memory was allocated/deallocated) in the Debug pane of the output window.
2527

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+
![Enable ASan for an MSBuild project](media/msbuild-asan-prop-page.png)
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+
![Configure ASan runtime flags](media/msbuild-asan-runtime-flags.png)
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:
43+
44+
![Linix Debug Configuration](media/linux-debug-configuration.png)
2745

28-
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.
47+
48+
![Linix Debug Configuration](media/cmake-settings-asan-options.png)
49+
50+
## Install the ASan debug symbols
51+
52+
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:
2953

3054
|**ASan version**|**GCC version**|
3155
| --- | --- |
@@ -55,14 +79,3 @@ sudo apt-get install libasan4-dbg
5579

5680
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.
5781

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.
9.81 KB
Loading
2.24 KB
Loading
42.4 KB
Loading
55.3 KB
Loading

0 commit comments

Comments
 (0)