Sourceware Bugzilla – Attachment 14302 Details for
Bug 29434
Memory leak in `dwarf_getscopes`
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
dwarf_getscopes debug trace
dwarf_getscopes_trace.patch (text/plain), 5.91 KB, created by
Mark Wielaard
on 2022-08-29 15:28:08 UTC
(
hide
)
Description:
dwarf_getscopes debug trace
Filename:
MIME Type:
Creator:
Mark Wielaard
Created:
2022-08-29 15:28:08 UTC
Size:
5.91 KB
patch
obsolete
>diff --git a/libdw/dwarf_getscopes.c b/libdw/dwarf_getscopes.c >index 5662eecf..bfd1729f 100644 >--- a/libdw/dwarf_getscopes.c >+++ b/libdw/dwarf_getscopes.c >@@ -30,6 +30,8 @@ > # include <config.h> > #endif > >+#include <stdio.h> >+ > #include <assert.h> > #include <stdlib.h> > #include "libdwP.h" >@@ -50,6 +52,9 @@ pc_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > { > struct args *a = arg; > >+ fprintf (stderr, "%*spc_match => [%lx]\n", depth, "", >+ dwarf_dieoffset (&die->die)); >+ > if (a->scopes != NULL) > die->prune = true; > else >@@ -67,6 +72,8 @@ pc_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > && error != DWARF_E_NO_DEBUG_RNGLISTS) > { > __libdw_seterrno (error); >+ fprintf (stderr, "%*spc_match <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), -1); > return -1; > } > result = 0; >@@ -79,6 +86,8 @@ pc_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > a->inlined = depth; > } > >+ fprintf (stderr, "%*spc_match <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), 0); > return 0; > } > >@@ -89,8 +98,15 @@ origin_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > { > struct args *a = arg; > >+ fprintf (stderr, "%*sorigin_match => [%lx]\n", depth, "", >+ dwarf_dieoffset (&die->die)); >+ > if (die->die.addr != a->inlined_origin.addr) >- return 0; >+ { >+ fprintf (stderr, "%*sorigin_match <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), 0); >+ return 0; >+ } > > /* We have a winner! This is the abstract definition of the inline > function of which A->scopes[A->nscopes - 1] is a concrete instance. >@@ -102,9 +118,12 @@ origin_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > { > free (a->scopes); > __libdw_seterrno (DWARF_E_NOMEM); >+ fprintf (stderr, "%*sorigin_match <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), -1); > return -1; > } > >+ struct Dwarf_Die_Chain *orig_die = die; > a->scopes = scopes; > do > { >@@ -113,6 +132,8 @@ origin_match (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > } > while (a->nscopes < nscopes); > assert (die->parent == NULL); >+ fprintf (stderr, "%*sorigin_match <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&orig_die->die), a->nscopes); > return a->nscopes; > } > >@@ -122,8 +143,15 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > { > struct args *a = arg; > >+ fprintf (stderr, "%*spc_record => [%lx]\n", depth, "", >+ dwarf_dieoffset (&die->die)); >+ > if (die->prune) >- return 0; >+ { >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), 0); >+ return 0; >+ } > > if (a->scopes == NULL) > { >@@ -134,9 +162,12 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > if (a->scopes == NULL) > { > __libdw_seterrno (DWARF_E_NOMEM); >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), -1); > return -1; > } > >+ struct Dwarf_Die_Chain *orig_die = die; > for (unsigned int i = 0; i < a->nscopes; ++i) > { > a->scopes[i] = die->die; >@@ -146,6 +177,8 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > if (a->inlined == 0) > { > assert (die == NULL); >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&orig_die->die), a->nscopes); > return a->nscopes; > } > >@@ -159,7 +192,13 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > DW_AT_abstract_origin, > &attr_mem); > if (INTUSE (dwarf_formref_die) (attr, &a->inlined_origin) == NULL) >- return -1; >+ { >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&orig_die->die), -1); >+ return -1; >+ } >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&orig_die->die), 0); > return 0; > } > >@@ -170,15 +209,23 @@ pc_record (unsigned int depth, struct Dwarf_Die_Chain *die, void *arg) > > assert (a->inlined); > if (depth >= a->inlined) >- /* Not there yet. */ >- return 0; >+ { >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), 0); >+ /* 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, NULL, &origin_match, NULL, a); >+ int ret = __libdw_visit_scopes (depth, die, NULL, &origin_match, NULL, a); >+ fprintf (stderr, "%*spc_record <= [%lx] %d\n", depth, "", >+ dwarf_dieoffset (&die->die), ret); >+ return ret; >+ > } > > >@@ -191,10 +238,22 @@ dwarf_getscopes (Dwarf_Die *cudie, Dwarf_Addr pc, Dwarf_Die **scopes) > struct Dwarf_Die_Chain cu = { .parent = NULL, .die = *cudie }; > struct args a = { .pc = pc }; > >+ fprintf (stderr, "__libdw_visit_scopes for pc 0x%lx, cudie [%lx]\n", >+ pc, dwarf_dieoffset (cudie)); > int result = __libdw_visit_scopes (0, &cu, NULL, &pc_match, &pc_record, &a); >+ fprintf (stderr, "__libdw_visit_scopes result %d, scopes %p, " >+ "inlined %d, nscopes %d\n", result, >+ a.scopes, a.inlined, a.nscopes); > > if (result == 0 && a.scopes != NULL) >- result = __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a); >+ { >+ fprintf (stderr, "__libdw_visit_scopes for origin_match 0x%lx, " >+ "cudie [%lx]\n", pc, dwarf_dieoffset (cudie)); >+ result = __libdw_visit_scopes (0, &cu, NULL, &origin_match, NULL, &a); >+ fprintf (stderr, "__libdw_visit_scopes origin_match result %d, " >+ "scopes %p, inlined %d, nscopes %d\n", result, >+ a.scopes, a.inlined, a.nscopes); >+ } > > if (result > 0) > *scopes = a.scopes;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29434
: 14302