What the best multi-thread application debugger for C++ apps - c++

I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin.
The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars, etc.
It does not have to be an eclipse plugin or a free tool, do any of you have heard of something similar?

Qt Creator does provide information on a per-thread basis. It also has the features you would expect from any standard debugger. (Watches, breakpoints, etc.)
Although designed for compiling Qt applications, it can be used for just about any C++ project. (I have used it for compiling/editing a non-Qt app before.)

TotalView (and MemoryScape) doesn't do precisely what you're asking for in its' default presentation, but it provides the data you need. It costs money, but a better C++ debugger for Linux cannot be found.
Free trials are available, and there are a number of cool and useful videos on their support site.

If you're on linux, you've got access to one of the most powerful debugging tools in the trade - Valgrind. Read about it, especially about it's additional tools like Helgrind.
Sure, the visualisation is lacking compared to commercial tools, but you can't beat it's level of detail.

Related

How to Detect Memory leaks for Qt windows desktop application, using QtCreator [duplicate]

Lately I have been developing in C++ with QT Creator. All is well and I'm nearly at the point of packaging and distributing my application. But obviously before any release you better make sure you have everything right. So I'm at the testing stage, and something tells me that I have some slight memory issues. Nothing serious, but I like to obsess over these ;-).
So I decided to try some memory leak detection libraries. For starters I looked at this question. I disregarded Purify and Insure++ because of the costs. Someone else suggested to use the MSVC compiler so I could use the CRT memory validation routines. Which I considered but decided against for now because of the implications it would have on using the debugger from within QT Creator.
Then I stumbled across DUMA which I got to compile using the MinGW32 compiler that comes with QT. However, I found that it doesn't really play well with QT because of the incredible amount of segmentation faults. I know they are how DUMA works, but I'm pretty sure I did not screw things up as much as DUMA tried to make me believe.
Another something I tried was the google-performance-tools which I sadly cannot get to compile with the MinGW32 version supplied with QT, even if I add in the required dependencies.
All of this brings me to my question: Is there any working solution out there for QT Creator developers that want to check their programs for memory leaks?
Thanks,
Personally, I find the valgrind / memcheck / callgrind / kcachegrind combo to be too powerful to pass up for memory leaks and performance analysis. Being free (gratis) is especially nice since I cannot personally afford the cost of some of these other professional tools.
I've been working on a cross platform Qt application for a couple years now. As I develop, I bounce back and forth between windows and linux when I want to test features and functionality. However, I always do my performance analysis in linux. The memory leaks and performance concerns that I find are always ones that are injected by my team of developers on top of Qt. So when these problems are fixed, regardless of being identified in Linux, the benefits will carry over into windows.
I suggest you investigate setting up a pure linux build environment that you can test in. Perhaps the easiest solution for you would be to create a virtual machine to do your performance analysis on. My preferred combination is VirtualBox and Ubuntu.
May be you can use these libs for windows
Hooks for Malloc [gnu.org]
Backtrace [gnu.org]
valgrind [valgrind.org]

Memory leak checking on Windows with QT and MinGW32

Lately I have been developing in C++ with QT Creator. All is well and I'm nearly at the point of packaging and distributing my application. But obviously before any release you better make sure you have everything right. So I'm at the testing stage, and something tells me that I have some slight memory issues. Nothing serious, but I like to obsess over these ;-).
So I decided to try some memory leak detection libraries. For starters I looked at this question. I disregarded Purify and Insure++ because of the costs. Someone else suggested to use the MSVC compiler so I could use the CRT memory validation routines. Which I considered but decided against for now because of the implications it would have on using the debugger from within QT Creator.
Then I stumbled across DUMA which I got to compile using the MinGW32 compiler that comes with QT. However, I found that it doesn't really play well with QT because of the incredible amount of segmentation faults. I know they are how DUMA works, but I'm pretty sure I did not screw things up as much as DUMA tried to make me believe.
Another something I tried was the google-performance-tools which I sadly cannot get to compile with the MinGW32 version supplied with QT, even if I add in the required dependencies.
All of this brings me to my question: Is there any working solution out there for QT Creator developers that want to check their programs for memory leaks?
Thanks,
Personally, I find the valgrind / memcheck / callgrind / kcachegrind combo to be too powerful to pass up for memory leaks and performance analysis. Being free (gratis) is especially nice since I cannot personally afford the cost of some of these other professional tools.
I've been working on a cross platform Qt application for a couple years now. As I develop, I bounce back and forth between windows and linux when I want to test features and functionality. However, I always do my performance analysis in linux. The memory leaks and performance concerns that I find are always ones that are injected by my team of developers on top of Qt. So when these problems are fixed, regardless of being identified in Linux, the benefits will carry over into windows.
I suggest you investigate setting up a pure linux build environment that you can test in. Perhaps the easiest solution for you would be to create a virtual machine to do your performance analysis on. My preferred combination is VirtualBox and Ubuntu.
May be you can use these libs for windows
Hooks for Malloc [gnu.org]
Backtrace [gnu.org]
valgrind [valgrind.org]

