Next: Architectures In Python, Previous: Finish Breakpoints in Python, Up: Python API [Contents][Index]

#### 23.2.2.32 Python representation of lazy strings

A lazy string is a string whose contents is not retrieved or encoded until it is needed.

A `gdb.LazyString` is represented in GDB as an `address` that points to a region of memory, an `encoding` that will be used to encode that region of memory, and a `length` to delimit the region of memory that represents the string. The difference between a `gdb.LazyString` and a string wrapped within a `gdb.Value` is that a `gdb.LazyString` will be treated differently by GDB when printing. A `gdb.LazyString` is retrieved and encoded during printing, while a `gdb.Value` wrapping a string is immediately retrieved and encoded on creation.

A `gdb.LazyString` object has the following functions:

Function: LazyString.value ()

  Convert the `gdb.LazyString` to a `gdb.Value`. This value will point to the string in memory, but will lose all the delayed retrieval, encoding and handling that GDB applies to a `gdb.LazyString`.

Variable: LazyString.address

  This attribute holds the address of the string. This attribute is not writable.

Variable: LazyString.length

  This attribute holds the length of the string in characters. If the length is -1, then the string will be fetched and encoded up to the first null of appropriate width. This attribute is not writable.

Variable: LazyString.encoding

  This attribute holds the encoding that will be applied to the string when the string is printed by GDB. If the encoding is not set, or contains an empty string, then GDB will select the most appropriate encoding when the string is printed. This attribute is not writable.

Variable: LazyString.type

  This attribute holds the type that is represented by the lazy string’s type. For a lazy string this is a pointer or array type. To resolve this to the lazy string’s character type, use the type’s `target` method. See Types In Python. This attribute is not writable.

Next: Architectures In Python, Previous: Finish Breakpoints in Python, Up: Python API [Contents][Index]