[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


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

Posted on 2015-02-23
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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.
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.


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 111

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: http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28622868.html
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 11

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 java.io.*;
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

import java.io.*;
public class Employee{
  String name;

  public Employee(String name){
    this.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 11

Accepted Solution

Jeffrey Dake earned 2000 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 11

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

656 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