View Issue Details

IDProjectCategoryView StatusLast Update
0002366XdebugProfilingpublic2025-09-18 19:27
ReporterNeil Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.4.5 
Summary0002366: Profiler output filepaths on Windows prevents Source Code view on Qcachegrind 0.7.4
Description

The file paths for fl= use backslashes and that seems to prevent Qcachegrind/Kcachegrind from showing the code in the Source Code tab.

If the backslashes are replaced with forward slashes then Qcachegrind/Kcachegrind will show the code in the Source Code tab as expected, see attached screenshots.

I looked at Settings->Configure->Source Annotation in Qcachegrind and tried changing it to the path of the source files but that had no effect.

Are you able the change the output paths on windows to use forward slashes / either by default or via a configuration setting?

As a quick fix I compiled a modified version of xdebug to use forward slashes and that seems to be working. See attached patch file.

Qcachegrind 0.7.4 @ https://sourceforge.net/projects/qcachegrindwin/

TagsNo tags attached.
Attached Files
SourceAnnotationDefault.png (22,274 bytes)   
SourceAnnotationDefault.png (22,274 bytes)   
SourceAnnotationSourceDir.png (26,054 bytes)   
SourceAnnotationSourceDir.png (26,054 bytes)   
callgrind.out.1758214038.603436.forward_slashes._xdebug_test_xdebug_info_php (349 bytes)   
version: 1
creator: xdebug 3.4.5 (PHP 8.3.25)
cmd: C:\wamp64\www\xdebug_test\xdebug_info.php
part: 1
positions: line

events: Time_(10ns) Memory_(bytes)

fl=(1) php:internal
fn=(1) php::xdebug_info
3 69520 112

fl=(2) C:/wamp64/www/xdebug_test/xdebug_info.php
fn=(2) {main}
1 4430 40
cfl=(1)
cfn=(1)
calls=1 0 0
3 69520 112

summary: 113060 459352

callgrind.out.1758214079.627359._xdebug_test_xdebug_info_php (349 bytes)   
version: 1
creator: xdebug 3.4.5 (PHP 8.3.25)
cmd: C:\wamp64\www\xdebug_test\xdebug_info.php
part: 1
positions: line

events: Time_(10ns) Memory_(bytes)

fl=(1) php:internal
fn=(1) php::xdebug_info
3 72080 112

fl=(2) C:\wamp64\www\xdebug_test\xdebug_info.php
fn=(2) {main}
1 9130 40
cfl=(1)
cfn=(1)
calls=1 0 0
3 72080 112

summary: 142700 521664

0001-Updated-to-use-forward-slashes.patch (2,302 bytes)   
Subject: [PATCH] Updated to use forward slashes

---
 src/lib/usefulstuff.c   | 18 ++++++++++++++++++
 src/lib/usefulstuff.h   |  1 +
 src/profiler/profiler.c |  4 ++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/src/lib/usefulstuff.c b/src/lib/usefulstuff.c
index 5ae8f0e..4b623de 100644
--- a/src/lib/usefulstuff.c
+++ b/src/lib/usefulstuff.c
@@ -727,3 +727,21 @@ int xdebug_format_filename(char **formatted_name, const char *default_fmt, zend_
 
 	return fname.l;
 }
+
+char *xdebug_path_to_forward_slash(char *path)
+{
+
+	if (path == NULL) {
+		return NULL;
+	}
+
+	char *p = path;
+	while (*p) {
+		if (*p == '\\') {
+			*p = '/';
+		}
+		p++;
+	}
+	
+	return path;
+}
\ No newline at end of file
diff --git a/src/lib/usefulstuff.h b/src/lib/usefulstuff.h
index c382810..a05ef96 100644
--- a/src/lib/usefulstuff.h
+++ b/src/lib/usefulstuff.h
@@ -39,5 +39,6 @@ FILE *xdebug_fopen(char *fname, const char *mode, const char *extension, char **
 int xdebug_format_output_filename(char **filename, char *format, char *script_name);
 int xdebug_format_file_link(char **filename, const char *error_filename, int error_lineno);
 int xdebug_format_filename(char **formatted_name, const char *default_format, zend_string *filename);
+char *xdebug_path_to_forward_slash(char *path);
 
 #endif
diff --git a/src/profiler/profiler.c b/src/profiler/profiler.c
index 31003f9..fb17b19 100644
--- a/src/profiler/profiler.c
+++ b/src/profiler/profiler.c
@@ -458,7 +458,7 @@ void xdebug_profiler_function_end(function_stack_entry *fse)
 	} else {
 
 		xdebug_str_add_literal(&file_buffer, "fl=");
-		add_filename_ref(&file_buffer, ZSTR_VAL(fse->profiler.filename));
+		add_filename_ref(&file_buffer, xdebug_path_to_forward_slash(ZSTR_VAL(fse->profiler.filename)));
 
 		xdebug_str_add_literal(&file_buffer, "\nfn=");
 		add_functionname_ref(&file_buffer, ZSTR_VAL(fse->profiler.function));
@@ -509,7 +509,7 @@ void xdebug_profiler_function_end(function_stack_entry *fse)
 		} else {
 			xdebug_str_add_literal(&file_buffer, "cfl=");
 			add_filename_ref(&file_buffer, ZSTR_VAL(call_entry->filename));
-
+			
 			xdebug_str_add_literal(&file_buffer, "\ncfn=");
 			add_functionname_ref(&file_buffer, ZSTR_VAL(call_entry->function));
 			xdebug_str_addc(&file_buffer, '\n');
-- 
2.51.0.windows.1

Operating SystemWindows 10 21H2
PHP Version8.3.10-8.3.19

Activities

Issue History

Date Modified Username Field Change
2025-09-18 19:27 Neil New Issue
2025-09-18 19:27 Neil File Added: callgrind.out.1758214079.627359._xdebug_test_xdebug_info_php.png
2025-09-18 19:27 Neil File Added: callgrind.out.1758214038.603436.forward_slashes._xdebug_test_xdebug_info_php.png
2025-09-18 19:27 Neil File Added: SourceAnnotationDefault.png
2025-09-18 19:27 Neil File Added: SourceAnnotationSourceDir.png
2025-09-18 19:27 Neil File Added: php_xdebug-3.4.5-8.3-ts-vs16-x86_64_with_forward_slashes.dll
2025-09-18 19:27 Neil File Added: callgrind.out.1758214038.603436.forward_slashes._xdebug_test_xdebug_info_php
2025-09-18 19:27 Neil File Added: callgrind.out.1758214079.627359._xdebug_test_xdebug_info_php
2025-09-18 19:27 Neil File Added: 0001-Updated-to-use-forward-slashes.patch