Skip to content

Commit

Permalink
Fix the wrong path mapping when reading dependencies on the core dump…
Browse files Browse the repository at this point in the history
… reader
  • Loading branch information
sj-i committed Apr 29, 2024
1 parent ff38ab4 commit 4af3660
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Inspector/CoreDumpReader/CoreDumpReaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function createFromPath(string $file_path, array $path_mapping): CoreDump
}
}
$file_path = $corresponding_file?->name ?? '';
$file_inode = $file_path === '' ? 0 : fileinode($file_path);
$file_inode = $file_path === '' ? 0 : (file_exists($file_path) ? fileinode($file_path) : 0);

$memory_areas[] = new ProcessMemoryArea(
dechex($load_segment->p_vaddr->toInt()),
Expand All @@ -131,13 +131,15 @@ public function createFromPath(string $file_path, array $path_mapping): CoreDump
$file_path,
);
}
$path_resolver = new MappedPathResolver($path_mapping);

Check failure on line 134 in src/Inspector/CoreDumpReader/CoreDumpReaderFactory.php

View workflow job for this annotation

GitHub Actions / phpcs check codestyles

Spaces must be used to indent lines; tabs are not allowed
$process_memory_map = new ProcessMemoryMap($memory_areas);
$memory_reader = new class ($binary, $process_memory_map, $file_maps) implements MemoryReaderInterface {
$memory_reader = new class ($binary, $process_memory_map, $file_maps, $path_resolver) implements MemoryReaderInterface {

Check warning on line 136 in src/Inspector/CoreDumpReader/CoreDumpReaderFactory.php

View workflow job for this annotation

GitHub Actions / phpcs check codestyles

Line exceeds 120 characters; contains 128 characters
/** @param NtFileEntry[] $file_maps */
public function __construct(
private ByteReaderInterface $core_dump_file,
private ProcessMemoryMap $process_memory_map,
private array $file_maps,
private MappedPathResolver $path_resolver,

Check failure on line 142 in src/Inspector/CoreDumpReader/CoreDumpReaderFactory.php

View workflow job for this annotation

GitHub Actions / phpcs check codestyles

Spaces must be used to indent lines; tabs are not allowed
) {
}
public function read(int $pid, int $remote_address, int $size): CData
Expand All @@ -146,7 +148,7 @@ public function read(int $pid, int $remote_address, int $size): CData
if ($memory_areas === []) {
foreach ($this->file_maps as $file_map) {
if ($file_map->isInRange(UInt64::fromInt($remote_address))) {
$fp = fopen($file_map->name, 'rb');
$fp = fopen($this->path_resolver->resolve($pid, $file_map->name), 'rb');
if ($fp === false) {
throw new \RuntimeException("failed to open file: $file_map->name");
}
Expand Down

0 comments on commit 4af3660

Please sign in to comment.