<p>pespin <strong>submitted</strong> this change.</p><p><a href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17488">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">doc/manuals: Add proper content for Debugging section<br><br>Change-Id: Iaed2544d59f7c5dd69eef3ddfade544b35c837cd<br>---<br>M doc/manuals/chapters/debugging.adoc<br>1 file changed, 64 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/doc/manuals/chapters/debugging.adoc b/doc/manuals/chapters/debugging.adoc</span><br><span>index bea1e5c..6c32e7a 100644</span><br><span>--- a/doc/manuals/chapters/debugging.adoc</span><br><span>+++ b/doc/manuals/chapters/debugging.adoc</span><br><span>@@ -1,4 +1,67 @@</span><br><span> [[debugging]]</span><br><span> == Debugging</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-*TODO*: describe how to invoke 'ipdb3' and step into a suite's test script</span><br><span style="color: hsl(120, 100%, 40%);">+{app-name} is a complex program which at the same time orchestrates sets of</span><br><span style="color: hsl(120, 100%, 40%);">+other complex programs to form a network of nodes. As such, it can be sometimes</span><br><span style="color: hsl(120, 100%, 40%);">+challenging to find out what is going on during a trial run. This section aims</span><br><span style="color: hsl(120, 100%, 40%);">+at providing some tips on how to debug possible issues.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== Logging level</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+{app-name} runs by default under 'info' log level. As a first debugging step, it</span><br><span style="color: hsl(120, 100%, 40%);">+is always a good idea to increase log verbosity. By switching to debug level</span><br><span style="color: hsl(120, 100%, 40%);">+(command line argument '-l dbg'), a lot more information and events are displayed which</span><br><span style="color: hsl(120, 100%, 40%);">+can give a much better idea to understand possible misconfigurations or wrong</span><br><span style="color: hsl(120, 100%, 40%);">+steps.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+In any case, {app-name} usually provides several log files of interest. In</span><br><span style="color: hsl(120, 100%, 40%);">+general, both a 'log' and a 'log_brief' are stored directly under the trial's</span><br><span style="color: hsl(120, 100%, 40%);">+run directory, the first containing output up to debug level included, while the</span><br><span style="color: hsl(120, 100%, 40%);">+second contains output up to info level included. Furthermore, {app-name} writes</span><br><span style="color: hsl(120, 100%, 40%);">+a debug level log file per test case under each test's run directory.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+It is also in general useful to enable the '-T' command line argument. By using</span><br><span style="color: hsl(120, 100%, 40%);">+it, it will instruct {app-name} to write the full backtrace to the log output</span><br><span style="color: hsl(120, 100%, 40%);">+when something wrong happens, such an unexpected exception.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+[[pdb]]</span><br><span style="color: hsl(120, 100%, 40%);">+=== python debugger</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+{app-name} can be further debugged using python's debugger 'pdb'. Easiest way to</span><br><span style="color: hsl(120, 100%, 40%);">+use it is to modify the python code were you want to break and add this code:</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+import pdb; pdb.set_trace()</span><br><span style="color: hsl(120, 100%, 40%);">+----</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+When {app-name} runs over that code, it will pause and provide a debugging</span><br><span style="color: hsl(120, 100%, 40%);">+interactive shell, where one can inspect variables, execute code, etc.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+TIP: Remember {app-name} is managed by its internal main loop, meaning if you</span><br><span style="color: hsl(120, 100%, 40%);">+jump into a debugger console you will still need to give back control to the</span><br><span style="color: hsl(120, 100%, 40%);">+main loop for events to be processed and checks done. That can be done for</span><br><span style="color: hsl(120, 100%, 40%);">+instance by calling the 'MainLoop.sleep(log_obj, secs)' internal API in general</span><br><span style="color: hsl(120, 100%, 40%);">+or `sleep(secs)' under test context.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+=== debug suite</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Sometimes, however, one may be interested in debugging the behavior of the</span><br><span style="color: hsl(120, 100%, 40%);">+software under test by {app-name} rather than {app-name} itself. For instance,</span><br><span style="color: hsl(120, 100%, 40%);">+one may simply want to set up a full running network of nodes and keep it up</span><br><span style="color: hsl(120, 100%, 40%);">+until some manual tests are done, or one may want {app-name} to do so at a given</span><br><span style="color: hsl(120, 100%, 40%);">+point of time.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+To fulfill this kind of scenarios, {app-name} provides some code available for</span><br><span style="color: hsl(120, 100%, 40%);">+tests to gain access to a high-level interactive console which is fully</span><br><span style="color: hsl(120, 100%, 40%);">+integrated with {app-name}'s own main loop. So the approach here is usually to</span><br><span style="color: hsl(120, 100%, 40%);">+write a regular test (with its corresponding <<suite_conf,suite.conf>>) to set</span><br><span style="color: hsl(120, 100%, 40%);">+up and run all required processes and then allow it to jump into the interactive</span><br><span style="color: hsl(120, 100%, 40%);">+console instance. Then the test pulls received commands from it and it is</span><br><span style="color: hsl(120, 100%, 40%);">+responsible for parsing and implementing them. One command can for instance ask</span><br><span style="color: hsl(120, 100%, 40%);">+a modem to send an sms to another. Another command can for instance jump into a</span><br><span style="color: hsl(120, 100%, 40%);">+<<pdb,debugger console>>.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+The interactive console is available to tests through the 'prompt' method, and</span><br><span style="color: hsl(120, 100%, 40%);">+its implementation can be found under 'method input_polling' in 'util.py'.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+An interactive console example as explained in this section can be found under</span><br><span style="color: hsl(120, 100%, 40%);">+the 'debug/interactive.py' test in osmo-gsm-tester.git.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17488">change 17488</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-gsm-tester/+/17488"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gsm-tester </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Iaed2544d59f7c5dd69eef3ddfade544b35c837cd </div>
<div style="display:none"> Gerrit-Change-Number: 17488 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-Reviewer: pespin <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>