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

F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

  • Upload
    dennis

  • View
    32

  • Download
    0

Embed Size (px)

DESCRIPTION

The Visual Code Navigator: An Interactive Toolset For Source Code Investigation. F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea. Eindhoven University of Technology , the Netherlands. Outline. The Visual Code Navigator (VCN): - PowerPoint PPT Presentation

Citation preview

Page 1: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

The Visual Code Navigator: An Interactive ToolsetFor Source Code Investigation

Eindhoven University of Technology, the Netherlands

Page 2: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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?

Page 3: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 4: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Existing fact extractors

++ very good+ goodo 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

Page 5: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

ConclusionsMany 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?

Page 6: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 7: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

EFES Architecture

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

Page 8: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

EFES EnhancementsSeveral 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. byskipping standard header information

output added compact binary output; reduces output size 10 timesgenerator: increases output speed 5 times

project lets users customize extraction (C++ dialect, filtering, parser concept: strictness, what to output, etc)

Page 9: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Performance & Results

Columbus

EFES We are 3..7 times faster

Page 10: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 11: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 12: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

cushionprofile f(x)

sourcecode

cushiontexture

resultsyntax tree

Page 13: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Classical code editor…

Page 14: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Blend in structure cushions…

Page 15: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: More structure cushions…

Page 16: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 17: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Zoom out, structure cushions only

Page 18: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Cushion vs ‘syntax highlighting’

syntax highlighting structure cushions

• clasical syntax highlighting is actually lexical lighlighting• we generalize and enhance syntax highlighting

Page 19: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Navigation

user points the mouse at some code location…

Page 20: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Spot cursor

…and brings the text in focus above the structure

Page 21: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Syntactic view: Structure cursor

…over a whole syntactic construct, if desired.

Page 22: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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?”

Page 23: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

2) Symbol view: N files, 1 version – interface view

files

‘public’symbolsin 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

Page 24: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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?”

Page 25: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Symbol view: ExampleC global

namespace C++ std namespace

brushedfile

symbolsin file

Page 26: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

3) Evolution view: M files, N versions

time (version) axis

file axis

source codedetails

Basic idea: CVSscan tool [Voinea & Telea, ACM SoftVis’05]

Page 27: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

Evolution view: M files, N versions

time(version)axis

fileaxis

• 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)

commentsfunction bodiesstringsfunction headers

Page 28: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 29: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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 changeswhat is the typical macro usage/frequency?what is the typical comment usage/frequency?

Questions Stx Sym Evo

preferred/first tooloptional/second tool

Page 30: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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 editorstart

fine insight

fine insight

syntax view

evolutionview

interface?

implementation?

Page 31: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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

Page 32: F. Boerboom, A. Janssen, G. Lommerse, F. Nossin, L. Voinea, A. Telea

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: www.win.tue.nl/~lvoinea/VCN.html