Pfff: PHP Program Analysis at Facebook Yoann Padioleau (Facebook) - - PowerPoint PPT Presentation

pfff php program analysis at facebook yoann padioleau
SMART_READER_LITE
LIVE PREVIEW

Pfff: PHP Program Analysis at Facebook Yoann Padioleau (Facebook) - - PowerPoint PPT Presentation

Pfff: PHP Program Analysis at Facebook Yoann Padioleau (Facebook) http://github.com/facebook/pfff OCaml Users and Developers Workshop 2013 About this talk n Feel free to ask questions during the talk PHP Program Analysis at Facebook n


slide-1
SLIDE 1

Pfff: PHP Program Analysis at Facebook Yoann Padioleau (Facebook) http://github.com/facebook/pfff

OCaml Users and Developers Workshop 2013

slide-2
SLIDE 2

About this talk

n Feel free to ask questions during the talk

slide-3
SLIDE 3

PHP Program Analysis at Facebook

n Deadcode removal (global analysis) n Test coverage (dynamic analysis) n Use/Def checker (e.g. use of undefined function) n Variable checker (e.g. use of undeclared variable) n Syntactical Grep lint rules n Tainting Analysis via abstract interpreter (XSS) n Type checker daemon (Julien’s talk at CUFP’13) n Separation Logic? (Monoidics ocaml startup acquired)

But I will not talk at all about any of this in this talk

slide-4
SLIDE 4

Pfff: Tools to Help Understand Large Codebase Yoann Padioleau (Facebook) http://github.com/facebook/pfff

OCaml Users and Developers Workshop 2013

slide-5
SLIDE 5

Demo Codemap

  • Google maps for source code
  • Program analysis + software visualization
  • Need a 30’ monitor to really appreciate
slide-6
SLIDE 6

Demo Codegraph

  • Focus on code relationships, not source code
  • Understand the “Software Architecture”
slide-7
SLIDE 7

Demo Codemap + Codegraph

slide-8
SLIDE 8

Pfff tools and APIs

n Other tools in Pfff:

n CodeQuery: Prolog queries on codebase n stags: precise TAGS generator n sgrep/spatch: syntactical grep and patch n scheck: linter

n Program analysis APIs for many languages (parsers,

AST visitor/dumper/matcher/highlighter, use/def global analysis, coverage analysis, refactoring, etc):

n OCaml (thx to .cmt in 4.00) n PHP n Java (thx to joust and javalib) n C/C++ (thx to yacfe and clang) n Html, Css, Javascript n …

slide-9
SLIDE 9

Conclusion

n CodeMap: a scalable semantic-based

source code visualizer/searcher/ navigator

n CodeGraph: a scalable dependencies

visualizer

n Future work:

n Reordering to minimize backward deps n Web UI (most of it done, with ocsigen)

$ git clone git://github.com/facebook/pfff.git

slide-10
SLIDE 10
slide-11
SLIDE 11

Features

n Big picture, treemaps, “macro level” n Search, navigation n Semantic-based code highlighting

“micro level”

n Connection to editor (emacs/vim) n Extensible via layers (predator mode)

Codemap is not an editor

slide-12
SLIDE 12

Features: treemap

n Each rectangle is a file n Size of rectangle =~ size of file n Color of rectangle = “aspect” (test,

main, storage, security, etc)

n “Code aware” (heuristics)

n Auto generated file do not eat real-estate n Code is more important than data, xml, jpg

n Tiling, use all the space

slide-13
SLIDE 13

Features: search and navigation

n Search

n Highlighted rectangle n Ranked entities

n Navigation

n Up/down (not as smooth as google maps) n Direct access to file (faster than speedbar

  • r expand-directory widgets)

n Can see spread directories

slide-14
SLIDE 14

Features: semantic code visualizer

n grammar-based highlighting, not

regexps as in emacs/vim

n Know records vs functions vs constants n Functions/classes are in bigger size than

statements

n Tiling, use all the space, multi columns n Semantic aware (global analysis)

n Important functions are in bigger size

slide-15
SLIDE 15

Layers: alternate color schemes

n Age (help find dead code) n #authors (important stuff usually) n Activity (what’s going on?) n Code coverage n Bugs/warnings of linter n grep/sgrep results n Top/Bottom modules n …

slide-16
SLIDE 16

Conclusion

n A semantic-based source code

visualizer/searcher/navigator

n Accelerate loading the code into your

brain (can see 20 files at once)

n Future work:

n Smoother zoom

$ git clone git://github.com/facebook/pfff.git

slide-17
SLIDE 17

Related work

n SeeSoft (does not scale, no treemaps) n Code Thumbnails (2 different modes) n 3d visualization (not sure it helps, eat

pixels)

n Disk explorer (not code aware, no micro-

level)