|Home > Iris APIs > Resources > Reading a resource|
The semantics of reading a resource are peek rather than architectural read. All instance implementations should aim for side-effect free reads, which are a prerequisite for non-intrusive debug, although it might not always be possible.
This interface can indicate which bits in which registers have an undefined value. It is optional for instances to support this.
It is not always possible to return the exact value of a resource. For example, this is the case when the instance that exposes the resource is not in a debuggable state. The
resource_read() function supports reporting approximate values.
resource_read() function does not fail with an error for existing targets and resources. Read errors are indicated in the
error member of
ResourceReadResult, for each resource.
resource_read() returns one
ResourceReadResult object, which contains the read result of all resources read, comprising values and errors. Numeric resource values and string resource values are split into two different arrays. Numeric resource values occupy one or more
NumberU64 values in the array, depending on their width. For example:
ResourceReadResult.data= [1, 2, 0xf00daaaa]
ResourceReadResult.data = [1, 2, 3]
ResourceReadResult.data = [0x7766554433221100, 0xffeeddccbbaa9988, 9]
ResourceReadResult.data =  ResourceReadResult.strings = ["abc"]
Reading a 32-bit resource with value 1, a string resource with value
"abc", and a 32-bit resource with value 3:
ResourceReadResult.data = [1, 3] ResourceReadResult.strings = ["abc"]
resource_read() operations give the same result as this example:
"abc", a 32-bit resource with value 1, and a 32-bit resource with value 3.
noValueresource, and a 32-bit resource with value 3:
ResourceReadResult.data = [1, 3]