Skip to content

Commit

Permalink
Merge pull request #166 from sj-i/remove-current-function
Browse files Browse the repository at this point in the history
remove i:current_function
  • Loading branch information
sj-i committed Feb 14, 2022
2 parents 0dac36e + aa4d5ad commit b102b9a
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 184 deletions.
107 changes: 0 additions & 107 deletions src/Command/Inspector/GetCurrentFunctionNameCommand.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Lib/PhpProcessReader/PhpMemoryReader/CallTraceReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,6 @@ private function getExecutorGlobals(
return $dereferencer->deref($eg_pointer);
}

/**
* @param value-of<ZendTypeReader::ALL_SUPPORTED_VERSIONS> $php_version
* @throws MemoryReaderException
*/
public function readCurrentFunctionName(int $pid, string $php_version, int $executor_globals_address): string
{
$dereferencer = $this->getDereferencer($pid, $php_version);
$eg = $this->getExecutorGlobals($executor_globals_address, $php_version, $dereferencer);
if (is_null($eg->current_execute_data)) {
throw new \Exception('cannot read current execute data');
}
/**
* @var ZendExecuteData $current_execute_data
* @psalm-ignore-var
*/
$current_execute_data = $dereferencer->deref($eg->current_execute_data);
return $current_execute_data->getFunctionName($dereferencer) ?? 'unknown';
}

/**
* @param value-of<ZendTypeReader::ALL_SUPPORTED_VERSIONS> $php_version
* @throws MemoryReaderException
Expand Down
58 changes: 0 additions & 58 deletions tests/Lib/PhpProcessReader/PhpMemoryReader/CallTraceReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,64 +54,6 @@ protected function tearDown(): void
}
}

public function testReadCurrentFunctionName()
{
$memory_reader = new MemoryReader();
$executor_globals_reader = new CallTraceReader(
$memory_reader,
new ZendTypeReaderCreator(),
new OpcodeFactory()
);
$this->child = proc_open(
[
PHP_BINARY,
'-r',
'fputs(STDOUT, "a\n");fgets(STDIN);'
],
[
['pipe', 'r'],
['pipe', 'w'],
['pipe', 'w']
],
$pipes
);

fgets($pipes[1]);
$child_status = proc_get_status($this->child);
$php_symbol_reader_creator = new PhpSymbolReaderCreator(
$memory_reader,
new ProcessModuleSymbolReaderCreator(
new Elf64SymbolResolverCreator(
new CatFileReader(),
new Elf64Parser(
new LittleEndianReader()
)
),
$memory_reader,
),
ProcessMemoryMapCreator::create(),
new LittleEndianReader()
);
$php_globals_finder = new PhpGlobalsFinder(
$php_symbol_reader_creator,
new LittleEndianReader(),
new MemoryReader()
);

/** @var int $child_status['pid'] */
$executor_globals_address = $php_globals_finder->findExecutorGlobals(
new ProcessSpecifier($child_status['pid']),
new TargetPhpSettings()
);
$name = $executor_globals_reader->readCurrentFunctionName(
$child_status['pid'],
ZendTypeReader::V74,
$executor_globals_address
);
$this->assertSame('fgets', $name);
}


public function testReadCallTrace()
{
$memory_reader = new MemoryReader();
Expand Down

0 comments on commit b102b9a

Please sign in to comment.