-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from sj-i/opcode
add opcode tracer
- Loading branch information
Showing
14 changed files
with
3,767 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use PhpProfiler\Lib\PhpProcessReader\CallTrace; | ||
/** @var CallTrace $call_trace */ | ||
?> | ||
<?php foreach ($call_trace->call_frames as $depth => $frame): ?> | ||
<?= $depth ?> <?= $frame->getFullyQualifiedFunctionName() ?> <?= $frame->file_name ?>:<?= $frame->getLineno() ?>:<?= $frame->getOpcodeName() , "\n" ?> | ||
<?php endforeach ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\PhpInternals\Opcodes; | ||
|
||
/** @psalm-immutable */ | ||
interface Opcode | ||
{ | ||
public function getName(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the sj-i/php-profiler package. | ||
* | ||
* (c) sji <sji@sj-i.dev> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PhpProfiler\Lib\PhpInternals\Opcodes; | ||
|
||
final class OpcodeFactory | ||
{ | ||
/** @var array<string, class-string<Opcode>> */ | ||
private const VERSION_MAP = [ | ||
'v70' => OpcodeV70::class, | ||
'v71' => OpcodeV71::class, | ||
'v72' => OpcodeV72::class, | ||
'v73' => OpcodeV73::class, | ||
'v74' => OpcodeV74::class, | ||
'v80' => OpcodeV80::class, | ||
]; | ||
|
||
/** | ||
* @template TVersion of key-of<self::VERSION_MAP> | ||
* @param TVersion $version | ||
* @return ( | ||
* TVersion is 'v70' ? OpcodeV70 : | ||
* TVersion is 'v71' ? OpcodeV71 : | ||
* TVersion is 'v72' ? OpcodeV72 : | ||
* TVersion is 'v73' ? OpcodeV73 : | ||
* TVersion is 'v74' ? OpcodeV74 : | ||
* OpcodeV80 | ||
* ) | ||
*/ | ||
public function create(string $version, int $opcode): Opcode | ||
{ | ||
return match ($version) { | ||
'v71' => new OpcodeV71($opcode), | ||
'v72' => new OpcodeV72($opcode), | ||
'v73' => new OpcodeV73($opcode), | ||
'v74' => new OpcodeV74($opcode), | ||
'v80' => new OpcodeV80($opcode), | ||
}; | ||
} | ||
} |
Oops, something went wrong.