Log Parser
==========

Changes
-------
  - 10/12/15 - Sylvain Henry


The log parser is a set of routines to parse optimization logs produced by
compilers such as GCC and ICC.

To produce the log with ICC, use the -qopt-report family of flags. If you use
-g, don't forget to set -O2 or -O3, otherwise the optimization log will be
empty. You can the verbosity of the log with -qopt-report=N (N is 0-5, default
is 2).

With GCC, use the -fopt-info family of flags (e.g. -fopt-info-all).


How to use it
-------------

Call tools.icc_parse(binfile,logfile) or tools.gcc_parse(binfile,logfile) where
"binfile" is the path of the binary file and "logfile" the path of the
optimization log produced by the compiler.

The output is not yet unified because of the differences between both logs.

Test script: test.lua
   local parsed = tools.icc_parse(arg[2],arg[3])
   Table:tostring(parsed)

$ maqao test.lua binfile logfile


ICC section
-----------

ICC adds a section ".debug_opt.report" in the binary ELF file. We decode it
almost completely in src/madras/intel.c but it is not yet clear how to use the
information in it. We get a list of 3-uplets (address, name, value).

Example:
Address	Name	                        Value
0x400a50	optimization_report_version	[0x10,0x81,0x2]
0x400a84	optimization_report	         [0x10,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc8,0x7]
0x400ac0	optimization_report	         [0x10,0x80,0x80,0x80,0x80,0x80,0x91,0x80,0x80,0x80,0x82,0x80,0xa0,0x8a,0x88,0xe3,0x1b]

The address in the first entry is the entry point (main). The other ones are
related to loops (beginning of the loop, remainder, etc.). I have not been able
to infer the meaning of the value bytes.
