>>> 3) A third thing that would be really nice would be a "don't break system
>>> calls" option. Basically, if one system call is pending when a second
>>> happens, DON'T display<pending...> unless a reasonable timeout has
>>> elapsed; rather just defer printing anything for the first system
>>> call until it returns, when it can be printed on one line.
>>
>> Uhhuh. That would not be so easy to implement. And some people
>> do want to know exact moment syscalls were entered/exited.
>>
>> -tt -ff does almost what you want. It separates logs one output file
>> per pid. A script can be written to combine them into one file,
>> using timestamps for ordering. Would this satisfy you?
>
> I am writing such a script right now, but saw on Ubuntu 11.10 (strace
> 4.5.20) that -ff does not record PID information inside the log file,
> only append the pid to the log file name. With my self-compiled strace
> 4.6 on mipsel embedded platform though, the logs contain pid information
> as first column. The NEWS document does not mention a change in log file
> format though. Can you comment on this please? I can easily create a
> script which supports both versions, doing different 'sed' replacements,
> but I was just wondering why this is necessary at all.
Okay, I just saw that the PIDs are only inserted into the log file if
strace is called with multiple -p arguments, which is what I did on the
mipsel platform. Anyway, these two cases need to be handled anyway:
> Necessary 'sed' replacement in 4.5.20: insert pid after timestamp
> (otherwise we cannot sort by timestamp).
>
> Necessary 'sed' replacement in 4.6: move pid from first column (before
> timestamp) to second column (otherwise we again cannot sort by timestamp).
Okay, here is the script as an attachment. Call it like this:
./strace_no_pending mc.log mc
./strace_no_pending test.log -p 719 -p 1010
Please note:
- If you want the PID as first column, you need to do that *after*
sorting by timestamp, which would make the script more complicated.
I guess this is not needed.
- The "trap" avoids the script to be aborted before log file
unification if the user wants to stop strace via Ctrl-C.
- The pid-numbered logfiles are cleaned up after unification. If you
still want to keep them, remove the last command.
Enjoy!
--
Alexander Kriegisch (kriegaex)
http://freetz.org
#!/bin/sh
# Logfile as first parameter is required
logfile="$1"
shift
# Ctrl-C should only kill strace, not the rest of the script
trap '' INT
# Create one logfiles per pid, then consolidate them into one,
# sorted by timestamp and containing the pid as 2nd column
strace -tt -ff -o "$logfile" "$@"
{
for file in "$logfile".*; do
pid=$(printf "%-5u" "${file##$logfile.}")
cat "$file" | sed -r "s/^([0-9]+ +)?([^ ]+)(.*)/\2 $pid\3/"
done
} | sort > "$logfile"
# Clean up temporary logfiles
rm "$logfile".*
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel