[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DWARF5 line number program header
From: |
Jose E. Marchesi |
Subject: |
Re: DWARF5 line number program header |
Date: |
Fri, 27 Oct 2023 14:26:31 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi Martin.
>> 40 file_name_entry_format_t[file_name_entry_format_count]
>> file_name_entry_format; // offset: 39, size: 4
>> 41 // DW_LNCT_path = 0x1
>> 42 // DW_FORM_line_strp = 0x1f
>> 43 // DW_LNCT_directory_index = 0x2
>> 44 // DW_FORM_udata = 0x0f
>> 45 ULEB128 file_names_count; // offset: 43, size: 1 value: 2
>> 46 uint<32> FILES;
If I understood properly, you basically have an array of format
descriptors, each descriptor determining the shape of each element in a
sequence of elements that follow the array. Schematically:
type Challenge =
struct
{
ElemForm[NELEM] forms;
Elem elem0; /* Shape determined by forms[0] */
Elem elem1; /* Shape determined by forms[1] */
...
Elem elemM; /* Shape determined by forms[NELEM-1] */
};
One possibility would be to define a computed field whose getter does it
imperative style, like:
type Elem =
struct
{
int<32> type;
union
{
Path path;
DirectoryIndex dirindex;
} value;
};
type ConformedElements =
struct
{
ElemForm[NELEM] forms;
var begin_elems = OFFSET;
computed Elem[] elems;
method get_elems = Elem[]:
{
var elems = Elem[]();
var off = begin_elems;
for (form in forms)
{
var elem = Elem {};
if (form is a path)
elem = Elem { type = PATH, value.path = Path @ off };
else if (form is a directory index)
elem = Elem { type = DIRINFO, value.dirinfo = DirInfo @ off };
else
...
apush (elems, elem);
off += elem'size;
}
return elems;
}
};
Seems to me that this is a more elaborated example of the sparse table
idiom described in this pokology article:
https://jemarch.net/pokology-20230128.html
Note that the `elems' computed field, which is an array, is not mapped
itself. But each elems[N].data.WHATEVER are mapped.
Hope this is helpful.