Skip to content
Clotilde Toullec edited this page Jun 20, 2018 · 14 revisions

Welcome to the collectors wiki!

A collector is a debugging tool used that records the execution history of an expression, as well as some chosen meta data. It allows us to browse this history to understand the origin of the bug we want to solve. We present here the installation, configuration and browsing of the collectors through the simple example of a chat bot : our bot records activity in a Discord server. We assume that it can't understand some of the messages sent and that we don't know why nor when this bug will arise. To understand and debug it, we will collect the problematic messages and some of their meta data, such as their author, their content and the channel in which they were sent. This wiki presents the installation and configuration of a collector and its use to explore the collected data.

Installation

We install a collector in the messagePosted: method of our bot class. This method is called when a message is received from a Discord server. Who install the collector by right-clicking on the instance variable that we want to collect. A collector also can collect a temporary variable, the receiver or the resulting value of an expression.

On the collector installation, a configuration page pops up, allowing us to specify the use of our collector (see Configuration). Once the collector installed, the instrumented expression is highlighted and the collection history is accessible through a menu in the method margin. This menu also allows us to uninstall the collector.

Configuration

A collector can be specified through the configuration page of the collectors browser. We can choose the meta data the collector will record and decide the use of this meta data.

We can add a condition, using the requested meta data, to determine whether or not an object should be collected. The conditions will be tested before any collection, and the object will not be collected unless all the conditions are true. In our case, we chose to collect the message instance variable only if the message is written in a particular channel. In order to do that, we request the #value meta data - which gives us access to the value of the message variable at collection time - and use it to compare the channel in which it was written with the channel we want to monitor.

We also can add a meta data transformation. This allows the collection of a particular state of the meta data. In our example, we want to keep record of the message content and of its author ID.

History

The collect points inspector allows us to visualize the history of our expression evaluation. It displays the times at which collections occurred. For each collection, the expression and its sub-expressions are shown. The developer can select every sub-expression and see its value and the corresponding collected meta data.

It is also possible to inspect the value of this sub-expression.

We have the possibility to use a particular value as a replay. This is useful when the occurrence of the bug we explore is not predictable. Instead of re-executing the problematic code waiting for an rogue value to provoke a bug, we can re-execute it only with the rogue value we collected, sure to raise the bug again so that we can explore its origin.

The collect point inspector also provides an execution stack visualization, facilitating the understanding of the context in which the bug occurred.

Clone this wiki locally