http:^^www.cs.washington.edu^homes^jbaer^layers.html

来自「This data set contains WWW-pages collect」· HTML 代码 · 共 375 行 · 第 1/2 页

HTML
375
字号
If lcc's checking of level boundaries succeeds, then it outputsintermediate .c files with the annotations stripped out and execs ccor gcc on those files.  This approach has the advantage that it bringssupport for layers closer to the language level.  The disadvantagewith this approach at the moment stems from the fact that lcc does notcontain a full C parser.  Thus, syntax errors may confuse lcc, causingit to output layer-related errors without telling you about the syntaxerrors.  In fact, in this case it will never actually produceintermediate files on which to run a real compiler, so the programmerwill essentially be stuck with trying to find the error by hand orremoving all annotations and compiling, neither of which aresatisfactory solutions.<p>The second approach, which has neither the advantages or disadvantagesof the first is to view lcc as an optional static checker.  In thisversion of lcc, levels are specified as annotations enclosed in Ccomments.  They still utilize the @level keyword and live in the sameplace in the source code, but since they are in a comment, the sourcecode can still be compiled using a regular C compiler.  In thisapproach, the example above now looks like:<pre>int foo(double x) /* @level 3 */{    <i>function body</i>}</pre><p>lcc performs the same basic analysis, except that it now must locatethese particular comments (since it normally skips all comments) tofind the annotations.  While the version of lcc using this secondapproach is currently much more usable than the version implementingthe first approach, it is the author's belief that bringing layersupport closer to the language level (as in the first approach) isultimately more desirable, given the addition of a complete C parser(with the addition of the @layer syntax) to lcc.<p><br><p><b>Layered C Extractor (lce)</b><p>lce is similar to lcc in that it checks C source code to see if theboundaries between levels are maintained.  However, rather than usingsource annotations to determine the level to which a function isassigned, lce will automatically generate the mapping of functions tolevels.  Thus, lce is perhaps more applicable to the process ofreverse engineering or program understanding than to a forwardengineering process.  The same options for recursion, invocation layercrossing thresholds, etc. from lcc are available in lce.<p>lce works by first extracting a call graph from the source in the samemanner as lcc.  It then performs a recursive depth-first search of thecall graph, starting at main.  A level counter is incremented at everylevel of recursion, and if a function is called from the currentlevel, the level of the that function is set to 1 + the current level,as long as it is not already deeper.  Note that lce assigns levels inan inverted order as that normally accepted by lce.  Namely, main() isat level 0, and functions lower in the hierarchy are at highernumbered levels.  lcc can optionally use this same "inverted" layerordering, but lce uses it exclusively.<p>Performing a depth-first search of the call graph does yield onepossible assignment of layers -- namely that assignment in which eachfunction gets assigned to the highest possible layer in the hierarchy.This may not, however, be the optimal assignment of layers.  One mightimagine, for example, that a desirable scheme for mapping functions tolayers would be to minimize the number of layers crossed by anyinvocation.  Rather than addressing this in the algorithm itself,however, an approach inspired by the reflexion models [MNS95] was taken.lce was modified to recognize the @level annotations used by lcc.This allows the user to set the levels of certain functions "in stone"with an annotation, and then see if the desired level boundaries aremaintained.  lce fixes only the level of the functions which areannotated, and still uses a depth-first search to map levels to therest of the functions.  <p>Following are two sample executions of lce, once on itself, and onceon the source for the UNIX command agrep.  As it turns out, neither ofthese programs have a strict layered invokes structure.  No invokeshierarchy exists for agrep in which no invocations cross less than 4level boundaries.  With allowable layer crossings set to 3, there wasone offending invokes.  To test whether this 4 layer crossing wastruly necessary, the calling function was annotated to be fixed at onelevel lower than the depth-first search had placed it.  However, whenthe test was re-run, the 4 layers of separation between these twofunctions remained.  The agrep example also illustrates anothercapability of lce which is a side effect of depth-first searching onthe call graph.  If a function or functions are never visited duringthe depth-first search, it may be that they are never called and lceflags this possibility.<pre>898 cindy:layered_c >lce -l -r lce.ccFunctions by level:level 0    lce.cc: mainlevel 1    lce.cc: FindFunctions    lce.cc: FindCallgraph    lce.cc: AssignLayers    lce.cc: CheckLayerslevel 2    lce.cc: AssignLayersDFS    lce.cc: AddToFnList    lce.cc: nextTokenStrlevel 3    lce.cc: HandleError    lce.cc: FunctionLookuplce.cc: Illegal level crossing:    FunctionLookup (level 3) invoked from FindCallgraph (level 1)lce.cc: Illegal level crossing:    FunctionLookup (level 3) invoked from FindCallgraph (level 1)lce.cc: Illegal level crossing:    FunctionLookup (level 3) invoked from AssignLayers (level 1)lce.cc: Illegal level crossing:    HandleError (level 3) invoked from AssignLayers (level 1)lce.cc: Illegal level crossing:    FunctionLookup (level 3) invoked from CheckLayers (level 1)lce.cc: Illegal level crossing:    FunctionLookup (level 3) invoked from CheckLayers (level 1)Exiting with errors 899 cindy:layered_c >lce -4 -r ../hw5/agrep2.04/*.cA layered invokes structure exists which satisfies the input constraints!Note: as far as lce can tell, the following functions willnever be invoked (though they may be through function pointers):    ../hw5/agrep2.04/utilities.c: subset_pset    ../hw5/agrep2.04/utilities.c: eq_pset</pre><p><br><p><b>Future Work</b><p>Few concrete conclusions can be drawn at this point about theusefulness of these tools, as they have yet to be used for any realsoftware engineering project.  The purpose of this paper however, hasbeen simply to provide some motivation for tools to support thedevelopment of layered systems, and describe some of the author'searly attempts at building such tools.<p>There are several directions in which future work would be beneficial.The most important direction would be to actually try building somenon-trivial size programs with a layered design using lcc.  Only bydoing this will any real measure of the value of these tools beattainable.  Some other interesting possibilities for future workinclude:<ul><li>Extend lcc to include a full C parser</li><li>Explore the support of layers for other languages (particularly thosethat already provide support for a greater degree of structure than C)</li><li>Explore other ways of grouping layer designations in source code</li><li>Improve the search capabilities of lce to look for more optimallayerings than those obtained from simple depth-first search.</li></ul><p><br><p><b>References</b><p>[P72] D. L. Parnas.  On the Criteria To Be Used in DecomposingSystems into Modules.  <i>Communications of the ACM</i>, 1053-1058,December 1972.<p>[P79] D. L. Parnas.  Designing Software for Ease of Extension andContraction.  <i>IEEE Transactions on Software Engineering</i>,SE5(2):128-138, March 1979.<p>[MNS95] Gail C. Murphy, David Notkin, and Kevin Sullivan.  ReflexionModels: Bridging the Gap between Source and High-Level Models,<i>ACM SIGSOFT Software Engineering Notes</i>, 20(4):18-28, October 1995.</body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?