From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13603 invoked by alias); 27 Aug 2008 17:46:55 -0000 Received: (qmail 13594 invoked by uid 22791); 27 Aug 2008 17:46:55 -0000 X-Spam-Check-By: sourceware.org Received: from mail-gx0-f22.google.com (HELO mail-gx0-f22.google.com) (209.85.217.22) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 27 Aug 2008 17:46:16 +0000 Received: by gxk3 with SMTP id 3so3782368gxk.0 for ; Wed, 27 Aug 2008 10:46:13 -0700 (PDT) Received: by 10.214.241.14 with SMTP id o14mr309480qah.92.1219859173730; Wed, 27 Aug 2008 10:46:13 -0700 (PDT) Received: from ?192.168.1.5? ( [200.161.1.30]) by mx.google.com with ESMTPS id 7sm20607267qwb.7.2008.08.27.10.46.10 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 27 Aug 2008 10:46:12 -0700 (PDT) Message-Id: From: "Dr. Rolf Jansen" To: gdb-patches@sourceware.org In-Reply-To: <20080827135553.GA19948@caradoc.them.org> Content-Type: multipart/mixed; boundary=Apple-Mail-3-1033797679 Mime-Version: 1.0 (Apple Message framework v928.1) Subject: Re: Two minor issues Date: Wed, 27 Aug 2008 17:46:00 -0000 References: <16C866B7-F5D2-4D95-922F-9D19ABC54D45@gmail.com> <1219844750.6615.4.camel@localhost.localdomain> <20080827135553.GA19948@caradoc.them.org> X-Mailer: Apple Mail (2.928.1) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00636.txt.bz2 --Apple-Mail-3-1033797679 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Content-length: 943 Am 27.08.2008 um 10:55 schrieb Daniel Jacobowitz: > On Wed, Aug 27, 2008 at 10:45:49AM -0300, Thiago Jung Bauermann wrote: >> On Wed, 2008-08-27 at 08:55 -0300, Dr. Rolf Jansen wrote: >>> Is there a global way to find out at compile-time at the build or >>> host >>> system the ptr-size and the long-size of the configured target >>> machine, something like size_attarget_of()? >> >> It's not enough to do that at compile time, since some targets >> support >> running both 32-bit and 64-bit programs (e.g., ppc64-linux). You can >> check at runtime, if you have a struct gdbarch nearby: > > Not in arch-independent code: > >> struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); > > since tdep is Target-DEPendent. But you can use the TYPE_LENGTH of > builtin types; see e.g. gnu-v3-abi.c. Thiago and Daniel, many thanks for your reply. I applied the proposal of Daniel to my working copy of objc-lang.c. Best regards Rolf Jansen --Apple-Mail-3-1033797679 Content-Disposition: attachment; filename*=WINDOWS-1252''Diff%201.66%20vs.%20Local%20%97%20objc%2Dlang.c Content-Type: application/octet-stream; x-unix-mode=0644; name="=?WINDOWS-1252?Q?Diff_1.66_vs._Local_=97_objc-lang.c?=" Content-Transfer-Encoding: 7bit Content-length: 5449 *** /var/folders/wT/wTZoT-C42RWBaSo8KCeiik+++TI/-Tmp-/.XcodeSCMTemp/temp916B2456.1.66.objc-lang.c Wed Aug 27 14:43:11 2008 --- /Users/Rolf/Desktop/xcxdb/gdb/objc-lang.c Wed Aug 27 14:31:30 2008 *************** _initialize_objc_language (void) *** 1568,1623 **** static void read_objc_method (CORE_ADDR addr, struct objc_method *method) { ! method->name = read_memory_unsigned_integer (addr + 0, 4); ! method->types = read_memory_unsigned_integer (addr + 4, 4); ! method->imp = read_memory_unsigned_integer (addr + 8, 4); } static unsigned long read_objc_methlist_nmethods (CORE_ADDR addr) { ! return read_memory_unsigned_integer (addr + 4, 4); } static void read_objc_methlist_method (CORE_ADDR addr, unsigned long num, struct objc_method *method) { gdb_assert (num < read_objc_methlist_nmethods (addr)); ! read_objc_method (addr + 8 + (12 * num), method); } static void read_objc_object (CORE_ADDR addr, struct objc_object *object) { ! object->isa = read_memory_unsigned_integer (addr, 4); } static void read_objc_super (CORE_ADDR addr, struct objc_super *super) { ! super->receiver = read_memory_unsigned_integer (addr, 4); ! super->class = read_memory_unsigned_integer (addr + 4, 4); }; static void read_objc_class (CORE_ADDR addr, struct objc_class *class) { ! class->isa = read_memory_unsigned_integer (addr, 4); ! class->super_class = read_memory_unsigned_integer (addr + 4, 4); ! class->name = read_memory_unsigned_integer (addr + 8, 4); ! class->version = read_memory_unsigned_integer (addr + 12, 4); ! class->info = read_memory_unsigned_integer (addr + 16, 4); ! class->instance_size = read_memory_unsigned_integer (addr + 18, 4); ! class->ivars = read_memory_unsigned_integer (addr + 24, 4); ! class->methods = read_memory_unsigned_integer (addr + 28, 4); ! class->cache = read_memory_unsigned_integer (addr + 32, 4); ! class->protocols = read_memory_unsigned_integer (addr + 36, 4); } static CORE_ADDR find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel) { CORE_ADDR subclass = class; while (subclass != 0) --- 1568,1634 ---- static void read_objc_method (CORE_ADDR addr, struct objc_method *method) { ! int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); ! method->name = read_memory_unsigned_integer (addr, addrsize); ! method->types = read_memory_unsigned_integer (addr += addrsize, addrsize); ! method->imp = read_memory_unsigned_integer (addr + addrsize, addrsize); } static unsigned long read_objc_methlist_nmethods (CORE_ADDR addr) { ! int intsize = TYPE_LENGTH (builtin_type_int); ! int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); ! return read_memory_unsigned_integer (addr + addrsize, intsize); } static void read_objc_methlist_method (CORE_ADDR addr, unsigned long num, struct objc_method *method) { + int intsize = TYPE_LENGTH (builtin_type_int); + int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); + // Apples 64bit ObjC runtime contains an extra int field + int offset = (addrsize == 8) ? addrsize + 2*intsize : addrsize + intsize; gdb_assert (num < read_objc_methlist_nmethods (addr)); ! read_objc_method (addr + offset + (3 * addrsize * num), method); } static void read_objc_object (CORE_ADDR addr, struct objc_object *object) { ! object->isa = read_memory_unsigned_integer (addr, TYPE_LENGTH (builtin_type_void_data_ptr)); } static void read_objc_super (CORE_ADDR addr, struct objc_super *super) { ! int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); ! super->receiver = read_memory_unsigned_integer (addr, addrsize); ! super->class = read_memory_unsigned_integer (addr + addrsize, addrsize); }; static void read_objc_class (CORE_ADDR addr, struct objc_class *class) { ! int longsize = TYPE_LENGTH (builtin_type_long); ! int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); ! class->isa = read_memory_unsigned_integer (addr, addrsize); ! class->super_class = read_memory_unsigned_integer (addr += addrsize, addrsize); ! class->name = read_memory_unsigned_integer (addr += addrsize, addrsize); ! class->version = read_memory_unsigned_integer (addr += addrsize, longsize); ! class->info = read_memory_unsigned_integer (addr += longsize, longsize); ! class->instance_size = read_memory_unsigned_integer (addr += longsize, longsize); ! class->ivars = read_memory_unsigned_integer (addr += longsize, addrsize); ! class->methods = read_memory_unsigned_integer (addr += addrsize, addrsize); ! class->cache = read_memory_unsigned_integer (addr += addrsize, addrsize); ! class->protocols = read_memory_unsigned_integer (addr + addrsize, addrsize); } static CORE_ADDR find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel) { + int addrsize = TYPE_LENGTH (builtin_type_void_data_ptr); CORE_ADDR subclass = class; while (subclass != 0) *************** find_implementation_from_class (CORE_ADD *** 1635,1641 **** unsigned long i; mlist = read_memory_unsigned_integer (class_str.methods + ! (4 * mlistnum), 4); if (mlist == 0) break; --- 1646,1652 ---- unsigned long i; mlist = read_memory_unsigned_integer (class_str.methods + ! (addrsize * mlistnum), addrsize); if (mlist == 0) break; --Apple-Mail-3-1033797679 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1 --Apple-Mail-3-1033797679--