{"id":521,"date":"2016-10-09T08:18:47","date_gmt":"2016-10-09T16:18:47","guid":{"rendered":"https:\/\/www.pnfsoftware.com\/blog\/?p=521"},"modified":"2017-08-06T10:48:05","modified_gmt":"2017-08-06T18:48:05","slug":"jeb-debuggers-interpreter","status":"publish","type":"post","link":"https:\/\/www.pnfsoftware.com\/blog\/jeb-debuggers-interpreter\/","title":{"rendered":"Advanced Debugger Usage via the Interpreter"},"content":{"rendered":"<p>This blog is a follow-up to the original debuggers tutorial published <a href=\"https:\/\/www.pnfsoftware.com\/blog\/jeb-android-debuggers\/\">here<\/a>. It focuses on the debuggers&#8217; <strong>command interpreters<\/strong>, and how to use the new advanced features introduced in <a href=\"https:\/\/www.pnfsoftware.com\/jeb2cl\">JEB 2.2.10<\/a> to make the most out of your live debugging sessions.<\/p>\n<h1>Context<\/h1>\n<p>When debugging with JEB,\u00a0 you have the standard basic visual options to set\/unset breakpoints, step and 3 tabs that gives some hints on the device being debugged<\/p>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-522 size-medium\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022-300x185.png\" alt=\"Debugger main features\" width=\"300\" height=\"185\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022-300x185.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022-768x473.png 768w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022-1024x630.png 1024w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/JEB2-home-clucas-jeb2-workspace-jeb2-core2-core-testdata-appcheck-debug.apk-DEBUGGING-_022.png 1178w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>So let&#8217;s see today a feature that has been newly refreshed: the interpreter. It is available in the <em>Console<\/em> window<\/p>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/S\u00e9lection_023.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-524\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/S\u00e9lection_023-300x80.png\" alt=\"Console Tab\" width=\"300\" height=\"80\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/S\u00e9lection_023-300x80.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/S\u00e9lection_023-768x205.png 768w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/S\u00e9lection_023.png 937w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>The first command to learn is <strong><em><span style=\"color: #0000ff;\">help<\/span><\/em><\/strong>: it lists all the available commands. The Console part, as well as the Logger part, is common to all debuggers. So the first step is to select the debugger to work with.<\/p>\n<p>Type <span style=\"color: #0000ff;\"><em><strong>list<\/strong><\/em><\/span> to see available debuggers<\/p>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreters_list.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-533\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreters_list-300x118.png\" alt=\"interpreters_list\" width=\"300\" height=\"118\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreters_list-300x118.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreters_list.png 334w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In this case, we have 2 active debuggers: <em>VM<\/em> (for java code) and <em>Process<\/em> (for native code). Let&#8217;s connect to the VM debugger (it is always available when you debug an android project). Type <span style=\"color: #0000ff;\"><em><strong>use 1<\/strong><\/em><\/span>. The prompt changes to indicate the current debugger. Use <em><strong><span style=\"color: #0000ff;\">exit<\/span><\/strong><\/em> to go back to root level.<\/p>\n<p>There are 2 types of commands in the VM interpreter: thread related commands and object interaction commands.<\/p>\n<h1>VM Commands<\/h1>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_thread.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-534\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_thread-300x79.png\" alt=\"interpreter_vm_thread\" width=\"300\" height=\"79\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_thread-300x79.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_thread-768x202.png 768w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_thread.png 818w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here is a summary of the thread management commands.\u00a0 It consists of a set of debugger basic features that are available in the UI: resume, step, manage breakpoints.<\/p>\n<blockquote><p>By pressing enter without any command, you can repeat the same action, which is pretty handy for step actions.<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>But that&#8217;s not all, the interpreter has some more powerful commands to manage objects\/classes and interact with them. Let&#8217;s take a look at these commands<\/p>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_objects.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-536\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_objects-300x44.png\" alt=\"interpreter_vm_objects\" width=\"300\" height=\"44\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_objects-300x44.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_objects.png 725w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<blockquote><p>To get more help on a command, type &#8220;help $command$&#8221;, there will be a full description of it.<\/p><\/blockquote>\n<h2>Class Commands<\/h2>\n<p>Now,\u00a0 here is the interesting step: you can retrieve <em><span style=\"color: #0000ff;\"><strong>fields<\/strong><\/span><\/em>\/<span style=\"color: #0000ff;\"><strong><em>methods<\/em><\/strong><\/span> from a <strong>cid<\/strong>. A cid (stands for classId) represents a way to access the class. It can be:<\/p>\n<ul>\n<li>the signature of this class (Ljava\/lang\/String;),<\/li>\n<li>the inner class id prefixed with <em>&#8216;c&#8217;<\/em> character<\/li>\n<\/ul>\n<pre>VM&gt; methods Ljava\/lang\/String;<\/pre>\n<p>But it can also be inferred from an object:<\/p>\n<ul>\n<li>most common <em>this<\/em> object<\/li>\n<li>the object id prefixed with <em>&#8216;@&#8217;<\/em> character<\/li>\n<li>any object that can be referenced from these ones.<\/li>\n<\/ul>\n<pre>VM&gt; methods this.mActionBar<\/pre>\n<blockquote><p>JEB interpreter supports auto completion using TAB key.<\/p><\/blockquote>\n<p>By default, the interpreter only retrieves fields and methods from the current class (not all from superclasses and interfaces). There are 2 options for this:<\/p>\n<ul>\n<li>-r will recursively process the parent superclasses<\/li>\n<li>-i will display interfaces of the class (it can also be combined with -r to retrieve all interfaces of the superclasses)<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_methods.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-537\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_methods-300x106.png\" alt=\"interpreter_vm_methods\" width=\"300\" height=\"106\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_methods-300x106.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_methods-768x271.png 768w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_methods.png 1000w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>It is also possible to select the Thread and the frame you want to work with (is case you use the <em>this<\/em> object):<\/p>\n<ul>\n<li><strong>-t threadId<\/strong> to select the thread. Remember that you can see all threads with command <strong><em><span style=\"color: #0000ff;\">threads<\/span><\/em><\/strong>.<\/li>\n<li><strong>-f frameIndex<\/strong> to select the frame. By default, the top frame is used.<\/li>\n<\/ul>\n<h2>Object Commands<\/h2>\n<p>The <strong><em><span style=\"color: #0000ff;\">read<\/span><\/em><\/strong> command provides the same features as the VM\/Local tree using the command line.<\/p>\n<blockquote><p>All commands implement the -b option that prints out a brief output in one or two lines.<\/p><\/blockquote>\n<p>The <span style=\"color: #0000ff;\"><em><strong>set<\/strong><\/em><\/span> command allow set native types, string and arrays (object creation is not supported for now)<\/p>\n<pre>VM&gt; set this.vArrayInt [I{1, 2, 3}<\/pre>\n<pre>VM&gt; set this.mystring \"new content\"<\/pre>\n<p>Finally, the <span style=\"color: #0000ff;\"><em><strong>call<\/strong><\/em><\/span> command allow invoking any method on objects or classes. Arguments must be separated by commas.<\/p>\n<p><a href=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_call.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-542\" src=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_call-300x35.png\" alt=\"interpreter_vm_call\" width=\"300\" height=\"35\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_call-300x35.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2016\/09\/interpreter_vm_call.png 544w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<h1>Conclusion<\/h1>\n<p>Visit the JEB public Google groups if you have additional questions on how to use the debuggers&#8217; interpreters. Thank you for your support.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog is a follow-up to the original debuggers tutorial published here. It focuses on the debuggers&#8217; command interpreters, and how to use the new advanced features introduced in JEB 2.2.10 to make the most out of your live debugging sessions. Context When debugging with JEB,\u00a0 you have the standard basic visual options to set\/unset &hellip; <a href=\"https:\/\/www.pnfsoftware.com\/blog\/jeb-debuggers-interpreter\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Advanced Debugger Usage via the Interpreter<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,8],"tags":[],"class_list":["post-521","post","type-post","status-publish","format-standard","hentry","category-debugging","category-jeb2"],"_links":{"self":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/521","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=521"}],"version-history":[{"count":0,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/521\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}