MantisBT

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000406XdebugFeature/Change requestpublic2008-08-27 20:022015-02-22 14:30
Reportercheesegrits 
Assigned Toderick 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version2.3.0 
Summary0000406: Need to see PHP defines/constants
DescriptionNeed to be able to see values of PHP defines in debug.
TagsNo tags attached.
Operating System
PHP Version5.2.4
Attached Files

- Relationships

-  Notes
(0000941)
derick (administrator)
2009-03-28 20:29

I don't know what you mean here, can you clarify?
(0000951)
toddw (reporter)
2009-04-15 02:36

I believe that the users wants to be able to see the values of any constants that are defined.

For example, if I make the following define:

  define('MY_CONSTANT','xyz');

It would be good to be able to retrieve the value of MY_CONSTANT through Xdebug. As far as I know, this is not currently possible (i.e. not support by "context_get", "property_get", etc...).
(0000952)
cheesegrits (reporter)
2009-04-16 21:49

Yes, that's exactly what I meant.

   -- hugh
(0000954)
p2409 (reporter)
2009-04-18 16:59

I agree it would be great - is it possible with PHP though?
(0000959)
ericp (reporter)
2009-06-02 02:50

It should be possible, but I don't know enough about PHP internals to see exactly how to do it.

One problem is that the defined constants appear to live in a single
global space, and are set at runtime. So it doesn't make sense to
display them in the locals table, nor in the "superglobals". A
separate "context" (in Xdebug terms) is needed - I would call it "Constants".

If someone can tell me where PHP stores this set of names and values, it
should be straightforward to add this new context to Xdebug.
(0000960)
toddw (reporter)
2009-06-02 20:04

You mean like "get_defined_constants":
http://nl2.php.net/manual/en/function.get-defined-constants.php [^]
(0000961)
ericp (reporter)
2009-06-02 20:10

Yes. What would the C code using the PHP API be to do that?
(0000962)
ericp (reporter)
2009-06-02 20:35

Just to sketch out what I have in mind, all in
xdebug_handler_dbgp.c:

#define DBGP_CONTEXT_LOCALS 0
#define DBGP_CONTEXT_SUPERGLOBALS 1
#define DBGP_CONTEXT_CONSTANTS 2
...

DBGP_FUNC(context_names)
{
...
    child = xdebug_xml_node_init("context");
    xdebug_xml_add_attribute(child, "name", "Constants");
    xdebug_xml_add_attribute(child, "id", "2");
    xdebug_xml_add_child(*retval, child);
}

static int attach_context_vars(...) {
    if (context_id == DBGP_CONTEXT_SUPERGLOBALS) { ...
    } else if (context_id == DBGP_CONTEXT_LOCALS) { ...
    } else if (context_id == DBGP_CONTEXT_CONSTANTS) {
        ?type? *constants_list = get_defined_functions();
        // And then something that converts constants_list
        // into an xdebug_hash, so we can do the following:
        xdebug_hash *tmp_hash = some_func(constants_list);
        tmp_hash = xdebug_used_var_hash_from_llist(fse->used_vars);
        xdebug_hash_apply_with_argument(tmp_hash, (void *) node, func, (void *) options);
        xdebug_hash_destroy(tmp_hash);
        return 0;
    }
    return 1;
}

I've only gotten my toe wet with the PHP internals, but
this is the path I'd follow.
(0002666)
derick (administrator)
2014-01-10 16:32

User defined constants, as defined with define() are now included in context 2 ("User defined constants").
(0002667)
derick (administrator)
2014-01-10 16:36

Xdebug now supports debugging user-defined constants. The constants will appear in "context" 2 with context_get (http://xdebug/docs-dbgp.php#id52 [^]) and this is also reflected in the context_names (http://xdebug/docs-dbgp.php#context-names [^]) command. It is also possible to call "property_get -c 2 -n ... to fetch the value.

The returned property information will have the facet set to "constant".

- Issue History
Date Modified Username Field Change
2008-08-27 20:02 cheesegrits New Issue
2009-03-28 20:29 derick Note Added: 0000941
2009-03-28 20:29 derick Status new => feedback
2009-04-15 02:36 toddw Note Added: 0000951
2009-04-16 21:49 cheesegrits Note Added: 0000952
2009-04-18 16:59 p2409 Note Added: 0000954
2009-06-02 02:50 ericp Note Added: 0000959
2009-06-02 20:04 toddw Note Added: 0000960
2009-06-02 20:10 ericp Note Added: 0000961
2009-06-02 20:35 ericp Note Added: 0000962
2014-01-10 16:32 derick Note Added: 0002666
2014-01-10 16:32 derick Status feedback => closed
2014-01-10 16:32 derick Assigned To => derick
2014-01-10 16:32 derick Resolution open => fixed
2014-01-10 16:32 derick Fixed in Version => 2.3dev
2014-01-10 16:36 derick Note Added: 0002667
2014-07-29 10:37 derick Summary Need to see PHP defines => Need to see PHP defines/constants
2015-02-22 14:30 derick Fixed in Version 2.3dev => 2.3.0


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker