/* Support for printing Fortran values for GDB, the GNU debugger.
- Copyright 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2005 Free
- Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2005, 2006,
+ 2007 Free Software Foundation, Inc.
Contributed by Motorola. Adapted from the C definitions by Farooq Butt
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdb_string.h"
int
f77_get_dynamic_lowerbound (struct type *type, int *lower_bound)
{
+ struct frame_info *frame;
CORE_ADDR current_frame_addr;
CORE_ADDR ptr_to_lower_bound;
switch (TYPE_ARRAY_LOWER_BOUND_TYPE (type))
{
case BOUND_BY_VALUE_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
*lower_bound =
break;
case BOUND_BY_REF_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
ptr_to_lower_bound =
int
f77_get_dynamic_upperbound (struct type *type, int *upper_bound)
{
+ struct frame_info *frame;
CORE_ADDR current_frame_addr = 0;
CORE_ADDR ptr_to_upper_bound;
switch (TYPE_ARRAY_UPPER_BOUND_TYPE (type))
{
case BOUND_BY_VALUE_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
*upper_bound =
break;
case BOUND_BY_REF_ON_STACK:
- current_frame_addr = get_frame_base (deprecated_selected_frame);
+ frame = deprecated_safe_get_selected_frame ();
+ current_frame_addr = get_frame_base (frame);
if (current_frame_addr > 0)
{
ptr_to_upper_bound =
static void
f77_print_array_1 (int nss, int ndimensions, struct type *type,
- const bfd_byte *valaddr, CORE_ADDR address,
+ const gdb_byte *valaddr, CORE_ADDR address,
struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty,
int *elts)
stuff and then immediately call f77_print_array_1() */
static void
-f77_print_array (struct type *type, const bfd_byte *valaddr,
+f77_print_array (struct type *type, const gdb_byte *valaddr,
CORE_ADDR address, struct ui_file *stream,
int format, int deref_ref, int recurse,
enum val_prettyprint pretty)
The PRETTY parameter controls prettyprinting. */
int
-f_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
+f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty)
{
struct type *elttype;
LONGEST val;
CORE_ADDR addr;
+ int index;
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
}
if (addressprint && format != 's')
- print_address_numeric (addr, 1, stream);
+ deprecated_print_address_numeric (addr, 1, stream);
/* For a pointer to char or unsigned char, also print the string
pointed to, unless pointer is null. */
CORE_ADDR addr
= extract_typed_address (valaddr + embedded_offset, type);
fprintf_filtered (stream, "@");
- print_address_numeric (addr, 1, stream);
+ deprecated_print_address_numeric (addr, 1, stream);
if (deref_ref)
fputs_filtered (": ", stream);
}
(TYPE_TARGET_TYPE (type),
unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr + embedded_offset));
- val_print (value_type (deref_val),
- value_contents (deref_val),
- 0,
- VALUE_ADDRESS (deref_val),
- stream,
- format,
- deref_ref,
- recurse,
- pretty);
+ common_val_print (deref_val, stream, format, deref_ref, recurse,
+ pretty);
}
else
fputs_filtered ("???", stream);
}
break;
+ case TYPE_CODE_FLAGS:
+ if (format)
+ print_scalar_formatted (valaddr, type, format, 0, stream);
+ else
+ val_print_type_code_flags (type, valaddr, stream);
+ break;
+
case TYPE_CODE_FLT:
if (format)
print_scalar_formatted (valaddr, type, format, 0, stream);
fprintf_filtered (stream, "<incomplete type>");
break;
+ case TYPE_CODE_STRUCT:
+ /* Starting from the Fortran 90 standard, Fortran supports derived
+ types. */
+ fprintf_filtered (stream, "{ ");
+ for (index = 0; index < TYPE_NFIELDS (type); index++)
+ {
+ int offset = TYPE_FIELD_BITPOS (type, index) / 8;
+ f_val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset,
+ embedded_offset, address, stream,
+ format, deref_ref, recurse, pretty);
+ if (index != TYPE_NFIELDS (type) - 1)
+ fputs_filtered (", ", stream);
+ }
+ fprintf_filtered (stream, "}");
+ break;
+
default:
error (_("Invalid F77 type code %d in symbol table."), TYPE_CODE (type));
}
first make sure that it is visible and if so, let
us display its contents */
- fi = deprecated_selected_frame;
-
- if (fi == NULL)
- error (_("No frame selected"));
+ fi = get_selected_frame (_("No frame selected"));
/* The following is generally ripped off from stack.c's routine
print_frame_info() */
be any minimal symbols in the middle of a function.
FIXME: (Not necessarily true. What about text labels) */
- struct minimal_symbol *msymbol = lookup_minimal_symbol_by_pc (get_frame_pc (fi));
+ struct minimal_symbol *msymbol =
+ lookup_minimal_symbol_by_pc (get_frame_pc (fi));
if (msymbol != NULL
&& (SYMBOL_VALUE_ADDRESS (msymbol)
if (msymbol != NULL)
funname = DEPRECATED_SYMBOL_NAME (msymbol);
+ else /* Got no 'funname', code below will fail. */
+ error (_("No function found for frame."));
}
/* If comname is NULL, we assume the user wishes to see the
if (comname == NULL)
error (_("Cannot deal with NULL common name!"));
- fi = deprecated_selected_frame;
-
- if (fi == NULL)
- error (_("No frame selected"));
+ fi = get_selected_frame (_("No frame selected"));
/* The following is generally ripped off from stack.c's routine
print_frame_info() */
_initialize_f_valprint (void)
{
add_info ("common", info_common_command,
- "Print out the values contained in a Fortran COMMON block.");
+ _("Print out the values contained in a Fortran COMMON block."));
if (xdb_commands)
add_com ("lc", class_info, info_common_command,
- "Print out the values contained in a Fortran COMMON block.");
+ _("Print out the values contained in a Fortran COMMON block."));
}