B::Disassembler(3)

NAME
B::Disassembler - Disassemble Perl bytecode

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

DESCRIPTION
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 ])
disassemble_fh takes an filehandle with bytecode and a printer coderef.

Two default printer functions are provided:

  print_insn print_insn_bare

print_insn
Callback function for disassemble_fh, which gets three arguments from the disassembler. insn (a string), arg (a string or number or undef) and the comment (an optional string).

This supports the new behaviour in scripts/disassemble. It prints each insn and optional argument with some additional comments, which looks similar to B::Assembler with option -S (commented source).

print_insn_bare
This is the same as the old behaviour of scripts/disassemble. It prints each insn and optional argument without any comments. Line per line.

get_header
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
Malcolm Beattie "MICB at cpan.org" (retired), Reini Urban "perl-compiler@googlegroups.com" since 2008.