[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/2] pickles: ctf: minor enhancements and add CTF_Dictionary
From: |
Jose E. Marchesi |
Subject: |
Re: [PATCH 1/2] pickles: ctf: minor enhancements and add CTF_Dictionary type |
Date: |
Thu, 25 Feb 2021 09:37:37 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Hi Indu.
> 2021-02-24 Indu Bhagat <indu.bhagat@oracle.com>
>
> * pickles/ctf.pk (ctf_kind_str): add string for slice.
> (CTF_Dictionary): new type.
> (CTF_Preamble): add _print function.
> (CTF_Header): add _print function.
> (ctf_get_header): rename to ctf_get_dict.
> ---
> pickles/ctf.pk | 69 +++++++++++++++++++++++++++++++++++++-------------
> 1 file changed, 52 insertions(+), 17 deletions(-)
>
> diff --git a/pickles/ctf.pk b/pickles/ctf.pk
> index 167628b0..a7b0f032 100644
> --- a/pickles/ctf.pk
> +++ b/pickles/ctf.pk
> @@ -67,7 +67,7 @@ var CTF_KIND_UNKNOWN = 0,
> var ctf_kind_str =
> ["unknown", "integer", "float", "pointer", "array",
> "function", "struct", "union", "enum", "forward",
> - "typedef", "volatile", "const", "restrict"];
> + "typedef", "volatile", "const", "restrict", "slice"];
>
> type CTF_Name =
> struct uint<32>
> @@ -96,6 +96,15 @@ type CTF_Preamble =
> uint<16> ctp_magic = CTF_MAGIC;
> byte ctp_version;
> byte ctp_flags;
> +
> + method _print = void:
> + {
> + print "#<\n";
> + printf " Magic Number: %v\n", ctp_magic;
> + printf " Version: %v\n", ctp_version;
> + printf " Flags: %v\n", ctp_flags;
> + print ">\n";
> + }
> };
>
> type CTF_Header =
> @@ -114,6 +123,16 @@ type CTF_Header =
> offset<uint32,B> cth_typeoff; /* Offset of type section. */
> offset<uint32,B> cth_stroff; /* Offset of string section. */
> offset<uint32,B> cth_strlen; /* Length of string section in
> bytes. */
> +
> + method _print = void:
> + {
> + printf "%v", cth_preamble;
> +
> + print "#<\n";
> + printf " Type Section: %u32d bytes\n", (cth_stroff-cth_typeoff)/#B;
> + printf " String Section: %u32d bytes\n", cth_strlen/#B;
> + print ">\n";
> + }
> };
>
> type CTF_Lblent =
> @@ -231,11 +250,14 @@ type CTF_Type =
> CTF_Name name;
> CTF_Info info;
>
> - /* Some types have a size. Others refer to other types. */
> + /* Some types have a size. Others refer to other types.
> + CTF_KIND_FORWARD is a distinct lone case where the field ttype refers
> + to the kind of forward (struct, union or enum). */
> union
> {
> uint32 ttype : info.kind in [CTF_KIND_POINTER,
> CTF_KIND_FUNCTION,
> + CTF_KIND_FORWARD,
> CTF_KIND_TYPEDEF,
> CTF_KIND_VOLATILE,
> CTF_KIND_CONST,
> @@ -280,22 +302,40 @@ type CTF_Type =
> } data;
> };
>
> +type CTF_Dictionary =
> + struct
> + {
> + CTF_Header header;
> +
> + var type_off = OFFSET + header.cth_typeoff;
> + var type_size = header.cth_stroff - header.cth_typeoff;
> +
> + var str_off = OFFSET + header.cth_stroff;
> +
> + CTF_Type[type_size] types @type_off;
> + string[header.cth_strlen] strings @str_off;
We usually write labels leving a space between the @ and the offset
expression.
Other than that, this is OK for master.
Thanks!