From: "Dr. Rolf Jansen" <rolf.anroni@gmail.com>
To: gdb-patches@sourceware.org
Subject: Re: Two minor issues
Date: Wed, 27 Aug 2008 17:46:00 -0000 [thread overview]
Message-ID: <B0B77CC9-026D-4312-B9E5-5274AE8D007A@gmail.com> (raw)
In-Reply-To: <20080827135553.GA19948@caradoc.them.org>
[-- Attachment #1: Type: text/plain, Size: 943 bytes --]
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
[-- Attachment #2: Diff 1.66 vs. Local — objc-lang.c --]
[-- Type: application/octet-stream, Size: 5449 bytes --]
*** /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;
[-- Attachment #3: Type: text/plain, Size: 1 bytes --]
prev parent reply other threads:[~2008-08-27 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 11:56 Dr. Rolf Jansen
2008-08-27 13:28 ` [commit] Add missing include (Re: Two minor issues) Ulrich Weigand
2008-08-27 13:58 ` Dr. Rolf Jansen
2008-08-27 13:48 ` Two minor issues Thiago Jung Bauermann
2008-08-27 13:56 ` Daniel Jacobowitz
2008-08-27 17:46 ` Dr. Rolf Jansen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B0B77CC9-026D-4312-B9E5-5274AE8D007A@gmail.com \
--to=rolf.anroni@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox