+type BTF_Ext_Line_Info_Rec =
+ struct
+ {
+ offset<uint<32>,B> insn_off;
+ offset<uint<32>,B> file_name_off;
+ offset<uint<32>,B> line_off;
+ struct uint<32>
+ {
+ uint<22> line_num; /* Line number of source line. */
+ uint<10> line_col; /* Column in source line. */
+ };
+ };
That anonymous struct will need a name, otherwise it wont' be possible
to access `line_num' nor `line_col'.
+
+/* A complete .BTF.ext section. */
+type BTF_Ext_Section =
+ struct
+ {
+ BTF_Ext_Header header : header.hdr_len == header'size;
+
+ var func_info_off = header.hdr_len + header.func_info_off;
+ var line_info_off = header.hdr_len + header.line_info_off;
+ var core_info_off = header.hdr_len + header.core_info_off;
+
+ var has_func_info = header.func_info_len > 0#B;
+ var has_line_info = header.line_info_len > 0#B;
+ var has_core_info = header.core_info_len > 0#B;
+
+ type BTF_Ext_Func_Info =
+ struct
+ {
+ offset<uint<32>,B> rec_size;
+
+ var sz = (header.func_info_len < rec_size'size)
+ ? 0UL#b
+ : (header.func_info_len - rec_size'size);
+
+ BTF_Ext_Func_Info_Sec [sz] sections;
+ };
+
+ type BTF_Ext_Line_Info =
+ struct
+ {
+ offset<uint<32>,B> rec_size;
+
+ var sz = (header.line_info_len < rec_size'size)
+ ? 0UL#b
+ : (header.line_info_len - rec_size'size);
+
+ BTF_Ext_Line_Info_Sec [sz] sections;
+ };
+
+ type BTF_Ext_Core_Info =
+ struct
+ {
+ offset<uint<32>,B> rec_size;
+
+ var sz = (header.core_info_len < rec_size'size)
+ ? 0UL#b
+ : (header.core_info_len - rec_size'size);
+
+ BTF_Ext_Core_Info_Sec [sz] sections;
+ };
The computation of sz may be abstracted into function (in
BTF_Ext_Section) avoiding replicating the logic, something like:
fun secsz = (offset<uint<64>,b> len) offset<uint<64>,b>:
{ return l < rec_size'size ? 0UB#b : len - rec_size'size; }
then
BTF_Ext_Func_Info_Sec[secsz (header.func_info_len)] sections;
BTF_Ext_Line_Info_Sec[secsz (header.line_info_len)] sections;
BTF_Ext_Core_Info_Sec[secsz (header.core_info_len)] sections;