Hi,

On Tue, 2010-08-10 at 17:24 +0200, Bostjan Skufca wrote:
> I've been digging a little deeper and have figured out that I probably
> could retrieve what I want (realpath of first executed file) from
> included_files hash (first entry, obviously). Unfortunately, doing it
> like this (sampled from get_included_files() implementation):

Interesting idea. Didn't think about that. But it isn't reliable either:
If an auto prepend file is set this will be in the list first.

>     char *hentry;
>     zend_hash_internal_pointer_reset(&EG(included_files));
>     zend_hash_get_current_key(&EG(included_files), &hentry, NULL, 1);
>     printf("%s", hentry);

I think you want the value, not the key. To be precise you want the
value for key 0. -> zend_hash_find()

But thinking about this idea I had another idea: Use the userland
stacktrace. While this won't work in RINIT/RSHUTDOWN but you'd have to
hook into the execution somewhere. Would look something like this:

char *filename;
struct _zend_execute_data current_frame = EG(curent_execute_data);
do {
    if (current_frame->type != ZEND_INTERNAL_FUNCTION) {
        filename = current_frame->filename;
    }
} while (current_frame = current_frame->prev_execute_data);
php_printf("%s, filename);

Again: Not tested at all.



johannes


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to