Standard library - debugger

module debugger
  // module was added in PR#1160

  type cmd = map(data)

  // Send debug commands to running sessions:
  def debugCommand : appstate -> string -> string -> cmd -> result(string, data)

  // Get the stream of Mix events:
  def debugEvents : string -> string -> stream(data)

  // Get the stream of DOM output:
  def debugMirror : string -> string -> stream(data)

  // Build debug commands:
  def cmd_profile_enable : cmd
  def cmd_profile_disable : cmd
  def cmd_profile_status : cmd
  def cmd_profile_clear : cmd
  def cmd_profile_get : cmd
  def cmd_profile_save : string -> cmd
  def cmd_trace_enable : cmd
  def cmd_trace_disable : cmd
  def cmd_trace_status : cmd
  def cmd_trace_setLevels : array(number) -> cmd
  def cmd_trace_getLevels : cmd
  def cmd_stats_clear : cmd
  def cmd_stats_get : cmd
  def cmd_stats_get_clear : cmd
  def cmd_mixEventLogging_set : string -> cmd
  def cmd_mixEventLogging_status : cmd
  def cmd_debugChannel_enable : string -> cmd
  def cmd_debugChannel_disable : cmd
  def cmd_debugChannel_status : cmd
  def cmd_domRestore_enable : cmd
  def cmd_domRestore_disable : cmd
  def cmd_vmMemStats : cmd
  def cmd_messaging_list : cmd
  def cmd_messaging_set : string -> data -> cmd
  def cmd_messaging_send : string -> data -> cmd
  def cmd_messaging_get : string -> cmd
  def cmd_viewstack_topViewID : cmd
  def cmd_viewstack_screenFlush : cmd
  def cmd_viewstack_list : cmd
  def cmd_viewstack_get : string -> cmd
  def cmd_view_get : string -> cmd
  def cmd_view_spreadsheet : string -> data -> cmd
  def cmd_view_spreadsheet_omitValue : string -> data -> cmd
  def cmd_view_actions : string -> cmd
  def cmd_action_get : string -> string -> cmd
  def cmd_db_query : data -> string -> bool -> bool -> number -> cmd
  def cmd_testing_startRecording : string -> cmd
  def cmd_testing_stopRecording : cmd
  def cmd_testing_replayTest : string -> cmd
  def cmd_testing_replayTestOverride : string -> testing.overrides -> cmd
  def cmd_testing_replayTestVisually : string -> cmd
  def cmd_testing_replayTestVisuallyOverride : string -> testing.overrides -> cmd
module end

Send debug commands to running sessions

  def debugCommand : appstate -> string -> string -> cmd -> result(string, data)

If there is a session for the given app which opened the debug channel called debugChannel it is possible to send a debug command cmd to this session so that the command is executed in the scope of that session:

let r = debugger.debugCommand(appstate, app, debugChannel, cmd)

How to open a debug channel? Just pass the special parameter _rmx_debugChannel and set it to the channel ID (any ID will do). For example, after opening

<https://remix-dev.remixlabs.com/e/preview/myApp/home?_rmx_debugChannel=xyz>

in the browser, you can send a debug command by running

debugger.debugCommand(appstate, "myApp", "xyz", cmd)

Alternatively, you can also open a debug channel by sending the cmd_debugChannel_enable message to the entry point debugCommand, e.g. with the Track message msg_introspect_debug.

Debug commands

See the wiki page about debug commands.

Mix events

With debugEvents(appname, channel) an (infinite) stream is returned that reports the Mix events of the target app. Note that you normally also need to adjust the level of the Mix event logging by sending cmd_mixEventLogging_set.

It is not possible to close this stream.

DOM mirroring

With debugMirror(appname, channel) an (infinite) stream is returned that includes the DOM output of the target app.

It is not possible to close this stream.