Presentation is loading. Please wait.

Presentation is loading. Please wait.

F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea The Visual Code Navigator: An Interactive Toolset For Source Code Investigation Eindhoven.

Similar presentations

Presentation on theme: "F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea The Visual Code Navigator: An Interactive Toolset For Source Code Investigation Eindhoven."— Presentation transcript:

1 F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea The Visual Code Navigator: An Interactive Toolset For Source Code Investigation Eindhoven University of Technology, the Netherlands

2 The Visual Code Navigator (VCN): an environment for interactive visualization of industry-size source code projects tuned for C/C++ code bases stored in CVS targets understanding code evolution and code structure based on three views with complementary purposes How can we extract facts from source code? Outline What can the VCN source code views show?

3 Fact extraction Notoriously difficult problem… Requirements (roughly): completeness: - extracts all elements & cross-refs from source code - extracts correct information - complies with latest C/C++ standard - includes preprocessor facilities tolerance: - handles incomplete/incorrect/ambiguous code efficiency: - memory/speed efficient on industry-size code bases availability: - can be built from source code, preferably cross-platform

4 Existing fact extractors ++ very good + good o could be better - limited -- unacceptable/missing ? insufficiently tested Testing: - get the tool as binary/source; try to build it - analyze very large systems (>0.5MLOC) - select extremely messy C/C++ code - try with/without includes (incomplete) - check output for size, correctness, completeness, throughput - investigate limitations’ causes

5 Conclusions Many surprises: most tools extract interface data quite ok … but badly fail at parsing implementation (function bodies) tolerance and completeness are mutually exclusive completeness and performance are also complementary GLR grammar based tools are by far the best Overall, we found just one reasonably good tool: Columbus However, it is: closed-source limited in some technical respects (template handling) quite slow (1 hr 20 min for ~150000 LOC) How can we do better than the above tools?

6 EFES: An own C/C++ fact extractor We chose to build an own extractor: based on the Elkhound C/C++ GLR parser uses a modified preprocessor, for tolerance extends the parser, for tolerance vs incomplete/incorrect code & handling templated code uses compression techniques to compact/speed up output So far: tests on very large projects (>200 MLOC) look good we are 3..7 times faster than Columbus we produce the ‘bare’ info, no metrics yet Hard, but unavoidable endeavour

7 EFES Architecture source:any C/C++ project, possibly incomplete/incorrect code preprocessor:libcpp, also used by GNU CPP parser:Elsa – uses the Elkhound GLR parser generator type checker:disambiguates code with type information filter:limits output to a set of interest (e.g. files, scopes, …) output generator:efficiently writes the output information to a file

8 EFES Enhancements Several enhancements to ‘standard’ fact extraction: preprocessor:enhanced CPP to produce exact location information (needed later for construct visualization & comparison) parser &enhanced Elsa to: type checker:- parse incorrect code with extra grammar rules – errors are caught at scope level - extended Elsa’s template support - added checkpoints at top-form level to trap internal errors filter:novel element; reduces output size dramatically, e.g. by skipping standard header information output added compact binary output; reduces output size 10 times generator: increases output speed 5 times project lets users customize extraction (C++ dialect, filtering, parser concept:strictness, what to output, etc)

9 Performance & Results Columbus EFES We are 3..7 times faster

10 Conclusions We’ve build a powerful C/C++ fact extractor: works on large projects (>200 MLOC) handles incorrect/incomplete code well extracts virtually all raw information there is is 3..7 times faster than a known commercial solution Desired additions distil raw information into more interesting facts (metrics, patterns, etc) add query layer atop basic extractor add interactive visualization layer atop query layer An evolving project

11 Visualization We have now our extracted facts: variables, types, functions, classes… cross-references between all these location information (file, line, column) of each construct We like to show it to the user & answer questions: how is the code structured? how are programming constructs distributed? how has the code changed in time? how are the typical function signatures used in a project? …and so on Several visualization tools

12 1) Syntactic view: 1 version, N files – code view Basic idea: combine a classical text editor with a pixel-based text display (e.g. SeeSoft) in a single view let users smoothly navigate between the two blend syntactic structures over code text using cushions + border size x cushion profile f(x) source code cushion texture result syntax tree