Profiling embedded application

I have an application that runs on an embedded processor (ARM), and I'd like to profile the application to get an idea of where it's using system resources, like CPU, memory, IO, etc. The application is running on top of Linux, so I'm assuming there's a number of profiling applications available. Does anyone have any suggestions?
Thanks!
edit: I should also add the version of Linux we're using is somewhat old (2.6.18). Unfortunately I don't have a lot of control over that right now.
As bobah said, gprof and valgrind are useful. You might also want to try OProfile. If your application is in C++ (as indicated by the tags), you might want to consider disabling exceptions (if your compiler lets you) and avoiding dynamic casts, as mentioned above by sashang. See also Embedded C++.
if your Linux is not very limited then you may find gprof and valgrind useful
On a related note, the C++ working group did a technical report on the performance cost of various C++ language features. For example they analyze the cost of dynamic_casting one or 2 levels deep. The reports here http://www.open-std.org/jtc1/sc22/wg21/docs/TR18015.pdf and it might give you some insight into where the pain points in your embedded application might be.
gprof may disappoint you.
Assuming the program you are testing is big enough to be useful, then chances are the call tree could be pruned, so the best opportunities for optimization are function/method calls that you can remove or avoid. That link shows a good way to find them.
Many people approach this as sort of a hierarchical sleuthing process of measuring times.
Or you can simply catch it in the act, which is what I do.

C++ Code Profiler

Can anybody recommend a good code profiler for C++?
I came across Shiny - any good? http://sourceforge.net/projects/shinyprofiler/
Callgrind for Unix/Linux
DevPartner for Windows
Not C++ specific, but AMD's CodeAnalyst software is free and is feature-packed.
http://developer.amd.com/cpu/codeanalyst/codeanalystwindows/Pages/default.aspx
Gprof if you use gcc. It may not be user friendly but still useful.
Probably you will be interested in Intel VTune. Rather useful and allows to collect low-level events like cache misses which helps a lot in tuning.
Quantify (part of the IBM/Rational PurifyPlus package) is a very good profiler, but not exactly cheap. It is available on several platforms, too - I've used it on Solaris, Windows and Linux.
Depends on what you need to do:
Measure, so you can do regressions testing to see if changes in performance happened.
Find reasons for suboptimal performance and optimize them.
These are not the same.
For 1, use one of the recommended profilers.
For 2, the profiler I much prefer is one you already have:
http://www.wikihow.com/Optimize-Your-Program%27s-Performance
To see how this goes, check this out.
For C++, as for C# and any language that encourages layers of abstraction, those layers may or may not be good from a software engineering standpoint, but they can kill performance. Every method call is a detour in the execution of your program, and the style encourages you to nest those things, sometimes needlessly. Also the style discourages you from knowing or caring what goes on inside them. You may find them creating and deleting objects underneath at a rate and level of generality far beyond what your application really needs.
AQtime (for Windows)
If you are running a Premium version of VS 2010 then you get a profiler with it.
I've also used a couple of other free ones, but they don't compare to the on MS ships. Useful as a second opinion though.
If you have access to a Mac, then I recommend using Shark from the CHUD tools.
You can use the analyzer that´s in Sun Studio 12 on Linux or Solaris. Itś free. http://developers.sun.com/sunstudio/index.jsp
If you cannot locate DevPartner it is because we've moved under new ownership. Check us out on the Micro Focus website: http://www.microfocus.com/products/micro-focus-developer/devpartner/index.aspx. Shameless plug: I work on the DevPartner team. Our long awaited 64-bit versions of BoundsChecker and C++/.NET profilers ship on February 4, 2011. We've changed our pricing model so you can choose either the whole suite or just the performance profiler if that's what you need. Please check out the new DPS 10.5 release when it goes live!

