package bap-std
- Overview
- No Docs
You can search for identifiers within the package.
in-package search v0.2.0
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=63ada71fa4f602bd679174dc6bf780d54aeded40ad4ec20d256df15886e3d2d5
md5=b8b1aff8c6846f2213eafc54de07b304
doc/bap/Bap/Std/Memory/index.html
Module Std.Memory
Memory region
type t = memval sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.tval create :
?pos:int ->
?len:int ->
endian ->
addr ->
Core_kernel.Bigstring.t ->
t Core_kernel.Or_error.tcreate ?pos ?len endian start data creates a memory region.
Creates a memory view of the provided data using the specified byte order endian and mapping the first (pos) byte to the start address. The pos and len parameters can be used to narrow down the view, and default to 0 and the length of the provided string, correspondingly.
The data may not be copied and the returned memory view may reference the same bigstring object.
rebase mem addr returns the same memory but with the new starting address addr.
val slot :
(Bap_core_theory.Theory.program, mem option) Bap_knowledge.Knowledge.slotmemory representation of a program
val of_file : endian -> addr -> string -> t Core_kernel.Or_error.tof_file endian start name creates a memory region from file. Takes data stored in a file with the given name and maps it to the memory region with the specified starting address start and using the endian for storing and reading words.
val view :
?word_size:size ->
?from:addr ->
?words:int ->
t ->
t Core_kernel.Or_error.tview word_size ~from ~words mem returns a new memory that represents the specified region of memory mem. copy function performs deep copy.
view_exn mem is the same as ok_exn @@view_exn mem but is slightly more efficient.
val range : t -> addr -> addr -> t Core_kernel.Or_error.trange mem a0 a1 returns a view on mem starting from address a0 and ending at a1, bounds inclusive
val merge : t -> t -> t Core_kernel.Or_error.tmerge m1 m2 takes two memory regions, that either intersects or share edges (i.e., difference between min_addr of one of the blocks and max_addr of another is less then or equal to one, and returns memory blocks that spans memory starting from the address
min (min_addr m1) (min_addr m2)and ending with address
max (max_addr m1) (max_addr m2).
Will return an error, if either the above state precondition doesn't hold, or if this two memory blocks doesn't share the same underlying memory (i.e., bases), or if they have different endianness.
val get :
?disp:int ->
?index:int ->
?scale:size ->
?addr:addr ->
t ->
word Core_kernel.Or_error.tget ?disp ?index ?scale ?addr mem reads a scale sized word from mem.
Parameters mimic the reference syntax in the gas assembler, e.g., dis(base,index,scale) denotes address at base + index * scale + dis.
The size of the returned word is equal to scale, bytes are read in the endian mem order.
val (^) : t -> addr -> word Core_kernel.Or_error.tm^n dereferences a byte at address n
val length : t -> intlength m returns a number of bytes in m
compare_with mem addr compares memory with addr
module Input : sig ... endA set of low level input operations. Note: it is more effective to use above head iterators, instead of this low level interface, since iterators do not need to check every memory access.
Printing and outputting
include Regular.Std.Printable.S with type t := t
val to_string : t -> stringto_string x returns a human-readable representation of x
val str : unit -> t -> stringstr () t is formatted output function that matches "%a" conversion format specifier in functions, that prints to string, e.g., sprintf, failwithf, errorf and, surprisingly all Lwt printing function, including Lwt_io.printf and logging (or any other function with type ('a,unit,string,...) formatN`. Example:
Or_error.errorf "type %a is not valid for %a"
Type.str ty Exp.str expval pps : unit -> t -> stringsynonym for str
val ppo : Core_kernel.Out_channel.t -> t -> unitwill print to a standard output_channel, useful for using in printf, fprintf, etc.
val pp_seq : Format.formatter -> t Core_kernel.Sequence.t -> unitprints a sequence of values of type t
this will include pp function from Core that has type t printer, and can be used in Format.printf family of functions
include Core_kernel.Pretty_printer.S with type t := t
val pp : Base__.Formatter.t -> t -> unitval hexdump : t -> stringhexdump t out outputs hexdump (as per hexdump -C) of the memory to formatter out
a set of iterators, with identity monad.
include Memory_iterators with type t := t and type 'a m = 'a
fold ~word_size ~init ~f t folds over elements of t, so a result is f (... (f (f a elt_1) elt_2) ...) elt_n
iter ~word_size ~f t applies f to elements of t
foldi ~word_size ~init ~f t is like fold, but also passes an address to the f
iteri ~word_size ~f t is like iter, but also passes an address to the f
exists ~word_size ~f t checks if at least one element of t satisfies the predicate f
for_all ~word_size ~f t checks if all elements of t satisfies the predicate f
count ~word_size ~f t is the number of elements in t that satisfies the predicate f.
find_if ~word_size ~f t returns the first element of t that satisfies the predicate p or None if no elements satisfied
module With_error :
Memory_iterators with type t := t and type 'a m = 'a Core_kernel.Or_error.titerators lifter to the Or_error monad
module Make_iterators
(M : sig ... end) :
Memory_iterators with type t := t and type 'a m = 'a M.tlifts iterators to monad M
Interfacing with C
The following interfaces is supposed to be used only for the purposes of exposing memory to c programs.
val to_buffer : t -> Core_kernel.Bigsubstring.tto_buffers mem creates a buffer representing the memory mem. It is not specified whether the returned buffer has some sharing with underlying implementation. In other words the returned buffer shouldn't be modified.
Since it is not guaranteed that memory is contiguous, a sequence of buffers is returned, with each buffer representing a contiguous part of memory.
module Trie : sig ... endTries over memory