Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces comprehensive support for tracking and propagating absolute base memory addresses (
_base_address) when creating and manipulating instances from memory buffers. This enhancement enables accurate pointer arithmetic and address calculations, especially when working with memory snapshots or overlays with known absolute addresses. The changes also include improved buffer handling, more robust type checking, and new tests to ensure correctness of address calculations across complex nested types and arrays.Absolute Address Handling and Propagation:
base_addressparameter to instance creation methods (such asfrom_bufferand internal_create_instance), ensuring that the absolute address is associated with instances created from memory snapshots or overlays. (src/dwarffi/dffi.py[1] [2] [3] [4] [5]BoundTypeInstanceclass to store and propagate_base_addressand to use it in pointer arithmetic and address calculations, including when extracting nested fields or creating array views. (src/dwarffi/instances.py[1] [2] [3]addressofmethod to use_base_address(if present) instead of_address, ensuring correct calculation of absolute addresses for both root and nested fields. (src/dwarffi/dffi.pysrc/dwarffi/dffi.pyL512-R513)Buffer and Type Handling Improvements:
BoundTypeInstanceto support both native Python buffers and proxy objects, and to ensure efficient zero-copy operations by wrapping buffers inmemoryviewwhen appropriate. (src/dwarffi/instances.pysrc/dwarffi/instances.pyL246-R283)src/dwarffi/instances.py[1] [2] [3]Testing and Coverage:
tests/test_ffi.pytests/test_ffi.pyR336-R441)tests/test_coverage_deep.pytests/test_coverage_deep.pyR1-R219)Other Improvements:
BytesBackendto avoid unnecessary buffer conversion when the input is already abytearray. (src/dwarffi/backend.pysrc/dwarffi/backend.pyR14-R16)LiveMemoryProxy. (src/dwarffi/instances.pysrc/dwarffi/instances.pyR5)