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:
Name | Signature | Description |
name | Property | Returns the name of the type. |
size | Property | Returns the size of the type as a 64-bit value. |
typeKind | Property | Returns 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". |
baseType | Property | Returns 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. |
fields | Property | Returns 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. |
baseClasses | Property | Returns an array of all the immediate base classes of the type. Each object in the array is a base class object as described below. |
functionReturnType | Property | For function types, this returns a type object representing the return type of the function. |
functionParameterTypes | Property | For function types, this returns an array of type objects representing the parameter types of the function. |
functionCallingConvention | Property | For 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". |
pointerKind | Property | For pointer types, this returns the kind of pointer as a string. This can be one of the following values: "standard", "reference", "rValueReference", or "cxHat". |
memberType | Property | For pointer types which are member pointers, this returns a type object representing the member class. |
isGeneric | Property | Returns whether the type is generic or not. This will return true for template types. |
genericArguments | Property | For types which are generic, this will return an array of generic arguments. Such arguments may be type arguments or may be constant values. |
isBitField | Property | Returns whether the storage for the type is a bitfield or not. |
bitFieldPositions | Property | For 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:
Name | Signature | Description |
name | Property | Returns the name of the field. |
type | Property | Returns a type object representing the static type of the field. |
locationKind | Property | Returns the location kind (storage) for the field as a string. This can be one of the following values: "member", "static", "constant", or "none". |
offset | Property | For 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. |
location | Property | For fields which have a location kind that indicates a location (e.g.: "static"), this returns the location of the field as a location object. |
value | Property | For 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:
Name | Signature | Description |
name | Property | Returns the name of the base class. |
offset | Property | Returns the offset of this base class within its containing type. |
type | Property | Returns 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