sim: profile: implement --profile-file backend
The profile code already has options and handling for accepting a file to
write the profile output like the trace code, but it doesn't actually use
it. At the moment, it simply opens the file at the start and closes it at
the end. So add two new local functions the way the trace code is doing
it and have them figure out whether to write the output to stdout or the
specified file. Then convert all existing output in the profile code to
use these helpers.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>