Share to: share facebook share twitter share wa share telegram print page

Call graph

A call graph generated for a simple computer program in Python.

A call graph (also known as a call multigraph[1][2]) is a control-flow graph,[3] which represents calling relationships between subroutines in a computer program. Each node represents a procedure and each edge (f, g) indicates that procedure f calls procedure g. Thus, a cycle in the graph indicates recursive procedure calls.

Basic concepts

Call graphs can be dynamic or static.[4] A dynamic call graph is a record of an execution of the program, for example as output by a profiler. Thus, a dynamic call graph can be exact, but only describes one run of the program. A static call graph is a call graph intended to represent every possible run of the program. The exact static call graph is an undecidable problem, so static call graph algorithms are generally overapproximations. That is, every call relationship that occurs is represented in the graph, and possibly also some call relationships that would never occur in actual runs of the program.

Call graphs can be defined to represent varying degrees of precision. A more precise call graph more precisely approximates the behavior of the real program, at the cost of taking longer to compute and more memory to store. The most precise call graph is fully context-sensitive, which means that for each procedure, the graph contains a separate node for each call stack that procedure can be activated with. A fully context-sensitive call graph is called a calling context tree. This can be computed dynamically easily, although it may take up a large amount of memory. Calling context trees are usually not computed statically, because it would take too long for a large program. The least precise call graph is context-insensitive, which means that there is only one node for each procedure.

With languages that feature dynamic dispatch (i.e. Java or C++),[5] first-class functions (i.e. Python or Racket), or function pointers (i.e. C), computing a static call graph precisely requires alias analysis results. Conversely, computing precise aliasing requires a call graph. Many static analysis systems solve the apparent infinite regress by computing both simultaneously.

Usages

Call graphs can be used in different ways. One simple application of call graphs is finding procedures that are never called. Call graphs can act as documentation for humans to understand programs.[6] Call graphs can also be used to detect anomalies of program execution or code injection attacks.[7]

Software

Free software call graph generators

Run-time call graph (most of tools listed are profilers with call graph functionality)

  • gprof : included in BSD or part of the GNU Binary Utilities
  • callgrind : part of Valgrind
  • KCachegrind : powerful tool to generate and analyze call graphs based on data generated by callgrind
  • Mac OS X Activity Monitor : Apple GUI process monitor Activity Monitor has a built-in call graph generator that can sample processes and return a call graph. This function is only available in Mac OS X Leopard
  • OpenPAT : includes the control_flow tool which automatically creates a Graphviz call-graph picture from runtime measurements.
  • pprof, open source tool for visualization and analysis of profile data, to be used in conjunction with gperftools.
  • CodeAnalyst from AMD (released under GPL)
  • makeppgraph is a dependency graph generator (at module level) for builds performed with makepp.
  • Intel(R) Single Event API (free, open-source)

Static for getting call graphs without running application

C/C++
  • Sourcetrail creates a static call graph, that can be dynamically explored by the user. Also supports Python and Java
  • doxygen : Uses Graphviz to generate static call/inheritance diagrams
  • Cally: a tool that uses GCC's Register Transfer Language (RTL) files to build a caller or callee call graphs for C projects.
  • cflow : GNU cflow is able to generate the direct and inverted call graph of a C program
  • egypt : a small Perl script that uses gcc and Graphviz to generate the static call graph of a C program.
  • Analizo: calculates source code metrics, generates dependency graphs.
  • CCTree : Native Vim plugin that can display static call graphs by reading a cscope database. Works for C programs.
  • codeviz : a static call graph generator (the program is not run). Implemented as a patch to gcc; works for C and C++ programs.
  • calltree.sh : Bash shell functions that glue together cscope, graphviz, and a sampling of dot-rendering tools to display "caller" and "callee" relationships above, below, and/or between the C functions you specify.
  • tceetree : like calltree.sh, it connects Cscope and Graphviz, but it is an executable rather than a bash script.
Go
  • go-callvis : an interactive call graph generator for Go programs whose output can be drawn with Graphviz
