|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the sj-i/php-profiler package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) sji <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace PhpProfiler\Command\Inspector; |
|
15
|
|
|
|
|
16
|
|
|
use PhpProfiler\Inspector\RetryingLoopProvider; |
|
17
|
|
|
use PhpProfiler\Inspector\Settings\InspectorSettingsException; |
|
18
|
|
|
use PhpProfiler\Inspector\Settings\TargetPhpSettings\TargetPhpSettingsFromConsoleInput; |
|
19
|
|
|
use PhpProfiler\Inspector\Settings\TargetProcessSettings\TargetProcessSettingsFromConsoleInput; |
|
20
|
|
|
use PhpProfiler\Inspector\TargetProcess\TargetProcessResolver; |
|
21
|
|
|
use PhpProfiler\Lib\Elf\Parser\ElfParserException; |
|
22
|
|
|
use PhpProfiler\Lib\Elf\Tls\TlsFinderException; |
|
23
|
|
|
use PhpProfiler\Lib\PhpProcessReader\PhpGlobalsFinder; |
|
24
|
|
|
use PhpProfiler\Lib\Process\MemoryReader\MemoryReaderException; |
|
25
|
|
|
use PhpProfiler\Lib\Elf\Process\ProcessSymbolReaderException; |
|
26
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
|
|
27
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
|
|
28
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
use function dechex; |
|
31
|
|
|
use function sprintf; |
|
32
|
|
|
|
|
33
|
|
|
final class GetEgAddressCommand extends Command |
|
34
|
|
|
{ |
|
35
|
|
|
public function __construct( |
|
36
|
|
|
private PhpGlobalsFinder $php_globals_finder, |
|
37
|
|
|
private TargetPhpSettingsFromConsoleInput $target_php_settings_from_console_input, |
|
38
|
|
|
private TargetProcessSettingsFromConsoleInput $target_process_settings_from_console_input, |
|
39
|
|
|
private TargetProcessResolver $target_process_resolver, |
|
40
|
|
|
private RetryingLoopProvider $retrying_loop_provider, |
|
41
|
|
|
) { |
|
42
|
|
|
parent::__construct(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function configure(): void |
|
46
|
|
|
{ |
|
47
|
|
|
$this->setName('inspector:eg_address') |
|
48
|
|
|
->setDescription('get EG address from an outer process or thread') |
|
49
|
|
|
; |
|
50
|
|
|
$this->target_process_settings_from_console_input->setOptions($this); |
|
51
|
|
|
$this->target_php_settings_from_console_input->setOptions($this); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @throws MemoryReaderException |
|
56
|
|
|
* @throws ProcessSymbolReaderException |
|
57
|
|
|
* @throws ElfParserException |
|
58
|
|
|
* @throws TlsFinderException |
|
59
|
|
|
* @throws InspectorSettingsException |
|
60
|
|
|
*/ |
|
61
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int |
|
62
|
|
|
{ |
|
63
|
|
|
$target_php_settings = $this->target_php_settings_from_console_input->createSettings($input); |
|
64
|
|
|
$target_process_settings = $this->target_process_settings_from_console_input->createSettings($input); |
|
65
|
|
|
|
|
66
|
|
|
$process_specifier = $this->target_process_resolver->resolve($target_process_settings); |
|
67
|
|
|
|
|
68
|
|
|
// see the comment at GetTraceCommand::execute() |
|
69
|
|
|
$eg_address = $this->retrying_loop_provider->do( |
|
70
|
|
|
try: fn () => $this->php_globals_finder->findExecutorGlobals( |
|
71
|
|
|
$process_specifier, |
|
72
|
|
|
$target_php_settings |
|
73
|
|
|
), |
|
74
|
|
|
retry_on: [\Throwable::class], |
|
75
|
|
|
max_retry: 10, |
|
76
|
|
|
interval_on_retry_ns: 1000 * 1000 * 10, |
|
77
|
|
|
); |
|
78
|
|
|
|
|
79
|
|
|
$output->writeln( |
|
80
|
|
|
sprintf( |
|
81
|
|
|
'0x%s', |
|
82
|
|
|
dechex($eg_address) |
|
|
|
|
|
|
83
|
|
|
) |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
return 0; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths