[][src]Struct haybale_pitchfork::AbstractData

pub struct AbstractData(_);

An abstract description of a value: its size, whether it is a pointer or not, whether it is public or secret (or maybe it's a struct with some public and some secret fields, or maybe it's a public pointer that points to some secret data), etc.

Unlike CompleteAbstractData, these may be "underspecified": parts of the value (or the whole value) may be marked default(), meaning to just use the default based on the LLVM type.

Methods

impl AbstractData[src]

pub fn pub_i8(value: AbstractValue) -> Self[src]

an 8-bit public value

pub fn pub_i16(value: AbstractValue) -> Self[src]

a 16-bit public value

pub fn pub_i32(value: AbstractValue) -> Self[src]

a 32-bit public value

pub fn pub_i64(value: AbstractValue) -> Self[src]

a 64-bit public value

pub fn pub_integer(bits: usize, value: AbstractValue) -> Self[src]

a public value with the given number of bits

pub fn sec_i8() -> Self[src]

an 8-bit secret value

pub fn sec_i16() -> Self[src]

a 16-bit secret value

pub fn sec_i32() -> Self[src]

a 32-bit secret value

pub fn sec_i64() -> Self[src]

a 64-bit secret value

pub fn sec_integer(bits: usize) -> Self[src]

a secret value with the given number of bits

pub fn pub_pointer_to(data: Self) -> Self[src]

A (public) pointer to something - another value, an array, etc

pub fn pub_maybe_null_pointer_to(data: Self) -> Self[src]

A (public) pointer which may either point to the given data or be NULL

pub fn pub_pointer_to_func(funcname: impl Into<String>) -> Self[src]

a (public) pointer to the LLVM Function with the given name

pub fn pub_pointer_to_hook(funcname: impl Into<String>) -> Self[src]

a (public) pointer to the hook registered for the given name

pub fn pub_pointer_to_self() -> Self[src]

A (public) pointer to this struct itself. E.g., in the C code

struct Foo {
    int x;
    Foo* f;
};

you could use this for Foo* f to indicate it should point to this exact Foo itself.

pub fn pub_pointer_to_parent() -> Self[src]

A (public) pointer to this struct's parent. E.g., in the C code

struct Foo {
    int x;
    Bar* bar1;
    Bar* bar2;
    ...
};

struct Bar {
    int y;
    Foo* parent;  // pointer to the Foo containing this Bar
};

you could use this for Foo* parent to indicate it should point to the Foo containing this Bar.

pub fn pub_pointer_to_parent_or(data: Self) -> Self[src]

Like pub_pointer_to_parent(), but if the parent is not the correct type (or if there is no parent, i.e., we are directly initializing this) then pointer to the given AbstractData instead

pub fn array_of(element_type: Self, num_elements: usize) -> Self[src]

A (first-class) array of values

pub fn _struct(
    name: impl Into<String>,
    elements: impl IntoIterator<Item = Self>
) -> Self
[src]

A (first-class) structure of values

(_struct used instead of struct to avoid collision with the Rust keyword)

pub fn default() -> Self[src]

Just use the default structure based on the LLVM type and/or the StructDescriptions. (The StructDescriptions override the LLVM type when they apply.)

The default structure based on the LLVM type is:

  • for LLVM integer type: public unconstrained value of the appropriate size
  • for LLVM pointer type (except function pointer): public concrete pointer value to allocated memory, depending on pointer type:
    • pointee is an integer type: pointer to allocated array of DEFAULT_ARRAY_LENGTH pointees (e.g., default for char* is pointer to array of 1024 chars)
    • pointee is an array type with 0 elements: pointer to allocated array of DEFAULT_ARRAY_LENGTH elements
    • pointee is any other type: pointer to one of that other type
    • (then in any case, apply these rules recursively to each pointee type)
  • for LLVM function pointer type: concrete function pointer value which, when called, will raise an error
  • for LLVM vector or array type: array of the appropriate length, containing public values
    • (then apply these rules recursively to each element)
  • for LLVM structure type:
    • if this struct is one of those named in the StructDescriptions, then use the appropriate struct description
    • if the structure type is entirely opaque (no definition anywhere in the Project), then allocate OPAQUE_STRUCT_SIZE_BYTES unconstrained bytes for it and assume that's enough (probably most of that memory will go unused, but that's fine)
    • else, apply these rules recursively to each field