Multi-language
  • callGraph : open-source call graph generator for awk, bash, basic, dart, fortran, go, lua, javascript, julia, kotlin, matlab, perl, pascal, php, python, R, raku, ruby, rust, scala, swift, tcl, and typescript.
.NET
  • NDepend :is a static analysis tool for .NET code. This tool supports a large number of code metrics, allows for visualization of dependencies using directed graphs and dependency matrix.
PHP, Perl and Python
  • Devel::NYTProf : a Perl performance analyser and call chart generator
  • phpCallGraph : a call graph generator for PHP programs that uses Graphviz. It is written in PHP and requires at least PHP 5.2.
  • pycallgraph Archived 2007-05-25 at the Wayback Machine : a call graph generator for Python programs that uses Graphviz.
  • pyan : a static call graph generator for Python programs that uses Graphviz.
  • gprof2dot : A call graph generator written in Python that converts profiling data for many languages/runtimes to a Graphviz callgraph.
  • code2flow: A call graph generator for Python and Javascript programs that uses Graphviz
  • rcviz : Python module for rendering runtime-generated call graphs with Graphviz. Each node represents an invocation of a function with the parameters passed to it and the return value.
XQuery

Proprietary call graph generators

LDRA Testbed
Static and dynamic analysis engines for both host and embedded software, with a myriad of reports including call graphs.
Project Analyzer
Static code analyzer and call graph generator for Visual Basic code
Visual Expert
Static code analyzer and call graph generator for Oracle PL/SQL, SQLServer Transact-SQL, C# and PowerBuilder code
Intel VTune Performance Analyzer
Instrumenting profiler to show call graph and execution statistics
DMS Software Reengineering Toolkit
Customizable program analysis tool with static whole-program global call graph extraction for C, Java and COBOL
Graphviz
Turns a text representation of any graph (including a call graph) into a picture.
tsort
Command-line utility that performs a topological sort.

Sample graph

A sample call graph generated from gprof analyzing itself:

index    called     name                              |index    called     name
      72384/72384       sym_id_parse [54]             |       1508/1508        cg_dfn [15]
[3]   72384             match [3]                     |[13]   1508             pre_visit [13]
----------------------                                |----------------------
          4/9052        cg_tally [32]                 |       1508/1508        cg_assemble [38]
       3016/9052        hist_print [49]               |[14]   1508             propagate_time [14]
       6032/9052        propagate_flags [52]          |----------------------
[4]    9052             sym_lookup [4]                |          2             cg_dfn [15]
----------------------                                |       1507/1507        cg_assemble [38]
       5766/5766        core_create_function_syms [41]|[15]   1507+2           cg_dfn [15]
[5]    5766             core_sym_class [5]            |       1509/1509        is_numbered [9]
----------------------                                |       1508/1508        is_busy [11]
         24/1537        parse_spec [19]               |       1508/1508        pre_visit [13]
       1513/1537        core_create_function_syms [41]|       1508/1508        post_visit [12]
[6]    1537             sym_init [6]                  |          2             cg_dfn [15]
----------------------                                |----------------------
       1511/1511        core_create_function_syms [41]|       1505/1505        hist_print [49]
[7]    1511             get_src_info [7]              |[16]   1505             print_line [16]
----------------------                                |          2/9           print_name_only [25]
          2/1510        arc_add [31]                  |----------------------
       1508/1510        cg_assemble [38]              |       1430/1430        core_create_function_syms [41]
[8]    1510             arc_lookup [8]                |[17]   1430             source_file_lookup_path [17]
----------------------                                |----------------------
       1509/1509        cg_dfn [15]                   |         24/24          sym_id_parse [54]
[9]    1509             is_numbered [9]               |[18]     24             parse_id [18]
----------------------                                |         24/24          parse_spec [19]
       1508/1508        propagate_flags [52]          |----------------------
[10]   1508             inherit_flags [10]            |         24/24          parse_id [18]
----------------------                                |[19]     24             parse_spec [19]
       1508/1508        cg_dfn [15]                   |         24/1537        sym_init [6]
