It also provides links to several browser interfaces for Xdebug, including (what claims to be) the easiest to use (Firefox), The easiest Xdebug. There's also plugins for Chrome, Safari, and Opera. Let me know if you need any further help. Again, may not be specific to. I would like to use xDebug with PHPStorm, z-Wamp and Firefox. XDebug is defined like this in PHP.Ini: XDebug xdebug.idekey=PHPSTORM xdebug.defaultenable=on xdebug.remoteenable=on xdebug.remotehost=localhost xdebug.remoteport=9001 xdebug.remoteconnectback=on xdebug.remoteautostart=on xdebug.remotelog=indicate a local xdebug.log file. Update xDebug 2.4.0 -Update xDebug 2.4.0 - 32 bit x86 Update xDebug 2.4.0 - 64 bit x64 XDebug update version 2.4.0 for all PHP versions installed. Can be reinstalled if addition of PHP version. See the first message, section UPDATES for the download links. Phpxdebug 2.5.x or later (development environments only; can have an adverse effect on performance) There is a known issue with xdebug that can affect Magento installations or access to the storefront or Magento Admin after installation. For details, see Known issue with xdebug.
Debugging a problem in an application is like solving a puzzle. There are certain tools that can help you solve the puzzle. This page documents some of the strategies, tools and tricks that you can use in solving these puzzles.
You can find bugs by using a debugger: setting breakpoints, running the code line-by-line, examining variables, changing its state, exploring what other threads are doing, and see what the call stacks for each routines are. See the sections Debugging with GDB and Debugging with LLDB for more information on this.
You can also debug an application by looking at stack traces. These are typically the result of an exception being thrown, or are the result of the code containing explicit calls to
Console.WriteLine(Environment.StackTrace). This helps you understand what the call frames were at the point of the stack traces and you can use this to understand what could have lead to the particular state that you are exploring (the crash, the exception, the report).
Debuggers and stack traces are not enough, sometimes you want to see what is happening as the application runs, “trace” its execution and look at parameters and return values that are being passed around. See the Tracing Programming Execution section for details on this technique.
Another diagnostics mechanism is exploring which exceptions are being thrown (you might be accidentally capturing exceptions that should be propagated, or your program might be performing sub optimally). See the section on Exceptions to understand how to see these.
To debug applications or obtain line number information in stack traces, it is necessary to compile your programs with debugging information. This is achieved using the -debug command line option of the C# compiler. In Mono 1.0.x this embeds the debugging information in the resulting assembly, in Mono 1.1.x a separate file with the extension .mdb is produced.
To get stack traces with line number information, you need to run your program like this:
Notice that the program will need to be compiled with the -debug flag and that running with –debug will slow down the execution.
Debugging with GDB
GDB can be used to obtain some information about your application and debug some problems. This section covers the details on debugging your Mono application with GDB.
First and foremost, Mono support libraries use a couple of signals internally that confuse gdb, to work around this, put this in your .gdbinit file (in your $HOME path):
If you use GDB to debug your mono process, you can use the function
mono_print_method_from_ip (which takes an address) to obtain the name of a method given an address. This is particularly useful when examining stack traces. The function was renamed to
mono_pmip in the Mono 1.1.x series (For a while the function was called
For example, when faced with a stack trace, like this:
You can find out what methods are at each address using the mono_print_method_from_ip function (or mono_pmip if you are using Mono 1.1.x):
Sometimes you will want to produce a complete dump of all the managed names from within gdb, this can be achieved with a gdb macro. Put this in your .gdbinit file in your HOME directory:
Then you can issue the “mono_backtrace 15” from the gdb prompt to obtain a trace of the last 15 frames.
If you use P/Invoke often, it is often helpful to set a breakpoint in an unmanaged function and then print a managed stack trace. Starting with 22.214.171.124, you can add the following gdb macro to your .gdbinit file. (Note, this has only been tested on x86):
Using “mono_stack” from gdb will print a managed stack trace to the program’s stdout. It will not print out in your gdb console! You can also use “thread apply all mono_stack” to print stacks for all threads.
Output will look something like this:
In versions after Mono 1.1.18, a few new functions are available to assist in debugging applications from within GDB.
mono_object_describe to get a small description of the object obj.
mono_object_describe_fields to get a small description of all the fields on the given object.
mono_value_describe_fields to prints to stdout a small description of each field of the value type stored at @addr of type @klass.
mono_class_describe_statics to prints to stdout a small description of each static field of the type @klass in the current application domain.
mono_debug_print_vars to prints to stdout the information about the local variables in a method (if @only_arguments is false) or about the arguments.
The information includes the storage info (where the variable lives, in a register or in memory). The method is found by looking up what method has been emitted at the instruction address @ip.
Xdebug Firefox Extension
Here is an example session:
Debugging with LLDB
You can use the following LLDB python script to get backtraces in lldb: monobt.py
Assuming the above script is saved in
~/Library/lldb/monobt.py, you can load it automatically in every lldb session by putting the following into .lldbinit (in your $HOME directory):
Once the script is loaded, you can type
monobt to get a backtrace of the currently selected thread with managed frames symbolicated.
Usually you will debug Mono after building it yourself, but it is possible todebug a prebuilt Mono package, using LLDB’s
If a segmentation fault occurs (
EXC_BAD_ACCESS) LLDB can’t resume to the signal handler. Unfortunately this conflicts with implicit null checks used by Mono. Workarounds until this is fixed:
- Run mono with
MONO_DEBUG=explicit-null-checks, so the runtime won’t use mentioned technique. Performance-wise this is a bit slower, but for debugging purposes that’s fine.
gdb. Unfortunately this requires some work on macOS these days.
Debugging With Visual Studio on Windows
Most of the techniques that you can use in GDB can also be used on Windows using the Visual Studio debugger. You can use the Immediate Window to enter your commands. if the gdb command is:
the equivalent command for the immediate window is the same without the p, and explicitly casting the argument to a void*
When mono was loaded from a dynamic library, and the above command doesn’t work, you can tell visual studio more explicitly where to find the function. Assuming mono was loaded from “mono.dll”, the somewhat cryptic command is:
Debugging Managed Lock Deadlocks
Xdebug Firefox Vscode
Managed locks (implemented in the Monitor class and usually invoked with the lock () construct in C#) are subject to the same incorrect uses of normal locks, though they can be safely taken recursively by the same thread.
One of the obviously incorrect way to use locks is to have multiple locks and acquire them in different orders in different codepaths. Here is an example:
There is an explicit Sleep () call to make the race condition happen almost every time you run such a program. The issue with such deadlocks is that usually the race time window is very small and it will go unnoticed during testing. The new feature in the mono runtime is designed to help find the issue when a process is stuck and we don’t know why.
Now you can attach to the stuck process using gdb and issue the following command:
which results in output like this:
You can see that there are three locks currently held by three different threads. The first has been recursively acquired 2 times. The other two are more interesting because they each have a thread waiting on a semaphore associated with the lock structure: they must be the ones involved in the deadlock.
Once we know the threads that are deadlocking and the objects that hold the lock we might have a better idea of where exactly to look in the code for incorrect ordering of lock statements.
In this particular case it’s pretty easy since the objects used for locking are static fields. The easy way to get the class is to notice that the object which is locked twice (0x2ffd8) is of the same class as the static fields:
Now we know the class (0x820922c) and we can get a list of the static fields and their values and correlate with the objects locked in the mono_locks_dump () list:
Note that the lockA and lockB objects are the ones listed above as deadlocking.
Debugging Unmanaged Deadlocks
If the deadlock you’re experiencing is not caused by your code, it might be a Mono runtime issue. To find out, get some backtraces with these steps:
- Get your application to deadlock.
- Launch gdb from the command line.
attach <the-mono-process-id>(to find the process, pursue
ps -A grep mono).
thread apply all bt.
The output you got with the last step is good to diagnose the problem or to attach to a bug.
Debugging Pinned Objects
The Mono GC will conservatively scan part of the stacks of the threads to find if they reference objects that thus would need to be kept alive. Sometimes the stack, though, contains integers or other data that look like a pointer to an object, but it isn’t really used to hold a reference to managed memory. When using the SGen GC, to help debug those cases, you can call the function find_pinning_ref_from_thread(obj, obj_size) to check whether the object obj is being pinned from some thread locations. Make sure you have a mono debug build, as the linker could optimize away this function from production builds.
Triggering the Debugger
From managed code, you can invoke the System.Diagnostics.Debugger.Break () method in your code to break execution and get to the GDB prompt.
From unmanaged code, you can use the G_BREAKPOINT() macro in your code.
Debugging with GDB in XDEBUG mode
With mono 2.6 or later, it is now possible to ask the runtime to generate debugging information which can be used by gdb. This currently only works on amd64/x86/arm linux. To use it:
For gdb 7.0
- No setup is needed, gdb will automatically load the mono mode written in python, and the the runtime will register debugging information with gdb using the new JIT interface in gdb 7.0.
gdb is not designed to handle 1000s of symbol files (one per JITted method), so the runtime groups them into fewer symbol files. This can lead to debug info missing for recently JITted methods. Typing ‘xdb’ will flush the debug info collected by the runtime.
For older gdb versions
- Set the MONO_XDEBUG env variable to ‘1’.
- Add the following to your .gdbinit:
- Run mono under gdb with –debug (if you want to run moon, just launch ‘firefox -d gdb’, or ‘firefox -g -d gdb’ in case you’re using Firefox > 3.5). Having .mdb files available helps a lot.
- When the program is stopped, type ‘xdb’. This will cause the runtime to generate the debugging info, and gdb to load it.
The output will now look like this:
The XDEBUG support in mono is modeled after the similar functionality in Kaffe.
Sometimes try/catch sequences can hide underlying problems in your code, you might want to look at the exceptions produced by your program using Mono’s trace facility, to use this, try:
That will display the exceptions that you program is throwing.
If you want to look into where those exceptions are being produced using gdb, you can use the following trick:
This requires a Mono with symbols to be installed though. Then you can inspect various aspects of your program:
Tracing Program Execution
Tracing allows developers to see when methods are entered/left as their application runs. This is enabled by passing the –trace command line argument to mono. The output can be quite verbose:
The default will output traces for all methods invoked in your application which can be a lot of data. It is possible to pass filter the routines that will be traced by passing options to the trace command line to limit its scope, for example:
The above example will limit the tracing to methods in the MyApplication namespace.
Or to trace multiple namespaces:
Ga6hp19z. The full options available are:
For example, to trace a namespace but ignore some types:
You can toggle the trace output by sending the SIGUSR2 signal to the mono process. And you might also want to start your application with the tracing output turned off until your application reaches the point that you are interested in debugging:
Then from another console, you can turn on the output:
Where `pid’ is the process ID of the Mono process that is being traced.
You can turn off the output by sending the USR2 signal again to the process.
You can ask the runtime to log various message to stdout using: MONO_LOG_LEVEL=debug
Using Valgrind on Mono
Sometimes it might be useful to run Mono with Valgrind to track problems in the application. This is particularly helpful when debugging problems with P/Invoked libraries or bindings.
Historically Mono and Valgrind didn’t always played well together. If this has discouraged you in the past then it’s time to try it again!
Recent valgrind versions are able to deal with for self-modifying programs (which is what the mono JIT does) by using the –smc-check=all option.
As an extra bonus, Paolo (lupus) has shared his suppression file for Mono. This removes a lot, but not all, false positives (or unimportant) logs coming from the Mono runtime. This makes it easier and faster to find what you’re looking for. The suppression file is available in Mono’s git as /mono/data/mono.supp
This will run the app.exe application using mono and create a log file named “log.####” (where #### is the process id). The log file will indicates what leaked (and from where), what was (badly) reused after being freed
Cairo supplies it’s own suppression file that is useful to add if your application depends on System.Drawing (or System.Windows.Forms).
The file is located under
libgdiplus/cairo/test/.valgrind-suppressions and can be used simultaneously with the one provided for Mono.
This is a list of performance analysis tools for use in software development.
General purpose, language independent
The following tools work based on log files that can be generated from various systems.
- time (Unix) - can be used to determine the run time of a program, separately counting user time vs. system time, and CPU time vs. clock time.
- timem (Unix) - can be used to determine the wall-clock time, CPU time, and CPU utilization similar to time (Unix) but supports numerous extensions.
- Supports reporting peak resident set size, major and minor page faults, priority and voluntary context switches via getrusage.
- Supports sampling procfs on supporting systems to report metrics such as page-based resident set size, virtual memory size, read-bytes, and write-bytes, etc.
- Supports collecting hardware counters when built with PAPI support.
The following tools work for multiple languages or binaries.
Xdebug Php 7
|Name/Manufacturer||OS||Compiler/Language||What It Does||License|
|Arm MAP||Linux||C, C++, Fortran/Fortran90 and Python applications.||Performance profiler. Shows I/O, communication, floating point operation usage and memory access costs.|
Supports multi-threaded and multi-process applications - such as those with MPI or OpenMP parallelism and scales to very high node counts.
|AppDynamics by Cisco||Linux, Windows, iOS, Android, Azure, AWS, AIX||.NET, Java, PHP, HTML5, ObjectiveC/iOS, Java/Android, C/C++, Apache, Nginx, Cassandra, DataBases||See Application Performance Management.||Proprietary|
|AQtime by SmartBear Software||Windows||.NET 1.0 to 4.0 applications (including ASP.NET applications), Silverlight 4.0 applications, Windows 32- and 64-bit applications including C, C++, Delphi for Win32 and VBScript and JScript functions||Performance profiler and memory/resource debugging toolset.||Proprietary|
|CodeAnalyst by AMD||Linux, Windows||C, C++,Objective C .NET, Java (works at the executable level)||AMD uProf supersedes CodeAnalyst and CodeXL for CPU and Power profiling on AMD processors.||Free/open source (GPL) or proprietary|
|AMD CodeXL by AMD||Linux, Windows||For GPU profiling and debugging: OpenCL.||A tool suite for GPU profiling, GPU debugger and a static kernel analyzer.||Free/open source (MIT)|
|AMD uProf by AMD||Linux, Windows||C, C++, .NET, Java, Fortran||Code profiler, does sampling based profiling on AMD processors.||Proprietary|
|DevPartner by Borland / Micro Focus||.NET, Java||Test suite that automatically detects and diagnoses software defects and performance problems.||Proprietary|
|DTrace by Sun Microsystems||Solaris, Linux, BSD, macOS||Comprehensive dynamic tracing framework for troubleshooting kernel and application problems on production systems in real time.||Free/open source (CDDL)|
|dynamoRIO by RIO||Linux, Windows||Dynamic binary instrumentation framework for the development of dynamic program analysis tools.||Free/open source - BSD|
|Dynatrace||Linux, Windows, iOS, Android, Azure, AWS, AIX, Solaris, HP/UX, zOS, zLinux||.NET, Java, PHP, HTML5, Ajax (for web sites), Objective-C/iOS, Java/Android, C/C++, CICS, Apache, Nginx, Cassandra, Hadoop, MongoDB, HBase||See Application Performance Management.||Proprietary|
|Extrae||Linux, Android||Primarily C/C++/Fortran, but can profile any application linking against supported parallel libraries (e.g. MPI4PY)||HPC performance analysis tool with viewer and supporting utilities. Primarily designed for parallel applications with support for MPI, OpenMP, CUDA, OpenCL, pthreads, and OmpSs. Additional features include user function tracing and hardware event capture via PAPI.||Free/open source - LGPL-2.1|
|FusionReactor||Linux, Windows, macOS, AWS, Azure, Google Cloud||Java, ColdFusion, Apache, MongoDB Works with any Language supported by the JVM||Performs Application Performance Management and Performance and Root Cause Analysis. Combines APM and Low Level Developer Style Tooling; also includes a debugger and Java, memory, thread, and CPU profilers.||Proprietary|
|GlowCode||Windows||64-bit and 32-bit applications, C, C++, .NET, and dlls generated by any language compiler.||Performance and memory profiler that identifies time-intensive functions and detects memory leaks and errors.||Proprietary|
|gprof||Linux/Unix||Any language supported by gcc||Several tools with combined sampling and call-graph profiling. A set of visualization tools, VCG tools, uses the Call Graph Drawing Interface (CGDI) to interface with gprof. Another visualization tool that interfaces with gprof is KProf.||Free/open source - BSD version is part of 4.2BSD and GNU version is part of GNU Binutils (by GNU Project)|
|Instana||Linux, Windows, iOS, Android, Azure, AWS, AIX, Solaris, HP/UX, zOS, zLinux||.NET, .Net core, Java, PHP, Ruby, Python, Crystal, Scala, Kotlin, Clojure, Haskell, Node.js, Web Browser, Apache, Nginx, Cassandra, Hadoop, MongoDB, Elasticsearch, Kafka||See Application Performance Management.||Proprietary|
|Instruments with Xcode||macOS||C, C++, Objective-C/C++, Swift, Cocoa apps.||Instruments shows a time line displaying any event occurring in the application, such as CPU activity variation, memory allocation, and network and file activity, together with graphs and statistics.|
Group of events are monitored by selecting specific instruments from: File Activity, Memory Allocations, Time Profiler, GPU activity etc. For system wide impact of the executable: System Trace, System usage, Network Usage, Energy log etc are useful.
|Free. Proprietary. Bundled with Xcode, which is also free.|
|Intel Advisor||Linux and Windows. Viewer only on macOS.||C, C++, Data Parallel C++ and Fortran||A collection of design and analysis tools - vectorization (SIMD) optimization, thread prototyping, automated roofline analysis, offload modeling and flow graph analysis||Freeware and Proprietary. Available as part of Intel oneAPI Base Toolkit.|
|Linux Trace Toolkit (LTT)||Linux||Requires patched kernel||Collects data on processes blocking, context switches, and execution time. This helps identify performance problems over multiple processes or threads. Superseded by LTTng.||GPL|
|LTTng (Linux Trace Toolkit Next Generation)||Linux||System software package for correlated tracing of kernel, applications and libraries.||GPL/LGPL/MIT|
|OProfile||Linux||Profiles everything running on the Linux system, including hard-to-profile programs such as interrupt handlers and the kernel itself.||Sampling profiler for Linux that counts cache misses, stalls, memory fetches, etc.||Open Source GPLv2|
|Linux, Solaris||C, C++, Fortran, Java; MPI||Performance and memory profiler.||Proprietary freeware|
|perf tools||Linux kernel 2.6.31+||Sampling profiler with support of hardware events on several architectures.||GPL|
|Performance Application Programming Interface (PAPI)||Various||Library for hardware performance counters on modern microprocessors.|
|LIKWID||Linux||C/C++, Fortran, Python, Java and Lua||Toolsuite of command line applications and library for performance oriented programmers (hardware performance monitoring, affinity control, etc.).||GPLv3|
|Pin by Intel||Linux, Windows, macOS, Android||Dynamic binary instrumentation system that allows users to create custom program analysis tools.||Proprietary but free for non-commercial use|
|Rational PurifyPlus||AIX, Linux, Solaris, Windows||Performance profiling tool, memory debugger and code coverage tool.||Proprietary|
|Scalasca||Linux||C/C++, Fortran||Parallel trace analyser.||Free/open source (BSD license)|
|Shark by Apple||macOS (discontinued with 10.7)||Performance analyzer.||Proprietary freeware|
|Superluminal Performance||Windows, Xbox, PlayStation||C, C++, Rust||Hybrid sampling & instrumenting profiler, built with usability and scalability in mind.||Proprietary|
|Systemtap||Linux||Programmable system tracing/probing tool; may be scripted to generate time- or performance-counter- or function-based profiles of the kernel and/or its userspace.||Open source|
|timemory||Linux, macOS, Windows||C, C++, Python, Fortran||Modular C++ toolkit for creating scalable custom instrumentation and sampling tools for performance analysis. Designed to minimize overhead by adapting to the interface of each performance analysis component at compile-time and simplify adding support for invocation and data storage within multi-threaded and multi-process runtimes. Includes many pre-built components for timing, resource usage, hardware-counters, Roofline Model, and the instrumentation APIs for VTune, Intel Advisor, LIKWID, and Arm MAP, among others. Components can be arbitrarily bundled together into a single handle for collective invocations and input argument broadcasting. Python bindings are provided for every component as a stand-alone class for implementing low-overhead Python profiling tools. Profiling via dynamic instrumentation is available on Linux.||Free/Open-source (MIT)|
|Valgrind||Linux, macOS, Solaris, Android||Any, including assembler||System for debugging and profiling; supports tools to either detect memory management and threading bugs, or profile performance (cachegrind and callgrind). KCacheGrind, valkyrie and alleyoop are front-ends for valgrind.||Free/open source (GPL)|
|VTune Profiler by Intel Corporation|
(formerly VTune Amplifier)
|Linux, Windows, viewer only for macOS||C, C++, C#, Data Parallel C++ (DPC++), Fortran, .NET, Java, Python, Go, ASM Assembly||A collection of profiling analyses implemented with sampling, instrumentation and processor trace technologies. Includes Hotspot, Threading, HPC, I/O, FPGA, GPU, System, Throttling and Microarchitecture analyses.||Freeware and Proprietary. Also available as a part of Intel oneAPI base toolkit.|
|Windows Performance Analysis Toolkit by Microsoft||Windows||Proprietary freeware|
|RotateRight Zoom||Linux, macOS, Viewer Only for Windows||Supports most compiled languages on ARM and x86 processors.||Graphical and command-line statistical (event-based) profiler.|
|VisualSim||Linux, macOS, Microsoft Windows||Supports C/C++/SystemC||Graphical modeling and Simulation platform to select, analyze and validate architecture of complex electronics systems for performance, power and reliability.||Proprietary|
C and C++
- Arm MAP, a performance profiler supporting Linux platforms.
- AppDynamics, an application performance management solution[buzzword] for C/C++ applications via SDK.
- AQtime Pro, a performance profiler and memory allocation debugger that can be integrated into Microsoft Visual Studio, and Embarcadero RAD Studio, or can run as a stand-alone application.
- IBM Rational Purify was a memory debugger allowing performance analysis.
- Instruments (bundled with Xcode) is used to profile an executable's memory allocations, time usage, filesystem activity, GPU activity etc.
- Intel Parallel Studio contains Intel VTune Amplifier, which tunes both serial and parallel programs. It also includes Intel Advisor and Intel Inspector. Intel Advisor optimizes vectorization (use of SIMD instructions) and prototypes threading implementations. Intel Inspector detects and debugs races, deadlocks and memory errors.
- ParasoftInsure++ provides a graphical tool that displays and animates memory allocations in real time to expose memory blowout, fragmentation, overuse, bottlenecks and leaks.
- Timemory, a modular C++ toolkit for creating performance analysis tools which provides numerous command-line tools and libraries as a by-product of its flexibility and reusability.
- Visual Studio Team System Profiler, commercial profiler by Microsoft.
- inspectIT is an open-source application performance management (APM) solution[buzzword] for monitoring and analyzing software applications, available under the Apache License, Version 2.0 (ALv2).
- JConsole is the profiler which comes with the Java Development Kit
- JRockit Mission Control, a profiler with low overhead.
- Netbeans Profiler, a profiler integrated into the NetBeans IDE (internally uses jvisualvm profiler)
- Plumbr, Java application performance monitoring with automated root cause detection. Links memory leaks, GC inefficiency, slow database and external web service calls, locked threads, and other performance problems to the line in source code that causes them.
- OverOps, Continuous reliability for the modern software supply chain, automatically detect and deliver root cause automation for all errors.
- VisualVM is a visual tool integrating several commandline JDK tools and lightweight profiling capabilities. It is bundled with the Java Development Kit since version 6, update 7.
- FusionReactor, Java application performance monitoring - low overhead, production grade tools for production debugging, code profiling, memory and thread analysis
- CLR Profiler is a free memory profiler provided by Microsoft for CLR applications.
- GlowCode is a performance and memory profiler for .NET applications using C# and other .NET languages. It identifies time-intensive functions and detects memory leaks and errors in native, managed and mixed Windows x64 and x86 applications.
- Xdebug is a PHP extension which provides debugging and profiling capabilities.
- Memory debugger (includes list of memory profilers)
- ^'CodeXL'. Archived from the original on 19 September 2013. Retrieved 26 September 2013.CS1 maint: discouraged parameter (link)
Firefox Xdebug Not Showing
- Performance Analysis Tools, article from the Lawrence Livermore National Laboratory