mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 14:39:09 +08:00
gdb/
Fix resolving external references to TLS variables. * findvar.c: Include `objfiles.h'. (read_var_value <LOC_UNRESOLVED>): New variable `obj_section'. Handle SEC_THREAD_LOCAL variables. * printcmd.c (address_info <LOC_UNRESOLVED>): Handle SEC_THREAD_LOCAL variables. gdb/testsuite/ Test resolving external references to TLS variables. * gdb.threads/tls.exp: New tests to examine A_THREAD_LOCAL and FILE2_THREAD_LOCAL. (testfile2, srcfile2): New variables. * gdb.threads/tls.c (file2_thread_local) (function_referencing_file2_thread_local): New. * gdb.threads/tls2.c: New file.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2008-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
Fix resolving external references to TLS variables.
|
||||||
|
* findvar.c: Include `objfiles.h'.
|
||||||
|
(read_var_value <LOC_UNRESOLVED>): New variable `obj_section'. Handle
|
||||||
|
SEC_THREAD_LOCAL variables.
|
||||||
|
* printcmd.c (address_info <LOC_UNRESOLVED>): Handle SEC_THREAD_LOCAL
|
||||||
|
variables.
|
||||||
|
|
||||||
2008-12-02 Doug Evans <dje@google.com>
|
2008-12-02 Doug Evans <dje@google.com>
|
||||||
|
|
||||||
* infrun.c (handle_inferior_event): Delete unused local tp.
|
* infrun.c (handle_inferior_event): Delete unused local tp.
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include "regcache.h"
|
#include "regcache.h"
|
||||||
#include "user-regs.h"
|
#include "user-regs.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
|
#include "objfiles.h"
|
||||||
|
|
||||||
/* Basic byte-swapping routines. GDB has needed these for a long time...
|
/* Basic byte-swapping routines. GDB has needed these for a long time...
|
||||||
All extract a target-format integer at ADDR which is LEN bytes long. */
|
All extract a target-format integer at ADDR which is LEN bytes long. */
|
||||||
@ -536,6 +537,7 @@ read_var_value (struct symbol *var, struct frame_info *frame)
|
|||||||
case LOC_UNRESOLVED:
|
case LOC_UNRESOLVED:
|
||||||
{
|
{
|
||||||
struct minimal_symbol *msym;
|
struct minimal_symbol *msym;
|
||||||
|
struct obj_section *obj_section;
|
||||||
|
|
||||||
msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
|
msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (var), NULL, NULL);
|
||||||
if (msym == NULL)
|
if (msym == NULL)
|
||||||
@ -545,6 +547,11 @@ read_var_value (struct symbol *var, struct frame_info *frame)
|
|||||||
SYMBOL_OBJ_SECTION (msym));
|
SYMBOL_OBJ_SECTION (msym));
|
||||||
else
|
else
|
||||||
addr = SYMBOL_VALUE_ADDRESS (msym);
|
addr = SYMBOL_VALUE_ADDRESS (msym);
|
||||||
|
|
||||||
|
obj_section = SYMBOL_OBJ_SECTION (msym);
|
||||||
|
if (obj_section
|
||||||
|
&& (obj_section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
|
||||||
|
addr = target_translate_tls_address (obj_section->objfile, addr);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1241,8 +1241,16 @@ address_info (char *exp, int from_tty)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
section = SYMBOL_OBJ_SECTION (msym);
|
section = SYMBOL_OBJ_SECTION (msym);
|
||||||
printf_filtered (_("static storage at address "));
|
|
||||||
load_addr = SYMBOL_VALUE_ADDRESS (msym);
|
load_addr = SYMBOL_VALUE_ADDRESS (msym);
|
||||||
|
|
||||||
|
if (section
|
||||||
|
&& (section->the_bfd_section->flags & SEC_THREAD_LOCAL) != 0)
|
||||||
|
printf_filtered (_("a thread-local variable at offset %s "
|
||||||
|
"in the thread-local storage for `%s'"),
|
||||||
|
paddr_nz (load_addr), section->objfile->name);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf_filtered (_("static storage at address "));
|
||||||
fputs_filtered (paddress (load_addr), gdb_stdout);
|
fputs_filtered (paddress (load_addr), gdb_stdout);
|
||||||
if (section_is_overlay (section))
|
if (section_is_overlay (section))
|
||||||
{
|
{
|
||||||
@ -1254,6 +1262,7 @@ address_info (char *exp, int from_tty)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOC_OPTIMIZED_OUT:
|
case LOC_OPTIMIZED_OUT:
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2008-12-02 Jan Kratochvil <jan.kratochvil@redhat.com>
|
||||||
|
|
||||||
|
Test resolving external references to TLS variables.
|
||||||
|
* gdb.threads/tls.exp: New tests to examine A_THREAD_LOCAL and
|
||||||
|
FILE2_THREAD_LOCAL.
|
||||||
|
(testfile2, srcfile2): New variables.
|
||||||
|
* gdb.threads/tls.c (file2_thread_local)
|
||||||
|
(function_referencing_file2_thread_local): New.
|
||||||
|
* gdb.threads/tls2.c: New file.
|
||||||
|
|
||||||
2008-11-28 Joel Brobecker <brobecker@adacore.com>
|
2008-11-28 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
* gdb.ada/int_deref.exp: Convert the addresses into long_integer
|
* gdb.ada/int_deref.exp: Convert the addresses into long_integer
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
__thread int a_thread_local;
|
__thread int a_thread_local;
|
||||||
__thread int another_thread_local;
|
__thread int another_thread_local;
|
||||||
|
|
||||||
|
/* psymtabs->symtabs resolving check. */
|
||||||
|
extern __thread int file2_thread_local;
|
||||||
|
|
||||||
/* Global variable just for info addr in gdb. */
|
/* Global variable just for info addr in gdb. */
|
||||||
int a_global;
|
int a_global;
|
||||||
|
|
||||||
@ -118,6 +121,12 @@ void *spin( vp )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
function_referencing_file2_thread_local (void)
|
||||||
|
{
|
||||||
|
file2_thread_local = file2_thread_local;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
do_pass()
|
do_pass()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
set testfile tls
|
set testfile tls
|
||||||
|
set testfile2 tls2
|
||||||
set srcfile ${testfile}.c
|
set srcfile ${testfile}.c
|
||||||
|
set srcfile2 ${testfile2}.c
|
||||||
set binfile ${objdir}/${subdir}/${testfile}
|
set binfile ${objdir}/${subdir}/${testfile}
|
||||||
|
|
||||||
if [istarget "*-*-linux"] then {
|
if [istarget "*-*-linux"] then {
|
||||||
@ -24,7 +26,7 @@ if [istarget "*-*-linux"] then {
|
|||||||
set target_cflags ""
|
set target_cflags ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
|
if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile2}" "${binfile}" executable [list debug "incdir=${objdir}"]] != "" } {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +286,20 @@ gdb_test "info address a_global" \
|
|||||||
setup_kfail "gdb/1294" "*-*-*"
|
setup_kfail "gdb/1294" "*-*-*"
|
||||||
gdb_test "info address me" ".*me.*is a variable at offset.*" "info address me"
|
gdb_test "info address me" ".*me.*is a variable at offset.*" "info address me"
|
||||||
|
|
||||||
|
|
||||||
|
# Test LOC_UNRESOLVED references resolving for `extern' TLS variables.
|
||||||
|
|
||||||
|
gdb_test "p a_thread_local" " = \[0-9\]+"
|
||||||
|
# Here it could crash with: Cannot access memory at address 0x0
|
||||||
|
gdb_test "p file2_thread_local" " = \[0-9\]+"
|
||||||
|
# Depending on the current lookup scope we get LOC_UNRESOLVED or LOC_COMPUTED
|
||||||
|
# both printing:
|
||||||
|
# Symbol "file2_thread_local" is a thread-local variable at offset 8 in the thread-local storage for `.../gdb.threads/tls'.
|
||||||
|
gdb_test "info address file2_thread_local" "Symbol \"file2_thread_local\" is a thread-local variable.*"
|
||||||
|
# Here it could also crash with: Cannot access memory at address 0x0
|
||||||
|
gdb_test "p a_thread_local" " = \[0-9\]+" "p a_thread_local second time"
|
||||||
|
gdb_test "info address a_thread_local" "Symbol \"a_thread_local\" is a thread-local variable.*"
|
||||||
|
|
||||||
# Done!
|
# Done!
|
||||||
#
|
#
|
||||||
gdb_exit
|
gdb_exit
|
||||||
|
28
gdb/testsuite/gdb.threads/tls2.c
Normal file
28
gdb/testsuite/gdb.threads/tls2.c
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* This testcase is part of GDB, the GNU debugger.
|
||||||
|
|
||||||
|
Copyright 2008 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Please email any bugs, comments, and/or additions to this file to:
|
||||||
|
bug-gdb@prep.ai.mit.edu */
|
||||||
|
|
||||||
|
extern __thread int a_thread_local;
|
||||||
|
__thread int file2_thread_local;
|
||||||
|
|
||||||
|
void
|
||||||
|
function_referencing_a_thread_local (void)
|
||||||
|
{
|
||||||
|
a_thread_local = a_thread_local;
|
||||||
|
}
|
Reference in New Issue
Block a user