feat: add data type creation, function signatures, and namespace support#8
feat: add data type creation, function signatures, and namespace support#8encounter wants to merge 2 commits intoakiselev:masterfrom
Conversation
Add type import-c command for parsing C type definitions into Ghidra's
data type manager with optional category placement. Add function
set-signature command for applying C-style function prototypes including
calling conventions. Enhance symbol rename to accept address or name
targets and support namespace assignment via Ns::Name syntax or
--namespace flag.
Normalize bridge command naming to {entity}_{action} pattern. Remove
handleRenameFunction in favor of routing through symbol_rename. Add
findUniqueSymbolByNameOrAddress and createNamespaceHierarchy helpers.
Summary of ChangesHello @encounter, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the Ghidra CLI's capabilities for reverse engineering and program analysis. It introduces powerful new commands for defining complex C data types, precisely setting function signatures with calling conventions, and organizing symbols within namespaces. These additions streamline the process of enriching Ghidra projects with recovered type information and better structured symbols, making the CLI a more robust tool for automated analysis workflows. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Apologies for the LLM-y PR description, just wanted to quickly note that I (a human) was actively and carefully iterating on the design and details here. Let me know what you think! |
There was a problem hiding this comment.
Code Review
This pull request introduces significant new features, including C-style data type creation, function signature updates, and namespace support for symbols. The implementation is robust and includes corresponding documentation and test updates. I have a couple of suggestions to improve API consistency for symbol operations and to make the handling of the __thiscall calling convention more robust. Overall, this is an excellent set of enhancements.
…x for __thiscall Change symbol_delete JSON key from "name" to "address" to match symbol_rename. Use \b word boundaries when stripping __thiscall to avoid matching substrings.
Summary
Adds commands to define Ghidra data types using C syntax, adjust function prototypes, and organize symbols into namespaces.
type import-ccommand to parse and import C type definitions (structs, unions, enums, typedefs)function set-signaturecommand to apply C-style function prototypes (with calling convention support)symbol renameto support namespace assignment viaNs::Namesyntax and--namespaceflag{entity}_{action}patternNew Commands
type import-cParses C type definitions and imports them into the program's data type manager. Supports structs, unions, enums, typedefs (including function pointers), bitfields, and struct inheritance.
function set-signatureParses a C-style function prototype and applies it to the target function, including return type, parameters, calling convention, and name.
Enhanced
symbol renameNow accepts an address or name as target, and supports namespace assignment in a single operation.
Internal Changes
list_functions/get_function/etc. tofunction_list/function_get/etc. for consistency with thesymbol_*/type_*/comment_*patternhandleRenameFunction— function renaming now routes throughsymbol_renamefindUniqueSymbolByNameOrAddress()helper used by bothsymbol_renameandsymbol_deletecreateNamespaceHierarchy()for creating nestedA::B::CnamespacesTests
test_symbol_rename_non_primary_label_by_name— verifies renaming targets the correct label, not the primary symbol at the same addresstest_type_import_c_category_keeps_existing_same_named_types— verifies importing same-named types into different categories doesn't clobber existing ones