* [PATCH] C++ Dwarf2 inner scope PR/789
@ 2002-10-07 21:10 David Edelsohn
2002-10-10 13:26 ` Jim Blandy
2002-10-10 13:27 ` Jim Blandy
0 siblings, 2 replies; 6+ messages in thread
From: David Edelsohn @ 2002-10-07 21:10 UTC (permalink / raw)
To: gdb-patches
While debugging a C++ application compiled with g++-3.2 and Dwarf2
debugging information, we discovered that some functions would not have
any symbols available. This problem occurs when a method is defined
inside a class-local function and prevents any symbols from appearing.
We traced this back to gdb/dwarf2read.c:read_func_scope(). That
function is called recursively for the inner scope, but it currently is
written to always pop back to file scope instead of the previous scope.
The appended patch saves the current scope in a local variable on the
stack and restores that scope after parsing the inner scope. This allows
global symbols to be seen, but we still have not been able to fix the
innermost scope problem.
Thanks, David
--- dwarf2read.c.orig Sun Oct 6 15:00:32 2002
+++ dwarf2read.c Sun Oct 6 14:05:39 2002
@@ -1663,6 +1663,7 @@ read_func_scope (struct die_info *die, s
struct die_info *child_die;
struct attribute *attr;
char *name;
+ struct pending **prev_list_in_scope;
name = dwarf2_linkage_name (die);
@@ -1704,6 +1705,7 @@ read_func_scope (struct die_info *die, s
new = push_context (0, lowpc);
new->name = new_symbol (die, die->type, objfile, cu_header);
+ prev_list_in_scope = list_in_scope;
list_in_scope = &local_symbols;
if (die->has_children)
@@ -1720,7 +1722,10 @@ read_func_scope (struct die_info *die, s
/* Make a block for the local symbols within. */
finish_block (new->name, &local_symbols, new->old_blocks,
lowpc, highpc, objfile);
- list_in_scope = &file_symbols;
+
+ local_symbols = new->locals;
+ param_symbols = new->params;
+ list_in_scope = prev_list_in_scope;
}
/* Process all the DIES contained within a lexical block scope. Start
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] C++ Dwarf2 inner scope PR/789
2002-10-07 21:10 [PATCH] C++ Dwarf2 inner scope PR/789 David Edelsohn
@ 2002-10-10 13:26 ` Jim Blandy
2002-10-10 13:27 ` David Edelsohn
2002-10-10 13:27 ` Jim Blandy
1 sibling, 1 reply; 6+ messages in thread
From: Jim Blandy @ 2002-10-10 13:26 UTC (permalink / raw)
To: David Edelsohn; +Cc: gdb-patches
Could you provide a test case for this?
David Edelsohn <dje@watson.ibm.com> writes:
> While debugging a C++ application compiled with g++-3.2 and Dwarf2
> debugging information, we discovered that some functions would not have
> any symbols available. This problem occurs when a method is defined
> inside a class-local function and prevents any symbols from appearing.
>
> We traced this back to gdb/dwarf2read.c:read_func_scope(). That
> function is called recursively for the inner scope, but it currently is
> written to always pop back to file scope instead of the previous scope.
> The appended patch saves the current scope in a local variable on the
> stack and restores that scope after parsing the inner scope. This allows
> global symbols to be seen, but we still have not been able to fix the
> innermost scope problem.
>
> Thanks, David
>
>
> --- dwarf2read.c.orig Sun Oct 6 15:00:32 2002
> +++ dwarf2read.c Sun Oct 6 14:05:39 2002
> @@ -1663,6 +1663,7 @@ read_func_scope (struct die_info *die, s
> struct die_info *child_die;
> struct attribute *attr;
> char *name;
> + struct pending **prev_list_in_scope;
>
> name = dwarf2_linkage_name (die);
>
> @@ -1704,6 +1705,7 @@ read_func_scope (struct die_info *die, s
>
> new = push_context (0, lowpc);
> new->name = new_symbol (die, die->type, objfile, cu_header);
> + prev_list_in_scope = list_in_scope;
> list_in_scope = &local_symbols;
>
> if (die->has_children)
> @@ -1720,7 +1722,10 @@ read_func_scope (struct die_info *die, s
> /* Make a block for the local symbols within. */
> finish_block (new->name, &local_symbols, new->old_blocks,
> lowpc, highpc, objfile);
> - list_in_scope = &file_symbols;
> +
> + local_symbols = new->locals;
> + param_symbols = new->params;
> + list_in_scope = prev_list_in_scope;
> }
>
> /* Process all the DIES contained within a lexical block scope. Start
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] C++ Dwarf2 inner scope PR/789
2002-10-10 13:26 ` Jim Blandy
@ 2002-10-10 13:27 ` David Edelsohn
2002-10-28 13:37 ` David Edelsohn
0 siblings, 1 reply; 6+ messages in thread
From: David Edelsohn @ 2002-10-10 13:27 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches
>>>>> Jim Blandy writes:
Jim> Could you provide a test case for this?
That's why I listed the PR number. The testcase and the patch
both are attached to the PR in the GDB bugs database.
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] C++ Dwarf2 inner scope PR/789
2002-10-10 13:27 ` David Edelsohn
@ 2002-10-28 13:37 ` David Edelsohn
2002-11-04 13:19 ` Jim Blandy
0 siblings, 1 reply; 6+ messages in thread
From: David Edelsohn @ 2002-10-28 13:37 UTC (permalink / raw)
To: gdb-patches
Any status on PR gdb/789 and the patch earlier in this thread?
Thanks, David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] C++ Dwarf2 inner scope PR/789
2002-10-28 13:37 ` David Edelsohn
@ 2002-11-04 13:19 ` Jim Blandy
0 siblings, 0 replies; 6+ messages in thread
From: Jim Blandy @ 2002-11-04 13:19 UTC (permalink / raw)
To: David Edelsohn; +Cc: gdb-patches
David Edelsohn <dje@watson.ibm.com> writes:
> Any status on PR gdb/789 and the patch earlier in this thread?
I think the patch breaks into two parts:
First, restoring local_symbols and param_symbols from the popped
context seems right. That's a two-line fix, so I'll just make it
myself, with credit to you.
I think restoring prev_list_in_scope can be done more simply, by
checking whether context_stack is empty: if it is, then the list in
scope is file_symbols; otherwise, it's local_symbols.
However, I've seen some odd behavior when running your test case that
I want to understand before I proceed with this. I appreciate your
patience.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] C++ Dwarf2 inner scope PR/789
2002-10-07 21:10 [PATCH] C++ Dwarf2 inner scope PR/789 David Edelsohn
2002-10-10 13:26 ` Jim Blandy
@ 2002-10-10 13:27 ` Jim Blandy
1 sibling, 0 replies; 6+ messages in thread
From: Jim Blandy @ 2002-10-10 13:27 UTC (permalink / raw)
To: David Edelsohn; +Cc: gdb-patches
To be clear, I don't mean a whole dejagnu .exp thingy (although that
would be nice); I mean just a specific C++ program I can compile and
use to try to reproduce the problem myself.
Jim Blandy writes:
> Could you provide a test case for this?
>
> David Edelsohn <dje@watson.ibm.com> writes:
>
> > While debugging a C++ application compiled with g++-3.2 and Dwarf2
> > debugging information, we discovered that some functions would not have
> > any symbols available. This problem occurs when a method is defined
> > inside a class-local function and prevents any symbols from appearing.
> >
> > We traced this back to gdb/dwarf2read.c:read_func_scope(). That
> > function is called recursively for the inner scope, but it currently is
> > written to always pop back to file scope instead of the previous scope.
> > The appended patch saves the current scope in a local variable on the
> > stack and restores that scope after parsing the inner scope. This allows
> > global symbols to be seen, but we still have not been able to fix the
> > innermost scope problem.
> >
> > Thanks, David
> >
> >
> > --- dwarf2read.c.orig Sun Oct 6 15:00:32 2002
> > +++ dwarf2read.c Sun Oct 6 14:05:39 2002
> > @@ -1663,6 +1663,7 @@ read_func_scope (struct die_info *die, s
> > struct die_info *child_die;
> > struct attribute *attr;
> > char *name;
> > + struct pending **prev_list_in_scope;
> >
> > name = dwarf2_linkage_name (die);
> >
> > @@ -1704,6 +1705,7 @@ read_func_scope (struct die_info *die, s
> >
> > new = push_context (0, lowpc);
> > new->name = new_symbol (die, die->type, objfile, cu_header);
> > + prev_list_in_scope = list_in_scope;
> > list_in_scope = &local_symbols;
> >
> > if (die->has_children)
> > @@ -1720,7 +1722,10 @@ read_func_scope (struct die_info *die, s
> > /* Make a block for the local symbols within. */
> > finish_block (new->name, &local_symbols, new->old_blocks,
> > lowpc, highpc, objfile);
> > - list_in_scope = &file_symbols;
> > +
> > + local_symbols = new->locals;
> > + param_symbols = new->params;
> > + list_in_scope = prev_list_in_scope;
> > }
> >
> > /* Process all the DIES contained within a lexical block scope. Start
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2002-11-04 21:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-07 21:10 [PATCH] C++ Dwarf2 inner scope PR/789 David Edelsohn
2002-10-10 13:26 ` Jim Blandy
2002-10-10 13:27 ` David Edelsohn
2002-10-28 13:37 ` David Edelsohn
2002-11-04 13:19 ` Jim Blandy
2002-10-10 13:27 ` Jim Blandy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox