View Issue Details

IDProjectCategoryView StatusLast Update
0000450XdebugUncategorizedpublic2023-11-30 14:49
ReporterFreeaqingme Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Product Version2.0.0dev 
Target Version3.3devFixed in Version3.3.0 
Summary0000450: "Incomplete" backtraces when an exception gets rethrown
Description

Try the attached 'script'. I would have liked to know the exception was thrown in f6() however, unfortunately xdebug does show no more steps after f4(). This on itself is fairly well explainable, if it were not for php (without xdebug) to actually do show the exception was thrown in f6().

php version: 5.2.9, xdebug version 2.0.4

Additional Information
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
class test {
        function f4() {
                try {
                        $this->f5();
                } catch(exception $e) {
                        throw $e;
                }
        }

        function f5() {
                $this->f6();
        }

        function f6() {
                throw new exception('foo');
        }
}

$test = new test();

$test->f4();
?>
TagsNo tags attached.
Operating SystemGNU Linux
PHP Version5.2.8

Relationships

has duplicate 0001298 resolvedderick Incomplete stack trace when re-throwing exception 

Activities

derick

2016-12-13 21:38

administrator   ~0004054

This is likely going to be difficult to fix.

AndreKR

2020-12-11 16:33

reporter   ~0005586

This is likely going to be difficult to fix.

Why would that be? The information is in the Exception, it can be shown from within PHP with $e->getTrace(). Xdebug cannot access it?

In fact, my long time workaround for this issue is:

// Re-throw the exception
if (!extension_loaded('xdebug'))
  throw $e;
else
  throw new Exception(null, null, $e);

Then Xdebug does show the stack trace of the exception in addition to the (usually useless) stack trace of the re-throw.

derick

2023-08-24 16:22

administrator   ~0006642

https://github.com/xdebug/xdebug/pull/904

Freeaqingme

2023-08-24 17:50

reporter   ~0006643

Thanks for fixing!

I'll have to admit I had totally forgotten this 14 year old issue, but it's great to see that even though it's been sitting idle for a while it was still picked up. Thanks & have a good one!

ps I have no idea why I used f4,f5 and f6, instead of e.g. f1-3. Guess we'll never know...