Επεξεργασία

Κοινή χρήση μέσω


Native Debugger Objects in JavaScript Extensions - Type Objects

Native debugger objects represent various constructs of the debugger environment. JavaScript extensions have direct access to the type system of the underlying language. This access is expressed through the notion of type objects. This topic describes the properties associated with type objects.

Native debugger objects represent various constructs and behaviors of the debugger environment. The objects can be passed into (or acquired in) JavaScript extensions to manipulate the state of the debugger.

For information about Debugger object JavaScript extensions, see Native Debugger Objects in JavaScript Extensions.

For general information about working with JavaScript, see JavaScript Debugger Scripting.

Type Objects

A type object can be acquired in a number of ways:

  • From an Object: If a script has a native object within JavaScript, the targetType property can be accessed on that object in order to get a type object representing the static type of the native object.
  • From the Host: The host.getModuleType API can be called in order to return the type object for any type defined in a particular module.

Once the type object is acquired, it has the following properties:

NameSignatureDescription
namePropertyReturns the name of the type.
sizePropertyReturns the size of the type as a 64-bit value.
typeKindPropertyReturns the kind of the type as a string. This can be one of the following values: "udt", "pointer", "memberPointer", "array", "function", "typedef", "enum", or "intrinsic".
baseTypePropertyReturns a type object for the type on which this type is based. This does not represent C++ inheritance. For a pointer type, this is the type of the thing pointed to. For an array type, this is the type contained in the array.
fieldsPropertyReturns an object which has all the named fields of the type accessible as named properties. The value of each property is a field object as described below.
baseClassesPropertyReturns an array of all the immediate base classes of the type. Each object in the array is a base class object as described below.
functionReturnTypePropertyFor function types, this returns a type object representing the return type of the function.
functionParameterTypesPropertyFor function types, this returns an array of type objects representing the parameter types of the function.
functionCallingConventionPropertyFor function types, this returns the calling convention of the function as a string. This can be one of the following values: "unknown", "__cdecl", "fastcall", "stdcall", or "thiscall".
pointerKindPropertyFor pointer types, this returns the kind of pointer as a string. This can be one of the following values: "standard", "reference", "rValueReference", or "cxHat".
memberTypePropertyFor pointer types which are member pointers, this returns a type object representing the member class.
isGenericPropertyReturns whether the type is generic or not. This will return true for template types.
genericArgumentsPropertyFor types which are generic, this will return an array of generic arguments. Such arguments may be type arguments or may be constant values.
isBitFieldPropertyReturns whether the storage for the type is a bitfield or not.
bitFieldPositionsPropertyFor types which represent bitfield storage, this will return a bit field description type indicating the positions of the bitfield.

All of these entries are present during phase 2 initialization.

Field Objects

Each field within a type is described by a field object having properties as follows:

NameSignatureDescription
namePropertyReturns the name of the field.
typePropertyReturns a type object representing the static type of the field.
locationKindPropertyReturns the location kind (storage) for the field as a string. This can be one of the following values: "member", "static", "constant", or "none".
offsetPropertyFor fields which have a location kind that indicates an offset (e.g.: "member"), this returns the offset of the field within its containing type as a 64-bit value.
locationPropertyFor fields which have a location kind that indicates a location (e.g.: "static"), this returns the location of the field as a location object.
valuePropertyFor fields which have a location kind that indicates a value (e.g.: "constant"), this returns the value of the field.

All of these entries are present during phase 2 initialization.

Base Class Objects

Each base class within a type is described by a base class object having properties as follows:

NameSignatureDescription
namePropertyReturns the name of the base class.
offsetPropertyReturns the offset of this base class within its containing type.
typePropertyReturns a type object representing the static type of the base class.

All of these entries are present during phase 2 initialization.

Code Example

For a code example, see the ImageInfo.js script. For more information on code samples, see JavaScript Debugger Example Scripts.

// fieldType references basic types that should be present in **ANY** symbolic information.
// Just grab the first module as the "reference module" for this purpose.  We cannot grab
// "ntdll" generically as we want to avoid a situation in which the debugger opens a module (-z ...)
// from failing.
//
var moduleName = contextInheritorModule.__ComparisonName;
var typeObject = host.getModuleType(moduleName, field.fieldType, contextInheritorModule);
var result = host.createTypedObject(addr, typeObject);

See also

Native Debugger Objects in JavaScript Extensions

Native Debugger Objects in JavaScript Extensions - Design and Testing Considerations

JavaScript Debugger Scripting

JavaScript Debugger Example Scripts