[Dwarf-discuss] bit-string

David Blaikie dblaikie@gmail.com
Wed Dec 18 18:22:07 GMT 2024


What sort of string-like behavior would one want on a bit-string? Seems
like array would be the better fit to me...

On Wed, Dec 18, 2024 at 9:03 AM pogo 59 via Dwarf-discuss <
dwarf-discuss@lists.dwarfstd.org> wrote:

> My first thought would be that DW_TAG_string_type with a one-bit base
> type, but it's not clear that the other attributes would be interpreted in
> a way that correctly navigated the bit string. You could try using
> DW_TAG_packed_type pointing to a DW_TAG_string_type, in the hopes that
> consumers would figure out that it was a "packed" string of bits, and that
> the element stride and sizes should be bits. I believe Pascal would
> describe "packed array of boolean" that way, or however Pascal spells that
> type.
>
> If that doesn't pan out, DW_TAG_array_type can certainly describe
> bit-sized elements, with DW_AT_bit_stride of 1. This might not get you
> string-like semantics in the consumer, but it would describe the data
> accurately.
> --paulr
>
> On Wed, Dec 18, 2024 at 8:50 AM Thomas David Rivers via Dwarf-discuss <
> dwarf-discuss@lists.dwarfstd.org> wrote:
>
>>
>> PL/I has the concept of a "string", which can be a fixed-length
>> (possibly not known at compile time), or a fixed size with a 4-byte or
>> 2-byte
>> runtime length prefix, or, depending on the consituents, a NULL
>> (zero-byte)
>> terminated string.
>>
>> For "character-like" strings, the constituents can be 1-byte, 2-byte,
>> 4-byte strings, or UTF-8 values.  (e.g. strings of characters, or strings
>> of UTF-8 values, or strings of 4-byte unicode values.)
>>
>> All of these seem to be straightforwardly handled by DWARF-5.
>>
>> However, PL/I also has a "BIT string", which is a left-adjusted string
>> of bits, either of a fixed length (# of bits) or of a fixed size
>> with a either a 2-byte or 4-byte length prefix. Of course, there isn't
>> a NULL-terminated variant of this string, because a zero-bit is part of
>> the data.  The sizes may not be known at compile time.
>>
>> I've gone thru the DWARF-5 standard a few times, but can't seem to
>> envision a straight-forward way to represent this.
>>
>> Furthermore, an un-prefixed bit-string doesn't necessarily begin
>> on a byte boundary, and, depending on the environment, needs to
>> be represented as a bit-offset which may be composed (even at runtime)
>> of (byte-location + bit-offset-in-byte).
>>
>> Any suggestions on how to represent this in DWARF (5 or later) would
>> be appreciated!   Perhaps it's just something obvious I'm overlooking??
>>
>>         - Many Thanks! -
>>         - Dave Rivers
>>
>> --
>> rivers@dignus.com
>> --
>> Dwarf-discuss mailing list
>> Dwarf-discuss@lists.dwarfstd.org
>> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>>
> --
> Dwarf-discuss mailing list
> Dwarf-discuss@lists.dwarfstd.org
> https://lists.dwarfstd.org/mailman/listinfo/dwarf-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.dwarfstd.org/pipermail/dwarf-discuss/attachments/20241218/abd69b57/attachment.htm>


More information about the Dwarf-discuss mailing list