|
From: <sv...@va...> - 2008-02-25 13:46:55
|
Author: sewardj
Date: 2008-02-25 13:46:58 +0000 (Mon, 25 Feb 2008)
New Revision: 7457
Log:
Partially fix handling of variables which have Compilation-Unit scope.
In C these correspond to top level 'static' variables.
Modified:
branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
Modified: branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-25 13:44:04 UTC (rev 7456)
+++ branches/DATASYMS/coregrind/m_debuginfo/debuginfo.c 2008-02-25 13:46:58 UTC (rev 7457)
@@ -2014,6 +2014,27 @@
in the stacks of all the threads. First try to figure out which
thread's stack data_addr is in. */
+ /* --- KLUDGE --- Try examining the top frame of all thread stacks.
+ This finds variables which are not stack allocated but are not
+ globally visible either; specifically it appears to pick up
+ variables which are visible only within a compilation unit.
+ These will have the address range of the compilation unit and
+ tend to live at Scope level 1. */
+ VG_(thread_stack_reset_iter)(&tid);
+ while ( VG_(thread_stack_next)(&tid, &stack_min, &stack_max) ) {
+ if (stack_min >= stack_max)
+ continue; /* ignore obviously stupid cases */
+ if (consider_vars_in_frame( dname1, dname2, n_dname,
+ data_addr,
+ VG_(get_IP)(tid),
+ VG_(get_SP)(tid),
+ VG_(get_FP)(tid), tid, 0 )) {
+ dname1[n_dname-1] = dname2[n_dname-1] = 0;
+ return True;
+ }
+ }
+ /* --- end KLUDGE --- */
+
/* Perhaps it's on a thread's stack? */
found = False;
VG_(thread_stack_reset_iter)(&tid);
@@ -2050,6 +2071,9 @@
all non-innermost IPs. Note that VG_(get_StackTrace_wrk) itself
has to use the same trick in order to use CFI data to unwind the
stack (as documented therein in comments). */
+ /* As a result of KLUDGE above, starting the loop at j = 0
+ duplicates examination of the top frame and so isn't necessary.
+ Oh well. */
vg_assert(n_frames >= 0 && n_frames <= N_FRAMES);
for (j = 0; j < n_frames; j++) {
Word ip_delta = j == 0 ? 0 : 1;
Modified: branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c
===================================================================
--- branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c 2008-02-25 13:44:04 UTC (rev 7456)
+++ branches/DATASYMS/coregrind/m_debuginfo/readdwarf3.c 2008-02-25 13:46:58 UTC (rev 7457)
@@ -1290,7 +1290,7 @@
UWord saved_die_c_offset = get_position_of_Cursor( c_die );
UWord saved_abbv_c_offset = get_position_of_Cursor( c_abbv );
- varstack_preen( parser, td3, level );
+ varstack_preen( parser, td3, level-1 );
if (dtag == DW_TAG_compile_unit) {
Bool have_lo = False;
|