fulltrace.sh: changed the buffer's heuristic to comply with ftrace

ftrace uses the number of possible CPUs instead of the number of present CPUs
to compute the size of the per CPU ring buffer. "Possible" refers to the number
of CPUs supported by the chipset, "present" refers instead to the number of
physically present CPUs in the system (which can be both online and offline).
On some machines these values are different, so we need to consider the actual
number of possible CPUs.
full-trace.sh: check first and last indexes before trimming the trace

The full-trace.sh script, in its write_trace() function, trims the
trace output by searching for the first and last context switches of
the traced process. It may happen, though, that a trace does not
cover all the execution of the traced process, and therefore does not
include context switches, or they are not in the expected order. This
would result in an uncorrect trimming of the trace output. This patch
addresses some of the corner-case failures concerning those indexes.
The patch also lets the trace output keep the dashed line at the end
of the last context switch.

Reported-by: Serena Ziviani <senseriumi@gmail.com>
Signed-off-by: Serena Ziviani <senseriumi@gmail.com>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
full-trace.sh: making fulltrace sudo compliant

Starting with kernel v3.7, the debugfs file system is unaccessible
without root privileges.
This patch adds sudo to every access at /sys/kernel/debug/, and sudo -v
at the beginning of the script, to ensure that the cache credentials are
updated.