pahole: Implement cu_exclude_lang flag
PATCH 1/1 pahole: Implement cu_exclude_lang flag
Exclude compilation units that have the language id equal to the one from the --cu_exclude_lang=LANG flag.
Required by Rust Linux builds due to failing BTF checks product of things like rustc's struct reordering.
--- dwarves.h | 18 ++++++++++++++++++ pahole.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
dwarves.h +18 -0
@@ -204,6 +204,24 @@ enum dwarf_languages { LANG_ObjC_plus_plus =0x11 ,/* Objective-C++ */ LANG_UPC =0x12 ,/* Unified Parallel C */ LANG_D =0x13 ,/* D */ + LANG_Python =0x14 ,/* Python */ + LANG_OpenCL =0x15 ,/* OpenCL */ + LANG_Go =0x16 ,/* Go */ + LANG_Modula3 =0x17 ,/* Modula-3 */ + LANG_Haskell =0x18 ,/* Haskell */ + LANG_C_plus_plus_03 =0x19 ,/* ISO C++:2003 */ + LANG_C_plus_plus_11 =0x1a ,/* ISO C++:2011 */ + LANG_OCaml =0x1b ,/* OCaml */ + LANG_Rust =0x1c ,/* Rust */ +LANG_C11 =0x1d ,/* ISO C:2011 */ + LANG_Swift =0x1e ,/* Swift */ + LANG_Julia =0x1f ,/* Julia */ + LANG_Dylan =0x20 ,/* Dylan */ + LANG_C_plus_plus_14 =0x21 ,/* ISO C++:2014 */ + LANG_Fortran03 =0x22 ,/* ISO/IEC 1539-1:2004 */ + LANG_Fortran08 =0x23 ,/* ISO/IEC 1539-1:2010 */ + LANG_RenderScript =0x24 ,/* RenderScript Kernal Language */ + LANG_BLISS = 0x25, /* BLISS */ };/** struct debug_fmt_ops - specific to the underlying debug file format
pahole.c +48 -0
84 lines not on this page · raw message
Signature · 1 line
2.36.0
Em Thu, Apr 21, 2022 at 11:47:15AM -0300, Martin Reboredo escreveu:
Quoted 5 lines
Exclude compilation units that have the language id equal to the one from the --cu_exclude_lang=LANG flag.
Required by Rust Linux builds due to failing BTF checks product of things like rustc's struct reordering.
Sorry, when I saw this patch I already had committed a similar one, can you please take a look?
Its in the "next" branch at:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=next
- Arnaldo
Quoted 132 lines
Signed-off-by Martin Reboredo <[email protected]>Tested-by Martin Reboredo <[email protected]>--- dwarves.h | 18 ++++++++++++++++++ pahole.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)dwarves.h +18
-0@@ -204,6 +204,24 @@ enum dwarf_languages { LANG_ObjC_plus_plus =0x11 ,/* Objective-C++ */ LANG_UPC =0x12 ,/* Unified Parallel C */ LANG_D =0x13 ,/* D */ + LANG_Python =0x14 ,/* Python */ + LANG_OpenCL =0x15 ,/* OpenCL */ + LANG_Go =0x16 ,/* Go */ + LANG_Modula3 =0x17 ,/* Modula-3 */ + LANG_Haskell =0x18 ,/* Haskell */ + LANG_C_plus_plus_03 =0x19 ,/* ISO C++:2003 */ + LANG_C_plus_plus_11 =0x1a ,/* ISO C++:2011 */ + LANG_OCaml =0x1b ,/* OCaml */ + LANG_Rust =0x1c ,/* Rust */ +LANG_C11 =0x1d ,/* ISO C:2011 */ + LANG_Swift =0x1e ,/* Swift */ + LANG_Julia =0x1f ,/* Julia */ + LANG_Dylan =0x20 ,/* Dylan */ + LANG_C_plus_plus_14 =0x21 ,/* ISO C++:2014 */ + LANG_Fortran03 =0x22 ,/* ISO/IEC 1539-1:2004 */ + LANG_Fortran08 =0x23 ,/* ISO/IEC 1539-1:2010 */ + LANG_RenderScript =0x24 ,/* RenderScript Kernal Language */ + LANG_BLISS = 0x25, /* BLISS */ };/** struct debug_fmt_ops - specific to the underlying debug file format pahole.c +48
-0@@ -57,6 +57,8 @@ static size_t class__include_prefix_len;static char *cu__exclude_prefix;static size_t cu__exclude_prefix_len; +static uint32_t cu__exclude_lang; +static char *decl_exclude_prefix;static size_t decl_exclude_prefix_len;@@ -615,6 +617,10 @@ static struct cu *cu__filter(struct cu *cu) cu__exclude_prefix_len) == 0))return NULL ; +if (cu__exclude_lang !=0 && + cu__exclude_lang == cu->language) +return NULL ; +return cu; }@@ -988,6 +994,39 @@ static void cu__account_nr_methods(struct cu *cu) } } +static const struct { +const char *name; +uint32_t id; +} language_table[] = { + {"C" ,LANG_C }, + {"C89" ,LANG_C89 }, + {"C99" ,LANG_C99 }, + {"C11" ,LANG_C11 }, + {"C++" , LANG_C_plus_plus }, + {"C++03" , LANG_C_plus_plus_03 }, + {"C++11" , LANG_C_plus_plus_11 }, + {"C++14" , LANG_C_plus_plus_14 }, + {"Fortran77" , LANG_Fortran77 }, + {"Fortran90" , LANG_Fortran90 }, + {"Fortran95" , LANG_Fortran95 }, + {"Fortran03" , LANG_Fortran03 }, + {"Fortran08" , LANG_Fortran08 }, + {"Go" , LANG_Go }, + {"Haskell" , LANG_Haskell }, + {"Rust" , LANG_Rust }, + {NULL ,0 }, +}; + +static uint32_t language_id (const char *lang) { +for (int l =0 ; language_table[l].name; l++) { +if (strcmp (lang, language_table[l].name) ==0 ) { +return language_table[l].id; + } + } + +return 0 ; +} +static char tab[128 ];static void print_structs_with_pointer_to (struct cu *cu,uint32_t type)@@ -1137,6 +1176,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version;#define ARGP_skip_missing 332#define ARGP_skip_encoding_btf_type_tag 333#define ARGP_compile 334 +#define ARGP_exclude_lang 335static const struct argp_option pahole__options[] = { {@@ -1512,6 +1552,12 @@ static const struct argp_option pahole__options[] = { .key = ARGP_devel_stats, .doc = "Print internal data structures stats", }, + { + .name = "cu_exclude_lang", + .key = ARGP_exclude_lang, + .arg = "LANG", + .doc = "exclude LANGuage compilation units", + }, { .name = "skip_encoding_btf_decl_tag", .key = ARGP_skip_encoding_btf_decl_tag,@@ -1681,6 +1727,8 @@ static error_t pahole__options_parser(int key, char *arg, conf_load.hashtable_bits =atoi (arg);break ;case ARGP_devel_stats: conf_load.ptr_table_stats = true;break ; +case ARGP_exclude_lang: + cu__exclude_lang =language_id (arg);break ;case ARGP_skip_encoding_btf_decl_tag: conf_load.skip_encoding_btf_decl_tag = true;break ;case ARGP_skip_missing:Signature · 1 line
2.36.0
Signature · 1 line
- Arnaldo
Quoted 7 lines
Em Thu, Apr 21, 2022 at 11:47:15AM -0300, Martin Reboredo escreveu:
Quoted 5 lines
Exclude compilation units that have the language id equal to the one from the --cu_exclude_lang=LANG flag.
Required by Rust Linux builds due to failing BTF checks product of things like rustc's struct reordering.
Quoted 6 lines
Sorry, when I saw this patch I already had committed a similar one, can you please take a look?
Its in the "next" branch at:
https://git.kernel.org/pub/scm/devel/pahole/pahole.git/commit/?h=next
I've saw said patches and performed local testing with a Rust-for-Linux kernel, both in Qemu and bare metal, the kernel and it was working as expected, bpftool could eject a proper header
$ bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
and I could do BTF test from a guide by Aniket Bhattacharyea in containiq.com (https://www.containiq.com/post/btf-bpf-type-format).
So yeah, I can say that this patch was effectively superseeded by the patch series at next. Thanks for your attention though.