View Issue Details

IDProjectCategoryView StatusLast Update
0000406XdebugStep Debuggingpublic2020-03-12 17:36
Reportercheesegrits Assigned Toderick  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Fixed in Version2.3.0 
Summary0000406: Need to see PHP defines/constants
Description

Need to be able to see values of PHP defines in debug.

TagsNo tags attached.
Operating System
PHP Version5.2.4

Activities

derick

2009-03-28 20:29

administrator   ~0000941

I don't know what you mean here, can you clarify?

toddw

2009-04-15 01:36

reporter   ~0000951

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...).

cheesegrits

2009-04-16 20:49

reporter   ~0000952

Yes, that's exactly what I meant.

-- hugh

p2409

2009-04-18 15:59

reporter   ~0000954

I agree it would be great - is it possible with PHP though?

ericp

2009-06-02 01:50

reporter   ~0000959

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.

toddw

2009-06-02 19:04

reporter   ~0000960

You mean like "get_defined_constants":
http://nl2.php.net/manual/en/function.get-defined-constants.php

ericp

2009-06-02 19:10

reporter   ~0000961

Yes. What would the C code using the PHP API be to do that?

ericp

2009-06-02 19:35

reporter   ~0000962

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.

derick

2014-01-10 16:32

administrator   ~0002666

User defined constants, as defined with define() are now included in context 2 ("User defined constants").

derick

2014-01-10 16:36

administrator   ~0002667

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 19: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 01:36 toddw Note Added: 0000951
2009-04-16 20:49 cheesegrits Note Added: 0000952
2009-04-18 15:59 p2409 Note Added: 0000954
2009-06-02 01:50 ericp Note Added: 0000959
2009-06-02 19:04 toddw Note Added: 0000960
2009-06-02 19:10 ericp Note Added: 0000961
2009-06-02 19: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 09: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
2020-03-12 16:55 derick Severity minor => feature
2020-03-12 17:36 derick Category Feature/Change request => Step Debugging