class PrettyType

Defined at line 35 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

Base class for a type we can do "pretty" things with.

At the most basic level, a PrettyType provides alternate formatting which can properly

encapsulate more complex data structures like vectors and arrays.

We also provide expression evaluation support for these types, allowing them to implement

getters, pointer derefercing, and array access. This allows the debugger to emulate common

queries on types that may not have an otherwise easy access point. For example, users will often

want to query the size, capacity, or a single indexed element of a vector. This is difficult to

do using just the struct information, and we do not allow actually executing code to run the real

implementations of these functions.

Public Methods

void PrettyType ()

Defined at line 42 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

void ~PrettyType ()

Defined at line 53 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

void PrettyType (std::initializer_list<std::pair<std::string, std::string>> getters)

This variant takes a list of getter names and expressions for this type. For example, a vector

might pass something like

{

{"size", "end_ - begin_"},

{"capacity", "capacity_" }

}

to provide size() and capacity() getters.

Defined at line 353 of file ../../src/developer/debug/zxdb/expr/pretty_type.cc

void AddGetterExpression (const std::string & getter_name, const std::string & expression)

Adds a getter expression to the lookup table returned by GetGetter().

Defined at line 358 of file ../../src/developer/debug/zxdb/expr/pretty_type.cc

void Format (FormatNode * node, const FormatOptions & options, const fxl::RefPtr<EvalContext> & context, fit::deferred_callback cb)

Fills the given FormatNode. Upon completion, issues the given deferred_callback. If the format

node is filled asynchronously the implementation should take a weak pointer to it since the

lifetime is not guaranteed.

EvalFunction GetMember (const std::string & member_name)

Returns a function which can be evaluated to fetch a member variable from an object of this

type. If there is no matching member, a null fit::function is returned.

Defined at line 73 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

EvalFunction GetDereferencer ()

Returns a function which can be evaluated to execute a unary "*" dereference operator on an

object of the given type.

This will also be used for "operator->" which is implemented as a dereference followed by

a ".".

This is used for smart-pointer-like classes without forcing the user to look into the guts of a

smart pointer. Returns an empty function if there is no member access operator.

Defined at line 83 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

EvalArrayFunction GetArrayAccess ()

Returns a function which can be executed to perform an array access. This allows the pretty

printer to implement "operator[]" on a type. This is important for implementing wrappers around

vector types.

Defined at line 88 of file ../../src/developer/debug/zxdb/expr/pretty_type.h

EvalFunction GetGetter (const std::string & getter_name)

Returns a function which can be evaluated to execute a getter on an object of this type.

If there is no matching getter, a null fit::function is returned.

(Implementation note: this design is so the caller can check if there is a getter and then

execute it with a callback, which is how most nodes want to run.)

Defined at line 363 of file ../../src/developer/debug/zxdb/expr/pretty_type.cc

Protected Methods

void EvalExpressionOn (const fxl::RefPtr<EvalContext> & context, const ExprValue & object, const std::string & expression, EvalCallback cb)

Evaluates the given expression in the context of the given object. The object's members will

be injected into the active scope.

Defined at line 373 of file ../../src/developer/debug/zxdb/expr/pretty_type.cc