Include line numbers in all of OPcache's debug dumps of bytecode
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
Description
opcache.opt_debug_level lets the CLI SAPI dump the bytecode of a file without executing it, for instance:
php -d opcache.enable_cli=1 -d opcache.opt_debug_level=0x10000 -r 'opcache_compile_file("file.php");'
For tools that need to know which source lines carry opcodes, the line number of each opline is essential. Code coverage is an example: whether a line is executable depends on decisions the compiler makes (whether a match expression is compiled to a jump table, whether constants are substituted, ...), see sebastianbergmann/php-code-coverage#1380. Compiling a file with opcache_compile_file() and reading the line numbers from the dump would answer that question for the bytecode that actually runs, without executing the file and without re-implementing the compiler's decisions.
Current state
zend_dump_op_array() supports ZEND_DUMP_LINE_NUMBERS, which prefixes each opline with Lnnnn (phpdbg's -p uses it). The dumps that OPcache emits for opcache.opt_debug_level pass hard-coded flags to it:
- PHP 8.4 and PHP 8.5: no dump includes line numbers, and there is no way to request them.
- PHP 8.6: the fix for GH-18985 (07d308a0deb) introduced
ZEND_DUMP_LINE_NUMBERS_PASSTHRU(bit 30,0x40000000). It adds line numbers to the "before optimizer" dump (opcache.opt_debug_level=0x40010000), but not to any other dump.
With this file (hooks.php, any file works):
<?php declare(strict_types=1);
final class Temperature
{
public float $celsius = 0.0 {
set {
if ($value < -273.15) {
throw new ValueError('Below absolute zero');
}
$this->celsius = $value;
}
}
}
opcache.opt_debug_level=0x40010000 (before optimizer) on PHP 8.6.1-dev:
Temperature::$celsius::set:
L0004 0000 CV0($value) = RECV 1
L0006 0001 T1 = IS_SMALLER CV0($value) float(-273.15)
L0006 0002 JMPZ T1 0007
L0007 0003 T2 = NEW 1 string("ValueError")
...
opcache.opt_debug_level=0x40020000 (after optimizer) on PHP 8.6.1-dev:
Temperature::$celsius::set:
0000 CV0($value) = RECV 1
0001 T1 = IS_SMALLER CV0($value) float(-273.15)
0002 JMPZ T1 0007
0003 T1 = NEW 1 string("ValueError")
...
Request
- Honor
ZEND_DUMP_LINE_NUMBERS_PASSTHRUin all dumps thatopcache.opt_debug_levelcontrols, not only in the "before optimizer" dump: at least the "after optimizer" dumps (inzend_optimize()and the one emitted after the call graph pass inzend_optimize_script()), and ideally also the "after pass N", block pass, and DFA dumps. When the optimizer is enabled, the optimized bytecode is what runs and what extensions such as Xdebug and PCOV observe, so the "after optimizer" dump is the one that tells which lines carry opcodes at run time. One way to implement this would be to derive the additional dump flags once fromctx->debug_leveland pass them to everyzend_dump_op_array()call of the optimizer. - Document the bit together with the other values of
opcache.opt_debug_level. I could not find it inphp.ini-development,UPGRADING, orNEWS(which only mentions the fix for GH-18985).
- Linguagem predominante
- C
- Estrelas
- 41.8k
- Forks
- 8.5k
- Merge médio
- 2d 12h
- PRs com merge (30d)
- 137
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de php/php-src
-
SNMP accepts malformed remote portsTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 Meio dia Facilidade para iniciantes 62/100
php/php-src#25137 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Bug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Mantenedores costumam responder em até 1 dia
-
quoted_printable_encode() produces lines longer than 76 characters for bytes 0xF5 to 0xFFTalvez já em andamento Um pull request vinculado a esta issue está aberto ou já foi mesclado. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia
-
Bug Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
php/php-src#24196 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Feature Status: Needs Triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
php/php-src#24183 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
Todas as issues de php/php-src
Issues semelhantes
-
enhancement good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
-
bug multiplayer status: planned
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
ChupathingyCE/chupathingyce#851 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 73/100
HigherOrderCO/Bend#2104 ·
-
research-radar
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
good first issue help wanted program
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
hffgzktbcc-blip/ounce-core#297 ·
Mantenedores costumam responder em até 1 dia