aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGuillermo E. Martinez <guillermo.e.martinez@oracle.com>2022-10-31 09:32:50 -0700
committerIndu Bhagat <indu.bhagat@oracle.com>2022-10-31 09:34:22 -0700
commit8422861bddc7c4fd202cd59c8487d4bc6b807dc3 (patch)
tree77b0ba2573ec7b9086227a747d7457d3b2047fce /include
parentcbf56503d5e2bbafb06a507cb37d30805a1013a0 (diff)
downloadgcc-8422861bddc7c4fd202cd59c8487d4bc6b807dc3.zip
gcc-8422861bddc7c4fd202cd59c8487d4bc6b807dc3.tar.gz
gcc-8422861bddc7c4fd202cd59c8487d4bc6b807dc3.tar.bz2
btf: Add support to BTF_KIND_ENUM64 type
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 dtd_enum_unsigned in ctf_dtdef structure to distinguish when CTF enum is a signed or unsigned type, 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 enumeration type sign using dtd_enum_unsigned field for both: BTF_KIND_ENUM{,64}. (btf_asm_enum_const): New argument to represent the size of the BTF enum type, writing the enumerator constant value for 32 bits, if it's 64 bits then explicitly writes lower 32-bits value and higher 32-bits value. (output_asm_btf_enum_list): Add enumeration size argument. * ctfc.cc (ctf_add_enum): New argument to represent CTF enum basic information. (ctf_add_generic): Use of ei_{name. size, unsigned} to build the dtd structure containing enumeration information. (ctf_add_enumerator): Update comment mention support for BTF enumeration in 64-bits. * dwarf2ctf.cc (gen_ctf_enumeration_type): Extract signedness for enumeration type and use it in ctf_add_enum. * ctfc.h (ctf_dmdef): Update dmd_value to HOST_WIDE_INT to allow use 32/64 bits enumerators. information. (ctf_dtdef): New field to describe enum signedness. include/ * btf.h (btf_enum64): Add new definition and new symbolic constant to BTF_KIND_ENUM64 and BTF_KF_ENUM_{UN,}SIGNED. 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.
Diffstat (limited to 'include')
-rw-r--r--include/btf.h19
1 files changed, 16 insertions, 3 deletions
diff --git a/include/btf.h b/include/btf.h
index 78b551c..eba67f9 100644
--- a/include/btf.h
+++ b/include/btf.h
@@ -109,7 +109,8 @@ struct btf_type
#define BTF_KIND_VAR 14 /* Variable. */
#define BTF_KIND_DATASEC 15 /* Section such as .bss or .data. */
#define BTF_KIND_FLOAT 16 /* Floating point. */
-#define BTF_KIND_MAX BTF_KIND_FLOAT
+#define BTF_KIND_ENUM64 19 /* Enumeration up to 64 bits. */
+#define BTF_KIND_MAX BTF_KIND_ENUM64
#define NR_BTF_KINDS (BTF_KIND_MAX + 1)
/* For some BTF_KINDs, struct btf_type is immediately followed by
@@ -130,14 +131,17 @@ struct btf_type
#define BTF_INT_BOOL (1 << 2)
/* BTF_KIND_ENUM is followed by VLEN struct btf_enum entries,
- which describe the enumerators. Note that BTF currently only
- supports signed 32-bit enumerator values. */
+ which describe the enumerators. */
struct btf_enum
{
uint32_t name_off; /* Offset in string section of enumerator name. */
int32_t val; /* Enumerator value. */
};
+/* BTF_KF_ENUM_ holds the flags for kflags in BTF_KIND_ENUM{,64}. */
+#define BTF_KF_ENUM_UNSIGNED (0)
+#define BTF_KF_ENUM_SIGNED (1 << 0)
+
/* BTF_KIND_ARRAY is followed by a single struct btf_array. */
struct btf_array
{
@@ -190,6 +194,15 @@ struct btf_var_secinfo
uint32_t size; /* Size (in bytes) of variable. */
};
+/* BTF_KIND_ENUM64 is followed by VLEN struct btf_enum64 entries,
+ which describe the 64 bits enumerators. */
+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 */
+};
+
#ifdef __cplusplus
}
#endif