[11]   1508             is_busy [11]                  |----------------------
----------------------                                |         24/24          main [1210]
       1508/1508        cg_dfn [15]                   |[20]     24             sym_id_add [20]
[12]   1508             post_visit [12]               |

See also

References

  1. ^ Callahan, D.; Carle, A.; Hall, M. W.; Kennedy, K. (April 1990). "Constructing the procedure call multigraph". IEEE Transactions on Software Engineering. 16 (4): 483–487. doi:10.1109/32.54302.
  2. ^ Uday Khedker; Amitabha Sanyal; Bageshri Sathe (2009). Data Flow Analysis: Theory and Practice. CRC Press. p. 234. ISBN 978-0-8493-3251-7.
  3. ^ Pankaj Jalote (1997). An Integrated Approach to Software Engineering. Springer Science & Business Media. p. 372. ISBN 978-0-387-94899-7.
  4. ^ Ryder, B.G. (May 1979). "Constructing the Call Graph of a Program". IEEE Transactions on Software Engineering. SE-5 (3): 216–226. doi:10.1109/tse.1979.234183. S2CID 16527042.
  5. ^ Grove, David; DeFouw, Greg; Dean, Jeffrey; Chambers, Craig; Grove, David; DeFouw, Greg; Dean, Jeffrey; Chambers, Craig (9 October 1997). "Call graph construction in object-oriented languages". ACM SIGPLAN Notices. 32 (10). ACM: 108, 108–124, 124. doi:10.1145/263700.264352.
  6. ^ Eisenbarth, T.; Koschke, R.; Simon, D. (2001). "Aiding program comprehension by static and dynamic feature analysis". Proceedings IEEE International Conference on Software Maintenance. ICSM 2001. pp. 602–611. doi:10.1109/icsm.2001.972777. ISBN 0-7695-1189-9. S2CID 5934718.
  7. ^ Gao, Debin; Reiter, Michael K.; Song, Dawn (25 October 2004). "Gray-box extraction of execution graphs for anomaly detection". Proceedings of the 11th ACM conference on Computer and communications security - CCS '04. ACM. pp. 318–329. doi:10.1145/1030083.1030126. ISBN 1581139616. S2CID 1189805.

Read other articles:

LeviathanPoster Rilis TeatrikalSutradaraAndrey ZvyagintsevProduserAlexander RodnyanskyDitulis olehAndrey ZvyagintsevOleg NeginPemeranAleksei SerebryakovElena LyadovaVladimir VdovichenkovRoman MadyanovSinematograferMikhail KrichmanTanggal rilis 23 Mei 2014 (2014-05-23) (Cannes) 5 Februari 2015 (2015-02-05) (Rusia) Durasi141 minutes[1]NegaraRusiaBahasaRusiaAnggaranRUB 220 Mn.Pendapatankotor$3,400,000[2] Leviathan (bahasa Rusia: Левиафан, Leviafan) adal…

Ćevapi. Masakan Bosnia meliputi makanan, masakan, dan perilaku makan tradisional orang Bosnia-Herzegovina. Masakan Bosnia merupakan pengaruh Barat dan Timur. Makanan Bosnia berhubungan dekat dengan masakan Turki, Timur Tengah dan Mediterania lain. Namun begitu, oleh karena bertahun-tahun berada di bawah pemerintahan Austria, ada juga banyak pengaruh dari Eropa Tengah. Referensi * Tim Clancy, Bosnia & Herzegovina, The Bradt Travel Guide, 2004, pp. 93–97, ISBN 1-84162-094-7 * Darra Gol…

American professional wrestler Cedric AlexanderAlexander in May 2016Birth nameCedric Alexander Johnson[1]Born (1989-08-16) August 16, 1989 (age 34)[2]Charlotte, North Carolina, U.S.[3]Spouse(s) Aerial Hull ​(m. 2018)​Children1Professional wrestling careerRing name(s)Cedric Alexander[4]Gary Garbutt[5][6]Billed height5 ft 10 in (178 cm)[4]Billed weight205 lb (93 kg)[4]Billed f…

