CLion 2017.3 EAP: Valgrind memcheck integration

Hi,

Today we are rolling out a new CLion 2017.3 EAP build (173.3415.24) with support for memory check from Valgrind and some polishing of the toolchains rework.

banner_valgrind_800х400@2

Download CLion 2017.3 EAP

Valgrind: memcheck

Good news everyone! CLion now comes with Memcheck integration; this means you can detect runtime errors and memory leaks right from the IDE. We know you are eager to try it out on your project, but first let me put a few general thoughts down here:

  • This is just a first step toward the support of profiling tools in CLion
  • Memcheck is just one member of the big Valgrind family, but probably the most famous (and used) one
  • Valgrind doesn’t require a program recompilation and supports both GCC and Clang
  • There are dozens of great tools available to C and C++ developers other than Valgrind, like Google sanitizers, and gprof. If you are interested in any of these, feel free to upvote existing requests or fill out a new one in our tracker.

System requirements & settings

Valgrind works on Linux and macOS and is available in CLion on both of these platforms. CLion detects it automatically by searching for it in the standard locations defined by the system PATH variable. Or you can point CLion to Valgrind’s executable using: Settings/Preferences | Build, Execution, Deployment | Valgrind:
valgrind_settings

Options with which to run Valgrind and a list of suppression files which can be used, can also be configured on this page. For example, you may want to add a non-default suppression file to turn off Valgrind checks on some particular libraries you are using in your project. The typical case here, for example, would normally be to suppress OpenSSL or Boost.

Default Valgrind options include:

  • --read-inline-info=yes which is supported in Valgrind 3.10.0+, so if you have an earlier version remove this parameter
  • --read-var-info=yes which causes issues on macOS platform, so remove it in this case

Running targets under Valgrind

Select a Run/Debug configuration and run it under Valgrind memcheck via the Run | Run Valgrind Memcheck… or special icon in the Navigation bar located next to the Run and Debug options:
valgrind_icon

This icon is present on all three platforms, but it is disabled on Windows as Valgrind is not available there.

You’ll get a new tab called ‘Valgrind’ in the Run toolwindow. It provides the information about all the possible errors found by Valgrind, along with the source code location (use F4 on Linux and ⌘↓ on macOS to Jump to Source) and a stack trace. The results are grouped by the type of leak encountered:

modernize

In the context menu on a particular error you can:

  • Exclude the error from the current results log, error will be back on the next Valgrind run
  • Suppress the function that causes an error by adding a corresponding record to the selected suppression file

Running tests under Valgrind

Google Test, Catch and Boost.Test targets can also be run with memcheck. You can either select necessary test target and press ‘Run Valgrind Memcheck’ icon in the Navigation bar, or use test icons in the left gutter when the file with tests is opened in the editor:
test_memcheck

Check out the memcheck (Valgrind) integration into CLion and let us know what you think! Mind, UI is not final yet, so your feedback here is appreciated.

Toolchains, CMake profiles & more

Multiple toolchains support was brought in with CLion 2017.3 EAP which allowed:

  • easier compilers configuration
  • different CMake versions/debugger for different projects and configurations
  • on Windows different toolchains (MinGW, Cygwin or Microsoft Visual C++) for different projects and configurations

This EAP build polishes these changes and allows you to get several CMake profiles with the same build type. For example, you can use it if you want to build different Debug targets in your project with different toolchains. In previous CLion versions, you have to switch the toolchain in the CMake profile that corresponds to the Debug build type. Now you can configure several such profiles:

  1. In Settings/Preferences | Build, Execution, Deployment | Toolchains create several toolchains:
    toolchains_new
  2. In Settings/Preferences | Build, Execution, Deployment | CMake add several CMake profiles which use different toolchains:
    cmake_profiles_new
    Profile names should be unique. Default CMake generation path will be cmake-build-. Build options are now specified per CMake profile.
  3. Create several Run/Debug configurations with different CMake profiles:
    run_configurations_profiles

That’s it! Full release notes can be found here.

Download CLion 2017.3 EAP

Your CLion Team
The Drive to Develop

This entry was posted in Announcement, Early Access Preview and tagged , , , , , . Bookmark the permalink.

