Experiment Result: Chapter-4
Experiment Result: Chapter-4
CHAPTER-4
EXPERIMENT RESULT
4.1 Results and Analysis
First of all we will build the project inside Eclipse IDE, building project means fetching /
importing the J oomla project inside the workspace and then eclipse, the eclipse IDE will parse
through all the files validating and indexing them inside the workspace
Figure 4.1: PHP.ini file settings
4.2 Code Debugging
Now as we already have set the Eclipse, XDEBUG, J OOMLA, and Apache server with MySQL
database we are ready for the debug process. The main aim here is to run the installed erroneous
website and step by step debug the code to bring the website online completely, since the
FATAL, CRITICAL errors are mostly absent from the J oomla default code. To simulate
environment with hidden issue we are installing a module called mod_stats on the J oomla
website, and after enabling this module we have issues on the site. The website is for example
46
purpose for this project only and is created with php and mysql using J oomla content
management system which is a robust, open source web development system in use since mid-
2000, as J oomla is already been discussed in previous sections we will skip anymore description
about what is J oomla and how it works. Initially the site was visible with all the information,
frontend formatting as shown in following screenshot:
The text box show where the statistics module which we are using for generating bug will be
placed.
Figure 4.2: Website Frontpage without errors & stats module
(Previous to addition of stats module)
47
Statistics page would like to insert will allow seeing the server and website statistics as follows:
The code of the above module is as follows:
<?php
/**
* @package J oomla.Site
* @subpackage mod_stats
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// no direct access
defined('_J EXEC') or die;
// Include the syndicate functions only once
require_once dirname(__FILE__).'/helper.php';
$serverinfo =$params->get('serverinfo');
$siteinfo =$params->get('siteinfo');
$list =modStatsHelper::getList($params);
$moduleclass_sfx =htmlspecialchars($params->get('moduleclass_sfx'));
require J ModuleHelper::getLayoutPath('mod_stats', $params->get('layout', 'default'));
After installing the above statistics module when the website code is run, we get following error
screen and website never loads
Figure 4.3: Error while launching the website
48
4.3 Finding the bug and debugging process
The reason we have such elaborate display of bugs and errors on the J oomla site is because we
have enabled error display function in php.ini file as follows:
display_startup_errors =On
log_errors =On
log_errors_max_len =1024
Using the information generated by the error display we can go and check each function and
associated page in the eclipse code browser, and run debug through each mentioned function of
related pages.
4.4 Analyzing Debug Info
After reading the debug info in Eclipse IDE, the very first function from module mod_stats
which is listed here is mod_stats.php.include () at line no.10 of the file mod_stats.php is pointing
us to check the mod_stats.php file at line no 10 for the possible error, now after opening the
mod_stats.php file and checking the code with the help of the eclipse-xdebug:
no direct access defined('_JEXEC') or die;
Include the syndicate functions only once require_once
dirname(__FILE__).'/helper.php'; $serverinfo = $params-
>get('serverinfo'); $siteinfo = $params->get('siteinfo');
$list = modStatsHelper::getList($params1); $moduleclass_sfx =
htmlspecialchars($params-
get('moduleclass_sfx'))
require JModuleHelper::getLayoutPath('mod_stats', $params-
>get('layout', default'));
We can see that following line is highlighted in the Eclipse code
browser:
$list = modStatsHelper::getList($params1);
Next, what we will do is to check what is getting stored in this variable and if it is initialized (if
related function is executed or not), for this we will go to the top left corner where the variables
used are shown and there values are also listed. To make it easier to explain here we have
49
highlighted the variables which are in yellow color (detailed diagrams available in main thesis).
As we can see from the screenshot above that variable $list is uninitialized, another variable
$params is initialized and is able to collect the values from code. But the other variable listed as
$params1 is uninitialized and is empty; the hint for checking this variable specially is that the
code execution (website launch) is breaking at this point! It seems like that the variable
$params1 is possibly wrongly written, to verify if this variable is used anywhere else in the code
we will use Search function provided in Eclipse menu, since there may be multiple php files in a
website it is cumbersome to search for a single function or variable by name but with eclipse
inbuilt search we can make it do it conveniently, this feature of eclipse has been used in this
project as well.
4.5 Analysis Of Main () Function
Software Main(), function is in /index.php page which is website is loaded, using eclipse IDE we
will first analyze all the functions by setting breakpoints in the code, the code is of 55 lines and
we are setting breakpoints at line no.10, 24 and 39. After launching debug the program sequence
breaks at line. No. 9 just before where we set our first break point at line 10:
Fig.1: Break Point
50
To make it concise inside the project work, we are not following through the screenshots of each
and every breakpoint; the code is available in appendix of main thesis. While running through all
the three breakpoints using step over and step into functions we found that there is nothing
unusual until we arrive at end line of the code, Eclipse IDE debugger stops and suspends the
triggered launch of the website saying that there is error in the launch due to errors at possible
lines, the exact same lines which are shown in figure 1 above. By just debugging the index.php
of the website in the web application debugging mode we are now able to see the possible errors
due to which the launch of the website is suspended, in the Debug section in top right corner
we can see that DEBUG has listed all the possible errors due to which the launch has been
suspended, now we can go through each function which is listed there and check what is causing
the problem.
4.6 Analyzing The Directory Tree
The complete directory tree pinpoints the location of sparam1 with this we can see that this
function is used no where else and is probably not written correctly, on doing the similar search
for variable $params we have following result, with this we can be sure that $params is
commonly used variable throughout the code. Thus what we will try next is to change the
$params1 to $params and see the difference, and what we are expecting is that the remote launch
of the website from Eclipse will be fully processed and not suspended, the reason for the website
launch suspension is the critical and fatal errors in the code.
4.7 Correcting And Re-Launching
After correcting the code and re-launching the debug session we can see that the session has
started successfully with no errors so far in the eclipse debug window, the session can be seen
active in the web browser and as we step over and into the code we see that every singles line of
/index.php is being parsed successfully without errors. And after reaching line no.55 we are now
redirected to mod_stats.php file within the eclipse and after stepping over to all the code lines in
mod_stats.php the website launches successfully showing the statistics module with any errors.
Thus by using eclipse and XDEBUG we successfully debugged an internal module with error
and debugged the website as whole (web application) and not file by file to find the bugs and
fixing them. we achieved the task of successfully finding the bug in the software code and use an
integrated development IDE with automated debugger (XDEBUG), the new aspects we learned
in this process are the automation of the website debugging process, using search functions,
parsing the suspected files presented by XDEBUG to Eclipse and pinpointing the problem.Other
major point of this project is that it is c
demonstrated that integrating the various available software development platforms we can not
only automate the cumbersome process of software debugging but also provide a platform to
write error free code by providing developer a unique feature of embedding debugging
procedure in the development cycle.
4.8 Functions included in the error report are:
Main()
Main(), function is in /index.php page which is the very first page parsed while the website is
loaded, using eclipse IDE we will first analyze all the functions by setting breakpoints in the
code, the code is of 55 lines and we are setting breakpoints at line no.10, 24 and 39.
After launching debug the program sequence breaks at line. No. 9 just befo
first break point at line 10:
Figure 4.4: Breakpoint setting at line no.10
To make it concise inside the project work, we are not following through the screenshots of each
and every breakpoint; the code is available in appendix for an
the pen drive. While running through all the three breakpoints using step over and step into
functions we found that there is nothing unusual until we arrive at end line of the code, Eclipse
51
parsing the suspected files presented by XDEBUG to Eclipse and pinpointing the problem.Other
major point of this project is that it is cross platform-ed based, which means it is successfully
demonstrated that integrating the various available software development platforms we can not
only automate the cumbersome process of software debugging but also provide a platform to
code by providing developer a unique feature of embedding debugging
procedure in the development cycle.
4.8 Functions included in the error report are:
Main(), function is in /index.php page which is the very first page parsed while the website is
oaded, using eclipse IDE we will first analyze all the functions by setting breakpoints in the
code, the code is of 55 lines and we are setting breakpoints at line no.10, 24 and 39.
After launching debug the program sequence breaks at line. No. 9 just before where we set our
Figure 4.4: Breakpoint setting at line no.10
To make it concise inside the project work, we are not following through the screenshots of each
and every breakpoint; the code is available in appendix for analysis and also can be provided in
the pen drive. While running through all the three breakpoints using step over and step into
functions we found that there is nothing unusual until we arrive at end line of the code, Eclipse
parsing the suspected files presented by XDEBUG to Eclipse and pinpointing the problem.Other
ed based, which means it is successfully
demonstrated that integrating the various available software development platforms we can not
only automate the cumbersome process of software debugging but also provide a platform to
code by providing developer a unique feature of embedding debugging
Main(), function is in /index.php page which is the very first page parsed while the website is
oaded, using eclipse IDE we will first analyze all the functions by setting breakpoints in the
code, the code is of 55 lines and we are setting breakpoints at line no.10, 24 and 39.
re where we set our
To make it concise inside the project work, we are not following through the screenshots of each
alysis and also can be provided in
the pen drive. While running through all the three breakpoints using step over and step into
functions we found that there is nothing unusual until we arrive at end line of the code, Eclipse
52
IDE debugger stops and suspends the triggered launch of the website saying that there is error in
the launch due to errors at possible lines, the exact same lines which are shown in figure above
(Error while launching the website) and we have the following window in front of us:
Figure 4.5: Bugs in functions listed by Eclipse using Xdebug
By just debugging the index.php of the website in the web application debugging mode we are
now able to see the possible errors due to which the launch of the website is suspended, in the
Debug section in top right corner we can see that XDEBUG has listed all the possible errors
due to which the launch has been suspended, now we can go thought each function which is
listed there and check what is causing the problem.
Figure 4.6: Variable values
The very first function from module mod_stats which is listed here is mod_stats.php.include() at
line no.10 of the file mod_stats.php is pointing us to check the mod_stats.php file at line no 10
for the possible error, we will now open the mod_s
of the eclipse-xdebug:
<?php
/**
* @packageJ oomla.Site
* @subpackage mod_stats
* @copyright Copyright (C) 2005
* @licenseGNU General Public License
*/
// no direct access
defined('_J EXEC') or die;
// Include the syndicate functions only once
require_once dirname(__FILE__).'/helper.php';
53
Figure 4.6: Variable values at runtime
The very first function from module mod_stats which is listed here is mod_stats.php.include() at
line no.10 of the file mod_stats.php is pointing us to check the mod_stats.php file at line no 10
for the possible error, we will now open the mod_stats.php file and check the code with the help
mod_stats
Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
GNU General Public License version 2 or later; see LICENSE.txt
// Include the syndicate functions only once
dirname(__FILE__).'/helper.php';
The very first function from module mod_stats which is listed here is mod_stats.php.include() at
line no.10 of the file mod_stats.php is pointing us to check the mod_stats.php file at line no 10
tats.php file and check the code with the help
2013 Open Source Matters, Inc. All rights reserved.
54
$serverinfo =$params->get('serverinfo');
$siteinfo =$params->get('siteinfo');
$list =modStatsHelper::getList($params1);
$moduleclass_sfx =htmlspecialchars($params->get('moduleclass_sfx'));
require J ModuleHelper::getLayoutPath('mod_stats', $params->get('layout', 'default'));
We can see that following line is highlighted in the Eclipse code browser:
$list =modStatsHelper::getList($params1);
Next, what we will do is to check what is getting stored in this variable and if it is initialized (if
related function is executed or not), for this we will go to the top left corner where the variables
used are shown and there values are also listed:
Figure 4.7: Checking Uninitialized Variables in suspected php file
To make it easier to explain here we have highlighted the variables which we have to focus in
yellow color. As we can see from the screenshot above that variable $list is uninitialized, another
variable $params is initialized and is able to collect the values from code. But the other variable
55
listed as $params1 is uninitialized and is empty; the hint for checking this variable specially is
that the code execution (website launch) is breaking at this point!
It seems like that the variable $params1 is possibly wrongly written, to verify if this variable is
used anywhere else in the code we will use Search function provided in Eclipse menu, since
there may bemultiple php files in a website these days it is cumbersome to search for a single
function or variableby name but with eclipse inbuilt search we can make it do it conveniently as
shown in the figure below:
Figure 4.8: Searching for variable value in working set
Above search revealed us following information:
56
Figure 4.9: Searching for variable value in working set
The complete directory tree is shown to pinpoint the location of $params1, with this we can see
that this function is used nowhere else and is probably not written correctly, on doing the similar
search for variable $params we have following result, with this we can be sure that $params is
commonly used variable throughout the code.
Thus what we will try next is to change the $params1 to $params and see the difference, and
what we are expecting is that the remote launch of the website from Eclipse will be fully
processed and not suspended, the reason for the website launch suspension is the critical and
fatal errors in the code.
Figure 4.10: Searching for variable value in working set
57
After correcting the code and re-launching the debug session we can see that the session has
started successfully with no errors so far in the eclipse debug window, the session can be seen
active in the web browser and as we step over and into the code we see that every singles line of
/index.php is being parsed successfully without errors. It is successfully demonstrated that
integrating the various available software development platforms we can not only automate the
cumbersome process of software debugging but also provide a platform to write error free code
by providing developer a unique feature of embedding debugging procedure in the development
cycle.
And after reaching line no.55 we are now redirected to mod_stats.php file within the eclipse and
after stepping over to all the code lines in mod_stats.php the website launches successfully
showing the statistics module with any errors.
Figure 4.11: Bug free display of website with desired module
58
Thus by using eclipse and XDEBUG we successfully debugged an internal module with error
and debugged the website as whole (web application) and not file by file to find the bugs and
fixing them.
CHAPTER-5
CONCLUSION AND FUTURE WORK
5.1 Conclusion.
Software debugging has been an important aspect of creating software, many a times a
programmer after coding doesn't get the intended output, even when everything seems correct
there can be always something which hinders the expected output, it may be syntax error, or
error in logic itself.With Eclipse and XDEBUG we were able to execute the code with
breakpoints and check the possible erroneous function one by one, Eclipse also creates trace logs
which can be utilized to check the code offline manually. In coming days software development
IDEs such as Eclipse and Netbeans are going to be more and more feature rich as they are
supported by open source web community who is busy in development of specialized plugins to
enhance the siteFinding the bugs in software is complicated and time consuming. Using
automation in eclipse for php reduces the time required.Searching the variables and functions
inside the code iseasier in eclipse.
In this project work the whole remote setup, and debugging process has been automated
successfully..In this project we achieved the task of successfully finding the bug in the software
code and use an integrated development IDE with automated debugger (XDEBUG), the new
aspects we learned in this process are the automation of the website debugging process, using
search functions, parsing the suspected files presented by XDEBUG to Eclipse and pinpointing
the problem.
Other major point of this project is that it is cross platformed based, which means it is
successfully demonstrated that integrating the various available software development platforms
we can not only automate the cumbersome process of software debugging but also provide a
59
platform to write error free code by pro Other major point of this project is that it is cross
platform-ed based, which means it is successfully demonstrated that integrating the various
available software development platforms we can not only automate the cumbersome process of
software debugging but also provide a platform to write error free code by providing developer a
unique feature of embedding debugging procedure in the development cycle.viding developer a
unique feature of embedding debugging procedure in the development cycle.
5.2 Future Work.
It has been a fruitful venture to integrate the cross platforms to perform the software debugging
automation, this time it is successfully demonstrated that by tweaking the php.ini, apache web
server, Eclipse settings and enabling php extensions plus XDEBUG we can create an automated
robust development plus debugging platform with all the necessary tools which a software
developer requires.
For future work I would suggest to integrate the multiple sites so that their debugging can be
done remotely and in time efficient way, this time we debugged the code on local machine where
the webserver, mysql database, and IDE with debugger were all installed on single machine.
Remote debugging could help freelancers or remote developers who prefer to work for multiple
clients remotely. Such a facility will not only save their time but also let them create different
workspaces to switch easily and check the codes to find the bugs.
REFERENCES
[1] Zheng, A. (1999). Statistical software debugging. (Doctoral dissertation) Retrieved from
http://research.microsoft.com/en-us/um/people/alicez/papers/thesis.
[2] HailpernB&Santhanam,P.(2001).Software debugging, testing, and verification.
Informallypublishedmanuscript,Retrievedfromhttp://www.cs.uleth.ca/~benkoczi/3720/pre
s/debug-test-verify_hailpern02.pdf.
[3] Rethans, D. (2002-13). Xdebug. Retrieved from http://xdebug.org/docs/.
[4] Leon, Y. (2006). Pdt. Retrieved from http://www.eclipse.org/pdt/documents/PDT%20-
%20Debug%20Protocol.pdf.
60
[5] Meyer, Stumptner (2007), Abstract Interpretation of Programs for Model-Based Debugging.
[6] Good. A. Nathan (2008, JUNE, 17). Debugging PHP using Eclipse and PDT.
[7] KelseY, D. (2008, DECEM 31). Xdebug support in pdt 2.0 version: 1.0 . Retrieved from
http://www.eclipse.org/pdt/documents/XDebugGuideForPDT2.0.pdf.
[8] Chris Parnin and Alessandro OrsoGeorgia (2011,JULY 17) Institute of Technology College of
Computing{chris.parnin| orso}@gatech.edu
[9] Grndler, R. (2013, MAY 30). Debugging using xdebug. Retrieved from
http://wiki.eclipse.org/Debugging_using_XDebug.
[10]Joomla! EDL. (2013, NOVEM). Joomla! documentation. Retrieved from
http://docs.joomla.org/.
[11]Eclipse, T. (2013). Eclipse - the eclipse foundation open source community website.
Retrieved from http://www.eclipse.org/.
[12]Alter Way. (2013). Wampserver, a windows web development environment. Retrieved
from http://www.wampserver.com/en/.
[13]Teodorescu, R., & Torrellas, J. (n.d.). Empowering software debugging through architectural
support for program rollback. (Master's thesis, University of Illinois at Urbana-Champaign)
Retrievedfromhttp://www.cse.ohiostate.edu/~teodores/download/papers/teodorescuBUG
S05.pdf.
[14]Adrangna. P, Software debugging techniques, Queen Mary, University of London.