# Class Debug.Inspect

Description

  Allows for interactive debugging and live data structure inspection in both single- and multi-threaded programs. Creates an independent background thread that every pollinterval will show a list of running threads. Optionally, a triggersignal can be specified which allows the dump to be triggered by a signal.

  Example: In the program you'd like to inspect, insert the following one-liner:

      Debug.Inspect("/tmp/test.pike");

  Then start the program and keep it running. Next you create a /tmp/test.pike with the following content:

      void create() {
       werror("Only once per modification of test.pike\n");
      }

      int main() {
       werror("This will run every iteration\n");
       werror("By returning 1 here, we disable the stacktrace dumps\n");
       return 0;
      }

      void destroy() {
       werror("destroy() runs just as often as create()\n");
      }

  Whenever you edit /tmp/test.pike, it will automatically reload the file.

Variable _callback

  ``string`|`function`(`void`:`void`) Debug.Inspect._callback`

Description

  Either the callback function which is invoked on each iteration, or the name of a file which contains a class which is (re)compiled automatically and called on each iteration.

See also

  create

Variable _loopthread

  ``Thread.Thread` Debug.Inspect._loopthread`

Description

  The inspect-thread. It will not appear in the displayed thread-list.

Variable pollinterval

  ``int` Debug.Inspect.pollinterval`

Description

  The polling interval in seconds, defaults to 4.

Variable triggersignal

  ``int` Debug.Inspect.triggersignal`

Description

  If assigned to, it will allow the diagnostics inspection to be triggered by this signal.

Method create

  `Debug.Inspect Debug.Inspect(`string`|`function`(`void`:`void`)|`void` `cb`)`

Description

  Starts up the background thread.

Parameter `cb`

  Specifies either the callback function which is invoked on each iteration, or the name of a file which contains a class which is (re)compiled automatically with an optional `main()` method, which will be called on each iteration. If the `main()` method returns 0, new stacktraces will be dumped every iteration; if it returns 1, stacktrace dumping will be suppressed.

Note

  The compilation and the running of the callback is guarded by a catch(), so that failures (to compile) in that section will not interfere with the running program.

Note

  If the list of running threads did not change, displaying the list again will be suppressed.

See also

  triggersignal, pollinterval, _loopthread, _callback, Debug.globals