From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10340 invoked by alias); 12 Oct 2005 15:59:32 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10333 invoked by uid 22791); 12 Oct 2005 15:59:28 -0000 Received: from ns.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Wed, 12 Oct 2005 15:59:28 +0000 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id D786FE0BB for ; Wed, 12 Oct 2005 17:59:22 +0200 (CEST) From: Andreas Schwab To: gdb-patches@sources.redhat.com Subject: Re: Broken cast in linux-thread-db References: <20051012142427.GA21308@nevyn.them.org> <20051012144130.GA21870@nevyn.them.org> X-Yow: Hmmm... an arrogant bouquet with a subtle suggestion of POLYVINYL CHLORIDE... Date: Wed, 12 Oct 2005 15:59:00 -0000 In-Reply-To: <20051012144130.GA21870@nevyn.them.org> (Daniel Jacobowitz's message of "Wed, 12 Oct 2005 10:41:30 -0400") Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2005-10/txt/msg00110.txt.bz2 Daniel Jacobowitz writes: > Well presumably it honors POINTERS_EXTEND_UNSIGNED. No. http://gcc.gnu.org/onlinedocs/gcc/Arrays-and-pointers-implementation.html#Arrays-and-pointers-implementation >> If notify.u.bptaddr has the high bit set it will be sign extended, but the >> breakpoint address when the thread event breakpoint is hit will be zero >> extended, so they don't match and the breakpoint is not recognized. > > Then this will break thread debugging on MIPS, where the breakpoint > address will be sign extended. Note that CORE_ADDR is always unsigned, even on MIPS. > We'll only be in linux-thread-db.c if we have enough symbols to load > shared libraries; maybe bfd_get_sign_extend_vma (exec_bfd) and assert > that exec_bfd is provided? Like this? 2005-10-12 Andreas Schwab * Makefile.in (linux-thread-db.o): Depend on $(gdbcore_h). * linux-thread-db.c (enable_thread_event): Extend pointer value as specified by target. (thread_db_get_thread_local_address): Likewise. Index: gdb/Makefile.in =================================================================== RCS file: /cvs/src/src/gdb/Makefile.in,v retrieving revision 1.755 diff -u -a -p -u -p -a -r1.755 gdb/Makefile.in --- gdb/Makefile.in 28 Sep 2005 02:55:41 -0000 1.755 +++ gdb/Makefile.in 12 Oct 2005 15:11:48 -0000 @@ -2182,7 +2182,7 @@ linux-nat.o: linux-nat.c $(defs_h) $(inf linux-thread-db.o: linux-thread-db.c $(defs_h) $(gdb_assert_h) \ $(gdb_proc_service_h) $(gdb_thread_db_h) $(bfd_h) $(exceptions_h) \ $(gdbthread_h) $(inferior_h) $(symfile_h) $(objfiles_h) $(target_h) \ - $(regcache_h) $(solib_svr4_h) + $(regcache_h) $(solib_svr4_h) $(gdbcore_h) lynx-nat.o: lynx-nat.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) \ $(gdbcore_h) $(regcache_h) m2-exp.o: m2-exp.c $(defs_h) $(gdb_string_h) $(expression_h) $(language_h) \ --- gdb/linux-thread-db.c 12 Sep 2005 11:04:57 +0200 1.10 +++ gdb/linux-thread-db.c 12 Okt 2005 15:11:31 +0200 @@ -36,6 +36,7 @@ #include "target.h" #include "regcache.h" #include "solib-svr4.h" +#include "gdbcore.h" #ifdef HAVE_GNU_LIBC_VERSION_H #include @@ -505,9 +506,14 @@ enable_thread_event (td_thragent_t *thre return err; /* Set up the breakpoint. */ - (*bp) = gdbarch_convert_from_func_ptr_addr (current_gdbarch, - (CORE_ADDR) notify.u.bptaddr, - ¤t_target); + gdb_assert (exec_bfd); + (*bp) = (gdbarch_convert_from_func_ptr_addr + (current_gdbarch, + /* Do proper sign extension for the target. */ + (bfd_get_sign_extend_vma (exec_bfd) > 0 + ? (CORE_ADDR) (intptr_t) notify.u.bptaddr + : (CORE_ADDR) (uintptr_t) notify.u.bptaddr), + ¤t_target)); create_thread_event_breakpoint ((*bp)); return TD_OK; @@ -1277,7 +1283,11 @@ thread_db_get_thread_local_address (ptid (("%s")), thread_db_err_str (err)); /* Cast assuming host == target. Joy. */ - return (CORE_ADDR) address; + /* Do proper sign extension for the target. */ + gdb_assert (exec_bfd); + return (bfd_get_sign_extend_vma (exec_bfd) > 0 + ? (CORE_ADDR) (intptr_t) address + : (CORE_ADDR) (uintptr_t) address); } if (target_beneath->to_get_thread_local_address) Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."