From: Sami Wagiaalla <swagiaal@redhat.com>
To: Roland McGrath <roland@redhat.com>
Cc: frysk <frysk@sourceware.org>
Subject: Re: Dwarf expertise needed
Date: Thu, 19 Jul 2007 15:31:00 -0000 [thread overview]
Message-ID: <469F83A5.8090803@redhat.com> (raw)
In-Reply-To: <20070718224349.165984D05CF@magilla.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]
>> That will do, although I think there might be a bug there :(. Let me
>> double check.
>>
>
> There is certainly a bug hit by Stan's test case, since it gets an error.
>
So yes there is a bug, I have not checked to see if it is Stan's bug,
but here it goes:
This is the test case that I am using:
inline void second(){
int* a = 0;
a[0] = 0; <-------- pc
}
void first(){
second();
}
int main(){
first();
return 0;
}
So if I try to dwarf_getscopes at pc i get 0 scopes returned. The
problem is in the pc_record function from dwarf_getscopes.c:
> /* Now we are in a scope that contains the concrete inlined instance.
> Search it for the inline function's abstract definition.
> If we don't find it, return to search the containing scope.
> If we do find it, the nonzero return value will bail us out
> of the postorder traversal. */
> return __libdw_visit_scopes (depth, die, &origin_match, NULL, &a);
> }
The problem is that if the die passed to __libdw_visit_scopes has no
children, __libdw_visit_scopes returns -1 which means that pc_record
returns -1 and the search aborts, and no scopes are returned.
The particular childless die in this case happens to be the one
corresponding to main. I can fudge it by adding some variables to main
and get the following scopes:
scopes[0] DW_TAG_lexical_block name:
scopes[1] DW_TAG_inlined_subroutine name: second
scopes[2] DW_TAG_compile_unit name:
/to/scratch/swagiaal/frysks/frysk/frysk-core/frysk/pkglibdir/funit-scopes.c
I have attached two of possible patches:
patch1 just check for children before the call, patch2 takes the
responsibility away from pc_record and relies on the later call to
pc_origin in dwarf_getscopes:
[...]
int result = __libdw_visit_scopes (0, &cu, &pc_match, &pc_record, &a);
if (result == 0 && a.scopes != NULL)
result = __libdw_visit_scopes (0, &cu, &origin_match, NULL, &a);
[...]
I personally like patch2 better. This way you only do two searches.
Thoughts ?
Thanks,
Sami Wagiaalla
[-- Attachment #2: patch1 --]
[-- Type: text/plain, Size: 713 bytes --]
Index: libdw/dwarf_getscopes.c
===================================================================
RCS file: /cvs/frysk/frysk-imports/elfutils/libdw/dwarf_getscopes.c,v
retrieving revision 1.3
diff -u -r1.3 dwarf_getscopes.c
--- libdw/dwarf_getscopes.c 26 Apr 2007 15:18:42 -0000 1.3
+++ libdw/dwarf_getscopes.c 19 Jul 2007 15:22:53 -0000
@@ -170,6 +170,10 @@
/* Not there yet. */
return 0;
+ struct Dwarf_Die_Chain child;
+ if (INTUSE(dwarf_child) (&die->die, &child.die) != 0)
+ return 0;
+
/* Now we are in a scope that contains the concrete inlined instance.
Search it for the inline function's abstract definition.
If we don't find it, return to search the containing scope.
[-- Attachment #3: patch2 --]
[-- Type: text/plain, Size: 1073 bytes --]
Index: libdw/dwarf_getscopes.c
===================================================================
RCS file: /cvs/frysk/frysk-imports/elfutils/libdw/dwarf_getscopes.c,v
retrieving revision 1.3
diff -u -r1.3 dwarf_getscopes.c
--- libdw/dwarf_getscopes.c 26 Apr 2007 15:18:42 -0000 1.3
+++ libdw/dwarf_getscopes.c 19 Jul 2007 15:24:47 -0000
@@ -159,23 +159,8 @@
return -1;
return 0;
}
-
-
- /* We've recorded the scopes back to one that is a concrete inlined
- instance. Now return out of the traversal back to the scope
- containing that instance. */
-
- assert (a->inlined);
- if (depth >= a->inlined)
- /* Not there yet. */
- return 0;
-
- /* Now we are in a scope that contains the concrete inlined instance.
- Search it for the inline function's abstract definition.
- If we don't find it, return to search the containing scope.
- If we do find it, the nonzero return value will bail us out
- of the postorder traversal. */
- return __libdw_visit_scopes (depth, die, &origin_match, NULL, &a);
+
+ return 0;
}
next prev parent reply other threads:[~2007-07-19 15:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-19 15:22 Sami Wagiaalla
2007-06-19 15:46 ` Sami Wagiaalla
2007-06-19 18:28 ` Sami Wagiaalla
2007-06-19 21:11 ` Sami Wagiaalla
2007-06-19 21:27 ` Roland McGrath
2007-06-19 21:31 ` Sami Wagiaalla
2007-06-19 21:31 ` Roland McGrath
2007-07-17 17:07 ` Sami Wagiaalla
2007-07-18 9:03 ` Roland McGrath
2007-07-18 15:38 ` Sami Wagiaalla
2007-07-18 22:43 ` Roland McGrath
2007-07-19 15:31 ` Sami Wagiaalla [this message]
2007-07-21 0:29 ` Roland McGrath
2007-07-26 15:42 ` Sami Wagiaalla
2007-08-07 9:04 ` Roland McGrath
2007-08-09 17:06 ` Sami Wagiaalla
2007-07-19 15:40 ` Sami Wagiaalla
2007-06-19 21:38 ` Sami Wagiaalla
2007-06-19 21:58 ` Sami Wagiaalla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=469F83A5.8090803@redhat.com \
--to=swagiaal@redhat.com \
--cc=frysk@sourceware.org \
--cc=roland@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).