36 Responses to CLion 2017.3 EAP: Valgrind memcheck integration

  1. Tano says:

    Hi Anastasia,
    I noticed that the order of the articles in this page is wrong:https://blog.jetbrains.com/clion/
    The top article is from 7 sept, then the next from 26 oct, then the next from 19 oct.
    Isn’t it normal for the latest article to be the first? That’s how blogs work, to be easy to check if a new article appeared on the site.

  2. Roman says:

    Do you plan to bundle Valgrind like other tools (CMake, GDB, LLDB) ? Or there is some technical reason why end-user has to install manually?

    • Anastasia Kazakova says:

      We don’t want to increase the size of package w/o a good reason. CMake is essential to CLion, as you can’t do anything w/o it in the IDE. But Valgrind is some extra tool that you might not need. This can be changed but now we don’t think it’s reasonable enough.

  3. Roman says:

    Can you put a CMake configuration selector on toolbar? Near target selector?
    So we can easily switch between various configs like in MSVC
    http://fordiac.sourceforge.net/ehelp/html/installation/img/VSreleaseDebug.png

    Currently there is no way to know from main GUI what configuration is selected w/o going to “Edit configurations”. Very inconvenient. I have to work on cross-platform library now, and I have to switch between configurations very often.

    Another nice feature in MSVC is that they have a JSON file for Launch configurations, instead of GUI: https://blogs.msdn.microsoft.com/vcblog/2016/10/05/cmake-support-in-visual-studio/
    Really helpful when you need to run application with different command line options. Personally I would prefer to use CTest for this purpose, but JSON is already better than GUI.

    • Anastasia Kazakova says:

      Currently we work on the easier switcher of the build type in the toolbar (i.e. Debug/Release). It’s in development, you can expect in 2017.3 EAP soon.

      Regarding the JSON configuration file, not sure I completely understand why it’s better than UI. Probably, the UI has some issues that make is hardly usable in this case?

      • Roman says:

        I’m ok with GUI, if there is a text representation behind it, so I can (1) put it to repo and (2) run all configurations automatically. CTest ideally solves the problem, but I can write some automation around json myself too.

      • Roman says:

        Another problem with GUI is that I can’t share my run configurations with colleagues using other IDEs.

        • Anastasia Kazakova says:

          That’s another story. While CMake profile is a general things, it related to Toolchains and Run/Debug configurations, that is completely CLion specific. So using some common format here (to be able to share with other IDEs) is a bit tricky task. But we’ll consider the idea. Thanks!

  4. Tano says:

    Please try to not break existing things, when releasing a new version please :(
    This worked in 2016, 2017.1 and 2017, now it’s broken…
    https://youtrack.jetbrains.com/issue/CPP-11076

    • Anastasia Kazakova says:

      Thanks for pointing, we’ll check.

      But I’d like to remind you that EAP is not a release version. It can be unstable, have regressions, etc. We are rolling it exactly for checking plenty of configurations and situations that we can’t cover with our testing, so that users report and we fix.

      Anyway, we are looking at the issue now.

  5. Tano says:

    Anastasia, are there any news on CLion 2018 regarding the estimated date, roadmap and the features that will include? :)
    Thanks

  6. Evgenii says:

    Any plans for sanitizers(ASan, TSan, etc.)?

  7. Maksim says:

    Please add debugging with Visual Studio! Thanks in advance!

  8. James P. says:

    I have just downloaded it but Error shows that Valgrind executable is not found. Do I have to install or set my computer additionally from just downloading the new version of CLion?

    • Anastasia Kazakova says:

      Do you have Valgrind installed on you machine? If yes, just point to the executable in Settings | Build, Execution, Deployment | Valgrind

  9. Do Hyun Lee says:

    I tried to use memory leak check after downloading Clion 2017.3. But I can only see “Valgrind executable is not found”. Do I have to install or set other things to use this function? Thank you

    • Anastasia Kazakova says:

      Do you have Valgrind installed on you machine? If yes, just point to the executable in Settings | Build, Execution, Deployment | Valgrind

  10. Haresh Kainth says:

    Absolutely fantastic. I just tried this in 2017.3 RC2 and so far it works like a dream. Thank you.

  11. Alexander Zaitsev says:

    Hello. When will be available assembly view for existing source code? In which Clion release?

    • Anastasia Kazakova says:

      There is no clear plan for this task for now. There are dozens of very important debugger tasks, and while this one is a high priority, still there are others which are even more important.

Leave a Reply

Your email address will not be published. Required fields are marked *