* Two minor issues
@ 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:48 ` Two minor issues Thiago Jung Bauermann
0 siblings, 2 replies; 6+ messages in thread
From: Dr. Rolf Jansen @ 2008-08-27 11:56 UTC (permalink / raw)
To: gdb-patches
6.8.50.20080826-cvs
This GDB was configured as "--host=powerpc-apple-darwin9.4.0 --
target=i386-mingw32msvc"
1. remote.c does not compile because the new function
remote_bfd_iovec_stat() makes a reference to the stat structure and
that is not defined by default on MaC OS X. In order to fix this I
added "#include <sys/stat.h>" somewhere at the top of the file.
2. quite at the top of objc-lang.c the Class structure is declared:
struct objc_class {
CORE_ADDR isa;
CORE_ADDR super_class;
CORE_ADDR name;
long version;
long info;
long instance_size;
CORE_ADDR ivars;
CORE_ADDR methods;
CORE_ADDR cache;
CORE_ADDR protocols;
};
In read_objc_class() a variable of that struct type is filled with the
contents at a CORE_ADDR:
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);
}
As a matter of fact, this code works only for targets with a pointer-
size and long-size of 4-bytes, but even with this, the offset to class-
>instance_size shall be 20 and not 18.
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()?
Best regards
Rolf
^ permalink raw reply [flat|nested] 6+ messages in thread* [commit] Add missing include (Re: Two minor issues) 2008-08-27 11:56 Two minor issues Dr. Rolf Jansen @ 2008-08-27 13:28 ` Ulrich Weigand 2008-08-27 13:58 ` Dr. Rolf Jansen 2008-08-27 13:48 ` Two minor issues Thiago Jung Bauermann 1 sibling, 1 reply; 6+ messages in thread From: Ulrich Weigand @ 2008-08-27 13:28 UTC (permalink / raw) To: Dr. Rolf Jansen; +Cc: gdb-patches Dr. Rolf Jansen wrote: > 1. remote.c does not compile because the new function > remote_bfd_iovec_stat() makes a reference to the stat structure and > that is not defined by default on MaC OS X. In order to fix this I > added "#include <sys/stat.h>" somewhere at the top of the file. Ah, sorry for the breakage. I've committed the patch below, which should fix this problem. Thanks, Ulrich ChangeLog: * remote.c: Include "gdb_stat.h". Index: gdb/remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.307 diff -c -p -r1.307 remote.c *** gdb/remote.c 26 Aug 2008 17:30:35 -0000 1.307 --- gdb/remote.c 27 Aug 2008 13:23:03 -0000 *************** *** 59,64 **** --- 59,65 ---- #include "remote-fileio.h" #include "gdb/fileio.h" + #include "gdb_stat.h" #include "memory-map.h" -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [commit] Add missing include (Re: Two minor issues) 2008-08-27 13:28 ` [commit] Add missing include (Re: Two minor issues) Ulrich Weigand @ 2008-08-27 13:58 ` Dr. Rolf Jansen 0 siblings, 0 replies; 6+ messages in thread From: Dr. Rolf Jansen @ 2008-08-27 13:58 UTC (permalink / raw) To: gdb-patches Am 27.08.2008 um 10:27 schrieb Ulrich Weigand: > Dr. Rolf Jansen wrote: > >> 1. remote.c does not compile because the new function >> remote_bfd_iovec_stat() makes a reference to the stat structure and >> that is not defined by default on MaC OS X. In order to fix this I >> added "#include <sys/stat.h>" somewhere at the top of the file. > > Ah, sorry for the breakage. I've committed the patch below, which > should fix this problem. Many thanks. It does compile now at OS X. Best regards Rolf Jansen ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two minor issues 2008-08-27 11:56 Two minor issues Dr. Rolf Jansen 2008-08-27 13:28 ` [commit] Add missing include (Re: Two minor issues) Ulrich Weigand @ 2008-08-27 13:48 ` Thiago Jung Bauermann 2008-08-27 13:56 ` Daniel Jacobowitz 1 sibling, 1 reply; 6+ messages in thread From: Thiago Jung Bauermann @ 2008-08-27 13:48 UTC (permalink / raw) To: Dr. Rolf Jansen; +Cc: gdb-patches 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: struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); if (tdep->wordsize == 4) { ... } if (tdep->wordsize == 8) { ... } -- []'s Thiago Jung Bauermann IBM Linux Technology Center ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two minor issues 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 0 siblings, 1 reply; 6+ messages in thread From: Daniel Jacobowitz @ 2008-08-27 13:56 UTC (permalink / raw) To: Thiago Jung Bauermann; +Cc: Dr. Rolf Jansen, gdb-patches 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. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Two minor issues 2008-08-27 13:56 ` Daniel Jacobowitz @ 2008-08-27 17:46 ` Dr. Rolf Jansen 0 siblings, 0 replies; 6+ messages in thread From: Dr. Rolf Jansen @ 2008-08-27 17:46 UTC (permalink / raw) To: gdb-patches [-- 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 --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-27 17:46 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-08-27 11:56 Two minor issues 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox