aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Maguire <alan.maguire@oracle.com>2023-02-21 15:48:40 +0000
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-02-28 12:38:16 -0300
commit721ca66d5be462b28ba07a79e72d48e5e5a6959e (patch)
tree43e2a73c1fa3f063793094bdc8c064b541139f64
parentef68019c357845b41ae99c0af7a4d21194d3738b (diff)
downloadpahole-721ca66d5be462b28ba07a79e72d48e5e5a6959e.tar.gz
dwarf_loader: Fix detection of struct parameters
In some cases, param__is_struct() was failing to notice that a parameter was a struct. The first was where a parameter was a const struct; the second was where the type information was in the original subroutine information, and additional parameters that referred to it via abstract origin did not also specify type information. We combine information about type, name etc in ftype__recode_dwarf_types(), but since we share the tag->type (rather than the dwarf tag), param__is_struct() was failing to handle this case as it represents parameters like this: <7e0f7d4> DW_AT_sibling : <0x7e0f924> <2><7e0f7d8>: Abbrev Number: 7 (DW_TAG_formal_parameter) <7e0f7d9> DW_AT_abstract_origin: <0x7e0dc80> <7e0f7dd> DW_AT_location : 0x2797488 (location list) <7e0f7e1> DW_AT_GNU_locviews: 0x2797484 <2><7e0f7e5>: Abbrev Number: 7 (DW_TAG_formal_parameter) <7e0f7e6> DW_AT_abstract_origin: <0x7e0dc8b> <7e0f7ea> DW_AT_location : 0x27974ca (location list) <7e0f7ee> DW_AT_GNU_locviews: 0x27974c8 ...which do not specify a type and did not use the tag->type information. Fix param__is_struct() to use cu__type(cu, tag->type) to look up type information, and to handle the const case. Signed-off-by: Alan Maguire <alan.maguire@oracle.com> Tested-by: Jiri Olsa <jolsa@kernel.org> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Andrii Nakryiko <andrii@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: Eduard Zingerman <eddyz87@gmail.com> Cc: Hao Luo <haoluo@google.com> Cc: John Fastabend <john.fastabend@gmail.com> Cc: KP Singh <kpsingh@chromium.org> Cc: Kui-Feng Lee <sinquersw@gmail.com> Cc: Martin KaFai Lau <martin.lau@kernel.org> Cc: Song Liu <songliubraving@fb.com> Cc: Stanislav Fomichev <sdf@google.com> Cc: Timo Beckers <timo@incline.eu> Cc: Yonghong Song <yhs@fb.com> Cc: bpf@vger.kernel.org Link: https://lore.kernel.org/r/1676994522-1557-2-git-send-email-alan.maguire@oracle.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--dwarf_loader.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/dwarf_loader.c b/dwarf_loader.c
index 014e130d..73e36704 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -2645,19 +2645,17 @@ out:
static bool param__is_struct(struct cu *cu, struct tag *tag)
{
- const struct dwarf_tag *dtag = tag->priv;
- struct dwarf_tag *dtype = dwarf_cu__find_type_by_ref(cu->priv, &dtag->type);
- struct tag *type;
+ struct tag *type = cu__type(cu, tag->type);
- if (!dtype)
+ if (!type)
return false;
- type = dtype->tag;
switch (type->tag) {
case DW_TAG_structure_type:
return true;
+ case DW_TAG_const_type:
case DW_TAG_typedef:
- /* handle "typedef struct" */
+ /* handle "typedef struct", const parameter */
return param__is_struct(cu, type);
default:
return false;