# Adding vars to debug_backtrace()

- Thread: https://externals.io/message/4984
- Original archive: https://news-web.php.net/php.internals/4984
- Started by Christian Schneider on 2003-10-25T13:07:43+00:00
- Messages: 4
- 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

---

## #4984 — Christian Schneider — 2003-10-25T13:07:43+00:00

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

Hey folks,
I'd like to add the local variables for all stack-frames to the result 
of `debug_backtrace()`, i.e. each array entry contains a 'vars' field 
pointing to the symbol table of that frame. A patch for PHP4/Zend is 
attached.

Opinions?
- Chris

---

## #4985 — Christian Schneider — 2003-10-25T13:26:51+00:00

URL: https://externals.io/message/4984#4985 · In reply to: #4984

Oops, after I first added FREE_ZVAL(vars) to my patch to get rid of the 
memory leak I now realized that it simply doesn't work like this. I 
still have to learn about the memory management/gc of Zend I guess :-)

If you want to try my patch and don't care about a memory leak, remove 
the line FREE_ZVAL(vars);

- Chris

---

## #4986 — Timm Friebe — 2003-10-25T14:28:49+00:00

URL: https://externals.io/message/4984#4986 · In reply to: #4984

[...]
> I'd like to add the local variables for all stack-frames to the result 
> of `debug_backtrace()`, 
[...]

I'd like having this. Using declare(ticks = 1),
register_tick_function('debug'), and `debug_backtrace()` you'd be able to
build a simple debugger in PHP userland.

- Timm

---

## #5007 — Christian Schneider — 2003-10-26T11:54:05+00:00

URL: https://externals.io/message/4984#5007 · In reply to: #4984

Ok, I worked out a patch which does not leak memory. I don't think 
thread-safety is an issue here but if anyone with deeper insight into 
Zend sees any problem with this patch, please tell me.

What's the process (and chance :-)) of having this included in a future 
version of PHP? Should I also look into making a PHP5/Zend2 version of it?

Comments welcome,
- Chris