Protein(s) forming a major part of an organism's immune system This article is about the class of proteins. For other uses, see Antibody (disambiguation). Each antibody binds to a specific antigen in a highly specific interaction analogous to a lock and key. An antibody (Ab) is the secreted form of a B cell receptor; the term immunoglobulin (Ig) can refer to either the membrane-bound form or the secreted form of the B cell receptor, but they are, broadly speaking, the same protein, and so the te…

Ongoing COVID-19 viral pandemic in Saint Barthélemy, France COVID-19 pandemic in Saint BarthélemyDiseaseCOVID-19Virus strainSARS-CoV-2LocationSaint BarthélemyArrival date1 March 2020(4 years, 1 month and 5 days)Confirmed cases5,507[1]Recovered5,472[2]Deaths5[1]Government websiteguadeloupe.ars.sante.fr The COVID-19 pandemic in Saint Barthélemy was a part of the ongoing global viral pandemic of coronavirus disease 2019 (COVID-19), which was confirmed to h…

областьАтырауская областьказ. Атырау облысы, Atyrau oblysy Герб 47°07′ с. ш. 51°53′ в. д.HGЯO Страна  Казахстан Входит в Западный Казахстан Включает 7 районов и 1 городскую администрацию Адм. центр Атырау Аким области Шапкенов, Серик Жамбулович История и география Дата об…

Provinsi Satsuma (薩摩国code: ja is deprecated , satsuma no kuni) atau dikenal sebagai Sasshū (薩州code: ja is deprecated ) adalah provinsi lama Jepang dengan wilayah yang sekarang menjadi bagian barat prefektur Kagoshima. Di zaman Sengoku, Satsuma merupakan daerah kekuasaan daimyo dari klan Shimazu yang menguasai hampir seluruh bagian selatan Kyushu dari pusat kekuasaan di kota Kagoshima. Pada tahun 1871 sesudah sistem han dihapus dan pemerintah Meiji memberlakukan sistem prefektur, Satsu…

Cette page contient des caractères d'alphasyllabaires indiens. En cas de problème, consultez Aide:Unicode. Pour les articles homonymes, voir Parti communiste du Népal. Cet article est une ébauche concernant un parti politique, le Népal et le communisme. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. Parti communiste du Népal(marxiste-léniniste unifié)(en) Communist Party of Nepal(Unified Marxist- Leninist)(…

American legislative district Maryland's legislative district 9BRepresentspart of Howard CountyDelegate(s)Courtney Watson (D)Registration50.2% Democratic24.3% Republican24.1% unaffiliatedDemographics49.4% White10.2% Black/African American0.3% Native American31.7% Asian0.0% Hawaiian/Pacific Islander1.9% Other race6.5% Two or more races4.8% HispanicPopulation (2020)46,786Voting-age population35,064Registered voters31,234 Maryland House of…

Tambang tembaga di Prefektur Okayama Pertambangan di Jepang adalah industri yang terus menurun secara drastis sejak tahun 1980-an. Letak geografis Jepang di zona subduksi menyebabkan Jepang memiliki sumber daya mineral yang kaya, tetapi hanya sedikit memiliki minyak bumi dan gas alam. Produk pertambangan seperti batu bara, emas, perak, perunggu, besi, dan seng dieksploitasi secara besar-besaran hingga dekade 1970-an. Semakin menipisnya persediaan sumber daya tambang yang diikuti penurunan mutu d…

Andromakhe Meratapi Hektor karya Jacques-Louis David, 1783 Dalam mitologi Yunani, Andromakhe (/ænˈdrɒməkiː/; bahasa Yunani Kuno: Ἀνδρομάχη) adalah istri Hektor dan putri Eetion, serta merupakan saudari Podes. Ia lahir dan dibesarkan di kota Thebe Kilikia, yang diperintah oleh ayahnya. Nama Andromakhe bermakna pertempuran manusia, dari kata ἀνδρός (andros) manusia dan μάχη (makhē) pertempuran.[1] Dalam Perang Troya, Hektor dibunuh oleh Akhilles, dan putra me…

