Anybody know of a debugger whose variable window shows call stack object properties

Posted on 2015-02-23
Last Modified: 2015-02-28
I'm using a debugger for php.  In break mode, I can navigate the call stack to examine code and the variables window for any stack frame; however, the "this" variables window panel seems only to report property values associated with the scope of the current breakpoint (i.e. top stack frame) instead of the currently selected stack frame.

I'm curious if anyone knows of a debugger (for php or any other OO  languages) which display the properties of the object associated with a stack frame, and in addition, those property values displayed are those which were in effect at the time that stack frame was the current/top frame?
Question by:SAbboushi
LVL 13

Expert Comment

by:George K.
ID: 40626759

Have a look at  Xdebug 2 and let me know.
LVL 40
ID: 40626779
Such a debugger would require a lot of resources, because it has to record the state of a lot of variables.

Think about what is should record in big loops or recursions that deal with objects that have a lot of properties. And one of the things that designers try to optimize when they create a debugger is that it uses few resources in order to have as little impact as possible on the running application.

I do not know if php has the concept of a local variable, but in VB.NET, to solve such a problem, I simply create a local variable at the point where I want to check my class level variable, and assign it the value of the variable I want to check. When I hit a breakpoint, I simply navigate to the calling method from the Call Stack and get the from of the local variable.

Author Comment

ID: 40626831
Merci Jacques-

Thanks for sharing your thoughts.

Anyone else?  I'm not looking for any solutions here, just whether or not anyone knows of a debugger which behaves as I've described.
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Author Comment

ID: 40626851
Thanks George - I scanned through the link you posted, but a lot of it is beyond my knowledge, so I couldn't tell...
LVL 110

Expert Comment

by:Ray Paseur
ID: 40627080
PHP has both local variables and object properties.  The latter are referred to with $this-> prepended to the variable name.  These local variables are visible only inside the method that defines the variables.  Object properties are visible in other methods, subject to the rules of scope inheritance, and outside of the scope of the object via var_dump() as shown here.

object(Thing)#1 (1) {

<?php // demo/temp_sabboushi.php

 * SEE:
echo '<pre>';

Class Thing
    public function set_a_variable($x)
        $y = $x;

    public function set_a_property($x)
        $this->y = $x;

$abc = new Thing;


Open in new window

As a practical matter, developers do not use debuggers in PHP any more.  Instead we rely on unit testing with products like phpunit.  These tools allow us to create mock objects with highly predictable inputs and outputs, and we can use these mock objects to run our code and get a near-real-time report of success or failure in each of the inflection points.  A phpunit test takes at most a few seconds, even for a complex application.  If you run one prior to every commit, you can be sure that your new code additions did not break any of your earlier code!

Author Comment

ID: 40627189
Thanks Ray.  I'll look into phpunit.

Anyone else?
LVL 10

Expert Comment

by:Jeffrey Dake
ID: 40632388
I am mostly a Java developer and I use the debugger in eclipse. Java is a different beast then php and the debugger does let you look at any allocated object. However like the others it will still only show you variables that are within the call hierarchy.   Java is kind of a memory hog, which for debugging is kind of helpful. Not sure if this helps at all.

Author Comment

ID: 40633835
Hi Jeffrey - thanks for your response.

However like the others it will still only show you variables that are within the call hierarchy.

Can you clarify using the following java example (first time I've looked at java, so I hope my example is adequate):  

1  import*;
2  public class EmployeeTest{
4     public static void main(String args[]){
5        Employee empOne = new Employee("James Smith");
6        this.arrOne = empOne.arrOne;
7  	  ArrayList2 arrTwo = new ArrayList2();
8     }
9  }

Open in new window

public class Employee{
  String name;

  public Employee(String name){ = name;
    ArrayList1 arrOne = new ArrayList1();
    this.arrOne = arrOne.list;

Open in new window

public class ArrayList1 {
  public ArrayList1 {
    ArrayList<String> list = new ArrayList<String>();
    this.list = list;    

Open in new window

public class ArrayList2 {
  public ArrayList2 {
    ArrayList<String> list = new ArrayList<String>();
    this.list = list;
    ... Q1: If I break here, I expect the variables window to have a variable
                'list' that I can expand to see 'ItemA'...'ItemC'; I also expect an 
                entry somewhere for 'this' with property 'list' which I can also 
                expand to see 'ItemA'...'ItemC', correct?
    ... Q2: I expect the Call Stack to have an entry for EmployeeTest.main 
                line: 7 
               If you select that call stack entry and look at the variables 
               window, I expect to see 'empOne.arrOne'.  If so, can you expand 
               'empOne.arrOne' and see elements 'Item1'...'Item3'?
    ... Q3: I expect there to be an entry somewhere for 'this' with property 
               'arrOne'. If so, can you expand 'this.arrOne' and see elements 
            Responding with a screen shot of the call stack and the variable 
             windows for both stack frame entries would be really helpful, but 
             I'd be grateful if you merely gave me a correct answer ; )
             The key issue here is whether variables in the variables window 
             for all call stack frames maintain the correct scope values, 
             particularly for those variables/properties which must be 
             expanded (like arrays) in order to see their values (e.g. array 

Open in new window

LVL 10

Accepted Solution

Jeffrey Dake earned 500 total points
ID: 40636722
Sorry it took awhile to get back.  I have attached three pictures that I think will show what you were expecting see.  The debug window in the top right shows the values of the variables, and the left screen shows the call hierarchy that you can jump through.

First shows values of the list
More data on the list.
Going back to see the employee record.
Hope this helps

Author Comment

ID: 40636746
Perfect!  Thanks for spending the time to do that!

I also confirmed that Visual Studios (I tested php) behaves the same way i.e. retaining all variables for each stack frame.

Thanks again for your help.

PS - Curious if/what corrections you needed to make to my code (I don't know java, so I imagine it had some errors...)

Author Closing Comment

ID: 40636747
LVL 10

Expert Comment

by:Jeffrey Dake
ID: 40636767
Most of it worked as is.  Your usages of the keyword this. didn't always work, because you didn't have any instances variables of the class to set it too.  Here are the files I used.

Author Comment

ID: 40637398

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question