0

I have a somewhat global issue, I don’t know if someone can help me, I’m working on a big project with a somewhat old codebase, I’m trying to find a solution but I feel like there’s nothing on the internet that already exists / that suits me. My goal is to do variable traceability, I’ll explain a bit:

#include <iostream>
#include <map>
#include <string>

struct Variable {
std::map<std::string, Variable*> _mapXY;
};

int main() {
Variable* a = new Variable();
Variable* b = new Variable();
Variable* d = new Variable();

pgsql
Copier
Modifier
// b["b"] depends on a["e"]
b->_mapXY["b"] = a->_mapXY["e"]; 

// d["d"] depends on b["b"]
d->_mapXY["d"] = b->_mapXY["b"];

if (d->_mapXY["e"]) {
    Variable* c = new Variable();

    // c["c"] depends on d["d"]
    // but c["c"] also depends on d["e"] because of the if
    c->_mapXY["c"] = d->_mapXY["d"];
}

return 0;
}

I need to get as output,

Target column Column it depends on

b["b"] : a["e"]

d["d"] : b["b"]

Condition of the if → c->_mapXY["c"] depends on d["e"]

c["c"] : d["d"]

You have to imagine that there are complex cases with temporary variables etc.. I don’t know if there is a way to have some kind of dependency graph to know which map columns depend on which other map columns and do this automatically (there are 150 files to process, I want to avoid doing this work manually). Does anyone have an idea of something that exists, either at runtime or something external?

I’m testing syntax parsing with regex but it’s complicated because there are many different cases to take into

7
  • 1
    I voted to reopen, but I honestly have no idea what you're trying to ask. Why can't you just make some maps to store those dependencies? Commented May 26 at 19:00
  • I have a lot of files to process, and I want to avoid doing it manually, look at the dependency of the if condition, I need to have this information too Commented May 26 at 19:03
  • 2
    Stack Overflow Usage Note: try to refrain from story telling and stick to the details. For example only part of the last sentence, "[My goal is to do variable traceability,]" of the opening paragraph contains any information we can use to help you, and even that is unclear. Don't bother with salutations or thanks. Just lay out the requirements as clearly as possible. Commented May 26 at 19:16
  • In general, C++ doesn't do specific things for you. You will need to specify the relationships yourself. If the relationships are static, perhaps you can write a large initializer list. Perhaps you can read the relationships from the 150-ish files, but we need to know a lot more about these files to offer help on that. Perhaps there are other options, but the question doesn't go into enough detail for us to offer alternatives. Commented May 26 at 19:17
  • no it doesn't exist Commented May 26 at 21:35

1 Answer 1

0

Answering questions like these is the domain of program analysis, more specifically symbolic execution. However, symbolic execution is typically used in function of a broader program analysis (eg detecting concurrency issues, determining program order invariant violations, ...). You will not find a ready-made symbolic execution engine that you can just plug in.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.