class State

Defined at line 42 of file ../../zircon/system/ulib/inspect/include/lib/inspect/cpp/vmo/state.h

|State| wraps a |Heap| and implements the Inspect VMO API on top of

that heap. This class contains the low-level operations necessary to

deal with the various Inspect types and wrappers to denote ownership of

those values.

This class should not be used directly, prefer to use |Inspector|.

|State| writes version 2 of the Inspect Format.

Public Methods

void State (const State & )

Disallow copy and assign.

Defined at line 56 of file ../../zircon/system/ulib/inspect/include/lib/inspect/cpp/vmo/state.h

void State (State && )

Defined at line 57 of file ../../zircon/system/ulib/inspect/include/lib/inspect/cpp/vmo/state.h

State & operator= (const State & )

Defined at line 58 of file ../../zircon/system/ulib/inspect/include/lib/inspect/cpp/vmo/state.h

State & operator= (State && )

Defined at line 59 of file ../../zircon/system/ulib/inspect/include/lib/inspect/cpp/vmo/state.h

std::shared_ptr<State> Create (std::unique_ptr<Heap> heap)

Create a new State wrapping the given Heap.

On failure, returns nullptr.

Defined at line 233 of file ../../zircon/system/ulib/inspect/vmo/state.cc

std::shared_ptr<State> CreateWithSize (size_t size)

Create a new State wrapping a new heap of the given size.

On failure, returns an empty shared_ptr.

Defined at line 258 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void ~State ()

Destructor for State, which performs necessary cleanup.

Defined at line 268 of file ../../zircon/system/ulib/inspect/vmo/state.cc

const zx::vmo & GetVmo ()

Obtain a reference to the wrapped VMO.

This may be duplicated read-only to pass to a reader process.

Defined at line 270 of file ../../zircon/system/ulib/inspect/vmo/state.cc

bool DuplicateVmo (zx::vmo * vmo)

Obtain a read-only duplicate of the VMO backing this State.

Defined at line 275 of file ../../zircon/system/ulib/inspect/vmo/state.cc

std::optional<zx::vmo> FrozenVmoCopy ()

Obtain a copy-on-write copy of the backing VMO. Generation count

will be `kVmoFrozen`.

Defined at line 281 of file ../../zircon/system/ulib/inspect/vmo/state.cc

bool Copy (zx::vmo * vmo)

Obtain a copy of the VMO backing this state.

Returns true on success, false otherwise.

Defined at line 301 of file ../../zircon/system/ulib/inspect/vmo/state.cc

bool CopyBytes (std::vector<uint8_t> * out)

Obtain a copy of the bytes in the VMO backing this state.

Returns true on success, false otherwise.

Defined at line 320 of file ../../zircon/system/ulib/inspect/vmo/state.cc

IntProperty CreateIntProperty (std::string_view name, BlockIndex parent, int64_t value)

Create a new |IntProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 338 of file ../../zircon/system/ulib/inspect/vmo/state.cc

UintProperty CreateUintProperty (std::string_view name, BlockIndex parent, uint64_t value)

Create a new |UintProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 355 of file ../../zircon/system/ulib/inspect/vmo/state.cc

DoubleProperty CreateDoubleProperty (std::string_view name, BlockIndex parent, double value)

Create a new |DoubleProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 372 of file ../../zircon/system/ulib/inspect/vmo/state.cc

BoolProperty CreateBoolProperty (std::string_view name, BlockIndex parent, bool value)

Create a new |BoolProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 389 of file ../../zircon/system/ulib/inspect/vmo/state.cc

IntArray CreateIntArray (std::string_view name, BlockIndex parent, size_t slots, ArrayBlockFormat format)

Create a new |IntArray| in the Inspect VMO. The returned value releases

the array when destroyed.

Defined at line 405 of file ../../zircon/system/ulib/inspect/vmo/state.cc

StringArray CreateStringArray (std::string_view name, BlockIndex parent, size_t slots, ArrayBlockFormat format)

Create a new |StringArray| in the Inspect VMO. The returned value releases

the array when destroyed.

Defined at line 420 of file ../../zircon/system/ulib/inspect/vmo/state.cc

UintArray CreateUintArray (std::string_view name, BlockIndex parent, size_t slots, ArrayBlockFormat format)

Create a new |UintArray| in the Inspect VMO. The returned value releases

the array when destroyed.

Defined at line 410 of file ../../zircon/system/ulib/inspect/vmo/state.cc

DoubleArray CreateDoubleArray (std::string_view name, BlockIndex parent, size_t slots, ArrayBlockFormat format)

Create a new |DoubleArray| in the Inspect VMO. The returned value releases

the array when destroyed.

Defined at line 415 of file ../../zircon/system/ulib/inspect/vmo/state.cc

StringProperty CreateStringProperty (std::string_view name, BlockIndex parent, const std::string & value)

Create a new |StringProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 454 of file ../../zircon/system/ulib/inspect/vmo/state.cc

ByteVectorProperty CreateByteVectorProperty (std::string_view name, BlockIndex parent, cpp20::span<const uint8_t> value)

Create a new |ByteVectorProperty| in the Inspect VMO. The returned value releases

the property when destroyed.

Defined at line 482 of file ../../zircon/system/ulib/inspect/vmo/state.cc

Link CreateLink (std::string_view name, BlockIndex parent, std::string_view content, LinkBlockDisposition disposition)

Create a new [Link] in the Inspect VMO. The returned node releases the link when destroyed.

A Link is a low-level reference to a new Inspector linked off of the one managed by this

