This page was produced by an automated import process, and may have formatting errors; feel free to fix.

Address Classes

Sometimes information about different kinds of addresses is available via the debug information. For example, some programming environments define addresses of several different sizes. If the debug information distinguishes these kinds of address classes through either the size info (e.g, DW_AT_byte_size in DWARF 2) or through an explicit address class attribute (e.g, DW_AT_address_class in DWARF 2), the following macros should be defined in order to disambiguate these types within GDB as well as provide the added information to a GDB user when printing type expressions.

Function: ''int'' gdbarch_address_class_type_flags ''(struct gdbarch *''gdbarch'', int ''byte_size'', int ''dwarf2_addr_class'')''

Returns the type flags needed to construct a pointer type whose size is byte_size and whose address class is dwarf2_addr_class. This function is normally called from within a symbol reader. See dwarf2read.c.

Function: ''char *'' gdbarch_address_class_type_flags_to_name ''(struct gdbarch *''gdbarch'', int ''type_flags'')''

Given the type flags representing an address class qualifier, return its name.

Function: ''int'' gdbarch_address_class_name_to_type_flags ''(struct gdbarch *''gdbarch'', int ''name'', int *''type_flags_ptr'')''

Given an address qualifier name, set the int referenced by type_flags_ptr to the type flags for that address class qualifier.

Since the need for address classes is rather rare, none of the address class functions are defined by default. Predicate functions are provided to detect when they are defined.

Consider a hypothetical architecture in which addresses are normally 32-bits wide, but 16-bit addresses are also supported. Furthermore, suppose that the DWARF 2 information for this architecture simply uses a DW_AT_byte_size value of 2 to indicate the use of one of these "short" pointers. The following functions could be defined to implement the address class functions:

somearch_address_class_type_flags (int byte_size,
                                   int dwarf2_addr_class)
{
  if (byte_size == 2)
    return TYPE_FLAG_ADDRESS_CLASS_1;
  else
    return 0;
}

static char *
somearch_address_class_type_flags_to_name (int type_flags)
{
  if (type_flags & TYPE_FLAG_ADDRESS_CLASS_1)
    return "short";
  else
    return NULL;
}

int
somearch_address_class_name_to_type_flags (char *name,
                                           int *type_flags_ptr)
{
  if (strcmp (name, "short") == 0)
    {
      *type_flags_ptr = TYPE_FLAG_ADDRESS_CLASS_1;
      return 1;
    }
  else
    return 0;
}

The qualifier @short is used in GDB’s type expressions to indicate the presence of one of these “short” pointers. For example if the debug information indicates that short_ptr_var is one of these short pointers, GDB might show the following behavior:

(gdb) ptype short_ptr_var
type = int * @short

None: Internals Address-Classes (last edited 2013-08-20 23:40:17 by StanShebs)

All content (C) 2008 Free Software Foundation. For terms of use, redistribution, and modification, please see the WikiLicense page.