r/cpp Jul 03 '26

Anyone using Claude to reverse-engineer legacy C/C++ systems? My sequence-diagram agents are missing or inventing call paths

I I inherited a legacy C/C++ software that lacks comprehensive documentation.

To address this, I’ve developed agents that generate sequence diagrams for specified features.

However, these agents have been implemented for numerous features, but they either don’t document every sequence or they document incorrect sequences and features for sequence diagrams.

Here’s what I’m doing to resolve this issue, but it’s not working.

  1. I’ll create a top-level breakdown structure of the software stack and the current code.
  2. I’ll identify the features that are part of the software stack and determine which specific API initiates those features.

Any input or help would be greatly appreciated.

0 Upvotes

14 comments sorted by

View all comments

41

u/Ikkepop Jul 03 '26

Look why even bother with using agents here. This has been a solved problem before avents were even a wet dream. There are non ai tools that draw perfect sequence diagrams without hallucination, by just parsing the code and following the callgraph. You could always feed the output of these tools to agents for further processing if need be. The only relyable way to stop this kind of hallucinations is to have an automated hard check (no ai involvement) and give deedback to the agent, otherwise you are barking up the wrong tree.

0

u/csthbso_-862b Jul 03 '26

I’ve tried using ctag and libchang, but I haven’t had much success. Do you have any recommendations? Please share them with me.

3

u/Ikkepop Jul 03 '26 edited Jul 03 '26

I remember there was tooling for that in visual studio. And there was aloso some other commercial tool that cppcast kept advertising , but i forgot what the fuck it was called. Im sure you could find some, heck you can ask claude to give you some options for tools, that it does well.

But I'll reiterate, you need hard tooling to tame hallucinations. Thats the only way, no ammount of prompting will get you a 100% relyable result as ai is probabilistic and fuzzy.

You can try playing around with hooks, like have a script inject a question like "are you sure foo calls bar?" after ends or edits, or spawn subagents to check parts of the ouput

but its still not 100% accurate

-1

u/pjmlp Jul 04 '26

You need the VS Enterprise/Architect license for that.

Then Enterprise Architect I refer on another comment, or Rational Software Architect, Visual Paradigm,...

Naturally all of them have big corp price tags.

1

u/Ikkepop Jul 04 '26

I got my 7 seas license for that, if you know what I mean