On 9/28/22 13:45, David Faust wrote:
Hi Guillermo,
Hi David,
Thanks for the patch. Just a couple of small nits on the changelog entries below but otherwise very nice, LGTM. But, please wait a couple of days before pushing to give Indu time to raise any objections about the changes in ctfc/dwarf2ctf.
OK. Thanks for your comments!.
Thanks! David On 8/29/22 14:11, Guillermo E. Martinez via Gcc-patches wrote:Hello GCC team, The following patch update BTF/CTF backend to support BTF_KIND_ENUM64 type. Comments will be welcomed and appreciated!, Kind regards, guillermo -- BTF supports 64-bits enumerators with following encoding: struct btf_type: name_off: 0 or offset to a valid C identifier info.kind_flag: 0 for unsigned, 1 for signed info.kind: BTF_KIND_ENUM64 info.vlen: number of enum values size: 1/2/4/8 The btf_type is followed by info.vlen number of: struct btf_enum64 { uint32_t name_off; /* Offset in string section of enumerator name. */ uint32_t val_lo32; /* lower 32-bit value for a 64-bit value Enumerator */ uint32_t val_hi32; /* high 32-bit value for a 64-bit value Enumerator */ }; So, a new btf_enum64 structure was added to represent BTF_KIND_ENUM64 and a new field in ctf_dtdef to represent specific type's properties, in the particular case for CTF enums it helps to distinguish when its enumerators values are signed or unsigned, later that information is used to encode the BTF enum type. gcc/ChangeLog: * btfout.cc (btf_calc_num_vbytes): Compute enumeration size depending of enumerator type btf_enum{,64}. (btf_asm_type): Update btf_kflag according to enumerators sign, using correct BPF type in BTF_KIND_ENUMi{,64}. (btf_asm_enum_const): New argument to represent the size of the BTF enum type. * ctfc.cc (ctf_add_enum): Use and initialization of flag field to CTF_ENUM_F_NONE. (ctf_add_enumerator): New argument to represent CTF flags, updating the comment and flag vaue according to enumerators sing. * ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow use 32/64 bits enumerators. (ctf_dtdef): Add flags to to describe specifyc type's properties.typo: specific
Fixed in v2.
* dwarf2ctf.cc (gen_ctf_enumeration_type): Update flags field depending when a signed enumerator value is found. include/btf.h (btf_enum64): Add new definition and new symbolic constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED.Missing an * here for include/btf.h
Fixed in v2.
gcc/testsuite/ChangeLog: gcc.dg/debug/btf/btf-enum-1.c: Update testcase, with correct info.kflags encoding. gcc.dg/debug/btf/btf-enum64-1.c: New testcase.Likewise for these ChangeLog entries.
Fixed in v2.
You can use contrib/gcc-changelog/git_check_commit.py to check the formatting of the entries.
Oh. thanks for mention it, really useful.
--- gcc/btfout.cc | 24 ++++++++--- gcc/ctfc.cc | 14 ++++--- gcc/ctfc.h | 9 +++- gcc/dwarf2ctf.cc | 9 +++- gcc/testsuite/gcc.dg/debug/btf/btf-enum-1.c | 2 +- gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c | 41 +++++++++++++++++++ include/btf.h | 19 +++++++-- 7 files changed, 99 insertions(+), 19 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-enum64-1.c diff --git a/gcc/btfout.cc b/gcc/btfout.cc index 997a33fa089..4b11c867c23 100644 --- a/gcc/btfout.cc [...]
Regards, guillermo
