Hi Mathi, It may also be the case that your trace file(s) includes some TRACE_ENTER without matching TRACE_LEAVE or vice versa. The trace2dot can also be used to do "rudimentary" checks for missing TRACE_ENTER/TRACE_LEAVE by using -c as argument. With this info the files with mismatched TRACE_ENTER/TRACE_LEAVE can be updated. As we are using C++ in e.g. AMF we can adapt the TRACE_ENTER to the RAII idiom, then we don't have to specify any TRACE_LEAVES.
/Thanks HansN On 09/10/2015 12:10 PM, Hans Nordebäck wrote: > Hi Mathi, > > I use graphviz version 2.36.0. Can you send me your dot file(s), I can > have a look to see if > something is wrong. Anyhow I'll push the patch. /Thanks HansN > > On 09/10/2015 11:13 AM, Mathivanan Naickan Palanivelu wrote: >> Looks Good unlike what i see :-). It must be some problem with the >> dotty version or something. >> My graphviz version is 2.26.3, what would be yours? >> Anyways, ACK from me. >> >> Cheers, >> Mathi. >> >> ----- hans.nordeb...@ericsson.com wrote: >> >>> Hi Mathi, >>> >>> I attach two pictures from the output of: >>> >>> $./trace2dot -t osafamfd -f saClmDispatch -d amfd_trace.dot >>> $ dotty amfd_trace.dot >>> >>> and >>> >>> $./trace2dot -t osafamfd -d amfd_trace.dot >>> $ dotty amfd_trace.dot >>> >>> /Thanks HansN >>> >>> On 09/10/2015 10:59 AM, Mathivanan Naickan Palanivelu wrote: >>>> Hi Hans, >>>> >>>> I do appreciate the idea of suggesting dotty, good thought! >>>> I did run dotty as mentioned in the patch. We could place the >>> trace2dot with 'execute' >>>> permissions and place it under tools/devel/dot directory. >>>> >>>> Also, the output i get after running dotty doesn't looks intuitive >>> to me. >>>> So, for comparison sakes,could you send a picture (snapshot) of how >>> the graph >>>> looks to you when you run it on osafamfd trace file? >>>> >>>> BR, >>>> Mathi. >>>> >>>> ----- hans.nordeb...@ericsson.com wrote: >>>> >>>>> tools/devel/trace2dot | 169 >>>>> ++++++++++++++++++++++++++++++++++++++++++++++++++ >>>>> 1 files changed, 169 insertions(+), 0 deletions(-) >>>>> >>>>> >>>>> Python script to create a runtime callgraph from OpenSAF trace >>> files. >>>>> A dot file is created and can be viewed using e.g. dotty >>>>> >>>>> diff --git a/tools/devel/trace2dot b/tools/devel/trace2dot >>>>> new file mode 100755 >>>>> --- /dev/null >>>>> +++ b/tools/devel/trace2dot >>>>> @@ -0,0 +1,169 @@ >>>>> +#!/usr/bin/env python >>>>> +# >>>>> +# >>>>> +# (C) Copyright 201t The OpenSAF Foundation >>>>> +# >>>>> +# 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. This file and program are >>>>> licensed >>>>> +# under the GNU Lesser General Public License Version 2.1, >>> February >>>>> 1999. >>>>> +# The complete license can be accessed from the following >>> location: >>>>> +# http://opensource.org/licenses/lgpl-license.php >>>>> +# See the Copying file included with the OpenSAF distribution for >>>>> full >>>>> +# licensing terms. >>>>> +# >>>>> +# Author(s): Ericsson >>>>> +# >>>>> +# >>>>> +""" >>>>> + trace2dot creates a runtime call graph using an opensaf trace >>> file >>>>> as input >>>>> + and produces a dot file. The generated dot file can be viewed >>>>> graphically using e.g. dotty. >>>>> + >>>>> + Example: >>>>> + Create a dot file, amfd_trace.dot from osafamfd trace file. >>> Start >>>>> from function set_oper_state. >>>>> + $ trace2dot -t osafamfd -f ssaClmDispatch -d amfd_trace.dot >>>>> + $ dotty amfd_trace.dot >>>>> + >>>>> +""" >>>>> +import sys >>>>> +import os >>>>> +import argparse >>>>> + >>>>> + >>>>> +def run(trace_file, from_function, dot_file): >>>>> + ''' TBD ''' >>>>> + infile = open(trace_file) >>>>> + >>>>> + if dot_file: >>>>> + outfile = open(dot_file, 'w') >>>>> + else: >>>>> + outfile = sys.stdout >>>>> + >>>>> + outfile.write('strict digraph test {\n') >>>>> + outfile.write('node [shape=record, style=filled];\n') >>>>> + outfile.write('edge [shape=normal];\n') >>>>> + >>>>> + process_infile(infile, from_function, outfile) >>>>> + >>>>> + outfile.write('}\n') >>>>> + >>>>> + >>>>> +def check_infile(trace_file): >>>>> + ''' Rudimentary check for missing TRACE_ENTER/TRACE_LEAVE. >>> Will >>>>> not >>>>> + check for e.g. returns before TRACE_LEAVE. >>>>> + ''' >>>>> + infile = open(trace_file) >>>>> + trace_enter = set() >>>>> + trace_leave = set() >>>>> + for line in infile: >>>>> + items = line.split() >>>>> + if items.__len__() > 6: >>>>> + if items[5] == '>>': >>>>> + name = items[6].rstrip(':') >>>>> + trace_enter.add(name) >>>>> + >>>>> + if items[5] == '<<': >>>>> + name = items[6].rstrip(':') >>>>> + trace_leave.add(name) >>>>> + >>>>> + for name in trace_enter: >>>>> + if name not in trace_leave: >>>>> + print '%s %s' % ('TRACE_LEAVE is missing for function: >>> ', >>>>> name) >>>>> + >>>>> + for name in trace_leave: >>>>> + if name not in trace_enter: >>>>> + print '%s %s' % ('TRACE_ENTER is missing for function: >>> ', >>>>> name) >>>>> + >>>>> + infile.close() >>>>> + >>>>> + >>>>> +def process_infile(infile, from_function, outfile): >>>>> + ''' TBD ''' >>>>> + function_names = [] >>>>> + from_func_found = False >>>>> + >>>>> + for line in infile: >>>>> + items = line.split() >>>>> + if items.__len__() > 6: >>>>> + if items[5] == '>>': >>>>> + func_enter = items[6].rstrip(':') >>>>> + if from_function and not from_func_found: >>>>> + if from_function != func_enter: >>>>> + continue >>>>> + else: >>>>> + from_func_found = True >>>>> + >>>>> + function_names.append(func_enter) >>>>> + >>>>> + if len(function_names) > 1: >>>>> + outfile.write( >>>>> + func_enter + ' [color=grey, shape=box, >>>>> label="' + func_enter + '"];\n') >>>>> + else: >>>>> + outfile.write( >>>>> + func_enter + ' [color=red, shape=box, >>>>> label="' + func_enter + '"];\n') >>>>> + >>>>> + if items[5] == '<<': >>>>> + func_leave = items[6].rstrip(':') >>>>> + if from_function: >>>>> + if from_function == func_leave: >>>>> + break >>>>> + >>>>> + if len(function_names) > 0: >>>>> + func_enter = function_names.pop() >>>>> + if func_enter != func_leave: >>>>> + print '%s %s %s' % (func_enter, ' has no >>>>> matching TRACE_LEAVE, found ', func_leave) >>>>> + outfile.write(func_leave + ' -> ' + >>>>> func_enter + '\n') >>>>> + >>>>> + else: >>>>> + if len(function_names) > 0: >>>>> + caller = >>>>> function_names[len(function_names) - 1] >>>>> + outfile.write(caller + ' -> ' + >>>>> func_enter + '\n') >>>>> + >>>>> + >>>>> +def file_exists(filename): >>>>> + '''Check if arg is a valid file that already exists on the >>> file >>>>> + system. >>>>> + ''' >>>>> + if not os.path.exists(filename): >>>>> + raise argparse.ArgumentTypeError( >>>>> + "The file %s does not exist!" % filename) >>>>> + else: >>>>> + return filename >>>>> + >>>>> + >>>>> +def main(): >>>>> + ''' program main ''' >>>>> + >>>>> + parser = argparse.ArgumentParser( >>>>> + description="Create runtime callgraph from OpenSAF trace >>>>> file") >>>>> + >>>>> + parser.add_argument('-t', '--tracefile', nargs='+', >>>>> + type=file_exists, help='OpenSAF trace >>> file') >>>>> + parser.add_argument('-f', '--fromfunction', nargs='+', >>>>> + help='Show runtime callgraph from >>> function') >>>>> + parser.add_argument('-d', '--dotfile', nargs='+', >>> help='Result >>>>> file in dot format') >>>>> + parser.add_argument('-c', '--checkfile', nargs='+', >>>>> + type=file_exists, help='Check infile for >>>>> matching trace_enter trace_leave') >>>>> + >>>>> + args = parser.parse_args() >>>>> + >>>>> + from_function = '' >>>>> + dot_file = '' >>>>> + trace_file = '' >>>>> + >>>>> + if args.fromfunction: >>>>> + from_function = args.fromfunction[0] >>>>> + >>>>> + if args.dotfile: >>>>> + dot_file = args.dotfile[0] >>>>> + >>>>> + if args.checkfile: >>>>> + trace_file = args.checkfile[0] >>>>> + check_infile(trace_file) >>>>> + >>>>> + if args.tracefile: >>>>> + trace_file = args.tracefile[0] >>>>> + run(trace_file, from_function, dot_file) >>>>> + >>>>> +if __name__ == '__main__': >>>>> + main() > ------------------------------------------------------------------------------ Monitor Your Dynamic Infrastructure at Any Scale With Datadog! Get real-time metrics from all of your servers, apps and tools in one place. SourceForge users - Click here to start your Free Trial of Datadog now! http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140 _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel