Tola Odejayi
Tola Odejayi

Reputation: 3059

Is there a way of limiting the depth of the trace generated by xdebug?

The question says it all, really.

I am trying to figure out why a php app is misbehaving, but the sheer amount of data thrown at me by xdebug makes it hard to understand the flow.

If I could set the depth of the trace such that any call more than x levels deep was skipped, then it would be easier to understand what was happening. Any ideas how to make xdebug do this, or is there an alternative tool I can use?

Upvotes: 3

Views: 800

Answers (3)

cladelpino
cladelpino

Reputation: 338

A cheap trick:

Given a trace file, file_name you can use:

grep -E '[[:digit:]][[:space:]]{,n}->' file_name

with n = 2L + 1 to only show function calls with a depth of L.

So for example

grep -E '[[:digit:]][[:space:]]{,3}->' file_name

Will give you just the top level call.

enter image description here

Upvotes: 0

Dejv
Dejv

Reputation: 954

You can tell Xdebug where to start and stop the function tracing by calling functions xdebug_start_trace() and xdebug_stop_trace() in the code.

With Xdebug version 2.4 or higher, you can also limit Xdebug to only trace execution of some functions by calling function xdebug_start_function_monitor( array $list_of_functions_to_monitor ). The array contains the list of functions you want to trace.

Upvotes: 1

Derick
Derick

Reputation: 36774

Xdebug's function/execution tracing to file does currently not support this, and Xdebug's stacktraces always also show the whole stack I've just added a feature request to the issue tracker for it: http://bugs.xdebug.org/view.php?id=722

Derick

Upvotes: 2

Related Questions