Skip to content
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

[WIP] Compile-time Target Architecture Tags #143

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Commits on Aug 5, 2023

  1. Add ArchTag trait and its implementations for supported architectures

    This commit is the first commit among a series of patches that implement the
    compile-time architecture tag proposal in capstone-rust#118. It contains the following major
    changes:
    
    - Add the ArchTag trait. This trait indicates a "tag" type that represents a
      specific architecture. Its associated types specify specific data types
      corresponding to the architecture it represents.
    
    - Add ArchTag implementations for supported architectures, and a special
      DynamicArchTag that indicates the target architecture is unknown at compile
      time.
    
    - Update existing general type definitions (e.g. Capstone, Insn, etc.) to
      acquire a general arch tag type parameter.
    Lancern committed Aug 5, 2023
    Configuration menu
    Copy the full SHA
    182e5a0 View commit details
    Browse the repository at this point in the history

Commits on Aug 20, 2023

  1. Convert arch insn group and reg type to newtype enums

    This commit changes the bindgen settings so that bindgen generates newtype enums
    instead of modules of constants for arch insn group types and reg types. Usages
    of these binding types are updated as well.
    Lancern committed Aug 20, 2023
    Configuration menu
    Copy the full SHA
    260f346 View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2023

  1. Configuration menu
    Copy the full SHA
    061994f View commit details
    Browse the repository at this point in the history

Commits on Aug 29, 2023

  1. Make examples and benches compile

    This commit contains changes that make existing examples and benches compile
    with the latest API design. Unit tests will be covered in later commits.
    
    The primary changes include:
    - Implement DetailArchInsn for ArchDetail.
    - Add ArchOperandIterator enum that iterates values of ArchOperand inside an
      ArchDetail. The enum is basically a wrapper that holds all available arch-
      specific operand iterators in different variants.
    
    This commit also contains some refactors and minor changes, including:
    - Rename ArchDetail to ArchInsnDetail as the old name is a bit confusing.
    - Fully add sysz support.
    - Update existing examples and benches. In most cases, to migrate these existing
      examples and benches, I just need to add a small number of generic type
      arguments (e.g. X86ArchTag, ArmArchTag, DynamicArchTag, etc.) and the code
      just compiles.
    Lancern committed Aug 29, 2023
    Configuration menu
    Copy the full SHA
    3422ee7 View commit details
    Browse the repository at this point in the history

Commits on Aug 31, 2023

  1. Make unit tests compile and pass all tests

    This commit fixes a minor problem that prevents tests from compiling and running
    to success.
    
    Arch-specific register IDs (represented by ArchTag::RegId) and instruction group
    IDs (represented by ArchTag::InsnGroupId) are generated as newtype structs whose
    inner type is c_uint because their C definition are just C enums. However, in a
    cs_detail struct, the regs_read field is an array of u16, not an array of
    c_uint. So we cannot just type pun on the underlying array to get &[A::RegId]
    because the layout is totally different. The similar problem exists for
    InsnDetail::regs_write and InsnDetail::groups.
    
    This commit fixes the problem by making these function return an Iterator rather
    than a slice. The iterator will map the underlying array elements to actual
    arch-specific types when iterated.
    Lancern committed Aug 31, 2023
    Configuration menu
    Copy the full SHA
    445e43a View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2023

  1. Configuration menu
    Copy the full SHA
    5cd9258 View commit details
    Browse the repository at this point in the history