13.07.2015 Views

Patterns of Tracing Software Structures and Dependencies

Patterns of Tracing Software Structures and Dependencies

Patterns of Tracing Software Structures and Dependencies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>and</strong> others. Some tree-based parser outputs <strong>of</strong>fer a suitable parse tree representation, othershave to be converted. Token or event streams also have to be converted into a tree representation.If a conversion <strong>of</strong> the parsed data is necessary, we have to walk through the wholeparsed data in the order <strong>of</strong> appearance in the source document, <strong>and</strong> call factories [GHJV94] orbuilders [GHJV94] for the targeted tree representation.The pattern parser/builder [Ber96] reads in data from a stream <strong>and</strong> builds up a respective,generic object structure using a factory [GHJV94]. The pattern can be used for the parsingpart <strong>of</strong> a PARSE TREE INTERPRETER if there is a need to interpret a raw data stream with a generictree structure.The parse tree representation should be “suitable,” meaning that the tree’s node structuresshould represent the language structure <strong>and</strong> that the <strong>of</strong>fered tree traversal methods should supportthe application-specific requirements <strong>of</strong> the application effectively <strong>and</strong> efficiently:• Regarding the tree’s node structure, in case <strong>of</strong> a programming language, typically onenode object per statement is created (it is also possible to create one node per lexicaltoken, but this is usually overkill). Nested statements are represented as child nodes.Attributes <strong>of</strong> statements are represented as node object properties. Each node objecttype represented one kind <strong>of</strong> statement in the source language.• Regarding the <strong>of</strong>fered tree traversal methods the parse tree can either <strong>of</strong>fer a tree traversalAPI to navigate through the tree <strong>and</strong>/or a visitor [GHJV94] that step-by-step visits allnodes <strong>of</strong> a (sub-)tree.The interpretation step following the parsing step is implemented on the PARSE TREE INTER-PRETER class. This class uses the domain knowledge about the interpreted language <strong>and</strong> therequired trace information to effectively <strong>and</strong> efficiently extract (<strong>and</strong> perhaps modify) the traceinformation. Note that different, application-specific PARSE TREE INTERPRETER classes can reusethe same parse tree <strong>and</strong> parser implementations.If modification <strong>of</strong> data is supported, usually an operation to write the modifications back intothe source language is supported. This can be done with a visitor that visits all elements <strong>of</strong> thetree <strong>and</strong> converts them into the source language format.A PARSE TREE INTERPRETER avoids implementing a new parser for the source language. However,some existing parsers have very complex outputs, bugs, or other practical problems that causemore work than writing a simple PARTIAL INTERPRETER would cause. A PARSE TREE INTERPRETERcan only extract information that are (statically) given in the source documents.Indirection LayerContextProblemYou want to extract trace information from a system or sub-system.Trace information can consist <strong>of</strong> information in electronic documents (such as the sourcecode), but also <strong>of</strong> information derived from dynamic invocation data (<strong>and</strong> data flows).It is hard to integrate these two kinds <strong>of</strong> trace information, as the former is staticallyprovided in the sources, whereas the later is obtained from the running system. How togather <strong>and</strong> integrate all relevant static <strong>and</strong> dynamic trace information in a unique way?

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!