Struct haybale::Project [−][src]
pub struct Project { /* fields omitted */ }
Expand description
A Project
is a collection of LLVM code to be explored,
consisting of one or more LLVM modules.
Implementations
Construct a new Project
from a path to an LLVM bitcode file
pub fn from_bc_paths<P>(
paths: impl IntoIterator<Item = P>
) -> Result<Self, String> where
P: AsRef<Path>,
pub fn from_bc_paths<P>(
paths: impl IntoIterator<Item = P>
) -> Result<Self, String> where
P: AsRef<Path>,
Construct a new Project
from multiple LLVM bitcode files
Construct a new Project
from a path to a directory containing
LLVM bitcode files.
All files in the directory which have the extension extn
will
be parsed and added to the Project
.
Panics if there are no files in the directory with that extension.
Construct a new Project
from a path to a directory containing LLVM
bitcode files.
All files in the directory which have the extension extn
, except those
for which the provided exclude
closure returns true
, will be parsed
and added to the Project
.
Panics if there are no files in the directory with that extension, or if they were all excluded.
Add the code in the given LLVM bitcode file to the Project
Add the code in the given directory to the Project
.
See Project::from_bc_dir()
.
Add the code in the given directory, except for blacklisted files, to the Project
.
See Project::from_bc_dir_with_blacklist()
.
Get the pointer size used by the Project
, in bits.
E.g., this will be 64
if the LLVM bitcode was compiled for a 64-bit platform.
Iterate over all Function
s in the Project
.
Gives pairs which also indicate the Module
the Function
is defined in.
Iterate over all GlobalVariable
s in the Project
.
Gives pairs which also indicate the Module
the GlobalVariable
comes from.
Iterate over all GlobalAlias
es in the Project
.
Gives pairs which also indicate the Module
the GlobalAlias
comes from.
pub fn all_named_struct_types(
&self
) -> impl Iterator<Item = (&String, &NamedStructDef, &Module)>
pub fn all_named_struct_types(
&self
) -> impl Iterator<Item = (&String, &NamedStructDef, &Module)>
Iterate over all named struct types in the Project
.
Gives triplets (name, NamedStructDef, Module)
which indicate the struct’s name,
definition, and which module the definition comes from.
Get the names of the LLVM modules which have been parsed and loaded into
the Project
Search the project for a function with the given name. If a matching function is found, return both it and the module it was found in.
For projects containing C++ or Rust code, you can pass either the mangled or demangled function name (fully qualified with namespaces/modules).
If you have a State
handy, you may want to use
state.get_func_by_name()
instead, which will get the appropriate
(potentially module-private) definition based on the current LLVM module.
pub fn get_named_struct_def<'p>(
&'p self,
name: &str
) -> Result<(&'p NamedStructDef, &'p Module)>
pub fn get_named_struct_def<'p>(
&'p self,
name: &str
) -> Result<(&'p NamedStructDef, &'p Module)>
Get the definition of the named struct with the given name. Returns both the definition, and the module that definition was found in.
Returns Err
if neither a definition nor declaration for a named struct
type with the given name was found anywhere in the Project
.
If the named struct type is defined in multiple modules in the Project
,
this returns one of them arbitrarily. However, it will only return
NamedStructDef::Opaque
if all definitions are opaque; that is, it will
attempt to return some non-opaque definition if one exists, before
returning an opaque definition.
Get the size of the Type
, in bits.
Accounts for the Project
’s pointer size and named struct definitions.
Note that some types have size 0 bits, and this may return Some(0)
.
Returns None
for structs which have no definition in the entire Project
,
or for structs/arrays/vectors where one of the elements is a struct with no
definition in the entire Project
.
Get the size of the FPType
, in bits