pub fn default_for_llvm_struct_name(llvm_struct_name: impl Into<String>) -> Self[src]

Use the default structure for the given LLVM struct name.

If we are not in the middle of an override, this struct name must match the actual LLVM type's struct name.

If we are in the middle of an override and therefore don't have an LLVM type at the moment, this will act like default() with the LLVM type being the one for the given LLVM struct name.

pub fn unconstrained_pointer() -> Self[src]

A (public) pointer which may point anywhere, including being NULL

pub fn unconstrained() -> Self[src]

Just fill with the appropriate number of unconstrained bytes based on the LLVM type

pub fn secret() -> Self[src]

Fill with the appropriate number of secret bytes based on the LLVM type

pub fn void_override(llvm_struct_name: Option<&str>, data: AbstractData) -> Self[src]

When C code uses void*, this often becomes i8* in LLVM. However, within Pitchfork, we may want to specify some type other than i8* for the purposes of allocating and analyzing the data behind the void*.

This says to use the provided AbstractData even though the LLVM type is i8.

Note that the AbstractData here must actually be fully specified, perhaps with the help of StructDescriptions. If it's not, users of the AbstractData may panic.

If the optional llvm_struct_name is included, it will lookup that struct's type and use that both for any underspecified elements in the AbstractData, and for sanity typechecking. Otherwise, the AbstractData must be fully-specified, and no sanity typechecking will be performed (the AbstractData will be assumed correct).

pub fn pointer_override(llvm_struct_name: Option<&str>, data: Self) -> Self[src]

Use a pointer to the given data, even though the LLVM type will be a pointer to a different type. For instance, you could override a u64* to instead be a pointer to some struct of your choosing; this would ensure the pointed-to data is allocated and initialized as if it were that struct.

llvm_struct_name: see notes on void_override.

To override a void* type, you probably want void_override; see notes there.

pub fn same_size_override(data: AbstractData) -> Self[src]

Use the given data, even though it may not match the LLVM type. It still needs to be the same size (number of bits) as the LLVM type. For instance, you could specify that some LLVM pointer-size integer should actually be initialized to have a pointer value and point to some specified data.

To override a void* type, see void_override - and this probably won't work for that anyways because of the same-size restriction. See comments on void_override.

Note that the AbstractData here must actually be fully specified, perhaps with the help of StructDescriptions. If it's not, users of the AbstractData may panic.

pub fn with_watchpoint(name: impl Into<String>, data: Self) -> Self[src]

Use the given data, but also (during initialization) add a watchpoint with the given name to the State covering the memory region it occupies.

impl AbstractData[src]

pub const DEFAULT_ARRAY_LENGTH: usize[src]

pub const POINTER_SIZE_BITS: usize[src]

pub const OPAQUE_STRUCT_SIZE_BYTES: usize[src]

Trait Implementations

impl Clone for AbstractData[src]

impl Debug for AbstractData[src]

impl Display for AbstractData[src]

This Display is not meant to completely replace the derived Debug representation, but rather be a much more concise pretty representation (omitting a lot of the data in some cases)

impl Eq for AbstractData[src]

impl PartialEq<AbstractData> for AbstractData[src]

impl StructuralEq for AbstractData[src]

impl StructuralPartialEq for AbstractData[src]

Auto Trait Implementations

impl RefUnwindSafe for AbstractData

impl Send for AbstractData

impl Sync for AbstractData

impl Unpin for AbstractData

impl UnwindSafe for AbstractData

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.