This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FYI: fix PR 11803
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Tue, 14 Sep 2010 13:07:25 -0600
- Subject: FYI: fix PR 11803
I am checking this in.
This is a new patch to fix PR 11803, following Pedro's and Daniel's
advice.
In this patch, instead of changing the needs-frame logic for TLS, we
simply change static field evaluation to use value_of_variable.
I also had to remove a call to SET_FIELD_PHYSADDR here. This was
definitely wrong in this particular case, and it seems less than ideal
in general: as far as I can tell, nothing ever relocates these values.
So, after the first call to objfile_relocate, they are all wrong.
Built and regtested on x86-64 (compile farm).
Tom
2010-09-14 Tom Tromey <tromey@redhat.com>
PR exp/11803:
* value.c (value_static_field): Use value_of_variable.
2010-09-14 Tom Tromey <tromey@redhat.com>
PR exp/11803:
* gdb.threads/tls.exp: Use C++.
(check_thread_local): Use K::another_thread_local.
* gdb.threads/tls.c (class K): New.
(another_thread_local): Now a member of K.
(spin): Update. No longer K&R C.
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.111
diff -u -r1.111 value.c
--- value.c 18 Aug 2010 19:13:33 -0000 1.111
+++ value.c 14 Sep 2010 19:03:40 -0000
@@ -1903,17 +1903,7 @@
}
}
else
- {
- /* SYM should never have a SYMBOL_CLASS which will require
- read_var_value to use the FRAME parameter. */
- if (symbol_read_needs_frame (sym))
- warning (_("static field's value depends on the current "
- "frame - bad debug info?"));
- retval = read_var_value (sym, NULL);
- }
- if (retval && VALUE_LVAL (retval) == lval_memory)
- SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
- value_address (retval));
+ retval = value_of_variable (sym, NULL);
break;
}
default:
Index: testsuite/gdb.threads/tls.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.c,v
retrieving revision 1.3
diff -u -r1.3 tls.c
--- testsuite/gdb.threads/tls.c 2 Dec 2008 14:51:01 -0000 1.3
+++ testsuite/gdb.threads/tls.c 14 Sep 2010 19:03:42 -0000
@@ -18,7 +18,13 @@
/* Thread-local storage. */
__thread int a_thread_local;
-__thread int another_thread_local;
+
+class K {
+ public:
+ static __thread int another_thread_local;
+};
+
+__thread int K::another_thread_local;
/* psymtabs->symtabs resolving check. */
extern __thread int file2_thread_local;
@@ -64,8 +70,7 @@
}
/* Routine for each thread to run, does nothing. */
-void *spin( vp )
- void * vp;
+void *spin( void *vp )
{
int me = (long) vp;
int i;
@@ -74,19 +79,19 @@
a_global++;
a_thread_local = 0;
- another_thread_local = me;
+ K::another_thread_local = me;
for( i = 0; i <= me; i++ ) {
a_thread_local += i;
}
- another_thread_local_val[me] = another_thread_local;
+ another_thread_local_val[me] = K::another_thread_local;
thread_local_val[ me ] = a_thread_local; /* here we know tls value */
if (sem_post (&tell_main) == -1)
{
fprintf (stderr, "th %d post on sem tell_main failed\n", me);
print_error ();
- return;
+ return NULL;
}
#ifdef START_DEBUG
fprintf (stderr, "th %d post on tell main\n", me);
@@ -111,7 +116,7 @@
{
fprintf (stderr, "th %d wait on sem tell_thread failed\n", me);
print_error ();
- return;
+ return NULL;
}
}
@@ -119,6 +124,7 @@
fprintf (stderr, "th %d Wait on tell_thread\n", me);
#endif
+ return NULL;
}
void
Index: testsuite/gdb.threads/tls.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.threads/tls.exp,v
retrieving revision 1.12
diff -u -r1.12 tls.exp
--- testsuite/gdb.threads/tls.exp 1 Jan 2010 07:32:06 -0000 1.12
+++ testsuite/gdb.threads/tls.exp 14 Sep 2010 19:03:42 -0000
@@ -27,7 +27,7 @@
set target_cflags ""
}
-if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable [list c++ debug "incdir=${objdir}"]] != "" } {
return -1
}
@@ -75,7 +75,7 @@
"= $expected_value" \
"${number} thread local storage"
- gdb_test "p another_thread_local" \
+ gdb_test "p K::another_thread_local" \
"= $me_variable" \
"${number} another thread local storage"
@@ -83,7 +83,7 @@
".*a_thread_local.*a thread-local variable at offset.*" \
"${number} info address a_thread_local"
- gdb_test "info address another_thread_local" \
+ gdb_test "info address K::another_thread_local" \
".*another_thread_local.*a thread-local variable at offset.*" \
"${number} info address another_thread_local"
}