13 Syntactic view: Classical code editor…

14 Syntactic view: Blend in structure cushions…

15 Syntactic view: More structure cushions…

16 Syntactic view: Zoom out on 10 files, ~7000 LOC

17 Syntactic view: Zoom out, structure cushions only

18 Cushion vs ‘syntax highlighting’ syntax highlightingstructure cushions clasical syntax highlighting is actually lexical lighlighting we generalize and enhance syntax highlighting

19 Syntactic view: Navigation user points the mouse at some code location…

20 Syntactic view: Spot cursor …and brings the text in focus above the structure

21 Syntactic view: Structure cursor …over a whole syntactic construct, if desired.

22 Syntactic view - Conclusions Two main uses: 1)Overview: good for showing up to 10-15000 LOC on one screen colors code by construct type easy to spot presence/distribution of constructs in code 2)Detail: good for quick browsing a single source file gives structure context information typical question: “where was that function with that doubly-nested for ?”

23 2) Symbol view: N files, 1 version – interface view files ‘public’ symbols in files Displays public symbols in source files Nested by scope rules (global, namespace, method, argument) Visualized using a cushion treemap, colored by symbol type arguments functions fields typedefs files global vars

24 Symbol view - Details Treemap node size computation: - leafs: function bodies: number of LOC in declaration else number of LOC or sizeof() - non-leafs: sum of children Shading: - hue: construct type (typedef, function, argument, …) - saturation: construct nesting (global/class scope) Targeted questions: - “what kind of symbols are in a library’s headers?” - “how are namespaces used in interface headers?” - “does a header have a simple / uniform structure or not?” - “are there heavy functions from a parameter-passing view?”

25 Symbol view: Example C global namespace C++ std namespace brushed file symbols in file

26 3) Evolution view: M files, N versions time (version) axis file axis source code details Basic idea: CVSscan tool [Voinea & Telea, ACM SoftVis’05]

27 Evolution view: M files, N versions time (version) axis file axis extends the CVSscan tool [Voinea & Telea, ACM SoftVis’05] stacks several stripped-out file evolution views above each other line color = construct type helps spotting cross-file correlations (e.g. large changes) comments function bodies strings function headers

28 Evolution view - Results We look for: Large size jumps = large code changes Size jumps correlating across more files at same version = cross-system changes Less ‘wavy’ patterns = stable(r) files Horizontal patterns = unchanged code

29 Evaluation Method & materials: - VTK C++ library (1 MLOC, 100 versions) - 3 users with C++ but no VTK knowledge - 1 user with C++ and VTK knowledge (evaluator) - quantitative and qualitative questions to be answered on VTK with and without VCN are files fine/coarse grained? what is the typical class interface structure? what is the typical class implem. structure? find & describe a few large evolution changes what is the typical macro usage/frequency? what is the typical comment usage/frequency? Questions StxSym Evo preferred/first tool optional/second tool

30 Evaluation Results: VCN allowed getting answers (much) faster than by pure classical source code browsing views are complementary, serve different tasks in different ways a single view is usually not enough a fine-tuned, fast, integrated system is essential! users reluctant to work with lame/suboptimal tools symbol view text editor start fine insight syntax view evolution view interface? implementation?

31 Implementation Syntactic view: cushions: OpenGL textures - superimposed, not blended careful cushion border design (see paper) Symbol view: cushion treemap: OpenGL fragment programs essential for interactive, fast navigation! Evolution view: column cushions: OpenGL textures several LOC / pixel solve by software antialiasing efficient tool design essential for smooth navigation in large code bases important for user acceptance

32 Conclusions VCN: multi-view visual environment for understanding source code and its evolution Syntax view: 1 version, N files (compiler) Symbol view: 1 version, N version (linker) Evolution view: M versions, N files Dense pixel displays essential for viewing large datasets Cushion techniques effective for visualizing various kinds of visual nesting (syntax,symbol,file,…) Working to extend & generalize the VCN What to do when M,N exceed a few hundred? Check it out:

Download ppt "F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea The Visual Code Navigator: An Interactive Toolset For Source Code Investigation Eindhoven."

Similar presentations

Ads by Google