Skip to content

fix: global struct variable debugger shows no values#643

Open
thiagoralves wants to merge 1 commit into
developmentfrom
fix/global-struct-debugger-index
Open

fix: global struct variable debugger shows no values#643
thiagoralves wants to merge 1 commit into
developmentfrom
fix/global-struct-debugger-index

Conversation

@thiagoralves
Copy link
Copy Markdown
Contributor

@thiagoralves thiagoralves commented Mar 1, 2026

Summary

  • Fixes the debug path prefix used when resolving indices for members of global (external) struct/FB variables
  • Global variables use CONFIG0__ prefix in debug.c, but the variableInfoMap building code always constructed local RES0__INSTANCE paths, causing all index lookups for global struct members to fail silently
  • Checks variable.class === 'external' in three code paths that process nested FB/struct members and switches to buildGlobalDebugPath accordingly

Fixes #638

Test plan

  • Create a project with a struct type (e.g., MY_STRUCT with FIELD1: INT, FIELD2: BOOL)
  • Declare a global variable of that struct type (VAR_GLOBAL)
  • Reference it in a program via VAR_EXTERNAL
  • Start the debugger and verify struct member values are displayed for the global variable
  • Verify local struct variables still work correctly (no regression)
  • Verify local FB instances still debug correctly (no regression)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved handling of external and global variables during debugging sessions. Variables defined outside the current scope are now properly resolved and indexed, ensuring accurate real-time monitoring and inspection.
  • Refactor

    • Optimized internal path resolution logic for external variable references to enhance performance and consistency across nested variable processing.

Global (external) struct and FB variables use CONFIG0__ prefix in debug.c,
but the variableInfoMap building code always constructed local RES0__INSTANCE
paths when resolving member indices. This caused all lookups for global
struct members to fail, so their values were never polled by the debugger.

Check variable.class === 'external' in the three sections that process
nested FB/struct members and use buildGlobalDebugPath instead of
buildDebugPath for external variables.

Fixes #638

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e414315 and 2a60357.

📒 Files selected for processing (1)
  • src/renderer/screens/workspace-screen.tsx

Walkthrough

The PR adds support for debugging global (external) function block variables by introducing a buildGlobalDebugPath utility function and modifying the workspace screen's variable resolution logic to use global path prefixes instead of instance-based paths when processing external FB/UDT members and updating index mappings.

Changes

Cohort / File(s) Summary
Debugger Path Resolution Enhancement
src/renderer/screens/workspace-screen.tsx
Modified variable indexing and polling logic to detect external FB instances and resolve their debug paths using buildGlobalDebugPath instead of instance-based paths. Updated nested variable processing, top-level FB visitation, and composite-key index mapping to consistently apply global path resolution for external entities.
Global Path Builder Utility
@root/utils/debug-variable-finder
Added new buildGlobalDebugPath(name: string): string function to generate global-prefixed debug paths for external FB/UDT variables.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Global structs hop through the debugger now,
No longer lost in darkness, taking a bow!
Paths shine bright with global prefixes aglow,
External FBs dance—their values steal the show! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: global struct variable debugger shows no values' directly and concisely describes the main change—fixing debug visibility for global struct variables.
Description check ✅ Passed The PR description includes a clear summary, test plan, and reference to the linked issue; however, the DOD checklist template sections are missing.
Linked Issues check ✅ Passed The PR successfully addresses issue #638 by fixing the debug path prefix mismatch (CONFIG0__ vs RES0__INSTANCE) for global struct variables through detection and proper handling of external variables.
Out of Scope Changes check ✅ Passed All changes are focused on fixing the global struct variable debugger issue (#638); the addition of buildGlobalDebugPath and its usage in three code paths are directly related to this objective.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/global-struct-debugger-index

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global struct variable debugger failed

1 participant