Skip to content

Logging

Gregg Miskelly edited this page Mar 14, 2022 · 9 revisions

The MIEngine has logging in it to make it easy to see what commands we are sending to GDB/LLDB, what output GDB/LLDB is returning, and how long each command took.

Using debug builds of MIEngine

If you have the MIEngine solution open and you are hitting F5 using the debug configuration, the logging is automatically on. Just open the output window (Debug->Windows->Output) and you can see the interactions that MIEngine is having with the target debugger.

Enabling logging from Visual Studio

In Visual Studio 2017 and newer, it is easy to enable logging by opening the Visual Studio Command Window (View->Other Windows->Command Window), and use this command to control logging:

Debug.MIDebugLog  (/On[:<filename>] | /Off) [/OutputWindow]

Options:

  • /On[:] – Turn on MIEngine logging. Optionally specify a file to contain the log. Either the file must be supplied, or the “/OutputWindow” option must appear.
  • /Off -- Turn off MIEngine logging. If logging to a file the file is closed.
  • /OutputWindow -- Log to the “Debug” pane in the output Window.

The command may be issued at any point. Logging can be turned on and off as often as desired. If you have enabled logging via SetMIDebugLogging.cmd this command will override those settings. Unlike SetMIDebugLogging.cmd, the MIDebugLog state is not remembered between VS invocations.

Enabling logging with SetMIDebugLogging.cmd

The Visual Studio 2015 version of MIEngine didn't ship with logging controls built into the command window. But logging can still be enabled from the command prompt by:

  • Clone the sources: git clone https://github.com/Microsoft/MIEngine.git
  • Enable logging: src\MICore\SetMIDebugLogging.cmd on
  • Restart Visual Studio
  • Try the scenario
  • To turn logging back off, run src\MICore\SetMIDebugLogging.cmd off
  • Open %TMP%\Microsoft.MIDebug.log

Additional notes:

  • SetMIDebugLogging.cmd has no dependencies, so you can copy it to another computer if you don't want to enlist on the target box.
  • If you are looking at Android scenarios, there is a '/serverlogging' argument to SetMIDebugLogging.cmd which can be used to turn on gdbserver logging