Decent profiler for Windows? [duplicate]

This question already has answers here:
What are some good profilers for native C++ on Windows? [closed]
(8 answers)
Closed 9 years ago.
Does windows have any decent sampling (eg. non-instrumenting) profilers available? Preferably something akin to Shark on MacOS, although i am willing to accept that i am going to have to pay for such a profiler on windows.
I've tried the profiler in VS Team Suite and was not overly impressed, and was wondering if there were any other good ones.
[Edit: Erk, i forgot to say this is for C/C++, rather than .NET -- sorry for any confusion]
For Windows, check out the free Xperf that ships with the Windows SDK. It uses sampled profile, has some useful UI, & does not require instrumentation. Quite useful for tracking down performance problems. You can answer questions like:
Who is using the most CPU? Drill down to function name using call stacks.
Who is allocating the most memory?
Outstanding memory allocations (leaks)
Who is doing the most registry queries?
Disk writes? etc.
I know I'm adding my answer months after this question was asked, but I thought I'd point out a decent, open-source profiler: Very Sleepy.
It doesn't have the feature count that some of the other profilers mentioned before do, but it's a pretty respectable sampling profiler that will work very well in most situations.
Intel VTune is good and is non-instrumenting. We evaluated a whole bunch of profilers for Windows, and this was the best for working with driver code (though it does unmanaged user level code as well). A particular strength is that it reads all the Intel processor performance counters, so you can get a good understanding of why your code is running slowly, and it was useful for putting prefetch instructions into our code and sorting out data layout to work well with the cache lines, and the way cache lines get invalidated in multi core systems.
It is commercial, and I have to say it isn't the easiest UI in the world.
AMD's CodeAnalyst is FREE here
We use both VTune and AQTime, and I can vouch for both. Which works best for you depends on your needs. Both have free trial versions - I suggest you give them a go.
The Windows Driver Kit includes a non-instrumenting user/kernel sampling profiler called "kernrate". It seems useful for profiling multi-process applications, applications that spend most of their time in the kernel, and device drivers (of course). It's also available in the KrView (Kernrate Viewer) and Windows Server 2003 Resource Kit Tools packages.
Kernrate works on Windows 2000 and later (unlike Xperf, which requires Vista / Server 2008). It's command-line based and the documentation has a somewhat intimidating list of options. I'm not sure if it can record call stacks or just the program counter. If you use a symbol server, make sure to put an up-to-date dbghelp.dll and symsrv.dll in the same directory as kernrate.exe to prevent it from using the ancient version of dbghelp.dll that is installed in %SystemRoot%\system32.
I have tried Intel's vtune with a rather large project about two years ago. It was an instrumenting profiler then and it took so long to instrument the DLL that I was attempting to profile that I eventually lost patience after an hour.
The one tool that I have had quite good success and which i would highly recommend is that of AQTime. It not only provides excellent performance profiling resources but it also doe really good memory profiling which has been of significant help to me in tracking down memory leaks.
Luke Stackwalker seems promising -- it's not as polished as I'd like, but it is open source and it does do something that seems very close to what #Mike Dunlavey keeps saying we ought to do. (Of course, it then tries to smoosh it all down into the typically-unhelpful call graphs that Mike is so weary of, but it shouldn't be too hard to fix that with the source as our ally.)
It even seems to count time spent waiting in the kernel, as far as I can tell...
I'm not sure what a non-instrumenting profiler is, but I can say for .NET I love RedGate's ANTS Profiler. Version 3 beats the MS version for ease of use and Version 4, which allows arbitrary time slices, makes MS look like a joke.