-
Notifications
You must be signed in to change notification settings - Fork 1
fix: Handle global array/struct variable paths in debug.c generation #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,7 +94,15 @@ def GetIECProgramsAndVariables(self): | |
| parts = [config_FB] + parts[2:] | ||
| attrs["C_path"] = ".".join(parts) | ||
| else: | ||
| attrs["C_path"] = "__".join(parts[1:]) | ||
| # Check if this is a global array/struct variable at CONFIG level | ||
| # Pattern: CONFIG0.VARNAME.value.table[x] or CONFIG0.VARNAME.value.fieldname | ||
| # These should become: CONFIG0__VARNAME.value.table[x] or CONFIG0__VARNAME.value.fieldname | ||
| if parts[0].startswith("CONFIG") and parts[2].startswith("value"): | ||
| # Global array or struct access - keep CONFIG prefix | ||
| attrs["C_path"] = parts[0] + "__" + parts[1] + "." + parts[2] | ||
|
||
| else: | ||
| # For resource-level variables (RES0.INSTANCE.xxx) | ||
| attrs["C_path"] = "__".join(parts[1:]) | ||
| else: | ||
| attrs["C_path"] = "__".join(parts) | ||
| if attrs["vartype"] == "FB": | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition assumes
partshas at least 3 elements, but there's no length check before accessingparts[2]. This will raise an IndexError if the path has fewer than 3 parts. Add a length check:if len(parts) >= 3 and parts[0].startswith('CONFIG') and parts[2].startswith('value'):