Lazarus
Using the Lazarus IDE => General => Topic started by: julkas on September 21, 2019, 01:45:05 pm
-
How generate Call Graph - https://en.wikipedia.org/wiki/Call_graph and Dependency Graph - https://en.wikipedia.org/wiki/Dependency_graph in Lazarus?
-
I'm not sure to undestand your need. If you want to build a program with Lazarus that is able to generate flow charts and similar diagrams, as call graphs, I suggest to you the TEvsSimpleGraph component, available from https://github.com/taazz/EvsSimpleGraph or via Online Package Manager. It is very flexible and mature.
If you are searching for a tool that generates a static/run time call graph for a Lazarus program, I don't know if such a tool exists.
-
https://forum.lazarus.freepascal.org/index.php/topic,38983.0.html
https://forum.lazarus.freepascal.org/index.php/topic,34040.0.html
-
The IDE has a unit dependency graph: Menu View > Unit dependencies
(and a package graph)
That is as far as it currently gets.
As for callgraph...
If you are on linux you can get a runtime call graph with kcachegrid and valgrind.
-
I'm not sure to understand your need. If you want to build a program with Lazarus that is able to generate flow charts and similar diagrams, as call graphs, I suggest to you the TEvsSimpleGraph component, available from https://github.com/taazz/EvsSimpleGraph or via Online Package Manager. It is very flexible and mature.
If you are searching for a tool that generates a static/run time call graph for a Lazarus program, I don't know if such a tool exists.
https://forum.lazarus.freepascal.org/index.php/topic,38983.0.html
https://forum.lazarus.freepascal.org/index.php/topic,34040.0.html
The IDE has a unit dependency graph: Menu View > Unit dependencies
(and a package graph)
That is as far as it currently gets.
As for callgraph...
If you are on linux you can get a runtime call graph with kcachegrid and valgrind.
Interesting.
-
As for callgraph...
If you are on linux you can get a runtime call graph with kcachegrid and valgrind.
I am on Windows. I need only compile time functions/procedures calls(deps).
Example -
unit u1;
function fun1();
begin
...
x := fun2();
...
y := fun3();
...
end;
function fun4();
begin
...
z := fun2();
...
w := fun3();
...
end;
function fun2();
begin
....
end;
function fun3();
begin
....
end;
Call graph for unit u1:
fun1
|
|---fun2
|---fun3
fun4
|
|---fun2
|---fun3
fun2
fun3
I want XML, JSON or simple plain text repr. as above.
-
A few others. Not tested any of them... And they might be more for class structures....
https://sourceforge.net/projects/essmodelforlaza/
https://github.com/JuhaManninen/Laz-Model
Not a graph, but in the IDE you have: "Find Identifier references" (somewhere in the menu / also in the context menu)
It can find places where a function is called.
With virtual/overriden methods it may not find all....
-
As far as I know, none of the proposed tools is conceived to generate call graphs, i.e. graph that shows execution control flow. Pudgdb examines units dependencies. LazProfile is a performance profiler. EssModel and LazModel generates class diagram in UML style.
-
LazProfiler has information about runtime procedure calls. It only needs to be taken out
-
I did not know PudGdb and I want to try it, but when I open the project, the IDE fails to download following packages: ag_graph, ag_vector, zobjectinspector. Where can I find them?
-
https://forum.lazarus.freepascal.org/index.php/topic,34040.msg245712.html#msg245712 , but better https://github.com/zamtmn/pudgb/releases
-
How generate Call Graph and Dependency Graph
From the answers you've received above and, from my limited knowledge of Lazarus, I don't think Lazarus generates a procedure/function call graph for a program.
If you are familiar with AWK, it is fairly simple to generate the dependency sets from each function/procedure. From the dependency sets it's trivial to generate a call graph and a dependency graph.
There is one thing to be careful about, a topological sort is used to generate an ordered dependency graph, choose an algorithm that detects circular dependencies (most do) and handles them "gracefully" (some just stop, others can represent the cycle and continue sorting - the latter is obviously the kind of algorithm you want.)
Just FYI, way way back, TurboPower software had a product called Turbo Analyst which produced call graphs. I don't know if that is one of the products they open sourced after they closed shop. If it is available somewhere, it's likely it would need "improvements" to handle the FPC dialect but, for old Turbo Pascal code (circa TP6 and 7), it's likely to work without any changes.
-
Thanks all for replies.
I want simple and powerful static code analysis feature - A call graph (also known as a call multigraph) is a control flow graph, 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.
My code is not over complicated, so I will proceed manually.
-
Note LazModel/EssModel works even on a Raspberry Pi with some slight adjustments:
The QueryInterface/_AddRef/_Release need to be explicitly cdecl on Linux and QueyInterface must be adapted to take constref instead of const for recent FPC versions.
Maybe Juha reads this?
-
Something like here - https://www.peganza.com/products_pal.html
-
valgrind/callgrind?
-
valgrind/callgrind?
Can valgrind/callgrind generate compile time (not run time) call graph/tree ?
-
Yes. (just proof)
But there are more than enough dependency scanners.
One of which is the parser and lexer in the compiler itself. That happens to work....And you have the code... 8-)
fcl-passrc is almost just as good...
-
No, callgrind works in runtime.
I have not met static analyzers for FPC. Only for delphi, and they don't work with modern FPC
-
valgrind/callgrind?
Can valgrind/callgrind generate compile time (not run time) call graph/tree ?
Not that I know, but the initial post didn't mention that constraint. Lazarus does not really contain much source code metrics tools. Peganza is about the only choice there.
-
Not a graph, but in the IDE you have: "Find Identifier references" (somewhere in the menu / also in the context menu)
It can find places where a function is called.
With virtual/overriden methods it may not find all....
And or ifdefs...
-
How generate Call Graph - https://en.wikipedia.org/wiki/Call_graph and Dependency Graph - https://en.wikipedia.org/wiki/Dependency_graph in Lazarus?
Not in Lazarus, but with SciTools Understand:
https://scitools.com/clustered-call-graphs/
https://scitools.com/feature-category/dependency-analysis/
-
How generate Call Graph - https://en.wikipedia.org/wiki/Call_graph and Dependency Graph - https://en.wikipedia.org/wiki/Dependency_graph in Lazarus?
Not in Lazarus, but with SciTools Understand:
https://scitools.com/clustered-call-graphs/
https://scitools.com/feature-category/dependency-analysis/
@avra Thanks.