Valgrind For Windows
Is a set of tools aimed at finding bugs and performance problems in programs. By default, it catches reads of uninitialized memory, accesses to inaccessible memory, and memory leaks.
It's useful for debugging wine itself, as well as windows apps running on Wine. You need Valgrind 3.8.0 or newer to avoid (v3.8 was released in late summer 2012, but just in case there are still a few people that haven't upgraded). To get the full power of Valgrind while debugging Wine, you need to build Wine from source after installing Valgrind.
You'll also want to switch off certain compiler optimizations; the 'developer tools' section of the BuildingWine page has more details. Valgrind will work on (starting with partial support in macOS v10.8 'Mountain Lion').
From windows you could run a virtual machine running linux, running your software in the almost vm wine, in the valgrind vm. Bonus points if windows is run from a vm running linux inside a windows vm:) – Imbrondir May 6 '11 at 10:07.
If you want line numbers with Valgrind on Mac, don't forget to tell Xcode to generate a.dSYM file, though you can also use gdb after the fact to look up line numbers. In applications built with the debug version of the MS Visual C/C runtime, memory allocated via malloc is always initialized. This obscures any uninitialized memory accesses that would normally appear from Valgrind (see at MSDN for the full story).
Contents. Running Wine under Valgrind To analyze a program running on Wine with Valgrind, just call valgrind with the appropriate options in front of the normal wine command. For example: valgrind -trace-children=yes -vex-iropt-register-updates=allregs-at-mem-access -workaround-gcc296-bugs=yes wine foo.exe Note that this command will also trace the 'wineserver' if foo.exe is the first Wine application running. Swiss manager 7.0 serial.
Unless you're specifically looking to debug wineserver (usually you'll be more interested in specific dlls), this is a waste of resources. Valgrind can be pretty intensive on the CPU so you can speed things up quite a bit by not starting the wineserver under Valgrind. To do that, just start a dummy program under Wine first (e.g. Notepad or winemine), then without closing that program, start your desired program through wine and valgrind as you normally would. Valgrind Options Relevant for Wine Over the years, several Valgrind options have turned out to be necessary, or at least very helpful, when analyzing Wine. Two in particular are necessary for Wine to function well under Valgrind:.
is necessary because wine starts new processes for individual programs. ensures that bitmap-related code, such as, works under Valgrind Several more are useful for suppressing known bugs or exceptions in Wine:. quiets warnings about accesses slightly below the stack pointer. This is due to a known but benign piece of code in Wine's ntdll (see for details). lets you pass a file with custom suppression rules to Valgrind. Maintains a collection of suppression files for Wine at his This option can be repeated with multiple files.
silences warnings for when bit-alignments overlap both addressable and illegal ranges. In particular, try this if the last three bytes of allocations throw a lot of 'Invalid Read of Size N' warnings. There's a good chance these are false positives from vectorized string operations ( has more info). In the Valgrind bug report, someone also mentions using GCC with the -fno-builtin-strdup compiler option to make the warnings disappear. It hasn't been tested with Wine, but the 'Compiler Optimizations' section of has more details about changing compiler flags while building Wine. Controlling Memory Leak Reports There are a few more Valgrind options that let you fine-tune how much it reports about memory leaks. By default, Valgrind only gives a count of memory leaks detected at the end of execution.
To get more info, you want to pass the flag when running Valgrind. This will give you individual reports about certain types of memory leaks (but not all). Once this option is set, you can use several other options to specify which kinds of memory leaks you want detailed reports for:. only reports unfreed blocks with no pointers or that depend on interior pointers (the default).
or only reports unfreed blocks with no pointers. or reports all forms of unfreed blocks, even trivial ones with clear pointers Finally, by passing the option, you can ask Valgrind to give you stack backtraces to the point where a leaky memory block was allocated. This is terrifically helpful for debugging, but it has the downside of making valgrind run even slower. Conformance Tests under Valgrind To run Wine's ConformanceTests under Valgrind, you mainly need to set the WINETESTWRAPPER and VALGRINDOPTS variables, e.g. Export VALGRINDOPTS='-trace-children=yes -track-origins=yes -gen-suppressions=all -suppressions=$HOME/valgrind-suppressions-ignore -suppressions=$HOME/valgrind-suppressions-external -num-callers=20 -workaround-gcc296-bugs=yes -vex-iropt-register-updates=allregs-at-mem-access' WINETESTWRAPPER=valgrind make -k test test.log 2&1 Along with suppression files, also has some scripts to help run the tests under Valgrind. Changes to Wine Source There are also some tweaks you can make to the Wine source code itself that might help you uncover other problems.
First, the Wine source defines two constants that can be quickly changed and might reveal more bugs:. MAXFREEPENDING controls how long freed blocks are kept out of circulation and is set to 1024 by default. If you think your app is hanging on to freed pointers longer than it should, increasing it and recompiling wine might help Valgrind detect use-after-free errors. HEAPTAILEXTRASIZE gives the size of the redzone at the end of each block. If your app nests really big structs within another struct or array, you might need to increase this to catch overrun errors.
Watch out though because increasing it beyond 32 or so bytes can cause strange false positives sometimes. Additional Wine patches There are also a few patches that have accumulated on Bugzilla over the years to make Wine play better with Valgrind.
Valgrind Windows Install
As jakobengblom2 pointed out, valgrind has a suit of tools. Depending which one you are talking about there are different windows counter parts. I will only mention OSS or free tools here. MemCheck: Dr.
It is a relatively new tool, works very well on Windows 7. My favorite feature is that it groups the same leaks' allocation stacks in the report. I have also used UMDH( ) and found it quiet useful and easy to setup. It works from Win2000 to Win7. AppVerifier is a must have swissknife for windows native code developers, its 'memory' checker does similar job 2.
Callgrind: My favorite is verysleepy ( ) It is tiny but very useful and easy to use. If you need more features, AMD CodeAnalyst™ Performance Analyzer is free: Windows Performance Analysis tools is free from Microsoft, not very easy to use but can get the job done if you are willing to spend the time. Massif: Similar(not quite exact match) free tools on windows are: VMMap from sysinternals:!heap command in windbg: 4.
Cachegrind: Above mentioned Windows Performance Tools has certain level of L2 cache miss profiling capability but not quite as good and easy to use as Cachegrind. DRD: Haven't found anything free and as powerful on Windows yet, the only free tool for windows I can find that is slightly close is the 'lock' checker in AppVerifier.