Skip to content

feat(ghidra): add comment change listener and optimize comment operations - #233

Open
maci0 wants to merge 1 commit into
binsync:mainfrom
maci0:feat/ghidra-comment-sync
Open

feat(ghidra): add comment change listener and optimize comment operations#233
maci0 wants to merge 1 commit into
binsync:mainfrom
maci0:feat/ghidra-comment-sync

Conversation

@maci0

@maci0 maci0 commented Aug 22, 2026

Copy link
Copy Markdown

Summary

This PR adds comment change event monitoring and optimized comment retrieval to the Ghidra decompiler interface in DecLib:

  1. Comment Change Events (declib/decompilers/ghidra/hooks.py):

    • Added comment change event constants (DOCR_EOL_COMMENT_CHANGED, DOCR_PRE_COMMENT_CHANGED, DOCR_POST_COMMENT_CHANGED, DOCR_PLATE_COMMENT_CHANGED, DOCR_REPEATABLE_COMMENT_CHANGED) to DataMonitor.
    • Handled comment change events in do_change_handler by querying the updated comment at address and invoking self._deci.comment_changed(cmt, deleted=...).
  2. Optimized Comment Retrieval & Writing (declib/decompilers/ghidra/interface.py):

    • Added _code_unit_to_comment helper to handle comment extraction and multi-slot tag formatting ([PLATE], [PRE], [EOL], [POST], [REPEATABLE]).
    • Implemented O(1) _get_comment(addr) lookup.
    • Updated _comments() to use getCommentAddressIterator for bulk retrieval instead of iterating all code units in all functions.
    • Enhanced _set_comment to handle bracketed comment tags and deletion when text is empty/None.

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.

1 participant