Tool to plot thread context switch - c++

I'm looking for a tool for performance analysis and debugging that plots threads context switches, and maybe semaphore states, events, ...
I've used tools like that in the embedded world but I'm now looking for the same in the windows or Linux platforms.
The application I want to profile is a c++ multithreaded application.
Does anyone has a tool to recommend for this ?

For Linux and Solaris the Oracle Thread Analyzer from the Oracle Solaris Studio (it also runs on Linux despite its name) can provide a lot of insight into the performance problems of multithreaded applications. Besides Oracle Solaris Studio is still free.
Intel VTune Amplifier XE (previously called Intel Thread Analyzer) is available on both Linux and Windows.

On Windows you can use xperf tool to collect and plot context switches. It's a free tool, which is a part of Windows Performance Analysis Developer Center. Worked fine for me, see screenshot.

Windows Performance Monitor?
perfmon.exe
I think it's standard on most Windows Platforms and provides information on context switches and much much more.
Windows only I'm afraid though.

Probably this is not the tool you are thinking about, but it is simple, fast and can be useful.
When using GDB, you can type:
info threads
to see information about threads being run. Next you can switch to the chosen thread and print the backtrace to see, where it was:
thread <thread-id>
bt

Related

Using MATLAB Compiler Runtime on Chinese Windows box

Calling <libname>Initialize() or <libname>InitializeWithHandlers() is hanging when my (non-localized) software is used on a Windows 7 system with Chinese locale. We're using MCR v7.15.
I took a dump of the process and it appears to be a deadlock inside boost thread, if I can trust the stack trace.
I tried running the program with the AppLocale tool, selecting English.
Company let our support contract lapse, and I know from experience that Mathworks won't even review your support case w/o an active contract.
Any suggestions?

How to profile memory usage and performances of an openMPI program in C

I'm looking for a way to profile my openMPI program in C, i'm using openMPI 1.3 with Linux Ubuntu 9.10 and my programs are run under a Intel Duo T1600.
what I want in profile is cache-misses, memory usage and execution time in any part of the program.
thanks for reply
For Linux I recommend Zoom for this kind of profiling. You can get a free 30 day evaluation in order to try it out.
I finally found graphical tools for mpi profilling
vampir : www.vampir.eu and
paraprof at http://www.cs.uoregon.edu/research/tau/docs/paraprof/index.html
enjoy
Have a look at gprof and at Intel's VTune. Valgrind with the cachegrind tool could be useful, too.
Allinea MAP is ideal for this. It will highlight poor cache performance, memory usage and execution time right down to the source lines in your code. There is no need to recompile or instrument the application in order to profile it with Allinea MAP - which makes it unusually easy to get started with. On most HPC systems and with most MPIs it takes your binary, runs it, and loads up the source code automatically to display the recorded performance data.
Take a look to profiling MPI. Some tools for profiling is mpiP and pgprof.

Lightweight debugging on embedded Linux

I'm developing an application that runs on a small Linux-based SBC (~32MB RAM). Sadly, my app recently became too large to run under GDB anymore. Does anyone know of any good, lightweight debugging methods that I can use in embedded Linux? Even being able to view a thread's stack trace would be extremely helpful.
I should mention that this application is written in C++ and runs multiple threads, so gdbserver is a no-go as it doesn't work with multithreaded apps.
Thanks in advance,
Maha
gdbserver definitely works with multi-threaded applications, I'm working on an embedded project right now with >25 threads and we use gdbserver all the time.
info threads
lists all the threads in the system
thread <thread number from info threads>
switches to that thread of execution.
thread apply XXX <command>
Runs on the thread designated by XXX, which can also be 'all'. So if you want the back trace from all running threads do
thread apply all bt
Once you're in the execution flow of a given threads all your typical commands work as they would in a single threaded process.
I've heard of people doing hacks like running the application in an emulator like QEMU and then running GDB (or things like valgrind) on that. It sounds painful, but if it works....
Would you get anywhere with libunwind (to get stack traces) and printf-style logging?
Serial port printing is the most light weight I can think of ~~~
Easily seen in a Host PC, and simple and light weight code inside your app~~
If you do not have a serial port, once we used an GPIO port and simulated a serial port using it. It worked perfectly well, but was a bit slow :-( ~~~
Is there a reason why you have built your own debugger? I am developing a Linux system using an ARM processor (AT91SAM926x) and we are using both compiler and debugger from CodeSourcery. I do not think that they have released a version with GDB 7 yet but I am debugging multithreaded C++ applications using the gdbserver tool without any problems.
Gdbserver does indeed work with multithreaded applications. However you do need to compile a cross target debugger for your host to get it to work with your target gdb.
See this article for a detailed description of how to do it:
Remote cross-target debugging with GDB and GDBserver

Adding Blue Screen of Death to Non-Windows OS

I am looking to get into operating system kernel development and figured and have been reading books on operating systems (Tannenbaum) as well as studying how BSD and Linux have tackled this challenge but still am stuck on several concepts.
If I wanted to mimic the Windows Blue Screen of Death on an operating system, would I simply put this logic in the panic kernel method?
Are there ways to improve upon how Windows currently performs this functionality?
I'm not exactly sure where to look in the source but you might want to look into ReactOS, an open source Windows clone which has BSOD already.
BSDs actually handled this much better then Windows with DDB :)
Here's another link to FreeBSD Kernel Debugging docs.
You can emulate Windows's bugcheck functionality wherever you want. Most Linux systems put it in XScreenSaver.
However, I doubt that this is what you're really asking about. Are you asking how to generate a dump file?
To improve Windows bugchecks, Windows driver developers can use KeRegisterBugCheckReasonCallback() to record more information about the state of their drivers in the generated minidump. This potentially may improve the effectiveness of post-mortem debugging when full kernel/memory dumps are not enabled.

Profiling COM libraries used from a .NET Application

I am looking for a performance profiler that is able to profile a C++ library that is being called from a .NET Application.
I tried Purify+ without success (I don't get the calls the COM library) and a few others.
AQTime
Have you tried the IBM or AMD tools? They're really low level (being made from processor makers!) and so maybe they can profile your component.
Here is a thread that may be of use for you:
Decent profiler for Windows?
xperf might be good.
I know that at a previous job my group used vtune successfully.