state. A Link alone is not sufficient to populate the linked tree, see CreateLazyNode and

CreateLazyValues.

Defined at line 489 of file ../../zircon/system/ulib/inspect/vmo/state.cc

Node CreateNode (std::string_view name, BlockIndex parent)

Create a new |Node| in the Inspect VMO. Nodes are refcounted such that values nested under the

node remain valid until all such values values are destroyed.

Defined at line 547 of file ../../zircon/system/ulib/inspect/vmo/state.cc

zx_status_t CreateAndIncrementStringReference (std::string_view value, BlockIndex * out)

Create and allocate, if necessary, a StringReference block. The reference count will be 1

if the block is new, and incremented if it already existed.

Defined at line 1234 of file ../../zircon/system/ulib/inspect/vmo/state.cc

Node CreateRootNode ()

Create a special root |Node| in the Inspect VMO. This node is not backed by any storage,

rather it allows clients to use the |Node| interface to add properties and children directly

to the root of the VMO.

Defined at line 518 of file ../../zircon/system/ulib/inspect/vmo/state.cc

LazyNode CreateLazyNode (std::string_view name, BlockIndex parent, LazyNodeCallbackFn callback)

Create a new |LazyNode| with a new named |Link| that calls the given callback with child

disposition.

Defined at line 537 of file ../../zircon/system/ulib/inspect/vmo/state.cc

LazyNode CreateLazyValues (std::string_view name, BlockIndex parent, LazyNodeCallbackFn callback)

Create a new |LazyNode| with a new named |Link| that calls the given callback with inline

disposition.

Defined at line 542 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetIntProperty (IntProperty * property, int64_t value)

Setters for various property types

Defined at line 561 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetUintProperty (UintProperty * property, uint64_t value)

Defined at line 572 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetDoubleProperty (DoubleProperty * property, double value)

Defined at line 584 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetBoolProperty (BoolProperty * property, bool value)

Defined at line 596 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetIntArray (IntArray * array, size_t index, int64_t value)

Defined at line 607 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetUintArray (UintArray * array, size_t index, uint64_t value)

Defined at line 611 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetDoubleArray (DoubleArray * array, size_t index, double value)

Defined at line 615 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetStringArray (StringArray * array, size_t index, std::string_view value)

Defined at line 619 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetStringProperty (StringProperty * property, const std::string & value)

Defined at line 764 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SetByteVectorProperty (ByteVectorProperty * property, cpp20::span<const uint8_t> value)

Defined at line 773 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddIntProperty (IntProperty * property, int64_t value)

Adders for various property types

Defined at line 625 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddUintProperty (UintProperty * property, uint64_t value)

Defined at line 637 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddDoubleProperty (DoubleProperty * property, double value)

Defined at line 649 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddIntArray (IntArray * array, size_t index, int64_t value)

Defined at line 697 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddUintArray (UintArray * array, size_t index, uint64_t value)

Defined at line 707 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void AddDoubleArray (DoubleArray * array, size_t index, double value)

Defined at line 717 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractIntProperty (IntProperty * property, int64_t value)

Subtractors for various property types

Defined at line 661 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractUintProperty (UintProperty * property, uint64_t value)

Defined at line 673 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractDoubleProperty (DoubleProperty * property, double value)

Defined at line 685 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractIntArray (IntArray * array, size_t index, int64_t value)

Defined at line 702 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractUintArray (UintArray * array, size_t index, uint64_t value)

Defined at line 712 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void SubtractDoubleArray (DoubleArray * array, size_t index, double value)

Defined at line 722 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeIntProperty (IntProperty * property)

Free various entities

Defined at line 834 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeUintProperty (UintProperty * property)

Defined at line 850 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeDoubleProperty (DoubleProperty * property)

Defined at line 866 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeBoolProperty (BoolProperty * property)

Defined at line 882 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeIntArray (IntArray * array)

Defined at line 898 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeUintArray (UintArray * array)

Defined at line 900 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeDoubleArray (DoubleArray * array)

Defined at line 902 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeStringArray (StringArray * array)

Defined at line 904 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeStringProperty (StringProperty * property)

Defined at line 936 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeByteVectorProperty (ByteVectorProperty * property)

Defined at line 938 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeLink (Link * link)

Defined at line 942 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeNode (Node * node)

Defined at line 959 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void FreeLazyNode (LazyNode * lazy_node)

Defined at line 989 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void ReleaseStringReference (BlockIndex index)

Defined at line 1021 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void BeginTransaction ()

Use transactions to ensure that all operations appear in the same generation.

Defined at line 1080 of file ../../zircon/system/ulib/inspect/vmo/state.cc

void EndTransaction ()

Defined at line 1088 of file ../../zircon/system/ulib/inspect/vmo/state.cc

std::vector<std::string> GetLinkNames ()

Get the names of all links in this state.

Defined at line 1096 of file ../../zircon/system/ulib/inspect/vmo/state.cc

fpromise::promise<Inspector> CallLinkCallback (const std::string & name)

Call a specific link by name, return a promise for the Inspector it produces.

Defined at line 1105 of file ../../zircon/system/ulib/inspect/vmo/state.cc

std::string UniqueName (const std::string & prefix)

Create a unique name for children in this State.

Returned strings are guaranteed to be unique and will start with the given prefix.

Defined at line 1338 of file ../../zircon/system/ulib/inspect/vmo/state.cc

InspectStats GetStats ()

Return stats about this state.

Defined at line 1351 of file ../../zircon/system/ulib/inspect/vmo/state.cc

Friends

optional State (const State & stateBlockIndex index)