How to generate UML sequence diagrams from C code?
Asked Answered
D

4

2

I have looked at a utility trace2uml which parses the source code and looks for a Trace2UML syntax to describe the sequence diagram and creates the sequence diagram. I am interested to know if it is possible to create the sequence diagram by parsing the C source code alone?

Duluth answered 13/4, 2018 at 13:7 Comment(1)
I have answered you down below, so if you have any suggestions let me know.Demott
H
3

I don't think this is possible at all, by principle. Source code is inherently static. Sequence charts depict dynamical behavior. The dynamic behavior isn't in the source code, so it can't be extracted.

There are tools to make call graphs from C source in both directions, like cflow. Maybe a call graph can provide some insight into some source code's inner workings.

Hotheaded answered 5/5, 2018 at 18:15 Comment(0)
D
2

I am not a big connoisseur of UML diagrams but i know that generating diagrams from the code like: sequential diagram or class diagram are intended for object oriented languages like Java, c++, c# and many others. So if you ask me, it is not possible no generate sequence diagram from the code written in the C.

If you have some code written in the some objected language its possible to generate sequence diagram especially in the visual paradigm (tool for creating UML diagrams).

Demott answered 13/4, 2018 at 15:10 Comment(0)
W
1

It does not matter whether it's C (not-/) or C++ (OO). The problem is called Halting problem: see wikipedia. For that simple reason you can not create SDs from pure source. Anyway, a SD is meant to emphasize a certain phase of the executing code, not all paths. Just imagine how ridiculously spider-webby such a SD would look like. It were just useless.

Wail answered 5/5, 2018 at 18:0 Comment(0)
C
1

Have you tried with plantuml? It works really well with doxygen, I use it at work with the company template and the syntax it's really easy, you have to write the call sequence yourself though. There are plenty examples in the page, if you are working in Linux you can use your native packaging tool to install it, the same applies to doxygen (e.g. sudo apt-get plantuml). Otherwise if you are using Windows you can use the installers from the official pages too.

You'll have to do some configuration but it's pretty straightforward, I'll leave you the links to each tool.

Download pages:

Plantuml examples: http://plantuml.com/sequence-diagram

You can find the documentation in each page, for plantmul you use java executable (.jar) then you don't have to install nothing, you just need to configure doxygen to find the executable, you can find how in the doxygen documentation page:

http://www.doxygen.nl/manual/index.html

If you want to configure it without reading the documentation you could also watch this video: https://www.youtube.com/watch?v=LZ5E4vEhsKs

I hope this helps, cheers.

Crackup answered 24/9, 2018 at 17:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.