FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
php-src/scripts/gdb/debug_gdb_scripts_gen.php at master · php/php-src · GitHub
php
php-src
Repository navigation
Code
Issues
959
(959)
Pull requests
1.2k
(1.2k)
Actions
Security and quality
64
(64)
Insights
Expand file tree
Breadcrumbs
php-src
/
scripts
/
gdb
/
debug_gdb_scripts_gen.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
53 lines (45 loc) · 1.5 KB
Breadcrumbs
php-src
/
scripts
/
gdb
/
debug_gdb_scripts_gen.php
Copy path
File metadata and controls
executable file
·
53 lines (45 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env php
<?php
$
rootDir
=
dirname
(
__DIR__
,
2
);
$
mainDir
=
sprintf
(
'
%s/main
'
,
$
rootDir
);
$
outputFile
=
sprintf
(
'
%s/debug_gdb_scripts.c
'
,
$
mainDir
);
printf
(
"
Generating %s
\n"
,
$
outputFile
);
$
gdbscript
=
file_get_contents
(
sprintf
(
"
%s/.gdbinit
"
,
$
rootDir
));
$
pyscript
=
file_get_contents
(
sprintf
(
"
%s/php_gdb.py
"
,
__DIR__
));
// We can not inline .gdbinit, but we can embed it in the python script.
$
pyscript
=
sprintf
(
"
gdb.execute('''
\n
%s
\n
''')
\n
%s
"
,
addcslashes
(
$
gdbscript
,
'\'\\'
),
$
pyscript
,
);
$
ccode
=
sprintf
(
<<<'C'
/*
* Generated by %s.
*
* This inlines .gdbinit and php_gdb.py into the .debug_gdb_scripts
* section of the binary, so that they can be found by gdb.
*
* See https://sourceware.org/gdb/current/onlinedocs/gdb.html/dotdebug_005fgdb_005fscripts-section.html#dotdebug_005fgdb_005fscripts-section
*/
__asm__(
".pushsection \".debug_gdb_scripts\", \"MS\",%%progbits,1\n"
".byte 4 /* Python Text */\n"
".ascii \"gdb.inlined-script\\n\"\n"
%s
".byte 0\n"
".popsection\n"
);
C,
basename
(
__FILE__
),
implode
(
"\n
"
,
array_map
(
function
(
$
line
) {
$
escapedPy
=
addcslashes
(
$
line
.
"\n"
,
"\"\n\\"
);
$
escapedAsm
=
addcslashes
(
sprintf
(
"
.ascii
\"
%s
\"\n"
,
$
escapedPy
),
"\"\n\\
?
"
);
return
sprintf
(
'
"%s"
'
,
$
escapedAsm
);
},
explode
(
"\n"
,
$
pyscript
))),
);
$
len
=
file_put_contents
(
$
outputFile
,
$
ccode
);
if
(
$
len
!==
strlen
(
$
ccode
)) {
printf
(
"
Failed
\n"
);
exit
(
1
);
}
Back
|
FazBrowse Home
|
New Git URL