This biography of a living person needs additional citations for verification. Please help by adding reliable sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately from the article and its talk page, especially if potentially libelous.Find sources: Evdokiya Germanova – news · newspapers · books · scholar · JSTOR (August 2022) (Learn how and when to remove this template message) Evdokiya Germanov…

Fermanagh-based Gaelic games club This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Newtownbutler First Fermanaghs GAA – news · newspapers · books · scholar · JSTOR (January 2022) (Learn how and when to remove this message) Newtownbutler First FermanaghsAn Baile NuaFounded:1887County:FermanaghNickname:NewtownColo…

First election of Scott Walker as Governor of Wisconsin 2010 Wisconsin gubernatorial election ← 2006 November 2, 2010 2012 (recall) → Turnout49.7%   Nominee Scott Walker Tom Barrett Party Republican Democratic Running mate Rebecca Kleefisch Tom Nelson Popular vote 1,128,941 1,004,303 Percentage 52.3% 46.5% County results Precinct resultsWalker:      40–50%      50–60%      60–70%…

English actress (1927–2018) Fenella FieldingOBEFenella Fielding on her 90th birthday in 2017BornFenella Marion Feldman(1927-11-17)17 November 1927Hackney, London, EnglandDied11 September 2018(2018-09-11) (aged 90)Hammersmith, London, EnglandOccupationActressYears active1952–2018RelativesBasil Feldman, Baron Feldman (brother)Nick Feldman (nephew)Websitehttp://www.fenellafielding.com/ Fenella Fielding, OBE (born Fenella Marion Feldman; 17 November 1927 – 11 September 2018)[…

Indoor arena in El Monte, California (1927–1974) El Monte Legion StadiumThe Pink ElephantEl Monte Legion Stadium (c. mid-1950s)Former namesEl Monte Union High School AuditoriumEl Monte AuditoriumEl Monte GymnasiumAddress11151 Valley BoulevardEl Monte, CaliforniaUnited StatesOwnerEl Monte Union High School District (1927–1945)American Legion, Post 261 (1945–1973)United States Postal Service (1973–1974)Capacity3,500Acreage2.49 acresConstructionBuilt1927Opened1928Renovated1945Closed19…

English footballer For the British cyclist, see Adam Yates. Adam Yates Yates as a Port Vale player in September 2010.Personal informationFull name Adam Paul Yates[1]Date of birth (1983-05-28) 28 May 1983 (age 40)[2]Place of birth Werrington, Staffordshire, EnglandHeight 5 ft 10 in (1.78 m)[2]Position(s) Right-backYouth career1992–2002 Crewe AlexandraSenior career*Years Team Apps (Gls)2002–2004 Crewe Alexandra 0 (0)2003–2004 → Halifax Town (loan…

本條目存在以下問題,請協助改善本條目或在討論頁針對議題發表看法。 此條目可能包含原创研究。 (2018年3月29日)请协助補充参考资料、添加相关内联标签和删除原创研究内容以改善这篇条目。详细情况请参见讨论页。 此條目需要补充更多来源。 (2010年2月4日)请协助補充多方面可靠来源以改善这篇条目,无法查证的内容可能會因為异议提出而被移除。致使用者:请搜索一下…

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Schepdaal – news · newspapers · books · scholar · JSTOR (June 2021) (Learn how and when to remove this message) Schepdaal is a village and deelgemeente of Dilbeek in Flanders, Belgium. History The oldest mention dates back to 1260, when the area was called Scepdal…

Iranian national heritage site Mirza Mousa MosqueThe interior of Mirza Mousa MosqueReligionAffiliationIslamLocationLocationTehran Grand Bazaar, Tehran, IranShown within IranGeographic coordinates35°40′33.6″N 51°25′29.3″E / 35.676000°N 51.424806°E / 35.676000; 51.424806ArchitectureTypemosqueCompletedGhajar era Mirza Mousa Mosque is a prominent old mosque in Tehran, Iran, located in Naser Khosrou Street in Tehran Grand Bazaar. History The mosque was built in 127…

Kembali kehalaman sebelumnya