Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines for 2022.
[simgrid.git] / tools / fix-paje-trace.sh
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2010-2022. The SimGrid Team. All rights reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the license (GNU LGPL) which comes with this package.
7
8 if [ -z $1 ]
9 then
10   echo "Usage: $0 {X.trace}"
11   exit
12 fi
13
14 TRACE=$1
15 echo "input: $TRACE"
16 OUTPUT=${TRACE%.*}.fix.trace
17
18 grep ^% -- "$TRACE" > header
19 DEFEVENTS=( $(awk '/Define/ { print $3 }' header) )
20
21 GREP=()
22 for i in "${DEFEVENTS[@]}"
23 do
24   GREP+=( -e "^$i " )
25 done
26 GREP2=( -e $'^%[ \tE]' "${GREP[@]}" )
27
28 grep "${GREP[@]}" -- "$TRACE" > types
29 grep -v "${GREP2[@]}" -- "$TRACE" > events
30 sort -n -k 2 -s < events > events.sorted
31 cat header types events.sorted > "$OUTPUT"
32 rm -f types events events.sorted header
33
34 echo "output: $OUTPUT"