B::Disassembler - Disassemble Perl bytecode


B-C documentation  | view source Contained in the B-C distribution.

Index


NAME

Top

B::Disassembler - Disassemble Perl bytecode

SYNOPSIS

Top

	use Disassembler qw(print_insn);
        my $fh = new FileHandle "<$ARGV[0]";
	disassemble_fh($fh, \&print_insn);

DESCRIPTION

Top

disassemble_fh takes an filehandle with bytecode and a printer function. The printer function gets three arguments: insn, arg (optional) and the comment.

See lib/B/Disassembler.pm and scripts/disassemble.

disassemble_fh (filehandle, printer_coderef, [ verbose ])

Top

disassemble_fh takes an filehandle with bytecode and a printer coderef.

Two default printer functions are provided:

  print_insn print_insn_bare

print_insn

Top

print_insn_bare

Top

get_header

Top

Returns the .plc header as array of

  ( magic, archname, blversion, ivsize, ptrsize,
    byteorder, longsize, archflag, perlversion )

in ARRAY context, or in SCALAR context the array from above as named hash.

magic is always "PLBC". "PLJC" is reserved for JIT'ted code also loaded via ByteLoader.

archname is the archname string and is in the ByteLoader up to 0.06 checked strictly. Starting with ByteLoader 0.06_05 platform compatibility is implemented by checking the $archflag, and doing byteorder swapping for same length longsize, and adjusting the ivsize and ptrsize.

blversion is the ByteLoader version from the header as string. Up to ByteLoader 0.06 this version must have matched exactly, since 0.07 earlier ByteLoader versions are also accepted in the ByteLoader.

ivsize matches $Config{ivsize} of the assembling perl. A number, 4 or 8 only supported.

ptrsize matches $Config{ptrsize} of the assembling perl. A number, 4 or 8 only supported.

longsize is $Config{longsize} of the assembling perl. A number, 4 or 8. Only since blversion 0.06_03.

byteorder is a string of "0x12345678" on big-endian or "0x78563412" (?) on little-endian machines. The beginning "0x" is stripped for compatibility with intermediate ByteLoader versions, i.e. 5.6.1 to 5.8.0, Added with blversion 0.06_03, and also with blversion 0.04. See BcVersions

archflag is a bitmask of opcode platform-dependencies. Currently used: bit 1 for USE_ITHREADS bit 2 for MULTIPLICITY Added with blversion 0.06_05.

perlversion $] of the perl which produced this bytecode as string. Added with blversion 0.06_06.

AUTHORS

Top

Malcolm Beattie MICB at cpan.org (retired), Reini Urban perl-compiler@googlegroups.com since 2008.


B-C documentation  | view source Contained in the B-C distribution.