Now, when creating values corresponding to bitfields, gdb immediately fetches the values from the memory. That's not good if the memory is "read sensitive". The quick fix is just not to fetch the value, but in that case, if we have several bitfields sharing one byte, calling value_fetch_lazy on each bitfield will repeatedly read that byte -- again not good for read sensitive values. We've discussed this with Daniel and Jim, and the only workable solution appears to be adding a pointer from bitfield to the parent value. When calling value_fetch_lazy on a bitfield, the parent's content is obtained and necessary bits are extracted. If the parent is originally lazy, first access to its content fetches the bits from the memory. So, if we have 32-bit value in memory and some 10 bitfields inside it, first access to any bitfields will fetch the entire value from the memory, and accesses to other bitfields will just access already-read data. Until the first bitfield is accessed, no memory reads are performed at all. One slight problem here is if we have 'parent' pointer, we should make sure that the parent is not deleted while child still needs it. It turned out that a small bit of reference counting for parent pointers is sufficient -- no global changes in gdb are required. A patch that implements this idea is attached, no regressions on x86. One nit is that when writing a bitfield, we first fetch the entire parent value, modify bits and write entire parent value. In some *limited* set of cases it is possible to read only some of the bytes, or not read anything at all, but introducing bit-mask telling which bits are read and which are not is more trouble that its worth. Comments? - Volodya * value.c (struct value): New fields fieldno, parent and reference_count. (allocate_value): Initialize the parent and reference_count fields. (value_parent, value_fieldno): New functions. (value_free): New function. (value_copy): Copy the parent field, increase reference count for parent. (value_primitive_field): When accessing bitfield, not unconditionally fetch them. Don't copy lval type is already set inside the function. * value.h (value_parent, value_fieldno): Define. (value_free): Define as function, not as macro. * valops.c (value_fetch_lazy): Handle fetching of bitfields. (value_assign): Don't handle bitfields in lval_memory and lval_register values. Handle lval_bitfield only. * defs.h (enum lval_type): New enumerator lval_bitfield.