<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>Derick Rethans - tag: extensions</title>
    <link>http://derickrethans.nl/feed-extensions.xml</link>
    <description>This feed shows the latest 15 items with the tag extensions</description>
    <language>en-us</language>
    <copyright>All rights reserved - Derick Rethans</copyright>
    <managingEditor>derick@derickrethans.nl (Derick Rethans)</managingEditor>
    <pubDate>Wed, 03 Mar 2010 23:00:07 +0000</pubDate>
    <lastBuildDate>Wed, 03 Mar 2010 23:00:07 +0000</lastBuildDate>
    <generator>eZ Components Feed dev (http://ezcomponents.org/docs/tutorials/Feed)</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>60</ttl>
    <item>
      <title>Xdebug 2.1.0beta3 released</title>
      <link>http://derickrethans.nl/xdebug-210beta3.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_2_1_0beta3_released"/&gt;Xdebug 2.1.0beta3 released&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Europe/London&lt;/div&gt;
        &lt;div class="date"&gt;Saturday, February 27th 2010, 23:57 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;I've just released Xdebug 2.1.0beta3 which includes a few crash bugs as well as the issue that headers sent from PHP scripts are not actually set.&lt;/p&gt;
      &lt;p&gt;You can find the full changelog &lt;a href="http://xdebug.org/updates.php#x_2_1_0beta3"&gt;here&lt;/a&gt; and get the latest version from the &lt;a href="http://xdebug.org/download.php"&gt;download page&lt;/a&gt;.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002272352</guid>
      <pubDate>Sat, 27 Feb 2010 23:57:00 +0000</pubDate>
    </item>
    <item>
      <title>More source analysis with VLD</title>
      <link>http://derickrethans.nl/more-source-analysis-with-vld.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="more_source_analysis_with_vld"/&gt;More source analysis with VLD&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Friday, February 19th 2010, 11:27 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;&lt;a href="http://derickrethans.nl/projects.html#vld"&gt;VLD&lt;/a&gt; is a tool that I started working on years ago to visualise the opcode arrays in PHP. Opcode arrays are what PHP's compiler generates from your source code and can be compared to assembler code that is generated by a C compiler. Instead of it being directly executed by the CPU, it is instead executed by PHP's interpreter.&lt;/p&gt;
      &lt;p&gt;Over the years I've been adding some functionality, also aided by &lt;a href="http://ilia.ws"&gt;Ilia&lt;/a&gt; and some others, to show more information. For example Ilia has added a more verbose dumping format for opcodes (through the &lt;code&gt;vld.verbosity&lt;/code&gt; setting) whereas I have added routines to find out which ops in oparrays can never be reached. A very simple example of the latter is shown here:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
function test()
{
        echo "Hello!\n";
        return true;

        echo "This will not be executed.\n";
}
?&gt;

&lt;/pre&gt;
      &lt;p&gt;If we run the above through VLD with &lt;code&gt;php -dvld.active=1 test.php&lt;/code&gt;, you'll see the following output (I removed the part about the script body itself):&lt;/p&gt;
      &lt;pre&gt;Function test:
filename:       /tmp/test1.php
function name:  test
number of ops:  9
compiled vars:  none
line     # *  op           fetch  ext  return  operands
---------------------------------------------------------
   2     0  &gt;   EXT_NOP
   4     1      EXT_STMT
         2      ECHO                           'Hello%21%0A'
   5     3      EXT_STMT
         4    &gt; RETURN                         true
   7     5*     EXT_STMT
         6*     ECHO                           'This+will+not+be+executed.%0A'
   8     7*     EXT_STMT
         8*   &gt; RETURN                         null

End of function test.

&lt;/pre&gt;
      &lt;p&gt;Every opcode that has a &lt;code&gt;*&lt;/code&gt; after the number (like in &lt;code&gt;5*&lt;/code&gt;) is code that can not be reached, and can possibly be eliminated from the oparrays in an optimiser.&lt;/p&gt;
      &lt;p&gt;The dead code analysis routines have also made their way into &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; which uses them for the &lt;a href="http://xdebug.org/docs/code_coverage"&gt;code coverage&lt;/a&gt; functionality to highlight dead code. This mostly makes sense if you are running your code coverage together with unit tests such as you can do with &lt;a href="http://www.phpunit.de"&gt;PHPUnit&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;Recently I've been working on some new functionality to visualise all the code &lt;em&gt;paths&lt;/em&gt; that make up each function. These new routines sit on top of the routines that do dead code analysis. Every branch instruction (such as &lt;code&gt;if&lt;/code&gt;, but also &lt;code&gt;for&lt;/code&gt; and &lt;code&gt;foreach&lt;/code&gt;) is analysed and a list of branches is created. Each branch contains information about the line on which the branch starts, the starting and ending opcode numbers that belong to the branch, as well as to which other branches this branch can jump to. There can be either no linked branches (when for example a &lt;code&gt;return&lt;/code&gt; or &lt;code&gt;throw&lt;/code&gt; statement is found), one linked branch (for an unconditional jump) or two linked branches (on a branch instruction).  However, you need to be aware that internally, PHP's opcode don't always reflect the &lt;em&gt;source code&lt;/em&gt; exactly.&lt;/p&gt;
      &lt;p&gt;Once all the branches and their links are found, another algorithm runs to figure out which paths can be created out of all the branches. It is best to illustrate this with an example. So let us look at the following script:&lt;/p&gt;
      &lt;pre&gt;&lt;?php
function test()
{
        for( $i = 0; $i &lt; 10; $i++ )
        {
                if ( $i &lt; 5 )
                {
                        echo "-";
                }
                else
                {
                        echo "+";
                }
        }
        echo "\n";
}
?&gt;

&lt;/pre&gt;
      &lt;p&gt;In this script we have a &lt;code&gt;for&lt;/code&gt;-loop with a nested &lt;code&gt;if&lt;/code&gt; construct. When we run this script through VLD (with &lt;code&gt;php -dvld.verbosity=0 -dvld.dump_paths=1
-dvld.active=1 test2.php&lt;/code&gt;) we get the following output (again, only the &lt;code&gt;test()&lt;/code&gt; function and with some white space modifications):&lt;/p&gt;
      &lt;pre&gt;Function test:
filename:       /tmp/test2.php
function name:  test
number of ops:  22
compiled vars:  !0 = $i
line     # *  op             fetch  ext  return  operands
-----------------------------------------------------------
   2     0  &gt;   EXT_NOP
   4     1      EXT_STMT
         2      ASSIGN                             !0, 0
         3  &gt;   IS_SMALLER                 ~1      !0, 10
         4      EXT_STMT
         5    &gt; JMPZNZ                  9          ~1, -&gt;18
         6  &gt;   POST_INC                   ~2      !0
         7      FREE                               ~2
         8    &gt; JMP                                -&gt;3
   6     9  &gt;   EXT_STMT
        10      IS_SMALLER                 ~3      !0, 5
   7    11    &gt; JMPZ                               ~3, -&gt;15
   8    12  &gt;   EXT_STMT
        13      ECHO                               '-'
   9    14    &gt; JMP                                -&gt;17
  12    15  &gt;   EXT_STMT
        16      ECHO                               '%2B'
  14    17  &gt; &gt; JMP                                -&gt;6
  15    18  &gt;   EXT_STMT
        19      ECHO                               '%0A'
  16    20      EXT_STMT
        21    &gt; RETURN                             null

branch: #  0; line:  2- 4; sop:  0; eop:  2; out1:   3
branch: #  3; line:  4- 4; sop:  3; eop:  5; out1:  18; out2:   9
branch: #  6; line:  4- 4; sop:  6; eop:  8; out1:   3
branch: #  9; line:  6- 7; sop:  9; eop: 11; out1:  12; out2:  15
branch: # 12; line:  8- 9; sop: 12; eop: 14; out1:  17
branch: # 15; line: 12-14; sop: 15; eop: 16; out1:  17
branch: # 17; line: 14-14; sop: 17; eop: 17; out1:   6
branch: # 18; line: 15-16; sop: 18; eop: 21
path #1: 0, 3, 18,
path #2: 0, 3, 9, 12, 17, 6, 3, 18,
path #3: 0, 3, 9, 15, 17, 6, 3, 18,
End of function test.

&lt;/pre&gt;
      &lt;p&gt;This dump consists of a few different parts. First of all we can see some basic information containing the name, the number of ops (22) and the compiled variables. The second part is a dump of all the opcodes that make up this function. The last part contains information about all the branches and the possible paths.  This information is a bit hard to visualize in its textual form, so I've also added some code that dumps this information to a file format that the &lt;a href="http://graphviz.org/"&gt;GraphViz&lt;/a&gt; tool "dot" can use to create a pretty graph. For this we re-run the previous PHP invocation as &lt;code&gt;php -dvld.dump_paths=1
-dvld.verbosity=0 -dvld.save_paths=1 -dvld.active=1 test2.php&lt;/code&gt;. This creates the file &lt;code&gt;/tmp/paths.dot&lt;/code&gt; that "dot" can use. If we run &lt;code&gt;dot -Tpng
/tmp/paths.dot &gt; /tmp/paths.png&lt;/code&gt; we end up with the following picture:&lt;/p&gt;
      &lt;img src="/images/vld-paths.png" alt="vld-paths.png"/&gt;
      &lt;p&gt;If we put this graph next to the code, we can explain how this works. Every branch is named by the number of the first opcode in that branch:&lt;/p&gt;
      &lt;ul&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #1&lt;/code&gt; is the assignment of &lt;code&gt;$i&lt;/code&gt; in line 4.&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #3&lt;/code&gt; is the &lt;em&gt;loop test&lt;/em&gt; in line 4. If the condition doesn't match, we jump to &lt;code&gt;op #18&lt;/code&gt; on line 16 that echos the newline.&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #9&lt;/code&gt; is the &lt;code&gt;if&lt;/code&gt; condition on line 6.&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #12&lt;/code&gt; is when the &lt;code&gt;if&lt;/code&gt; condition returns true and&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #15&lt;/code&gt; is when the &lt;code&gt;if&lt;/code&gt; condition returns false.&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #17&lt;/code&gt; sits behind both &lt;code&gt;op #12&lt;/code&gt; and &lt;code&gt;op #15&lt;/code&gt; and makes sure there is a jump to the counting expression in &lt;code&gt;#op 6&lt;/code&gt;.&lt;/p&gt;
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;&lt;code&gt;op #6&lt;/code&gt; is the post increment operation on line 4 which will then again be followed by &lt;code&gt;op #3&lt;/code&gt; to check whether the end of the loop has been reached.&lt;/p&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
      &lt;p&gt;This is of course a very simple example, but it also works for (multiple) classes and functions in a file. You just need to make sure to tell VLD that you don't want the code &lt;em&gt;executed&lt;/em&gt; as the output could be very large. You can use the &lt;code&gt;vld.execute=0&lt;/code&gt; php.ini setting for that.&lt;/p&gt;
      &lt;p&gt;I hope this new functionality can spread some light on how loops etc. work in PHP. In order to play with the code, you need to check-out VLD from my SVN with &lt;code&gt;svn co svn://svn.xdebug.org/svn/php/vld/trunk vld&lt;/code&gt;. You can also view the code on-line at &lt;a href="http://svn.xdebug.org/cgi-bin/viewvc.cgi/vld/trunk/?root%3Dphp"&gt;http://svn.xdebug.org/cgi-bin/viewvc.cgi/vld/trunk/?root=php&lt;/a&gt;. Look out for a new release coming soon!&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002191145</guid>
      <pubDate>Fri, 19 Feb 2010 11:27:00 +0000</pubDate>
    </item>
    <item>
      <title></title>
      <link>http://derickrethans.nl/.html</link>
      <description></description>
      <guid></guid>
      <pubDate>Wed, 03 Mar 2010 23:00:07 +0000</pubDate>
    </item>
    <item>
      <title>New Xdebug browser extensions</title>
      <link>http://derickrethans.nl/new-xdebug-helper.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="new_xdebug_browser_extensions"/&gt;New Xdebug browser extensions&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; London, UK&lt;/div&gt;
        &lt;div class="date"&gt;Wednesday, February 17th 2010, 12:33 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;Years ago I &lt;a href="http://derickrethans.nl/starting-xdebugs-debugger-with-firefox.html"&gt;wrote&lt;/a&gt; about a Firefox extension that allows you to start an &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; debugging session by clicking on an icon in Firefox' status bar. For some unexplained reason, this extension is no longer available through Firefox' addon-site. Although I have a copy at &lt;a href="http://xdebug.org/files/xdebug_helper-0.3.1-fx.xpi"&gt;http://xdebug.org/files/xdebug_helper-0.3.1-fx.xpi&lt;/a&gt; for archival purposes, there are now a few other browser extensions that do the same thing.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;easy Xdebug&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/58688"&gt;easy Xdebug&lt;/a&gt; is an extension that serves as a replacement for the now unavailable Xdebug helper extension. It's written by &lt;a href="https://addons.mozilla.org/en-US/firefox/user/5114063"&gt;Brecht Vanhaesebrouck&lt;/a&gt; of &lt;a href="http://www.elime.be/"&gt;eLime&lt;/a&gt;. The extension was originally tested with &lt;a href="http://netbeans.org/"&gt;Netbeans&lt;/a&gt; but it also seems to work fine with &lt;a href="http://www.activestate.com/komodo/"&gt;Komodo&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;Xdebug enabler&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;&lt;a href="http://blog.remailed.net/2010/01/xdebug-enabler-v0-2/"&gt;Xdebug enabler&lt;/a&gt; is an extension for Google's Chrome browser. It &lt;em&gt;"allows you to enable and disable triggering Xdebug from with in Chrome. Useful if you are a web developer using an IDE that supports Xdebug like Eclipse with PDT."&lt;/em&gt; It's written by 'remailednet' and available through the &lt;a href="https://chrome.google.com/extensions/detail/eippbhbeglgcphcjmpjcjinjamabeoln"&gt;Google Chrome Extensions&lt;/a&gt; website.&lt;/p&gt;
      &lt;p&gt;
        &lt;strong&gt;JavaScript 'enabler'&lt;/strong&gt;
      &lt;/p&gt;
      &lt;p&gt;I also ran across a &lt;a href="http://highervisibilitywebsites.com/simple-cross-browser-xdebug-helper-session-starter-and-stopper-no-add-ons-needed"&gt;blog post&lt;/a&gt; by 'Caleb G' from &lt;a href="http://highervisibilitywebsites.com/"&gt;HigherVisibility&lt;/a&gt;. Instead of making an extension for a specific browser, he outlines two JavaScript bookmarklets that allow you to start and stop an &lt;a href="http://xdebug.org"&gt;Xdebug&lt;/a&gt; debugging session.&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; The "Xdebug enabler" Chrome Extension seems to have some issues. There is now also an alternative Chrome Extension called &lt;strong&gt;Xdebug helper&lt;/strong&gt; that integrates quite a bit better. You can find it at its &lt;a href="https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc"&gt;Google Chrome Extension&lt;/a&gt; page.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002171233</guid>
      <pubDate>Wed, 17 Feb 2010 12:33:00 +0000</pubDate>
    </item>
    <item>
      <title>Xdebug 2.1.0beta2 released</title>
      <link>http://derickrethans.nl/xdebug-210beta2.html</link>
      <description>&lt;div class="article"&gt;
  &lt;div class="body"&gt;
    &lt;div class="articleListItem"&gt;
      &lt;h1&gt;&lt;a name="xdebug_2_1_0beta2_released"/&gt;Xdebug 2.1.0beta2 released&lt;/h1&gt;
      &lt;dl class="head"/&gt;
      &lt;div class="articleMetaData"&gt;
        &lt;div class="location"&gt; Dieren, the Netherlands&lt;/div&gt;
        &lt;div class="date"&gt;Wednesday, February 3rd 2010, 18:51 GMT&lt;/div&gt;
      &lt;/div&gt;
      &lt;p&gt;I've just released Xdebug 2.1.0beta2 which features a few small bug fixes only. With this release the Windows 5.3/VC6 binaries also return.&lt;/p&gt;
      &lt;p&gt;One of the bug fixes is in a new feature that allows you to configure that the debugger should connect back to the IDE running on the machine that initiated the HTTP request. This feature, that originally was contributed by Lucas Nealan and Brian Shire of Facebook, allows more easy use of multiple IDEs (users) working on the same code base. In order to enable this, set &lt;a href="http://xdebug.org/docs/all_settings#remote_connect_back"&gt;xdebug.remote_connect_back&lt;/a&gt; to 1. See the documentation for more information.&lt;/p&gt;
      &lt;p&gt;Of course, this feature should only be enabled if &lt;em&gt;nobody&lt;/em&gt; besides authorized developers can access the machine on which the xdebug.remote_connect_back callback feature has been enabled. Instead of enabling this setting, you can also support multiple developers through the proxy functionality that the DBGp protocol supports. For more information on that, see &lt;a href="http://derickrethans.nl/debugging-with-multiple-users.html"&gt;Debugging with multiple users&lt;/a&gt;.&lt;/p&gt;
      &lt;p&gt;You can find the full changelog &lt;a href="http://xdebug.org/updates.php#x_2_1_0beta1"&gt;here&lt;/a&gt; and get the latest version from the &lt;a href="http://xdebug.org/download.php"&gt;download page&lt;/a&gt;.&lt;/p&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
      <guid>201002031832</guid>
      <pubDate>Wed, 03 Feb 2010 18:51:00 +0000</pubDate>
    </item>
  </channel>
</rss>
