Contributing Advent 17: Printing stacks
Anybody who is vaguely familiar with Xdebug probably has seen its glorious orange stack traces gracing their screens. In case you have not, they look like:
In this case, the tell_a_lie_and_hurt_you() function tried to call strlen() with incorrect arguments.
Xdebug overloads PHP's internal error handler to do this, but it is also possible to trigger stack traces yourself. You can of course use trigger_error(), but Xdebug also provides the xdebug_print_function_stack() function. Running xdebug_print_function_stack() instead of the erroneous strlen() results in:
As the documentation state, you can also provide your own message:
<?php
function tell_a_lie_and_hurt_you()
{
xdebug_print_function_stack("You have been rickrolled!");
}
Which then results in:
This was all good, and then my friend Rob asked:
hypothetically, how hard would it be to change xdebug_print_function_stack() so that it didn't output the filename and line number in the orange box?
Well, it didn't turn out to be very hard. Rob requested this feature because he was writing his own error handler. And with your own error handler it does not make a whole lot of sense to show where xdebug_print_function_stack() was called from. After my commit, you can now supply a second argument to xdebug_print_function_stack():
<?php
function tell_a_lie_and_hurt_you()
{
xdebug_print_function_stack("You have been rickrolled!", XDEBUG_STACK_NO_DESC);
}
Which then results in a stack trace without header:
This new feature will be part of Xdebug 2.3.
Life Line
π· Tufted Duck Pair
π© Outer Circle, City of Westminster, United Kingdom
RE: https://phpc.social/@Xdebug/115662135830755552
I have just released Xdebug 3.5.0!
In the next few weeks I will create some content (text, and perhaps video) highlighting some new features in more detail.
Please share it with the world!
The master branch is now for Xdebug 3.6, targetting PHP 8.6
Back to -dev
Tweak release instructions a little
Go with 3.5.0
Tweak message IDs and severities for control socket log entries
I walked 8.5km in 1h30m56s
My whisky of the month for December 2025, is a 15yo Aultmore bottled by Cadenhead's.
Fixed off-by-one error in address length name for control socket on Lβ¦
Merged pull request #1050
Fixed control socket name by removing silly trailing things (by not pβ¦
RE: https://en.osm.town/@harry_wood/115650834037247679
Fancy a friendly #OpenStreetMap chat in the pub, with some Christmas celebrations?
The London OSM gang is meeting on December 16th near Paddington.
I walked 8.7km in 1h29m30s
RE: https://mastodon.online/@afup/115648919275171255
This talk on what's New in PHP 8.5 is in English! Je ne parles pas FranΓ§ais!
I walked 10.0km in 1h46m14s
Merged pull request #1049
Reorder xdfree(name) and removing trailing whitespace
Tweak comments to use /* .. */ style
Reuse created \\.\pipe name


Shortlink
This article has a short URL available: https://drck.me/adv1317-afc