poke-devel
[Top][All Lists]
Advanced

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

[COMMITTED] poke: add field "optioness" info to .info type


From: Jose E. Marchesi
Subject: [COMMITTED] poke: add field "optioness" info to .info type
Date: Mon, 16 Sep 2024 20:38:34 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

This patch extends the output of the `.info type' dot-command to
include information about whether the struct fields are optional.
Example:

----
(big:poke) .info type Elf64_File
Class:      struct
Name:       Elf64_File
Complete:   no
Fields:
  Name     Type             Optional
  ehdr     Elf64_Ehdr       no
  shdr     Elf64_Shdr[]     yes
  phdr     Elf64_Phdr[]     yes
Methods:
  Name                     Type
  get_section_name         (offset<Elf_Word,8>)string
  get_symbol_name          (Elf64_Shdr,offset<Elf_Word,8>)string
  get_sections_by_name     (string)Elf64_Shdr[]
  get_sections_by_type     (Elf_Word)Elf64_Shdr[]
  section_name_p           (string)int<32>
  get_string               (offset<Elf_Word,8>)string
  get_group_signature      (Elf64_Shdr)string
  get_group_signatures     ()string[]
  get_section_group        (string)Elf64_Shdr[]
  vaddr_to_sec             (Elf64_Addr)int<32>
  vaddr_to_file_offset     (Elf64_Addr)Elf64_Addr
  get_load_base            ()Elf64_Addr
----

Note the new column "Optional" in the fields table.

2024-09-16  Jose E. Marchesi  <jemarch@gnu.org>

        * poke/pk-cmd-info.pk (pk_info_type): Print whether struct fields
        are optional or not.
        * doc/poke.texi (Pickles): Update accordingly.
---
 ChangeLog           | 6 ++++++
 doc/poke.texi       | 8 ++++----
 poke/pk-cmd-info.pk | 4 +++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eeba2f5a..60d6f99b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-09-16  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * poke/pk-cmd-info.pk (pk_info_type): Print whether struct fields
+       are optional or not.
+       * doc/poke.texi (Pickles): Update accordingly.
+
 2024-09-16  Jose E. Marchesi  <jemarch@gnu.org>
 
        * libpoke/pkl-rt.pk: New field `foptional'.
diff --git a/doc/poke.texi b/doc/poke.texi
index 8f8feed1..4971285e 100644
--- a/doc/poke.texi
+++ b/doc/poke.texi
@@ -4666,10 +4666,10 @@ Class:      struct
 Name:       Elf64_File
 Complete:   no
 Fields:
-  Name     Type
-  ehdr     Elf64_Ehdr
-  shdr     Elf64_Shdr[]
-  phdr     Elf64_Phdr[]
+  Name     Type             Optional
+  ehdr     Elf64_Ehdr       no
+  shdr     Elf64_Shdr[]     yes
+  phdr     Elf64_Phdr[]     yes
 Methods:
   Name                     Type
   get_section_name         (offset<Elf_Word,8>)string
diff --git a/poke/pk-cmd-info.pk b/poke/pk-cmd-info.pk
index b57564b3..7b38bfdf 100644
--- a/poke/pk-cmd-info.pk
+++ b/poke/pk-cmd-info.pk
@@ -164,11 +164,12 @@ fun pk_info_type = (Pk_Type typ) void:
         term_begin_class ("table-header");
         print "Fields:\n";
         term_end_class ("table-header");
-        var table = Pk_Table { num_columns = 2, indent = 2, max_column_size = 
80 };
+        var table = Pk_Table { num_columns = 3, indent = 2, max_column_size = 
80 };
 
         table.row ("table-header");
         table.column ("Name");
         table.column ("Type");
+        table.column ("Optional");
         for (var i = 0; i < typ.nfields; ++i)
           {
             if (typ.fcomputed[i] || typ.fnames[i] == "")
@@ -176,6 +177,7 @@ fun pk_info_type = (Pk_Type typ) void:
             table.row;
             table.column (typ.fnames[i]);
             table.column (typ.ftypes[i]);
+            table.column (typ.foptional[i] ? "yes" : "no");
           }
           table.print_table;
 
-- 
2.30.2




reply via email to

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