[RFC dwarves 1/3] dwarf_loader: fix detection of struct parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 dwarf_loader.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/dwarf_loader.c b/dwarf_loader.c
index 014e130..73e3670 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;
-- 
2.31.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux