From 4b261870631297760246cb2a41a240bd6aea4781 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 25 Oct 2009 12:39:10 +0000 Subject: [PATCH] Added to repository. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1274 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scripts/filter-trace-entry-exit | 69 +++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 scripts/filter-trace-entry-exit diff --git a/scripts/filter-trace-entry-exit b/scripts/filter-trace-entry-exit new file mode 100755 index 000000000..9aa07eda0 --- /dev/null +++ b/scripts/filter-trace-entry-exit @@ -0,0 +1,69 @@ +#!/usr/bin/gawk -f + +############################################################################ +# +# Script for filtering TRACE_ENTRY(), TRACE_EXIT() and TRACE_EXIT_RES() +# statements from a patch. +# +# Copyright (C) 2009 Bart Van Assche +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation, version 2 +# of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +############################################################################ + +function categorize_line() { + is_blank = 0 + is_trace_entry = 0 + is_trace_exit = 0 + if ($0 ~ "^+$") + is_blank = 1 + else if ($0 ~ "^+\tTRACE_ENTRY\\(\\);$") + is_trace_exit = 1 + else if ($0 ~ "^+\tTRACE_EXIT\\(\\);$" || $0 ~ "^+\tTRACE_EXIT_RES\\(.*\\);$") + is_trace_exit = 1 +} + +function print_conditionally() { + if (! previous_is_trace_entry \ + && ! (before_previous_is_trace_entry && previous_is_blank) \ + && ! previous_is_trace_exit \ + && ! (previous_is_blank && is_trace_exit)) + print previous_line +} + +function shift_state_variables() { + previous_line = $0 + before_previous_is_blank = previous_is_blank + before_previous_is_trace_entry = previous_is_trace_entry + before_previous_is_trace_exit = previous_is_trace_exit + previous_is_blank = is_blank + previous_is_trace_entry = is_trace_entry + previous_is_trace_exit = is_trace_exit +} + +BEGIN { + previous_is_blank = 0 + previous_is_trace_entry = 0 + previous_is_trace_exit = 0 + getline + categorize_line() + shift_state_variables() +} + +{ + categorize_line() + print_conditionally() + shift_state_variables() +} + +END { + print_conditionally() +}