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\Lib\Elf\Parser\ElfParserException; |
17
|
|
|
use PhpProfiler\Lib\Elf\Tls\TlsFinderException; |
18
|
|
|
use PhpProfiler\Lib\Process\MemoryReader\MemoryReaderException; |
19
|
|
|
use PhpProfiler\ProcessReader\PhpGlobalsFinder; |
20
|
|
|
use PhpProfiler\Lib\Elf\Process\ProcessSymbolReaderException; |
21
|
|
|
use Symfony\Component\Console\Command\Command; |
|
|
|
|
22
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
|
|
|
23
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
|
|
|
24
|
|
|
use Symfony\Component\Console\Output\ConsoleOutputInterface; |
|
|
|
|
25
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class GetEgAddressCommand |
29
|
|
|
* @package PhpProfiler\Command\Inspector |
30
|
|
|
*/ |
31
|
|
|
final class GetEgAddressCommand extends Command |
32
|
|
|
{ |
33
|
|
|
private PhpGlobalsFinder $php_globals_finder; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* GetEgAddressCommand constructor. |
37
|
|
|
* |
38
|
|
|
* @param PhpGlobalsFinder $php_globals_finder |
39
|
|
|
* @param string|null $name |
40
|
|
|
*/ |
41
|
|
|
public function __construct( |
42
|
|
|
PhpGlobalsFinder $php_globals_finder, |
43
|
|
|
string $name = null |
44
|
|
|
) { |
45
|
|
|
parent::__construct($name); |
46
|
|
|
$this->php_globals_finder = $php_globals_finder; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function configure(): void |
50
|
|
|
{ |
51
|
|
|
$this->setName('inspector:eg_address') |
52
|
|
|
->setDescription('get EG address from an outer process or thread') |
53
|
|
|
->addOption('pid', 'p', InputOption::VALUE_REQUIRED, 'process id'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @param InputInterface $input |
58
|
|
|
* @param OutputInterface $output |
59
|
|
|
* @return int |
60
|
|
|
* @throws MemoryReaderException |
61
|
|
|
* @throws ProcessSymbolReaderException |
62
|
|
|
* @throws ElfParserException |
63
|
|
|
* @throws TlsFinderException |
64
|
|
|
*/ |
65
|
|
|
public function execute(InputInterface $input, OutputInterface $output): int |
66
|
|
|
{ |
67
|
|
|
$pid = $input->getOption('pid'); |
68
|
|
|
if (is_null($pid)) { |
69
|
|
|
$error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
70
|
|
|
$error_output->writeln('pid is not specified'); |
71
|
|
|
return 1; |
72
|
|
|
} |
73
|
|
|
$pid = filter_var($pid, FILTER_VALIDATE_INT); |
74
|
|
|
if ($pid === false) { |
75
|
|
|
$error_output = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output; |
76
|
|
|
$error_output->writeln('pid is not integer'); |
77
|
|
|
return 2; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$output->writeln('0x' . dechex($this->php_globals_finder->findExecutorGlobals($pid))); |
81
|
|
|
|
82
|
|
|
return 0; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
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