# generators & php tools

- Thread: https://externals.io/message/63254
- Original archive: https://news-web.php.net/php.internals/63254
- Started by Stas Malyshev on 2012-10-01T04:21:35+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #63254 — Stas Malyshev — 2012-10-01T04:21:35+00:00

URL: https://externals.io/message/63254#63254

Hi!

I was looking into generators topic and I couldn't find answer to this
question: how generators are supposed to interact with PHP tools, such
as debuggers, profilers, etc.? Specifically, how calls to generator are
handled? Usually, the tool overrides zend_execute and
zend_execute_internal and every function call goes through there. But
generator does not use these - it uses execute_ex instead. So can
generator be debugged/profiled? What happens if I say "step out" inside
generator - would that work?
-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #63257 — Pierre Joye — 2012-10-04T05:52:59+00:00

URL: https://externals.io/message/63254#63257 · In reply to: #63254

Adding Zeev, Derick and Dmitry in case they miss this post.


> Hi!
>
> I was looking into generators topic and I couldn't find answer to this
> question: how generators are supposed to interact with PHP tools, such
> as debuggers, profilers, etc.? Specifically, how calls to generator are
> handled? Usually, the tool overrides zend_execute and
> zend_execute_internal and every function call goes through there. But
> generator does not use these - it uses execute_ex instead. So can
> generator be debugged/profiled? What happens if I say "step out" inside
> generator - would that work?
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227

---

## #63259 — Derick Rethans — 2012-10-04T07:45:52+00:00

URL: https://externals.io/message/63254#63259 · In reply to: #63254

> I was looking into generators topic and I couldn't find answer to this 
> question: how generators are supposed to interact with PHP tools, such 
> as debuggers, profilers, etc.? Specifically, how calls to generator 
> are handled? Usually, the tool overrides zend_execute and 
> zend_execute_internal and every function call goes through there. But 
> generator does not use these - it uses execute_ex instead. So can 
> generator be debugged/profiled? What happens if I say "step out" 
> inside generator - would that work?

It won't work with Xdebug right now, as it indeed overrides just 
zend_execute and zend_execute_internal  --- we should definitely look at 
fixing generators that they go through those as well. It's related to 
the zend_execute_internal hook missing from the other email that I just 
replied to (and your PR 178).

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine

---

## #63301 — Nikita Popov — 2012-10-09T11:44:56+00:00

URL: https://externals.io/message/63254#63301 · In reply to: #63259

> 
>
> > […]
>
> It won't work with Xdebug right now, as it indeed overrides just
> zend_execute and zend_execute_internal  --- we should definitely look at
> fixing generators that they go through those as well. It's related to
> the zend_execute_internal hook missing from the other email that I just
> replied to (and your PR 178).
>
> cheers,
> Derick

Generators won't be able to go through zend_execute, because they need
to work on an existing execution context and not create a new one on
every resume. So instead we will probably need an additional hook for
execute_ex (in which case the existing execute hook isn't really
necessary anymore).

Would that be okay?
Nikita

XDebug execute and execute_internal:
https://github.com/derickr/xdebug/blob/master/xdebug.c#L1215
https://github.com/derickr/xdebug/blob/master/xdebug.c#L1442

---

## #63302 — Derick Rethans — 2012-10-09T12:13:13+00:00

URL: https://externals.io/message/63254#63302 · In reply to: #63301

> 
> > […]
> 
> Generators won't be able to go through zend_execute, because they need 
> to work on an existing execution context and not create a new one on 
> every resume. So instead we will probably need an additional hook for 
> execute_ex (in which case the existing execute hook isn't really 
> necessary anymore).
> 
> Would that be okay?

Let's find out! I'd be happy to play around with this new hook and see 
whether it works.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
Posted with an email client that doesn't mangle email: alpine
