This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
RFC: Add TARGET_BFD_VMA_BIT, builtin_type_{CORE_ADDR,ptr,bfd_vma}
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: RFC: Add TARGET_BFD_VMA_BIT, builtin_type_{CORE_ADDR,ptr,bfd_vma}
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Mon, 06 Dec 1999 21:21:55 +1100
- CC: Jimmy Guo <guo at cup dot hp dot com>
- Organization: Cygnus Solutions
Hello,
The attatched patch (hopefully) addresses some of the needs previously
identified in the e-mail threads:
Subject: (patch) hpjyg23: gdbtypes.[ch] & values.c
http://sourceware.cygnus.com/ml/gdb-patches/1999-q4/msg00250.html
Subject: Test for 32/64 bit object file?
http://sourceware.cygnus.com/ml/gdb-patches/1999-q4/msg00267.html
Briefly, those e-mails identified the need to be able to determine, at
run-time, the properties of the different addresses that GDB
manipulates.
The change:
o Introduces the gdbarch vector member:
TARGET_BFD_VMA_BIT
The size of an addressed used
in the debug format by BFD.
o Adds the builtin types:
builtin_type_CORE_ADDR
ISA address size/type.
For the moment this is
determined by TARGET_PTR_BIT.
builtin_type_ptr
The C Language pointer type
(at present identical to
CORE_ADDR but should be
used in things like C/C++
files).
This is determined by
TARGET_PTR_BIT.
builtin_type_bfd_vma
The address used by object
file relocations.
This is determined by
TARGET_BFD_VMA_BIT
The number of bytes in the builtin types being available via
TYPE_LENGTH(builtin_type).
Comments thoughts, opinions?
Andrew
Mon Dec 6 20:31:28 1999 Andrew Cagney <cagney@b1.cygnus.com>
* gdbarch.sh: Replace field init_p with invalid_p.
(TARGET_BFD_VMA_BIT): New architecture vector method. Defaults to
architecture bits_per_address.
* gdbarch.h, gdbarch.c: Update.
* defs.h (TARGET_BFD_VMA_BIT): Provide default of TARGET_PTR_BIT
for non- multi-arch case.
* gdbtypes.h (builtin_type_bfd_vma, builtin_type_ptr,
builtin_type_CORE_ADDR): New GDB specific address types.
* gdbtypes.c (_initialize_gdbtypes, build_gdbtypes): Initialize
new builtin types.
Index: defs.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/defs.h,v
retrieving revision 1.282
diff -p -r1.282 defs.h
*** defs.h 1999/12/01 16:36:50 1.282
--- defs.h 1999/12/06 09:51:58
*************** extern char *alloca ();
*** 1052,1057 ****
--- 1052,1062 ----
#define TARGET_PTR_BIT TARGET_INT_BIT
#endif
+ /* Number of bits in a BFD_VMA for the target object file format. */
+ #if !defined (TARGET_BFD_VMA_BIT)
+ #define TARGET_BFD_VMA_BIT TARGET_PTR_BIT
+ #endif
+
/* If we picked up a copy of CHAR_BIT from a configuration file
(which may get it by including <limits.h>) then use it to set
the number of bits in a host char. If not, use the same size
Index: gdbarch.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.c,v
retrieving revision 2.59
diff -p -r2.59 gdbarch.c
*** gdbarch.c 1999/10/23 07:34:08 2.59
--- gdbarch.c 1999/12/06 09:52:04
*************** struct gdbarch
*** 125,130 ****
--- 125,131 ----
*/
+ int bfd_vma_bit;
int ptr_bit;
int short_bit;
int int_bit;
*************** struct gdbarch default_gdbarch = {
*** 224,229 ****
--- 225,231 ----
0, NULL, NULL,
/* Multi-arch values */
8 * sizeof (void*),
+ 8 * sizeof (void*),
8 * sizeof (short),
8 * sizeof (int),
8 * sizeof (long),
*************** gdbarch_alloc (const struct gdbarch_info
*** 325,330 ****
--- 327,333 ----
gdbarch->byte_order = info->byte_order;
/* Force the explicit initialization of these. */
+ gdbarch->bfd_vma_bit = TARGET_ARCHITECTURE->bits_per_address;
gdbarch->num_regs = -1;
gdbarch->sp_regnum = -1;
gdbarch->fp_regnum = -1;
*************** verify_gdbarch (struct gdbarch *gdbarch)
*** 366,371 ****
--- 369,377 ----
internal_error ("verify_gdbarch: bfd_arch_info unset");
/* Check those that need to be defined for the given multi-arch level. */
if ((GDB_MULTI_ARCH >= 1)
+ && (0))
+ internal_error ("gdbarch: verify_gdbarch: bfd_vma_bit invalid");
+ if ((GDB_MULTI_ARCH >= 1)
&& (gdbarch->ptr_bit == 0))
internal_error ("gdbarch: verify_gdbarch: ptr_bit invalid");
if ((GDB_MULTI_ARCH >= 1)
*************** gdbarch_dump (void)
*** 612,617 ****
--- 618,626 ----
"gdbarch_update: TARGET_BYTE_ORDER = %ld\n",
(long) TARGET_BYTE_ORDER);
fprintf_unfiltered (gdb_stdlog,
+ "gdbarch_update: TARGET_BFD_VMA_BIT = %ld\n",
+ (long) TARGET_BFD_VMA_BIT);
+ fprintf_unfiltered (gdb_stdlog,
"gdbarch_update: TARGET_PTR_BIT = %ld\n",
(long) TARGET_PTR_BIT);
fprintf_unfiltered (gdb_stdlog,
*************** gdbarch_byte_order (struct gdbarch *gdba
*** 937,942 ****
--- 946,969 ----
/* FIXME: gdb_std??? */
fprintf_unfiltered (gdb_stdlog, "gdbarch_byte_order called\n");
return gdbarch->byte_order;
+ }
+
+ int
+ gdbarch_bfd_vma_bit (struct gdbarch *gdbarch)
+ {
+ if (0)
+ internal_error ("gdbarch: gdbarch_bfd_vma_bit invalid");
+ if (gdbarch_debug >= 2)
+ /* FIXME: gdb_std??? */
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_bfd_vma_bit called\n");
+ return gdbarch->bfd_vma_bit;
+ }
+
+ void
+ set_gdbarch_bfd_vma_bit (struct gdbarch *gdbarch,
+ int bfd_vma_bit)
+ {
+ gdbarch->bfd_vma_bit = bfd_vma_bit;
}
int
Index: gdbarch.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbarch.h,v
retrieving revision 2.61
diff -p -r2.61 gdbarch.h
*** gdbarch.h 1999/10/25 08:17:47 2.61
--- gdbarch.h 1999/12/06 09:52:06
*************** extern int gdbarch_byte_order (struct gd
*** 99,104 ****
--- 99,112 ----
/* The following are initialized by the target dependant code. */
+ extern int gdbarch_bfd_vma_bit (struct gdbarch *gdbarch);
+ extern void set_gdbarch_bfd_vma_bit (struct gdbarch *gdbarch, int bfd_vma_bit);
+ #if GDB_MULTI_ARCH
+ #if (GDB_MULTI_ARCH > 1) || !defined (TARGET_BFD_VMA_BIT)
+ #define TARGET_BFD_VMA_BIT (gdbarch_bfd_vma_bit (current_gdbarch))
+ #endif
+ #endif
+
extern int gdbarch_ptr_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_ptr_bit (struct gdbarch *gdbarch, int ptr_bit);
#if GDB_MULTI_ARCH
Index: gdbtypes.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbtypes.c,v
retrieving revision 2.100
diff -p -r2.100 gdbtypes.c
*** gdbtypes.c 1999/12/01 22:31:47 2.100
--- gdbtypes.c 1999/12/06 09:52:19
*************** struct type *builtin_type_v4si;
*** 74,79 ****
--- 74,82 ----
struct type *builtin_type_v8qi;
struct type *builtin_type_v4hi;
struct type *builtin_type_v2si;
+ struct type *builtin_type_ptr;
+ struct type *builtin_type_CORE_ADDR;
+ struct type *builtin_type_bfd_vma;
int opaque_type_resolution = 1;
*************** build_gdbtypes ()
*** 2994,2999 ****
--- 2997,3019 ----
= init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4);
builtin_type_v2si
= init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
+
+ /* Pointer/Address types. */
+ /* NOTE: At present there is no way of differentiating between at
+ target address and the target C language pointer type type even
+ though the two can be different (cf d10v) */
+ builtin_type_ptr =
+ init_type (TYPE_CODE_INT, TARGET_PTR_BIT / 8,
+ TYPE_FLAG_UNSIGNED,
+ "__ptr", (struct objfile *) NULL);
+ builtin_type_CORE_ADDR =
+ init_type (TYPE_CODE_INT, TARGET_PTR_BIT / 8,
+ TYPE_FLAG_UNSIGNED,
+ "__CORE_ADDR", (struct objfile *) NULL);
+ builtin_type_bfd_vma =
+ init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8,
+ TYPE_FLAG_UNSIGNED,
+ "__bfd_vma", (struct objfile *) NULL);
}
*************** _initialize_gdbtypes ()
*** 3041,3045 ****
--- 3061,3068 ----
register_gdbarch_swap (&builtin_type_v8qi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v4hi, sizeof (struct type *), NULL);
register_gdbarch_swap (&builtin_type_v2si, sizeof (struct type *), NULL);
+ REGISTER_GDBARCH_SWAP (builtin_type_ptr);
+ REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
+ REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
register_gdbarch_swap (NULL, 0, build_gdbtypes);
}
Index: gdbtypes.h
===================================================================
RCS file: /cvs/cvsfiles/devo/gdb/gdbtypes.h,v
retrieving revision 2.77
diff -p -r2.77 gdbtypes.h
*** gdbtypes.h 1999/12/01 22:31:49 2.77
--- gdbtypes.h 1999/12/06 09:52:29
*************** extern struct type *builtin_type_double_
*** 846,852 ****
extern struct type *builtin_type_string;
extern struct type *builtin_type_bool;
! /* Explicit sizes - see <intypes.h> for naming schema */
extern struct type *builtin_type_int8;
extern struct type *builtin_type_uint8;
extern struct type *builtin_type_int16;
--- 846,863 ----
extern struct type *builtin_type_string;
extern struct type *builtin_type_bool;
! /* Address/pointer types: */
! /* (C) Language pointer type. Some target platforms use an implicitly
! {sign,zero} -extended 32 bit C language pointer on a 64 bit ISA. */
! extern struct type *builtin_type_ptr;
! /* The target CPU's address type. This is the ISA address size. */
! extern struct type *builtin_type_CORE_ADDR;
! /* The symbol table address type. Some object file formats have a 32
! bit address type even though the TARGET has a 64 bit pointer type
! (cf MIPS). */
! extern struct type *builtin_type_bfd_vma;
!
! /* Explicit sizes - see C9X <intypes.h> for naming scheme */
extern struct type *builtin_type_int8;
extern struct type *builtin_type_uint8;
extern struct type *builtin_type_int16;