Reini Urban > B-C > B::Disassembler

Download:
B-C-1.04_21.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Module Version: 1.05_03   Source  

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.

Two default printer functions are provided: print_insn print_insn_bare

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 )

$magic is always "PLBC"

$archname is the archname string and is in the ByteLoader up to 0.06 checked strictly. No platform compatibility yet implemented.

$blversion is the matching ByteLoader version 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.

$byteorder is a string of "12345678" on big-endian or "56781234" (?) on little-endian machines.

AUTHORS ^

Malcolm Beattie, mbeattie@sable.ox.ac.uk. Reini Urban <rurban@cpan.org> since 2008.