xref: /PHP-7.0/ext/phar/gdbhelp (revision 16b4d8e0)
1define ___pharglobals
2	if basic_functions_module.zts
3		set $tsrm_ls = ts_resource_ex(0, 0)
4		set $pharglobals = ((zend_phar_globals) (*((void ***) $tsrm_ls))[phar_globals_id-1])
5	else
6		set $pharglobals = phar_globals
7	end
8end
9
10define ____print_pharht
11	set $ht = $arg0
12	set $p = $ht.pListHead
13
14	while $p != 0
15		set $i = $ind
16		while $i > 0
17			printf "  "
18			set $i = $i - 1
19		end
20
21		set $temp = *(phar_archive_data*)$p->pDataPtr
22		____print_str $temp.fname $temp.fname_len
23		printf " => "
24
25		if $arg1 == 0
26
27			printf "%i (alias ", $temp.refcount
28			____print_str $temp.alias $temp.alias_len
29			printf ")\n"
30		end
31
32		set $p = $p->pListNext
33	end
34end
35
36define print_phar
37	set $ind = 1
38	___pharglobals
39	printf "{"
40	____print_pharht $pharglobals.phar_fname_map 0
41	printf "}\n"
42end
43
44document display_phar_globals
45	display phar globals
46end
47
48define display_phar_globals
49	___pharglobals
50	graph display $phar_globals.$arg0
51end
52
53define print_pharfp
54	___pharglobals
55	set $ht = $pharglobals.phar_fname_map
56	set $p = $ht.pListHead
57	set $fpcount = 0
58
59	while $p != 0
60		set $pharname = (*(phar_archive_data*)$p->pDataPtr).fname
61		set $pharrefcount = (*(phar_archive_data*)$p->pDataPtr).refcount
62		if (*(phar_archive_data*)$p->pDataPtr).fp != 0
63			set $fpcount = $fpcount + 1
64			printf "phar %s is open (%i)\n", $pharname, $pharrefcount
65		end
66		set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
67		set $m = $manifest.pListHead
68		while $m != 0
69			if (*(phar_entry_info *)$m->pData).fp
70				set $fpcount = $fpcount + 1
71				set $a = (*(phar_entry_info *)$m->pData).fp_refcount
72				printf "phar %s file %s is open (%i)\n", $pharname, (*(phar_entry_info *)$m->pData).filename, $a
73			end
74			set $m = $m->pListNext
75		end
76
77		set $p = $p->pListNext
78	end
79	printf "Open file pointers: %d\n", $fpcount
80end
81
82document print_pharfp
83	displays all open file pointers in phar, and the phars plus entries that are open with reference counts
84end
85
86define dump_entry
87	___pharglobals
88	set $ht = $pharglobals.phar_fname_map
89	set $p = $ht.pListHead
90	set $done = 0
91	while $p != 0
92		set $t = (*(phar_archive_data*)$p->pDataPtr)
93		if $t.fname[0] == $arg0[0] || $t.alias[0] == $arg0[0]
94			set $manifest = (*(phar_archive_data*)$p->pDataPtr).manifest
95			set $m = $manifest.pListHead
96			while $m != 0
97				if (*(phar_entry_info *)$m->pData).filename[0] == $arg1[0]
98					if $argc == 3
99						output *((phar_entry_info *)$m->pData)->fp
100					end
101					if $argc == 2
102						output *(phar_entry_info *)$m->pData
103					end
104					printf "\n"
105					set $done = 1
106					loop_break
107				end
108				set $m = $m->pListNext
109			end
110		end
111		if $done == 1
112			loop_break
113		end
114		set $p = $p->pListNext
115	end
116end
117
118document dump_entry
119	dump_entry "pharname"|"pharalias" "filename" [1]
120	display phar_entry_info for a file within a phar.  If the optional third param
121	is passed in, displays the php_stream that is the file's fp
122end