Counting machine instructions using gdb
Try this: set pagination off set $count = 0 while $pc != 0xyourstoppingaddress stepi set $count++ end print $count Then go get a cup of coffee. Or a long lunch.
Try this: set pagination off set $count = 0 while $pc != 0xyourstoppingaddress stepi set $count++ end print $count Then go get a cup of coffee. Or a long lunch.
It seems that there is no other solution except a CPU that supports it. More precisely, your kernel has to support Intel Processor Tracing (Intel PT). This can be checked in Linux with: grep intel_pt /proc/cpuinfo See also: https://unix.stackexchange.com/questions/43539/what-do-the-flags-in-proc-cpuinfo-mean The commands only works in record btrace mode. In the GDB source commit beab5d9, it is … Read more
You can add the following to your exe’s .config file. <?xml version=”1.0″?> <configuration> <system.diagnostics> <trace autoflush=”true”> <listeners> <add name=”logListener” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”cat.log” /> <add name=”consoleListener” type=”System.Diagnostics.ConsoleTraceListener”/> </listeners> </trace> </system.diagnostics> </configuration> I included the TextWriter as well, in case you’re interested in logging to a file.
This is easy, actually. I’ll give you the bare bones, and you can modify to suit. (gdb) define nstep > set $foo = $arg0 > while ($foo–) > step > end > end (gdb) nstep 100 I’ve done this many times. Hope this helps!
If you only want this ability at debug time, there’s Microsoft IntelliTrace that’s a part of Visual Studio 2010 Ultimate, and there’s Sergey Vlasov’s RunTime Flow. The former makes your program run very slow. Haven’t tried the latter.
I use this for C# winforms, should be easily adjustable to wpf public class MyTraceListener : TraceListener { private TextBoxBase output; public MyTraceListener(TextBoxBase output) { this.Name = “Trace”; this.output = output; } public override void Write(string message) { Action append = delegate() { output.AppendText(string.Format(“[{0}] “, DateTime.Now.ToString())); output.AppendText(message); }; if (output.InvokeRequired) { output.BeginInvoke(append); } else { … Read more
There is no such API provided by the JVM— even for agents started with -javaagent. The JVM TI is a native interface provided for native agents started with the -agent option or for debuggers. Java agents might use the Instrumentation API which provides the lowlevel feature of class instrumentation but no direct profiling capability. There … Read more
Start the python interpreter with -v: $ python -v -m /usr/lib/python2.6/timeit.py # installing zipimport hook import zipimport # builtin # installed zipimport hook # /usr/lib/python2.6/site.pyc matches /usr/lib/python2.6/site.py import site # precompiled from /usr/lib/python2.6/site.pyc # /usr/lib/python2.6/os.pyc matches /usr/lib/python2.6/os.py import os # precompiled from /usr/lib/python2.6/os.pyc import errno # builtin import posix # builtin # /usr/lib/python2.6/posixpath.pyc matches /usr/lib/python2.6/posixpath.py … Read more
Probably your best bet would be to use an AOP (aspect oriented programming) framework to automatically call tracing code before and after a method execution. A popular choice for AOP and .NET is PostSharp.
The basic steps of tracing for function calls are on a non-live node: > dbg:start(). % start dbg > dbg:tracer(). % start a simple tracer process > dbg:tp(Module, Function, Arity, []). % specify MFA you are interested in > dbg:p(all, c). % trace calls (c) of that MFA for all processes. … trace here > … Read more