URL
https://opencores.org/ocsvn/or2k/or2k/trunk
Subversion Repositories or2k
[/] [or2k/] [trunk/] [analysis-bin/] [insnanalysis/] [README] - Rev 28
Compare with Previous | Blame | View Log
Instruction analysis programThis application reads in a binary list of instructions, and analyses it with aset of functions looking at various parameters in each instruction.Right now it's not so user friendly. Everything is hardcoded, and only supportfor the OR1K instruction set exists.It has been written in a way that should allow other instructinos to be addedeasily. It remains to be seen how much would be reusable between the sets butfor now, at least it would be easy enough to take the OR1K instructionanalysis functions and drop in a different instruction set.The types of information given for OR1K instruction analysis is instructionfrequency, immediate frequency for each instruction, branch distance valuefrequency, and register usage frequency. For each instruction, the most commonn-tuple sets of instructions, finishing with that instruction, are presented,for pairs, triples and quadruples. Additionally output is the most commonoverall n-tuples.Compile the program with:$ make allAnd run a test (it needs the or32-elf- toolchain) with:$ make testStatic analysis:To generate a raw binary representation of the instructions that end up insomething like the Linux kernel, take the ELF file that results from compilationand pass it to or32-elf-objcopy like the following:$ or32-elf-objcopy -O binary -j .text -S vmlinux vmlinux.text.binUse the -f flag to indicate the input file, and -o to indicate the output file.$ ./insnanalysis -f vmlinux.text.bin o vmlinux.insnanalysisDynamic analysis with binary execution log from or1ksim:As of revision 202 of the OpenRISC repository, or1ksim is capable of generatingan execution trace log in binary format, logging each instruction executed.This log file can be given to insnanalysis.In the or1ksim config file ensure the line "exe_bin_insn_log = 1" is in thesim section. This will enable the binary instruction logging. The resultingoutput file is then given to insnanalysis in the same manner as above.Output:Currently there are only two output formats, human readable string and CSV.The output can be switched between human readable strings and CSV format (readyto be imported into a spreadsheet application) by uncommenting one of the"#define DISPLAY_" defines in the instruction set header. The program must berecompiled if this is changed.Individual instruction analysis:Instead of only breaking the instruction up and recording statistics on anopcode basis - the instructions can be tracked in their entireity and statisticson the most frequently seen entire instruction presented. Use the -u flag whenrunning the program. Note that this will make execution time longer. For abinary trace of Linux booting 1.7GB in size, a 2.5GHz Intel Core 2 Duo machinetook 30 minutes to parse with the -u option.TODO:o Collect and display information about l.j and l.jal instruction immediateso Add an easy way to switch between human readable and CSV outputo Figure out how to tack this thing onto a simulator (or1ksim for now) to giveresults of execution when that finishes executing, or just how to get thesimulator to output a binary dump of executed instructions to be fed throughthiso Add support for a list of binary files to be specified at the command lineo Allow statistics to be collated over different files - this would allow eachfunction to be broken out of a library, or application, and in that regardthe instruction sequence data would then be accurate for static analysis.July 25, 2010 - Julius Baxter
