poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] pickles: Add btf-ext.pk


From: David Faust
Subject: Re: [PATCH] pickles: Add btf-ext.pk
Date: Thu, 16 Dec 2021 10:07:11 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0



On 12/15/21 22:47, Jose E. Marchesi wrote:

+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'.


Oops. Fixed. :)

+
+/* 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;

Thanks for the suggestion. Updated with something very close to this.


+    BTF_Ext_Func_Info func_info @ func_info_off if has_func_info;
+    BTF_Ext_Line_Info line_info @ line_info_off if has_line_info;
+    BTF_Ext_Core_Info core_info @ core_info_off if has_core_info;
+
+  };

Other than that the patch is OK for master.
Thanks!


Pushed, thanks.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]