Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the target PHP version detection on some cases #422

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Command/Inspector/GetEgAddressCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Reli\Lib\Elf\Parser\ElfParserException;
use Reli\Lib\Elf\Tls\TlsFinderException;
use Reli\Lib\PhpProcessReader\PhpGlobalsFinder;
use Reli\Lib\PhpProcessReader\PhpVersionDetector;
use Reli\Lib\Process\MemoryReader\MemoryReaderException;
use Reli\Lib\Elf\Process\ProcessSymbolReaderException;
use Symfony\Component\Console\Command\Command;
Expand All @@ -37,6 +38,7 @@ public function __construct(
private TargetPhpSettingsFromConsoleInput $target_php_settings_from_console_input,
private TargetProcessSettingsFromConsoleInput $target_process_settings_from_console_input,
private TargetProcessResolver $target_process_resolver,
private PhpVersionDetector $php_version_detector,
private RetryingLoopProvider $retrying_loop_provider,
) {
parent::__construct();
Expand Down Expand Up @@ -65,11 +67,16 @@ public function execute(InputInterface $input, OutputInterface $output): int

$process_specifier = $this->target_process_resolver->resolve($target_process_settings);

$target_php_settings_version_decided = $this->php_version_detector->decidePhpVersion(
$process_specifier,
$target_php_settings
);

// see the comment at GetTraceCommand::execute()
$eg_address = $this->retrying_loop_provider->do(
try: fn () => $this->php_globals_finder->findExecutorGlobals(
$process_specifier,
$target_php_settings
$target_php_settings_version_decided
),
retry_on: [\Throwable::class],
max_retry: 10,
Expand Down
10 changes: 8 additions & 2 deletions src/Command/Inspector/MemoryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ public function execute(InputInterface $input, OutputInterface $output): int
defer($scope_guard, fn () => $this->process_stopper->resume($process_specifier->pid));
}

$eg_address = $this->php_globals_finder->findExecutorGlobals($process_specifier, $target_php_settings);
$cg_address = $this->php_globals_finder->findCompilerGlobals($process_specifier, $target_php_settings);
$eg_address = $this->php_globals_finder->findExecutorGlobals(
$process_specifier,
$target_php_settings_version_decided
);
$cg_address = $this->php_globals_finder->findCompilerGlobals(
$process_specifier,
$target_php_settings_version_decided
);

$collected_memories = $this->memory_locations_collector->collectAll(
$process_specifier,
Expand Down
2 changes: 2 additions & 0 deletions src/Lib/PhpProcessReader/PhpGlobalsFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function getSymbolReader(
}

/**
* @param TargetPhpSettings<value-of<ZendTypeReader::ALL_SUPPORTED_VERSIONS>> $target_php_settings
* @throws ElfParserException
* @throws MemoryReaderException
* @throws ProcessSymbolReaderException
Expand All @@ -93,6 +94,7 @@ public function findExecutorGlobals(
}

/**
* @param TargetPhpSettings<value-of<ZendTypeReader::ALL_SUPPORTED_VERSIONS>> $target_php_settings
* @throws ElfParserException
* @throws MemoryReaderException
* @throws ProcessSymbolReaderException
Expand Down
Loading