* ada-lang.c: run through gdb_indent.sh

* ada-lang.h: run through gdb_indent.sh
        * ada-tasks.c: run through gdb_indent.sh
        * ada-typeprint.c: run through gdb_indent.sh
        * ada-valprint.c: run through gdb_indent.sh
This commit is contained in:
Aidan Skinner 2002-08-18 18:11:12 +00:00
parent 01fc4e33eb
commit d2e4a39e32
6 changed files with 3279 additions and 3167 deletions

View file

@ -1,3 +1,11 @@
2002-08-18 Aidan Skinner <aidan@velvet.net>
* ada-lang.c: run through gdb_indent.sh
* ada-lang.h: run through gdb_indent.sh
* ada-tasks.c: run through gdb_indent.sh
* ada-typeprint.c: run through gdb_indent.sh
* ada-valprint.c: run through gdb_indent.sh
2002-08-18 Andrew Cagney <ac131313@redhat.com> 2002-08-18 Andrew Cagney <ac131313@redhat.com>
* osabi.c (gdbarch_init_osabi): Don't complain about an unknown * osabi.c (gdbarch_init_osabi): Don't complain about an unknown

File diff suppressed because it is too large Load diff

View file

@ -32,13 +32,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Chain of cleanups for arguments of OP_UNRESOLVED_VALUE names. Created in /* Chain of cleanups for arguments of OP_UNRESOLVED_VALUE names. Created in
yyparse and freed in ada_resolve. */ yyparse and freed in ada_resolve. */
extern struct cleanup* unresolved_names; extern struct cleanup *unresolved_names;
/* Corresponding mangled/demangled names and opcodes for Ada user-definable /* Corresponding mangled/demangled names and opcodes for Ada user-definable
operators. */ operators. */
struct ada_opname_map { struct ada_opname_map
const char* mangled; {
const char* demangled; const char *mangled;
const char *demangled;
enum exp_opcode op; enum exp_opcode op;
}; };
@ -53,7 +54,8 @@ extern const int MAX_NUMBER_OF_KNOWN_TASKS;
to update the table attribute_names in ada-lang.c whenever you change this. to update the table attribute_names in ada-lang.c whenever you change this.
*/ */
enum ada_attribute { enum ada_attribute
{
/* Invalid attribute for error checking. */ /* Invalid attribute for error checking. */
ATR_INVALID, ATR_INVALID,
@ -74,7 +76,8 @@ enum ada_attribute {
ATR_END ATR_END
}; };
enum task_states { enum task_states
{
Unactivated, Unactivated,
Runnable, Runnable,
Terminated, Terminated,
@ -89,14 +92,18 @@ enum task_states {
extern char *ada_task_states[]; extern char *ada_task_states[];
typedef struct { typedef struct
{
char *P_ARRAY; char *P_ARRAY;
int *P_BOUNDS; int *P_BOUNDS;
} fat_string; }
fat_string;
typedef struct entry_call { typedef struct entry_call
{
void *self; void *self;
} *entry_call_link; }
*entry_call_link;
struct task_fields struct task_fields
{ {
@ -126,7 +133,7 @@ struct task_fields
#if (defined (VXWORKS_TARGET) && defined (M68K_TARGET)) #if (defined (VXWORKS_TARGET) && defined (M68K_TARGET))
__attribute__ ((packed)) __attribute__ ((packed))
#endif #endif
; ;
struct task_entry struct task_entry
{ {
@ -139,17 +146,17 @@ struct task_entry
int stack_per; int stack_per;
}; };
extern struct type* builtin_type_ada_int; extern struct type *builtin_type_ada_int;
extern struct type* builtin_type_ada_short; extern struct type *builtin_type_ada_short;
extern struct type* builtin_type_ada_long; extern struct type *builtin_type_ada_long;
extern struct type* builtin_type_ada_long_long; extern struct type *builtin_type_ada_long_long;
extern struct type* builtin_type_ada_char; extern struct type *builtin_type_ada_char;
extern struct type* builtin_type_ada_float; extern struct type *builtin_type_ada_float;
extern struct type* builtin_type_ada_double; extern struct type *builtin_type_ada_double;
extern struct type* builtin_type_ada_long_double; extern struct type *builtin_type_ada_long_double;
extern struct type* builtin_type_ada_natural; extern struct type *builtin_type_ada_natural;
extern struct type* builtin_type_ada_positive; extern struct type *builtin_type_ada_positive;
extern struct type* builtin_type_ada_system_address; extern struct type *builtin_type_ada_system_address;
/* Assuming V points to an array of S objects, make sure that it contains at /* Assuming V points to an array of S objects, make sure that it contains at
least M objects, updating V and S as necessary. */ least M objects, updating V and S as necessary. */
@ -157,209 +164,225 @@ extern struct type* builtin_type_ada_system_address;
#define GROW_VECT(v, s, m) \ #define GROW_VECT(v, s, m) \
if ((s) < (m)) grow_vect ((void**) &(v), &(s), (m), sizeof(*(v))); if ((s) < (m)) grow_vect ((void**) &(v), &(s), (m), sizeof(*(v)));
extern void grow_vect (void**, size_t*, size_t, int); extern void grow_vect (void **, size_t *, size_t, int);
extern int ada_parse (void); /* Defined in ada-exp.y */ extern int ada_parse (void); /* Defined in ada-exp.y */
extern void ada_error (char *); /* Defined in ada-exp.y */ extern void ada_error (char *); /* Defined in ada-exp.y */
/* Defined in ada-typeprint.c */ /* Defined in ada-typeprint.c */
extern void ada_print_type (struct type*, char*, struct ui_file*, int, int); extern void ada_print_type (struct type *, char *, struct ui_file *, int,
int);
extern int ada_val_print (struct type*, char*, int, CORE_ADDR, extern int ada_val_print (struct type *, char *, int, CORE_ADDR,
struct ui_file*, int, int, int, enum val_prettyprint); struct ui_file *, int, int, int,
enum val_prettyprint);
extern int ada_value_print (struct value*, struct ui_file*, int, extern int ada_value_print (struct value *, struct ui_file *, int,
enum val_prettyprint); enum val_prettyprint);
/* Defined in ada-lang.c */ /* Defined in ada-lang.c */
extern struct value* value_from_contents_and_address (struct type*, char*, CORE_ADDR); extern struct value *value_from_contents_and_address (struct type *, char *,
CORE_ADDR);
extern void ada_emit_char (int, struct ui_file *, int, int); extern void ada_emit_char (int, struct ui_file *, int, int);
extern void ada_printchar (int, struct ui_file*); extern void ada_printchar (int, struct ui_file *);
extern void ada_printstr (struct ui_file*, char *, unsigned int, int, int); extern void ada_printstr (struct ui_file *, char *, unsigned int, int, int);
extern void ada_convert_actuals (struct value*, int, struct value**, CORE_ADDR*); extern void ada_convert_actuals (struct value *, int, struct value **,
CORE_ADDR *);
extern struct value* ada_value_subscript (struct value*, int, struct value**); extern struct value *ada_value_subscript (struct value *, int,
struct value **);
extern struct type* ada_array_element_type (struct type*, int); extern struct type *ada_array_element_type (struct type *, int);
extern int ada_array_arity (struct type*); extern int ada_array_arity (struct type *);
struct type* ada_type_of_array (struct value*, int); struct type *ada_type_of_array (struct value *, int);
extern struct value* ada_coerce_to_simple_array (struct value*); extern struct value *ada_coerce_to_simple_array (struct value *);
extern struct value* ada_coerce_to_simple_array_ptr (struct value*); extern struct value *ada_coerce_to_simple_array_ptr (struct value *);
extern int ada_is_simple_array (struct type*); extern int ada_is_simple_array (struct type *);
extern int ada_is_array_descriptor (struct type*); extern int ada_is_array_descriptor (struct type *);
extern int ada_is_bogus_array_descriptor (struct type*); extern int ada_is_bogus_array_descriptor (struct type *);
extern struct type* ada_index_type (struct type*, int); extern struct type *ada_index_type (struct type *, int);
extern struct value* ada_array_bound (struct value*, int, int); extern struct value *ada_array_bound (struct value *, int, int);
extern int ada_lookup_symbol_list (const char*, struct block*, namespace_enum, extern int ada_lookup_symbol_list (const char *, struct block *,
struct symbol***, struct block***); namespace_enum, struct symbol ***,
struct block ***);
extern char* ada_fold_name (const char*); extern char *ada_fold_name (const char *);
extern struct symbol* ada_lookup_symbol (const char*, struct block*, namespace_enum); extern struct symbol *ada_lookup_symbol (const char *, struct block *,
namespace_enum);
extern struct minimal_symbol* ada_lookup_minimal_symbol (const char*); extern struct minimal_symbol *ada_lookup_minimal_symbol (const char *);
extern void ada_resolve (struct expression**, struct type*); extern void ada_resolve (struct expression **, struct type *);
extern int ada_resolve_function (struct symbol**, struct block**, int, extern int ada_resolve_function (struct symbol **, struct block **, int,
struct value**, int, const char*, struct type*); struct value **, int, const char *,
struct type *);
extern void ada_fill_in_ada_prototype (struct symbol*); extern void ada_fill_in_ada_prototype (struct symbol *);
extern int user_select_syms (struct symbol**, struct block**, int, int); extern int user_select_syms (struct symbol **, struct block **, int, int);
extern int get_selections (int*, int, int, int, char*); extern int get_selections (int *, int, int, int, char *);
extern char* ada_start_decode_line_1 (char*); extern char *ada_start_decode_line_1 (char *);
extern struct symtabs_and_lines ada_finish_decode_line_1 (char**, struct symtab*, int, char***); extern struct symtabs_and_lines ada_finish_decode_line_1 (char **,
struct symtab *,
int, char ***);
extern int ada_scan_number (const char*, int, LONGEST*, int*); extern int ada_scan_number (const char *, int, LONGEST *, int *);
extern struct type* ada_parent_type (struct type*); extern struct type *ada_parent_type (struct type *);
extern int ada_is_ignored_field (struct type*, int); extern int ada_is_ignored_field (struct type *, int);
extern int ada_is_packed_array_type (struct type*); extern int ada_is_packed_array_type (struct type *);
extern struct value* ada_value_primitive_packed_val (struct value*, char*, long, int, extern struct value *ada_value_primitive_packed_val (struct value *, char *,
int, struct type*); long, int, int,
struct type *);
extern struct type* ada_coerce_to_simple_array_type (struct type*); extern struct type *ada_coerce_to_simple_array_type (struct type *);
extern int ada_is_character_type (struct type*); extern int ada_is_character_type (struct type *);
extern int ada_is_string_type (struct type*); extern int ada_is_string_type (struct type *);
extern int ada_is_tagged_type (struct type*); extern int ada_is_tagged_type (struct type *);
extern struct type* ada_tag_type (struct value*); extern struct type *ada_tag_type (struct value *);
extern struct value* ada_value_tag (struct value*); extern struct value *ada_value_tag (struct value *);
extern int ada_is_parent_field (struct type*, int); extern int ada_is_parent_field (struct type *, int);
extern int ada_is_wrapper_field (struct type*, int); extern int ada_is_wrapper_field (struct type *, int);
extern int ada_is_variant_part (struct type*, int); extern int ada_is_variant_part (struct type *, int);
extern struct type* ada_variant_discrim_type (struct type*, struct type*); extern struct type *ada_variant_discrim_type (struct type *, struct type *);
extern int ada_is_others_clause (struct type*, int); extern int ada_is_others_clause (struct type *, int);
extern int ada_in_variant (LONGEST, struct type*, int); extern int ada_in_variant (LONGEST, struct type *, int);
extern char* ada_variant_discrim_name (struct type*); extern char *ada_variant_discrim_name (struct type *);
extern struct type* ada_lookup_struct_elt_type (struct type*, char*, int, int*); extern struct type *ada_lookup_struct_elt_type (struct type *, char *, int,
int *);
extern struct value* ada_value_struct_elt (struct value*, char*, char*); extern struct value *ada_value_struct_elt (struct value *, char *, char *);
extern struct value* ada_search_struct_field (char*, struct value*, int, struct type*); extern struct value *ada_search_struct_field (char *, struct value *, int,
struct type *);
extern int ada_is_aligner_type (struct type*); extern int ada_is_aligner_type (struct type *);
extern struct type* ada_aligned_type (struct type*); extern struct type *ada_aligned_type (struct type *);
extern char* ada_aligned_value_addr (struct type*, char*); extern char *ada_aligned_value_addr (struct type *, char *);
extern const char* ada_attribute_name (int); extern const char *ada_attribute_name (int);
extern int ada_is_fixed_point_type (struct type*); extern int ada_is_fixed_point_type (struct type *);
extern DOUBLEST ada_delta (struct type*); extern DOUBLEST ada_delta (struct type *);
extern DOUBLEST ada_fixed_to_float (struct type *, LONGEST); extern DOUBLEST ada_fixed_to_float (struct type *, LONGEST);
extern LONGEST ada_float_to_fixed (struct type*, DOUBLEST); extern LONGEST ada_float_to_fixed (struct type *, DOUBLEST);
extern int ada_is_vax_floating_type (struct type*); extern int ada_is_vax_floating_type (struct type *);
extern int ada_vax_float_type_suffix (struct type*); extern int ada_vax_float_type_suffix (struct type *);
extern struct value* ada_vax_float_print_function (struct type*); extern struct value *ada_vax_float_print_function (struct type *);
extern struct type* ada_system_address_type (void); extern struct type *ada_system_address_type (void);
extern int ada_which_variant_applies (struct type*, struct type*, char*); extern int ada_which_variant_applies (struct type *, struct type *, char *);
extern struct value* ada_to_fixed_value (struct type*, char*, CORE_ADDR, struct value*); extern struct value *ada_to_fixed_value (struct type *, char *, CORE_ADDR,
struct value *);
extern struct type* ada_to_fixed_type (struct type*, char*, CORE_ADDR, struct value*); extern struct type *ada_to_fixed_type (struct type *, char *, CORE_ADDR,
struct value *);
extern int ada_name_prefix_len (const char*); extern int ada_name_prefix_len (const char *);
extern char* ada_type_name (struct type*); extern char *ada_type_name (struct type *);
extern struct type* ada_find_parallel_type (struct type*, const char *suffix); extern struct type *ada_find_parallel_type (struct type *,
const char *suffix);
extern LONGEST get_int_var_value (char*, char*, int* ); extern LONGEST get_int_var_value (char *, char *, int *);
extern struct type* ada_find_any_type (const char *name); extern struct type *ada_find_any_type (const char *name);
extern int ada_prefer_type (struct type*, struct type*); extern int ada_prefer_type (struct type *, struct type *);
extern struct type* ada_get_base_type (struct type*); extern struct type *ada_get_base_type (struct type *);
extern struct type* ada_completed_type (struct type*); extern struct type *ada_completed_type (struct type *);
extern char* ada_mangle (const char*); extern char *ada_mangle (const char *);
extern const char* ada_enum_name (const char*); extern const char *ada_enum_name (const char *);
extern int ada_is_modular_type (struct type*); extern int ada_is_modular_type (struct type *);
extern LONGEST ada_modulus (struct type*); extern LONGEST ada_modulus (struct type *);
extern struct value* ada_value_ind (struct value*); extern struct value *ada_value_ind (struct value *);
extern void ada_print_scalar (struct type*, LONGEST, struct ui_file*); extern void ada_print_scalar (struct type *, LONGEST, struct ui_file *);
extern int ada_is_range_type_name (const char*); extern int ada_is_range_type_name (const char *);
extern const char* ada_renaming_type (struct type*); extern const char *ada_renaming_type (struct type *);
extern int ada_is_object_renaming (struct symbol*); extern int ada_is_object_renaming (struct symbol *);
extern const char* ada_simple_renamed_entity (struct symbol*); extern const char *ada_simple_renamed_entity (struct symbol *);
extern char* ada_breakpoint_rewrite (char*, int*); extern char *ada_breakpoint_rewrite (char *, int *);
/* Tasking-related: ada-tasks.c */ /* Tasking-related: ada-tasks.c */
extern int valid_task_id (int); extern int valid_task_id (int);
extern int get_current_task (void); extern int get_current_task (void);
extern void init_task_list (void); extern void init_task_list (void);
extern void* get_self_id (void); extern void *get_self_id (void);
extern int get_current_task (void); extern int get_current_task (void);
extern int get_entry_number (void*); extern int get_entry_number (void *);
extern void ada_report_exception_break (struct breakpoint *); extern void ada_report_exception_break (struct breakpoint *);
extern int ada_maybe_exception_partial_symbol (struct partial_symbol* sym); extern int ada_maybe_exception_partial_symbol (struct partial_symbol *sym);
extern int ada_is_exception_sym (struct symbol* sym); extern int ada_is_exception_sym (struct symbol *sym);
#endif #endif

View file

@ -14,9 +14,9 @@
*/ */
#include <ctype.h> #include <ctype.h>
#include "defs.h" #include "defs.h"
#include "command.h" #include "command.h"
#include "value.h" #include "value.h"
#include "language.h" #include "language.h"
#include "inferior.h" #include "inferior.h"
@ -30,7 +30,7 @@
#if (defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET)) #if (defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET))
#include "gregset.h" #include "gregset.h"
#endif #endif
#include "ada-lang.h" #include "ada-lang.h"
@ -71,10 +71,10 @@ extern int dec_thread_get_registers (gdb_gregset_t *, gdb_fpregset_t *);
#elif defined (sun) && defined (__SVR4) #elif defined (sun) && defined (__SVR4)
#define GET_CURRENT_THREAD solaris_thread_get_current_thread #define GET_CURRENT_THREAD solaris_thread_get_current_thread
#define THREAD_FETCH_REGISTERS() (-1) #define THREAD_FETCH_REGISTERS() (-1)
extern void *GET_CURRENT_THREAD(); extern void *GET_CURRENT_THREAD ();
#elif defined (_AIX) || (defined(__alpha__) && defined(__osf__)) #elif defined (_AIX) || (defined(__alpha__) && defined(__osf__))
extern void *GET_CURRENT_THREAD(); extern void *GET_CURRENT_THREAD ();
#elif defined (__WIN32__) || defined (hpux) #elif defined (__WIN32__) || defined (hpux)
#define GET_CURRENT_THREAD() (inferior_pid) #define GET_CURRENT_THREAD() (inferior_pid)
@ -90,7 +90,7 @@ extern void *GET_CURRENT_THREAD();
#define READ_MEMORY(addr, var) read_memory (addr, (char*) &var, sizeof (var)) #define READ_MEMORY(addr, var) read_memory (addr, (char*) &var, sizeof (var))
/* external declarations */ /* external declarations */
extern struct value* find_function_in_inferior (char *); extern struct value *find_function_in_inferior (char *);
/* Global visible variables */ /* Global visible variables */
@ -110,8 +110,7 @@ const int MAX_NUMBER_OF_KNOWN_TASKS = 1000;
int current_task = -1, current_task_id = -1, current_task_index; int current_task = -1, current_task_id = -1, current_task_index;
void *current_thread, *current_lwp; void *current_thread, *current_lwp;
char *ada_task_states[] = char *ada_task_states[] = {
{
"Unactivated", "Unactivated",
"Runnable", "Runnable",
"Terminated", "Terminated",
@ -131,8 +130,7 @@ char *ada_task_states[] =
/* Global internal types */ /* Global internal types */
static char *ada_long_task_states[] = static char *ada_long_task_states[] = {
{
"Unactivated", "Unactivated",
"Runnable", "Runnable",
"Terminated", "Terminated",
@ -153,10 +151,10 @@ static char *ada_long_task_states[] =
/* Global internal variables */ /* Global internal variables */
static int highest_task_num = 0; static int highest_task_num = 0;
int thread_support = 0; /* 1 if the thread library in use is supported */ int thread_support = 0; /* 1 if the thread library in use is supported */
static int gdbtk_task_initialization = 0; static int gdbtk_task_initialization = 0;
static int static int
add_task_entry (void *p_task_id, int index) add_task_entry (void *p_task_id, int index)
{ {
struct task_entry *new_task_entry = NULL; struct task_entry *new_task_entry = NULL;
@ -176,11 +174,12 @@ add_task_entry (void *p_task_id, int index)
pt->next_task = new_task_entry; pt->next_task = new_task_entry;
pt->stack_per = 0; pt->stack_per = 0;
} }
else task_list = new_task_entry; else
task_list = new_task_entry;
return new_task_entry->task_num; return new_task_entry->task_num;
} }
int int
get_entry_number (void *p_task_id) get_entry_number (void *p_task_id)
{ {
struct task_entry *pt; struct task_entry *pt;
@ -204,7 +203,7 @@ get_thread_entry_vptr (void *thread)
while (pt != NULL) while (pt != NULL)
{ {
if (pt->thread == thread) if (pt->thread == thread)
return pt; return pt;
pt = pt->next_task; pt = pt->next_task;
} }
return 0; return 0;
@ -250,7 +249,7 @@ valid_task_id (int task)
void * void *
get_self_id (void) get_self_id (void)
{ {
struct value* val; struct value *val;
void *self_id; void *self_id;
int result; int result;
struct task_entry *ent; struct task_entry *ent;
@ -270,10 +269,11 @@ get_self_id (void)
return NULL; return NULL;
} }
int get_current_task () int
get_current_task ()
{ {
int result; int result;
/* FIXME: language_ada should be defined in defs.h */ /* FIXME: language_ada should be defined in defs.h */
/* if (current_language->la_language != language_ada) return -1; */ /* if (current_language->la_language != language_ada) return -1; */
@ -293,22 +293,22 @@ info_task (char *arg, int from_tty)
void *self_id, *caller; void *self_id, *caller;
struct task_fields atcb, atcb2; struct task_fields atcb, atcb2;
struct entry_call call; struct entry_call call;
int bounds [2]; int bounds[2];
char image [256]; char image[256];
int num; int num;
/* FIXME: language_ada should be defined in defs.h */ /* FIXME: language_ada should be defined in defs.h */
/* if (current_language->la_language != language_ada) /* if (current_language->la_language != language_ada)
{ {
printf_filtered ("The current language does not support tasks.\n"); printf_filtered ("The current language does not support tasks.\n");
return; return;
} }
*/ */
pt = get_entry_vptr (atoi (arg)); pt = get_entry_vptr (atoi (arg));
if (pt == NULL) if (pt == NULL)
{ {
printf_filtered ("Task %s not found.\n", arg); printf_filtered ("Task %s not found.\n", arg);
return; return;
} }
temp_task = pt->task_id; temp_task = pt->task_id;
@ -320,14 +320,16 @@ info_task (char *arg, int from_tty)
printf_filtered ("Ada Task: %p\n", temp_task); printf_filtered ("Ada Task: %p\n", temp_task);
/* print the name of the task */ /* print the name of the task */
if (atcb.image.P_ARRAY != NULL) { if (atcb.image.P_ARRAY != NULL)
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds); {
bounds [1] = EXTRACT_INT (bounds [1]); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds);
read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY), bounds[1] = EXTRACT_INT (bounds[1]);
(char*) &image, bounds [1]); read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
printf_filtered ("Name: %.*s\n", bounds [1], image); (char *) &image, bounds[1]);
} printf_filtered ("Name: %.*s\n", bounds[1], image);
else printf_filtered ("<no name>\n"); }
else
printf_filtered ("<no name>\n");
/* print the thread id */ /* print the thread id */
@ -339,9 +341,9 @@ info_task (char *arg, int from_tty)
if ((long) pt->lwp != 0) if ((long) pt->lwp != 0)
{ {
if ((long) pt->lwp < 65536) if ((long) pt->lwp < 65536)
printf_filtered ("LWP: %ld\n", (long int) pt->lwp); printf_filtered ("LWP: %ld\n", (long int) pt->lwp);
else else
printf_filtered ("LWP: %p\n", pt->lwp); printf_filtered ("LWP: %p\n", pt->lwp);
} }
/* print the parent gdb task id */ /* print the parent gdb task id */
@ -353,16 +355,17 @@ info_task (char *arg, int from_tty)
READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2); READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2);
/* print the name of the task */ /* print the name of the task */
if (atcb2.image.P_ARRAY != NULL) { if (atcb2.image.P_ARRAY != NULL)
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS), {
bounds); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
bounds [1] = EXTRACT_INT (bounds [1]); bounds);
read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY), bounds[1] = EXTRACT_INT (bounds[1]);
(char*) &image, bounds [1]); read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
printf_filtered (" (%.*s)\n", bounds [1], image); (char *) &image, bounds[1]);
} printf_filtered (" (%.*s)\n", bounds[1], image);
}
else else
printf_filtered ("\n"); printf_filtered ("\n");
} }
else else
printf_filtered ("No parent\n"); printf_filtered ("No parent\n");
@ -375,11 +378,12 @@ info_task (char *arg, int from_tty)
/* check if this task is accepting a rendezvous */ /* check if this task is accepting a rendezvous */
if (atcb.call == NULL) if (atcb.call == NULL)
caller = NULL; caller = NULL;
else { else
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call); {
caller = EXTRACT_ADDRESS (call.self); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
} caller = EXTRACT_ADDRESS (call.self);
}
if (caller != NULL) if (caller != NULL)
{ {
num = get_entry_number (caller); num = get_entry_number (caller);
@ -391,14 +395,15 @@ info_task (char *arg, int from_tty)
READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2); READ_MEMORY ((CORE_ADDR) pt2->task_id, atcb2);
/* print the name of the task */ /* print the name of the task */
if (atcb2.image.P_ARRAY != NULL) { if (atcb2.image.P_ARRAY != NULL)
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS), {
bounds); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_BOUNDS),
bounds [1] = EXTRACT_INT (bounds [1]); bounds);
read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY), bounds[1] = EXTRACT_INT (bounds[1]);
(char*) &image, bounds [1]); read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb2.image.P_ARRAY),
printf_filtered (" (%.*s)\n", bounds [1], image); (char *) &image, bounds[1]);
} printf_filtered (" (%.*s)\n", bounds[1], image);
}
else else
printf_filtered ("\n"); printf_filtered ("\n");
} }
@ -406,7 +411,7 @@ info_task (char *arg, int from_tty)
printf_filtered ("\n"); printf_filtered ("\n");
} }
else else
printf_filtered ("State: %s\n", ada_long_task_states [atcb.state]); printf_filtered ("State: %s\n", ada_long_task_states[atcb.state]);
} }
#if 0 #if 0
@ -418,28 +423,37 @@ info_task (char *arg, int from_tty)
print_align (void) print_align (void)
{ {
struct task_fields tf; struct task_fields tf;
void *tf_base = &(tf); void *tf_base = &(tf);
void *tf_state = &(tf.state); void *tf_state = &(tf.state);
void *tf_entry_num = &(tf.entry_num); void *tf_entry_num = &(tf.entry_num);
void *tf_parent = &(tf.parent); void *tf_parent = &(tf.parent);
void *tf_priority = &(tf.priority); void *tf_priority = &(tf.priority);
void *tf_current_priority = &(tf.current_priority); void *tf_current_priority = &(tf.current_priority);
void *tf_image = &(tf.image); void *tf_image = &(tf.image);
void *tf_call = &(tf.call); void *tf_call = &(tf.call);
void *tf_thread = &(tf.thread); void *tf_thread = &(tf.thread);
void *tf_lwp = &(tf.lwp); void *tf_lwp = &(tf.lwp);
printf_filtered ("\n"); printf_filtered ("\n");
printf_filtered ("(tf_base = 0x%x)\n", tf_base); printf_filtered ("(tf_base = 0x%x)\n", tf_base);
printf_filtered ("task_fields.entry_num at %3d (0x%x)\n", tf_entry_num - tf_base, tf_entry_num); printf_filtered ("task_fields.entry_num at %3d (0x%x)\n",
printf_filtered ("task_fields.state at %3d (0x%x)\n", tf_state - tf_base, tf_state); tf_entry_num - tf_base, tf_entry_num);
printf_filtered ("task_fields.parent at %3d (0x%x)\n", tf_parent - tf_base, tf_parent); printf_filtered ("task_fields.state at %3d (0x%x)\n",
printf_filtered ("task_fields.priority at %3d (0x%x)\n", tf_priority - tf_base, tf_priority); tf_state - tf_base, tf_state);
printf_filtered ("task_fields.current_priority at %3d (0x%x)\n", tf_current_priority - tf_base, tf_current_priority); printf_filtered ("task_fields.parent at %3d (0x%x)\n",
printf_filtered ("task_fields.image at %3d (0x%x)\n", tf_image - tf_base, tf_image); tf_parent - tf_base, tf_parent);
printf_filtered ("task_fields.call at %3d (0x%x)\n", tf_call - tf_base, tf_call); printf_filtered ("task_fields.priority at %3d (0x%x)\n",
printf_filtered ("task_fields.thread at %3d (0x%x)\n", tf_thread - tf_base, tf_thread); tf_priority - tf_base, tf_priority);
printf_filtered ("task_fields.lwp at %3d (0x%x)\n", tf_lwp - tf_base, tf_lwp); printf_filtered ("task_fields.current_priority at %3d (0x%x)\n",
printf_filtered ("\n"); tf_current_priority - tf_base, tf_current_priority);
printf_filtered ("task_fields.image at %3d (0x%x)\n",
tf_image - tf_base, tf_image);
printf_filtered ("task_fields.call at %3d (0x%x)\n",
tf_call - tf_base, tf_call);
printf_filtered ("task_fields.thread at %3d (0x%x)\n",
tf_thread - tf_base, tf_thread);
printf_filtered ("task_fields.lwp at %3d (0x%x)\n",
tf_lwp - tf_base, tf_lwp);
printf_filtered ("\n");
} }
#endif #endif
@ -448,15 +462,15 @@ print_align (void)
static void static void
info_tasks (char *arg, int from_tty) info_tasks (char *arg, int from_tty)
{ {
struct value* val; struct value *val;
int i, task_number, state; int i, task_number, state;
void *temp_task, *temp_tasks [MAX_NUMBER_OF_KNOWN_TASKS]; void *temp_task, *temp_tasks[MAX_NUMBER_OF_KNOWN_TASKS];
struct task_entry *pt; struct task_entry *pt;
void *self_id, *caller, *thread_id=NULL; void *self_id, *caller, *thread_id = NULL;
struct task_fields atcb; struct task_fields atcb;
struct entry_call call; struct entry_call call;
int bounds [2]; int bounds[2];
char image [256]; char image[256];
int size; int size;
char car; char car;
@ -474,7 +488,7 @@ info_tasks (char *arg, int from_tty)
task_number = 0; task_number = 0;
if (PIDGET(inferior_ptid) == 0) if (PIDGET (inferior_ptid) == 0)
{ {
printf_filtered ("The program is not being run under gdb. "); printf_filtered ("The program is not being run under gdb. ");
printf_filtered ("Use 'run' or 'attach' first.\n"); printf_filtered ("Use 'run' or 'attach' first.\n");
@ -494,7 +508,7 @@ info_tasks (char *arg, int from_tty)
known_tasks_addr = (void *) SYMBOL_VALUE_ADDRESS (msym); known_tasks_addr = (void *) SYMBOL_VALUE_ADDRESS (msym);
else else
#ifndef VXWORKS_TARGET #ifndef VXWORKS_TARGET
return; return;
#else #else
{ {
if (target_lookup_symbol (KNOWN_TASKS_NAME, &known_tasks_addr) != 0) if (target_lookup_symbol (KNOWN_TASKS_NAME, &known_tasks_addr) != 0)
@ -519,28 +533,29 @@ info_tasks (char *arg, int from_tty)
READ_MEMORY ((CORE_ADDR) known_tasks_addr, temp_tasks); READ_MEMORY ((CORE_ADDR) known_tasks_addr, temp_tasks);
for (i=0; i<MAX_NUMBER_OF_KNOWN_TASKS; i++) for (i = 0; i < MAX_NUMBER_OF_KNOWN_TASKS; i++)
{ {
temp_task = EXTRACT_ADDRESS (temp_tasks[i]); temp_task = EXTRACT_ADDRESS (temp_tasks[i]);
if (temp_task != NULL) if (temp_task != NULL)
{ {
task_number = get_entry_number (temp_task); task_number = get_entry_number (temp_task);
if (task_number == 0) if (task_number == 0)
task_number = add_task_entry (temp_task, i); task_number = add_task_entry (temp_task, i);
} }
} }
/* Return without printing anything if this function was called in /* Return without printing anything if this function was called in
order to init GDBTK tasking. */ order to init GDBTK tasking. */
if (init_only) return; if (init_only)
return;
/* print the header */ /* print the header */
#if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET) #if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET)
printf_filtered printf_filtered
(" ID TID P-ID Pri Stack %% State Name\n"); (" ID TID P-ID Pri Stack %% State Name\n");
#else #else
printf_filtered (" ID TID P-ID Pri State Name\n"); printf_filtered (" ID TID P-ID Pri State Name\n");
#endif #endif
@ -579,15 +594,15 @@ info_tasks (char *arg, int from_tty)
printf_filtered (" %9lx", (long) temp_task); printf_filtered (" %9lx", (long) temp_task);
#else #else
#ifdef TARGET_64 #ifdef TARGET_64
printf_filtered (" %#9lx", (unsigned long)pt->thread & 0x3ffffffffff); printf_filtered (" %#9lx", (unsigned long) pt->thread & 0x3ffffffffff);
#else #else
printf_filtered (" %#9lx", (long)pt->thread); printf_filtered (" %#9lx", (long) pt->thread);
#endif #endif
#endif #endif
/* print the parent gdb task id */ /* print the parent gdb task id */
printf_filtered printf_filtered
(" %4d", get_entry_number (EXTRACT_ADDRESS (atcb.parent))); (" %4d", get_entry_number (EXTRACT_ADDRESS (atcb.parent)));
/* print the base priority of the task */ /* print the base priority of the task */
printf_filtered (" %3d", EXTRACT_INT (atcb.priority)); printf_filtered (" %3d", EXTRACT_INT (atcb.priority));
@ -595,39 +610,41 @@ info_tasks (char *arg, int from_tty)
#if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET) #if defined(__alpha__) && defined(__osf__) && !defined(VXWORKS_TARGET)
if (pt->task_num == 1 || atcb.state == Terminated) if (pt->task_num == 1 || atcb.state == Terminated)
{ {
printf_filtered (" Unknown"); printf_filtered (" Unknown");
goto next; goto next;
} }
read_memory ((CORE_ADDR)atcb.thread, &thr, sizeof (thr)); read_memory ((CORE_ADDR) atcb.thread, &thr, sizeof (thr));
current_thread = atcb.thread; current_thread = atcb.thread;
regs.regs [SP_REGNUM] = 0; regs.regs[SP_REGNUM] = 0;
if (dec_thread_get_registers (&regs, NULL) == 0) { if (dec_thread_get_registers (&regs, NULL) == 0)
pt->stack_per = (100 * ((long)thr.__stack_base - {
regs.regs [SP_REGNUM])) / thr.__stack_size; pt->stack_per = (100 * ((long) thr.__stack_base -
/* if the thread is terminated but still there, the regs.regs[SP_REGNUM])) / thr.__stack_size;
stack_base/size values are erroneous. Try to patch it */ /* if the thread is terminated but still there, the
if (pt->stack_per < 0 || pt->stack_per > 100) pt->stack_per = 0; stack_base/size values are erroneous. Try to patch it */
} if (pt->stack_per < 0 || pt->stack_per > 100)
pt->stack_per = 0;
}
/* print information about stack space used in the thread */ /* print information about stack space used in the thread */
if (thr.__stack_size < 1024*1024) if (thr.__stack_size < 1024 * 1024)
{ {
size = thr.__stack_size / 1024; size = thr.__stack_size / 1024;
car = 'K'; car = 'K';
} }
else if (thr.__stack_size < 1024*1024*1024) else if (thr.__stack_size < 1024 * 1024 * 1024)
{ {
size = thr.__stack_size / 1024 / 1024; size = thr.__stack_size / 1024 / 1024;
car = 'M'; car = 'M';
} }
else /* Who knows... */ else /* Who knows... */
{ {
size = thr.__stack_size / 1024 / 1024 / 1024; size = thr.__stack_size / 1024 / 1024 / 1024;
car = 'G'; car = 'G';
} }
printf_filtered (" %4d%c %2d", size, car, pt->stack_per); printf_filtered (" %4d%c %2d", size, car, pt->stack_per);
next: next:
#endif #endif
/* print the current state of the task */ /* print the current state of the task */
@ -635,13 +652,15 @@ next:
/* check if this task is accepting a rendezvous */ /* check if this task is accepting a rendezvous */
if (atcb.call == NULL) if (atcb.call == NULL)
caller = NULL; caller = NULL;
else { else
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call); {
caller = EXTRACT_ADDRESS (call.self); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.call), call);
} caller = EXTRACT_ADDRESS (call.self);
}
if (caller != NULL) if (caller != NULL)
printf_filtered (" Accepting RV with %-4d", get_entry_number (caller)); printf_filtered (" Accepting RV with %-4d",
get_entry_number (caller));
else else
{ {
state = atcb.state; state = atcb.state;
@ -653,18 +672,21 @@ next:
/* Replace "Runnable" by "Running" if this is the current task */ /* Replace "Runnable" by "Running" if this is the current task */
printf_filtered (" %-22s", "Running"); printf_filtered (" %-22s", "Running");
else else
printf_filtered (" %-22s", ada_task_states [state]); printf_filtered (" %-22s", ada_task_states[state]);
} }
/* finally, print the name of the task */ /* finally, print the name of the task */
if (atcb.image.P_ARRAY != NULL) { if (atcb.image.P_ARRAY != NULL)
READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS), bounds); {
bounds [1] = EXTRACT_INT (bounds [1]); READ_MEMORY ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_BOUNDS),
read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY), bounds);
(char*)&image, bounds [1]); bounds[1] = EXTRACT_INT (bounds[1]);
printf_filtered (" %.*s\n", bounds [1], image); read_memory ((CORE_ADDR) EXTRACT_ADDRESS (atcb.image.P_ARRAY),
} (char *) &image, bounds[1]);
else printf_filtered (" <no name>\n"); printf_filtered (" %.*s\n", bounds[1], image);
}
else
printf_filtered (" <no name>\n");
pt = pt->next_task; pt = pt->next_task;
} }
@ -686,10 +708,10 @@ gdbtk_tcl_tasks_initialize (void)
static void static void
info_tasks_command (char *arg, int from_tty) info_tasks_command (char *arg, int from_tty)
{ {
if (arg == NULL || *arg == '\000') if (arg == NULL || *arg == '\000')
info_tasks (arg, from_tty); info_tasks (arg, from_tty);
else else
info_task (arg, from_tty); info_task (arg, from_tty);
} }
/* Switch from one thread to another. */ /* Switch from one thread to another. */
@ -730,7 +752,8 @@ task_switch (void *tid, void *lwpid)
#endif #endif
} }
if (res == 0) stop_pc = read_pc(); if (res == 0)
stop_pc = read_pc ();
select_frame (get_current_frame ()); select_frame (get_current_frame ());
return res; return res;
} }
@ -746,14 +769,14 @@ task_command (char *tidstr, int from_tty)
if (!tidstr) if (!tidstr)
error ("Please specify a task ID. Use the \"info tasks\" command to\n" error ("Please specify a task ID. Use the \"info tasks\" command to\n"
"see the IDs of currently known tasks."); "see the IDs of currently known tasks.");
num = atoi (tidstr); num = atoi (tidstr);
e = get_entry_vptr (num); e = get_entry_vptr (num);
if (e == NULL) if (e == NULL)
error ("Task ID %d not known. Use the \"info tasks\" command to\n" error ("Task ID %d not known. Use the \"info tasks\" command to\n"
"see the IDs of currently known tasks.", num); "see the IDs of currently known tasks.", num);
if (current_task_id == -1) if (current_task_id == -1)
{ {
@ -771,10 +794,11 @@ task_command (char *tidstr, int from_tty)
if (task_switch (e->thread, e->lwp) == 0) if (task_switch (e->thread, e->lwp) == 0)
{ {
/* FIXME: find_printable_frame should be defined in frame.h, and /* FIXME: find_printable_frame should be defined in frame.h, and
implemented in ada-lang.c */ implemented in ada-lang.c */
/* find_printable_frame (selected_frame, frame_relative_level (selected_frame));*/ /* find_printable_frame (selected_frame, frame_relative_level (selected_frame)); */
printf_filtered ("[Switching to task %d]\n", num); printf_filtered ("[Switching to task %d]\n", num);
print_stack_frame (selected_frame, frame_relative_level (selected_frame), 1); print_stack_frame (selected_frame,
frame_relative_level (selected_frame), 1);
} }
else else
printf_filtered ("Unable to switch to task %d\n", num); printf_filtered ("Unable to switch to task %d\n", num);
@ -786,13 +810,11 @@ _initialize_tasks (void)
static struct cmd_list_element *task_cmd_list = NULL; static struct cmd_list_element *task_cmd_list = NULL;
extern struct cmd_list_element *cmdlist; extern struct cmd_list_element *cmdlist;
add_info ( add_info ("tasks", info_tasks_command,
"tasks", info_tasks_command, "Without argument: list all known Ada tasks, with status information.\n"
"Without argument: list all known Ada tasks, with status information.\n" "info tasks n: print detailed information of task n.\n");
"info tasks n: print detailed information of task n.\n");
add_prefix_cmd ("task", class_run, task_command, add_prefix_cmd ("task", class_run, task_command,
"Use this command to switch between tasks.\n\ "Use this command to switch between tasks.\n\
The new task ID must be currently known.", &task_cmd_list, "task ", 1, The new task ID must be currently known.", &task_cmd_list, "task ", 1, &cmdlist);
&cmdlist);
} }

View file

@ -38,40 +38,42 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
static int print_record_field_types (struct type *, struct type *, static int print_record_field_types (struct type *, struct type *,
struct ui_file *, int, int); struct ui_file *, int, int);
static void print_array_type (struct type*, struct ui_file*, int, int); static void print_array_type (struct type *, struct ui_file *, int, int);
static void print_choices (struct type*, int, struct ui_file*, struct type*); static void print_choices (struct type *, int, struct ui_file *,
struct type *);
static void print_range (struct type*, struct ui_file*); static void print_range (struct type *, struct ui_file *);
static void print_range_bound (struct type*, char*, int*, struct ui_file*); static void print_range_bound (struct type *, char *, int *,
struct ui_file *);
static void static void
print_dynamic_range_bound (struct type*, const char*, int, print_dynamic_range_bound (struct type *, const char *, int,
const char*, struct ui_file*); const char *, struct ui_file *);
static void print_range_type_named (char*, struct ui_file*);
static void print_range_type_named (char *, struct ui_file *);
static char* name_buffer;
static char *name_buffer;
static int name_buffer_len; static int name_buffer_len;
/* The (demangled) Ada name of TYPE. This value persists until the /* The (demangled) Ada name of TYPE. This value persists until the
next call. */ next call. */
static char* static char *
demangled_type_name (struct type *type) demangled_type_name (struct type *type)
{ {
if (ada_type_name (type) == NULL) if (ada_type_name (type) == NULL)
return NULL; return NULL;
else else
{ {
char* raw_name = ada_type_name (type); char *raw_name = ada_type_name (type);
char *s, *q; char *s, *q;
if (name_buffer == NULL || name_buffer_len <= strlen (raw_name)) if (name_buffer == NULL || name_buffer_len <= strlen (raw_name))
{ {
@ -80,7 +82,7 @@ demangled_type_name (struct type *type)
} }
strcpy (name_buffer, raw_name); strcpy (name_buffer, raw_name);
s = (char*) strstr (name_buffer, "___"); s = (char *) strstr (name_buffer, "___");
if (s != NULL) if (s != NULL)
*s = '\0'; *s = '\0';
@ -91,18 +93,20 @@ demangled_type_name (struct type *type)
if (s == name_buffer) if (s == name_buffer)
return name_buffer; return name_buffer;
if (! islower (s[1])) if (!islower (s[1]))
return NULL; return NULL;
for (s = q = name_buffer; *s != '\0'; q += 1) for (s = q = name_buffer; *s != '\0'; q += 1)
{ {
if (s[0] == '_' && s[1] == '_') if (s[0] == '_' && s[1] == '_')
{ {
*q = '.'; s += 2; *q = '.';
s += 2;
} }
else else
{ {
*q = *s; s += 1; *q = *s;
s += 1;
} }
} }
*q = '\0'; *q = '\0';
@ -116,25 +120,26 @@ demangled_type_name (struct type *type)
NEW is the new name for a type TYPE. */ NEW is the new name for a type TYPE. */
void void
ada_typedef_print (struct type *type, struct symbol *new, struct ui_file *stream) ada_typedef_print (struct type *type, struct symbol *new,
struct ui_file *stream)
{ {
fprintf_filtered (stream, "type %.*s is ", fprintf_filtered (stream, "type %.*s is ",
ada_name_prefix_len (SYMBOL_SOURCE_NAME(new)), ada_name_prefix_len (SYMBOL_SOURCE_NAME (new)),
SYMBOL_SOURCE_NAME(new)); SYMBOL_SOURCE_NAME (new));
type_print (type, "", stream, 1); type_print (type, "", stream, 1);
} }
/* Print range type TYPE on STREAM. */ /* Print range type TYPE on STREAM. */
static void static void
print_range (struct type* type, struct ui_file* stream) print_range (struct type *type, struct ui_file *stream)
{ {
struct type* target_type; struct type *target_type;
target_type = TYPE_TARGET_TYPE (type); target_type = TYPE_TARGET_TYPE (type);
if (target_type == NULL) if (target_type == NULL)
target_type = type; target_type = type;
switch (TYPE_CODE (target_type)) switch (TYPE_CODE (target_type))
{ {
case TYPE_CODE_RANGE: case TYPE_CODE_RANGE:
case TYPE_CODE_INT: case TYPE_CODE_INT:
@ -156,8 +161,8 @@ print_range (struct type* type, struct ui_file* stream)
Note that if the name is not defined, then we don't print anything. Note that if the name is not defined, then we don't print anything.
*/ */
fprintf_filtered (stream, "%.*s", fprintf_filtered (stream, "%.*s",
ada_name_prefix_len (TYPE_NAME (type)), ada_name_prefix_len (TYPE_NAME (type)),
TYPE_NAME (type)); TYPE_NAME (type));
} }
else else
{ {
@ -165,7 +170,7 @@ print_range (struct type* type, struct ui_file* stream)
and the last element of the type->fields array */ and the last element of the type->fields array */
const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type); const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type);
const LONGEST upper_bound = const LONGEST upper_bound =
(LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) -1); (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1);
ada_print_scalar (target_type, lower_bound, stream); ada_print_scalar (target_type, lower_bound, stream);
fprintf_filtered (stream, " .. "); fprintf_filtered (stream, " .. ");
@ -177,7 +182,8 @@ print_range (struct type* type, struct ui_file* stream)
set *N past the bound and its delimiter, if any. */ set *N past the bound and its delimiter, if any. */
static void static void
print_range_bound (struct type* type, char* bounds, int* n, struct ui_file* stream) print_range_bound (struct type *type, char *bounds, int *n,
struct ui_file *stream)
{ {
LONGEST B; LONGEST B;
if (ada_scan_number (bounds, *n, &B, n)) if (ada_scan_number (bounds, *n, &B, n))
@ -189,13 +195,13 @@ print_range_bound (struct type* type, char* bounds, int* n, struct ui_file* stre
else else
{ {
int bound_len; int bound_len;
char* bound = bounds + *n; char *bound = bounds + *n;
char* pend; char *pend;
pend = strstr (bound, "__"); pend = strstr (bound, "__");
if (pend == NULL) if (pend == NULL)
*n += bound_len = strlen (bound); *n += bound_len = strlen (bound);
else else
{ {
bound_len = pend - bound; bound_len = pend - bound;
*n += bound_len + 2; *n += bound_len + 2;
@ -209,7 +215,8 @@ print_range_bound (struct type* type, char* bounds, int* n, struct ui_file* stre
"___U") according to the ___XD conventions. */ "___U") according to the ___XD conventions. */
static void static void
print_dynamic_range_bound (struct type* type, const char* name, int name_len, const char* suffix, struct ui_file* stream) print_dynamic_range_bound (struct type *type, const char *name, int name_len,
const char *suffix, struct ui_file *stream)
{ {
static char *name_buf = NULL; static char *name_buf = NULL;
static size_t name_buf_len = 0; static size_t name_buf_len = 0;
@ -230,12 +237,12 @@ print_dynamic_range_bound (struct type* type, const char* name, int name_len, co
/* Print the range type named NAME. */ /* Print the range type named NAME. */
static void static void
print_range_type_named (char* name, struct ui_file* stream) print_range_type_named (char *name, struct ui_file *stream)
{ {
struct type *raw_type = ada_find_any_type (name); struct type *raw_type = ada_find_any_type (name);
struct type *base_type; struct type *base_type;
LONGEST low, high; LONGEST low, high;
char* subtype_info; char *subtype_info;
if (raw_type == NULL) if (raw_type == NULL)
base_type = builtin_type_int; base_type = builtin_type_int;
@ -259,22 +266,24 @@ print_range_type_named (char* name, struct ui_file* stream)
bounds_str = strchr (subtype_info, '_'); bounds_str = strchr (subtype_info, '_');
n = 1; n = 1;
if (*subtype_info == 'L') if (*subtype_info == 'L')
{ {
print_range_bound (raw_type, bounds_str, &n, stream); print_range_bound (raw_type, bounds_str, &n, stream);
subtype_info += 1; subtype_info += 1;
} }
else else
print_dynamic_range_bound (raw_type, name, prefix_len, "___L", stream); print_dynamic_range_bound (raw_type, name, prefix_len, "___L",
stream);
fprintf_filtered (stream, " .. "); fprintf_filtered (stream, " .. ");
if (*subtype_info == 'U') if (*subtype_info == 'U')
print_range_bound (raw_type, bounds_str, &n, stream); print_range_bound (raw_type, bounds_str, &n, stream);
else else
print_dynamic_range_bound (raw_type, name, prefix_len, "___U", stream); print_dynamic_range_bound (raw_type, name, prefix_len, "___U",
stream);
} }
} }
/* Print enumerated type TYPE on STREAM. */ /* Print enumerated type TYPE on STREAM. */
@ -291,7 +300,8 @@ print_enum_type (struct type *type, struct ui_file *stream)
for (i = 0; i < len; i++) for (i = 0; i < len; i++)
{ {
QUIT; QUIT;
if (i) fprintf_filtered (stream, ", "); if (i)
fprintf_filtered (stream, ", ");
wrap_here (" "); wrap_here (" ");
fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream); fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream);
if (lastval != TYPE_FIELD_BITPOS (type, i)) if (lastval != TYPE_FIELD_BITPOS (type, i))
@ -317,7 +327,7 @@ print_fixed_point_type (struct type *type, struct ui_file *stream)
else else
{ {
fprintf_filtered (stream, "delta %g", (double) delta); fprintf_filtered (stream, "delta %g", (double) delta);
if (delta != small) if (delta != small)
fprintf_filtered (stream, " <'small = %g>", (double) small); fprintf_filtered (stream, " <'small = %g>", (double) small);
} }
} }
@ -337,7 +347,8 @@ print_vax_floating_point_type (struct type *type, struct ui_file *stream)
structure to show (see ada_print_type). */ structure to show (see ada_print_type). */
static void static void
print_array_type (struct type *type, struct ui_file *stream, int show, int level) print_array_type (struct type *type, struct ui_file *stream, int show,
int level)
{ {
int bitsize; int bitsize;
int n_indices; int n_indices;
@ -346,17 +357,17 @@ print_array_type (struct type *type, struct ui_file *stream, int show, int level
fprintf_filtered (stream, "array ("); fprintf_filtered (stream, "array (");
n_indices = -1; n_indices = -1;
if (show < 0) if (show < 0)
fprintf_filtered (stream, "..."); fprintf_filtered (stream, "...");
else else
{ {
if (ada_is_packed_array_type (type)) if (ada_is_packed_array_type (type))
type = ada_coerce_to_simple_array_type (type); type = ada_coerce_to_simple_array_type (type);
if (ada_is_simple_array (type)) if (ada_is_simple_array (type))
{ {
struct type* range_desc_type = struct type *range_desc_type =
ada_find_parallel_type (type, "___XA"); ada_find_parallel_type (type, "___XA");
struct type* arr_type; struct type *arr_type;
bitsize = 0; bitsize = 0;
if (range_desc_type == NULL) if (range_desc_type == NULL)
@ -371,24 +382,24 @@ print_array_type (struct type *type, struct ui_file *stream, int show, int level
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
} }
} }
else else
{ {
int k; int k;
n_indices = TYPE_NFIELDS (range_desc_type); n_indices = TYPE_NFIELDS (range_desc_type);
for (k = 0, arr_type = type; for (k = 0, arr_type = type;
k < n_indices; k < n_indices;
k += 1, arr_type = TYPE_TARGET_TYPE (arr_type)) k += 1, arr_type = TYPE_TARGET_TYPE (arr_type))
{ {
if (k > 0) if (k > 0)
fprintf_filtered (stream, ", "); fprintf_filtered (stream, ", ");
print_range_type_named (TYPE_FIELD_NAME (range_desc_type, k), print_range_type_named (TYPE_FIELD_NAME
stream); (range_desc_type, k), stream);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0) if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
} }
} }
} }
else else
{ {
int i, i0; int i, i0;
for (i = i0 = ada_array_arity (type); i > 0; i -= 1) for (i = i0 = ada_array_arity (type); i > 0; i -= 1)
@ -398,8 +409,8 @@ print_array_type (struct type *type, struct ui_file *stream, int show, int level
fprintf_filtered (stream, ") of "); fprintf_filtered (stream, ") of ");
wrap_here (""); wrap_here ("");
ada_print_type (ada_array_element_type (type, n_indices), "", stream, ada_print_type (ada_array_element_type (type, n_indices), "", stream,
show == 0 ? 0 : show-1, level+1); show == 0 ? 0 : show - 1, level + 1);
if (bitsize > 0) if (bitsize > 0)
fprintf_filtered (stream, " <packed: %d-bit elements>", bitsize); fprintf_filtered (stream, " <packed: %d-bit elements>", bitsize);
} }
@ -408,18 +419,19 @@ print_array_type (struct type *type, struct ui_file *stream, int show, int level
STREAM, assuming the VAL_TYPE is the type of the values. */ STREAM, assuming the VAL_TYPE is the type of the values. */
static void static void
print_choices (struct type *type, int field_num, struct ui_file *stream, struct type *val_type) print_choices (struct type *type, int field_num, struct ui_file *stream,
struct type *val_type)
{ {
int have_output; int have_output;
int p; int p;
const char* name = TYPE_FIELD_NAME (type, field_num); const char *name = TYPE_FIELD_NAME (type, field_num);
have_output = 0; have_output = 0;
/* Skip over leading 'V': NOTE soon to be obsolete. */ /* Skip over leading 'V': NOTE soon to be obsolete. */
if (name[0] == 'V') if (name[0] == 'V')
{ {
if (! ada_scan_number (name, 1, NULL, &p)) if (!ada_scan_number (name, 1, NULL, &p))
goto Huh; goto Huh;
} }
else else
@ -427,25 +439,25 @@ print_choices (struct type *type, int field_num, struct ui_file *stream, struct
while (1) while (1)
{ {
switch (name[p]) switch (name[p])
{ {
default: default:
return; return;
case 'S': case 'S':
case 'R': case 'R':
case 'O': case 'O':
if (have_output) if (have_output)
fprintf_filtered (stream, " | "); fprintf_filtered (stream, " | ");
have_output = 1; have_output = 1;
break; break;
} }
switch (name[p]) switch (name[p])
{ {
case 'S': case 'S':
{ {
LONGEST W; LONGEST W;
if (! ada_scan_number (name, p + 1, &W, &p)) if (!ada_scan_number (name, p + 1, &W, &p))
goto Huh; goto Huh;
ada_print_scalar (val_type, W, stream); ada_print_scalar (val_type, W, stream);
break; break;
@ -453,9 +465,8 @@ print_choices (struct type *type, int field_num, struct ui_file *stream, struct
case 'R': case 'R':
{ {
LONGEST L, U; LONGEST L, U;
if (! ada_scan_number (name, p + 1, &L, &p) if (!ada_scan_number (name, p + 1, &L, &p)
|| name[p] != 'T' || name[p] != 'T' || !ada_scan_number (name, p + 1, &U, &p))
|| ! ada_scan_number (name, p + 1, &U, &p))
goto Huh; goto Huh;
ada_print_scalar (val_type, L, stream); ada_print_scalar (val_type, L, stream);
fprintf_filtered (stream, " .. "); fprintf_filtered (stream, " .. ");
@ -498,7 +509,7 @@ print_variant_clauses (struct type *type, int field_num,
if (TYPE_CODE (var_type) == TYPE_CODE_PTR) if (TYPE_CODE (var_type) == TYPE_CODE_PTR)
{ {
var_type = TYPE_TARGET_TYPE (var_type); var_type = TYPE_TARGET_TYPE (var_type);
if (TYPE_FLAGS (var_type) & TYPE_FLAG_STUB) if (TYPE_FLAGS (var_type) & TYPE_FLAG_STUB)
{ {
var_type = ada_find_parallel_type (var_type, "___XVU"); var_type = ada_find_parallel_type (var_type, "___XVU");
if (var_type == NULL) if (var_type == NULL)
@ -506,13 +517,13 @@ print_variant_clauses (struct type *type, int field_num,
} }
} }
for (i = 0; i < TYPE_NFIELDS (var_type); i += 1) for (i = 0; i < TYPE_NFIELDS (var_type); i += 1)
{ {
fprintf_filtered (stream, "\n%*swhen ", level + 4, ""); fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
print_choices (var_type, i, stream, discr_type); print_choices (var_type, i, stream, discr_type);
fprintf_filtered (stream, " =>"); fprintf_filtered (stream, " =>");
if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i), if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
outer_type, stream, show, level+4) <= 0) outer_type, stream, show, level + 4) <= 0)
fprintf_filtered (stream, " null;"); fprintf_filtered (stream, " null;");
} }
} }
@ -530,9 +541,10 @@ print_variant_part (struct type *type, int field_num, struct type *outer_type,
struct ui_file *stream, int show, int level) struct ui_file *stream, int show, int level)
{ {
fprintf_filtered (stream, "\n%*scase %s is", level + 4, "", fprintf_filtered (stream, "\n%*scase %s is", level + 4, "",
ada_variant_discrim_name ada_variant_discrim_name
(TYPE_FIELD_TYPE (type, field_num))); (TYPE_FIELD_TYPE (type, field_num)));
print_variant_clauses (type, field_num, outer_type, stream, show, level + 4); print_variant_clauses (type, field_num, outer_type, stream, show,
level + 4);
fprintf_filtered (stream, "\n%*send case;", level + 4, ""); fprintf_filtered (stream, "\n%*send case;", level + 4, "");
} }
@ -561,13 +573,12 @@ print_record_field_types (struct type *type, struct type *outer_type,
{ {
QUIT; QUIT;
if (ada_is_parent_field (type, i) if (ada_is_parent_field (type, i) || ada_is_ignored_field (type, i))
|| ada_is_ignored_field (type, i))
; ;
else if (ada_is_wrapper_field (type, i)) else if (ada_is_wrapper_field (type, i))
flds += print_record_field_types (TYPE_FIELD_TYPE (type, i), type, flds += print_record_field_types (TYPE_FIELD_TYPE (type, i), type,
stream, show, level); stream, show, level);
else if (ada_is_variant_part (type, i)) else if (ada_is_variant_part (type, i))
{ {
print_variant_part (type, i, outer_type, stream, show, level); print_variant_part (type, i, outer_type, stream, show, level);
flds = 1; flds = 1;
@ -591,22 +602,23 @@ print_record_field_types (struct type *type, struct type *outer_type,
the number of levels of internal structure to show (see ada_print_type). */ the number of levels of internal structure to show (see ada_print_type). */
static void static void
print_record_type (struct type* type0, struct ui_file* stream, int show, int level) print_record_type (struct type *type0, struct ui_file *stream, int show,
int level)
{ {
struct type* parent_type; struct type *parent_type;
struct type* type; struct type *type;
type = type0; type = type0;
if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
{ {
struct type* type1 = ada_find_parallel_type (type, "___XVE"); struct type *type1 = ada_find_parallel_type (type, "___XVE");
if (type1 != NULL) if (type1 != NULL)
type = type1; type = type1;
} }
parent_type = ada_parent_type (type); parent_type = ada_parent_type (type);
if (ada_type_name (parent_type) != NULL) if (ada_type_name (parent_type) != NULL)
fprintf_filtered (stream, "new %s with ", fprintf_filtered (stream, "new %s with ",
demangled_type_name (parent_type)); demangled_type_name (parent_type));
else if (parent_type == NULL && ada_is_tagged_type (type)) else if (parent_type == NULL && ada_is_tagged_type (type))
fprintf_filtered (stream, "tagged "); fprintf_filtered (stream, "tagged ");
@ -621,15 +633,15 @@ print_record_type (struct type* type0, struct ui_file* stream, int show, int lev
flds = 0; flds = 0;
if (parent_type != NULL && ada_type_name (parent_type) == NULL) if (parent_type != NULL && ada_type_name (parent_type) == NULL)
flds += print_record_field_types (parent_type, parent_type, flds += print_record_field_types (parent_type, parent_type,
stream, show, level); stream, show, level);
flds += print_record_field_types (type, type, stream, show, level); flds += print_record_field_types (type, type, stream, show, level);
if (flds > 0) if (flds > 0)
fprintf_filtered (stream, "\n%*send record", level, ""); fprintf_filtered (stream, "\n%*send record", level, "");
else if (flds < 0) else if (flds < 0)
fprintf_filtered (stream, " <incomplete type> end record"); fprintf_filtered (stream, " <incomplete type> end record");
else else
fprintf_filtered (stream, " null; end record"); fprintf_filtered (stream, " null; end record");
} }
} }
@ -639,44 +651,43 @@ print_record_type (struct type* type0, struct ui_file* stream, int show, int lev
in case the element type itself has nested structure, and SHOW is the in case the element type itself has nested structure, and SHOW is the
number of levels of internal structure to show (see ada_print_type). */ number of levels of internal structure to show (see ada_print_type). */
static void static void
print_unchecked_union_type (struct type* type, struct ui_file* stream, print_unchecked_union_type (struct type *type, struct ui_file *stream,
int show, int level) int show, int level)
{ {
fprintf_filtered (stream, "record (?) is"); fprintf_filtered (stream, "record (?) is");
if (show < 0) if (show < 0)
fprintf_filtered (stream, " ... end record"); fprintf_filtered (stream, " ... end record");
else if (TYPE_NFIELDS (type) == 0) else if (TYPE_NFIELDS (type) == 0)
fprintf_filtered (stream, " null; end record"); fprintf_filtered (stream, " null; end record");
else else
{ {
int i; int i;
fprintf_filtered (stream, "\n%*scase ? is", fprintf_filtered (stream, "\n%*scase ? is", level + 4, "");
level+4, "");
for (i = 0; i < TYPE_NFIELDS (type); i += 1) for (i = 0; i < TYPE_NFIELDS (type); i += 1)
{ {
fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level+8, "", fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "",
level+12, ""); level + 12, "");
ada_print_type (TYPE_FIELD_TYPE (type, i), ada_print_type (TYPE_FIELD_TYPE (type, i),
TYPE_FIELD_NAME (type, i), TYPE_FIELD_NAME (type, i),
stream, show - 1, level + 12); stream, show - 1, level + 12);
fprintf_filtered (stream, ";"); fprintf_filtered (stream, ";");
} }
fprintf_filtered (stream, "\n%*send case;\n%*send record", fprintf_filtered (stream, "\n%*send case;\n%*send record",
level+4, "", level, ""); level + 4, "", level, "");
} }
} }
/* Print function or procedure type TYPE on STREAM. Make it a header /* Print function or procedure type TYPE on STREAM. Make it a header
for function or procedure NAME if NAME is not null. */ for function or procedure NAME if NAME is not null. */
static void static void
print_func_type (struct type *type, struct ui_file *stream, char* name) print_func_type (struct type *type, struct ui_file *stream, char *name)
{ {
int i, len = TYPE_NFIELDS (type); int i, len = TYPE_NFIELDS (type);
@ -685,10 +696,10 @@ print_func_type (struct type *type, struct ui_file *stream, char* name)
else else
fprintf_filtered (stream, "function"); fprintf_filtered (stream, "function");
if (name != NULL && name[0] != '\0') if (name != NULL && name[0] != '\0')
fprintf_filtered (stream, " %s", name); fprintf_filtered (stream, " %s", name);
if (len > 0) if (len > 0)
{ {
fprintf_filtered (stream, " ("); fprintf_filtered (stream, " (");
for (i = 0; i < len; i += 1) for (i = 0; i < len; i += 1)
@ -698,11 +709,11 @@ print_func_type (struct type *type, struct ui_file *stream, char* name)
fputs_filtered ("; ", stream); fputs_filtered ("; ", stream);
wrap_here (" "); wrap_here (" ");
} }
fprintf_filtered (stream, "a%d: ", i+1); fprintf_filtered (stream, "a%d: ", i + 1);
ada_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); ada_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
} }
fprintf_filtered (stream, ")"); fprintf_filtered (stream, ")");
} }
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID)
{ {
@ -726,35 +737,34 @@ print_func_type (struct type *type, struct ui_file *stream, char* name)
LEVEL indicates level of recursion (for nested definitions). */ LEVEL indicates level of recursion (for nested definitions). */
void void
ada_print_type (struct type* type0, char* varstring, struct ui_file* stream, ada_print_type (struct type *type0, char *varstring, struct ui_file *stream,
int show, int level) int show, int level)
{ {
enum type_code code; enum type_code code;
int demangled_args; int demangled_args;
struct type* type = ada_completed_type (ada_get_base_type (type0)); struct type *type = ada_completed_type (ada_get_base_type (type0));
char* type_name = demangled_type_name (type); char *type_name = demangled_type_name (type);
int is_var_decl = (varstring != NULL && varstring[0] != '\0'); int is_var_decl = (varstring != NULL && varstring[0] != '\0');
if (type == NULL) if (type == NULL)
{ {
if (is_var_decl) if (is_var_decl)
fprintf_filtered (stream, "%.*s: ", fprintf_filtered (stream, "%.*s: ",
ada_name_prefix_len(varstring), ada_name_prefix_len (varstring), varstring);
varstring);
fprintf_filtered (stream, "<null type?>"); fprintf_filtered (stream, "<null type?>");
return; return;
} }
if (show > 0) if (show > 0)
CHECK_TYPEDEF (type); CHECK_TYPEDEF (type);
if (is_var_decl && TYPE_CODE (type) != TYPE_CODE_FUNC) if (is_var_decl && TYPE_CODE (type) != TYPE_CODE_FUNC)
fprintf_filtered (stream, "%.*s: ", fprintf_filtered (stream, "%.*s: ",
ada_name_prefix_len (varstring), varstring); ada_name_prefix_len (varstring), varstring);
if (type_name != NULL && show <= 0) if (type_name != NULL && show <= 0)
{ {
fprintf_filtered (stream, "%.*s", fprintf_filtered (stream, "%.*s",
ada_name_prefix_len (type_name), type_name); ada_name_prefix_len (type_name), type_name);
return; return;
} }
@ -764,78 +774,78 @@ ada_print_type (struct type* type0, char* varstring, struct ui_file* stream,
else if (ada_is_packed_array_type (type)) else if (ada_is_packed_array_type (type))
print_array_type (type, stream, show, level); print_array_type (type, stream, show, level);
else else
switch (TYPE_CODE (type)) switch (TYPE_CODE (type))
{ {
default: default:
fprintf_filtered (stream, "<"); fprintf_filtered (stream, "<");
c_print_type (type, "", stream, show, level); c_print_type (type, "", stream, show, level);
fprintf_filtered (stream, ">"); fprintf_filtered (stream, ">");
break; break;
case TYPE_CODE_PTR: case TYPE_CODE_PTR:
fprintf_filtered (stream, "access "); fprintf_filtered (stream, "access ");
ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
level); break;
break; case TYPE_CODE_REF:
case TYPE_CODE_REF: fprintf_filtered (stream, "<ref> ");
fprintf_filtered (stream, "<ref> "); ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, break;
level); case TYPE_CODE_ARRAY:
break;
case TYPE_CODE_ARRAY:
print_array_type (type, stream, show, level);
break;
case TYPE_CODE_INT:
if (ada_is_fixed_point_type (type))
print_fixed_point_type (type, stream);
else if (ada_is_vax_floating_type (type))
print_vax_floating_point_type (type, stream);
else
{
char* name = ada_type_name (type);
if (! ada_is_range_type_name (name))
fprintf_filtered (stream, "<%d-byte integer>", TYPE_LENGTH (type));
else
{
fprintf_filtered (stream, "range ");
print_range_type_named (name, stream);
}
}
break;
case TYPE_CODE_RANGE:
if (ada_is_fixed_point_type (type))
print_fixed_point_type (type, stream);
else if (ada_is_vax_floating_type (type))
print_vax_floating_point_type (type, stream);
else if (ada_is_modular_type (type))
fprintf_filtered (stream, "mod %ld", (long) ada_modulus (type));
else
{
fprintf_filtered (stream, "range ");
print_range (type, stream);
}
break;
case TYPE_CODE_FLT:
fprintf_filtered (stream, "<%d-byte float>", TYPE_LENGTH (type));
break;
case TYPE_CODE_ENUM:
if (show < 0)
fprintf_filtered (stream, "(...)");
else
print_enum_type (type, stream);
break;
case TYPE_CODE_STRUCT:
if (ada_is_array_descriptor (type))
print_array_type (type, stream, show, level); print_array_type (type, stream, show, level);
else if (ada_is_bogus_array_descriptor (type)) break;
fprintf_filtered (stream, "array (?) of ? (<mal-formed descriptor>)"); case TYPE_CODE_INT:
else if (ada_is_fixed_point_type (type))
print_record_type (type, stream, show, level); print_fixed_point_type (type, stream);
break; else if (ada_is_vax_floating_type (type))
case TYPE_CODE_UNION: print_vax_floating_point_type (type, stream);
print_unchecked_union_type (type, stream, show, level); else
break; {
case TYPE_CODE_FUNC: char *name = ada_type_name (type);
print_func_type (type, stream, varstring); if (!ada_is_range_type_name (name))
break; fprintf_filtered (stream, "<%d-byte integer>",
} TYPE_LENGTH (type));
else
{
fprintf_filtered (stream, "range ");
print_range_type_named (name, stream);
}
}
break;
case TYPE_CODE_RANGE:
if (ada_is_fixed_point_type (type))
print_fixed_point_type (type, stream);
else if (ada_is_vax_floating_type (type))
print_vax_floating_point_type (type, stream);
else if (ada_is_modular_type (type))
fprintf_filtered (stream, "mod %ld", (long) ada_modulus (type));
else
{
fprintf_filtered (stream, "range ");
print_range (type, stream);
}
break;
case TYPE_CODE_FLT:
fprintf_filtered (stream, "<%d-byte float>", TYPE_LENGTH (type));
break;
case TYPE_CODE_ENUM:
if (show < 0)
fprintf_filtered (stream, "(...)");
else
print_enum_type (type, stream);
break;
case TYPE_CODE_STRUCT:
if (ada_is_array_descriptor (type))
print_array_type (type, stream, show, level);
else if (ada_is_bogus_array_descriptor (type))
fprintf_filtered (stream,
"array (?) of ? (<mal-formed descriptor>)");
else
print_record_type (type, stream, show, level);
break;
case TYPE_CODE_UNION:
print_unchecked_union_type (type, stream, show, level);
break;
case TYPE_CODE_FUNC:
print_func_type (type, stream, varstring);
break;
}
} }

View file

@ -32,9 +32,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "c-lang.h" #include "c-lang.h"
/* Encapsulates arguments to ada_val_print. */ /* Encapsulates arguments to ada_val_print. */
struct ada_val_print_args { struct ada_val_print_args
struct type* type; {
char* valaddr0; struct type *type;
char *valaddr0;
int embedded_offset; int embedded_offset;
CORE_ADDR address; CORE_ADDR address;
struct ui_file *stream; struct ui_file *stream;
@ -47,45 +48,47 @@ struct ada_val_print_args {
extern int inspect_it; extern int inspect_it;
extern unsigned int repeat_count_threshold; extern unsigned int repeat_count_threshold;
static void print_record (struct type*, char*, struct ui_file*, int, static void print_record (struct type *, char *, struct ui_file *, int,
int, enum val_prettyprint); int, enum val_prettyprint);
static int print_field_values (struct type*, char*, struct ui_file*, static int print_field_values (struct type *, char *, struct ui_file *,
int, int, enum val_prettyprint, int, int, enum val_prettyprint,
int, struct type*, char*); int, struct type *, char *);
static int print_variant_part (struct type*, int, char*, static int print_variant_part (struct type *, int, char *,
struct ui_file*, int, int, enum val_prettyprint, struct ui_file *, int, int,
int, struct type*, char*); enum val_prettyprint, int, struct type *,
char *);
static void val_print_packed_array_elements (struct type*, char *valaddr, int, static void val_print_packed_array_elements (struct type *, char *valaddr,
struct ui_file*, int, int, int, struct ui_file *, int, int,
enum val_prettyprint); enum val_prettyprint);
static void adjust_type_signedness (struct type*); static void adjust_type_signedness (struct type *);
static int ada_val_print_stub (PTR args0); static int ada_val_print_stub (PTR args0);
static int ada_val_print_1 (struct type*, char*, int, CORE_ADDR, struct ui_file*, static int ada_val_print_1 (struct type *, char *, int, CORE_ADDR,
int, int, int, enum val_prettyprint); struct ui_file *, int, int, int,
enum val_prettyprint);
/* Make TYPE unsigned if its range of values includes no negatives. */ /* Make TYPE unsigned if its range of values includes no negatives. */
static void static void
adjust_type_signedness (type) adjust_type_signedness (type)
struct type* type; struct type *type;
{ {
if (type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE if (type != NULL && TYPE_CODE (type) == TYPE_CODE_RANGE
&& TYPE_LOW_BOUND (type) >= 0) && TYPE_LOW_BOUND (type) >= 0)
TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED; TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
} }
/* Assuming TYPE is a simple array type, prints its lower bound on STREAM, /* Assuming TYPE is a simple array type, prints its lower bound on STREAM,
if non-standard (i.e., other than 1 for numbers, other than lower bound if non-standard (i.e., other than 1 for numbers, other than lower bound
of index type for enumerated type). Returns 1 if something printed, of index type for enumerated type). Returns 1 if something printed,
otherwise 0. */ otherwise 0. */
static int static int
print_optional_low_bound (struct ui_file *stream, struct type *type) print_optional_low_bound (struct ui_file *stream, struct type *type)
{ {
struct type *index_type; struct type *index_type;
@ -96,27 +99,28 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
if (index_type == NULL) if (index_type == NULL)
return 0; return 0;
if (TYPE_CODE (index_type) == TYPE_CODE_RANGE) if (TYPE_CODE (index_type) == TYPE_CODE_RANGE)
{ {
low_bound = TYPE_LOW_BOUND (index_type); low_bound = TYPE_LOW_BOUND (index_type);
index_type = TYPE_TARGET_TYPE (index_type); index_type = TYPE_TARGET_TYPE (index_type);
} }
else else
return 0; return 0;
switch (TYPE_CODE (index_type)) { switch (TYPE_CODE (index_type))
case TYPE_CODE_ENUM: {
if (low_bound == TYPE_FIELD_BITPOS (index_type, 0)) case TYPE_CODE_ENUM:
return 0; if (low_bound == TYPE_FIELD_BITPOS (index_type, 0))
break; return 0;
case TYPE_CODE_UNDEF: break;
index_type = builtin_type_long; case TYPE_CODE_UNDEF:
/* FALL THROUGH */ index_type = builtin_type_long;
default: /* FALL THROUGH */
if (low_bound == 1) default:
return 0; if (low_bound == 1)
break; return 0;
} break;
}
ada_print_scalar (index_type, (LONGEST) low_bound, stream); ada_print_scalar (index_type, (LONGEST) low_bound, stream);
fprintf_filtered (stream, " => "); fprintf_filtered (stream, " => ");
@ -128,7 +132,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type)
BITOFFSET from VALADDR on STREAM. Formats according to FORMAT and BITOFFSET from VALADDR on STREAM. Formats according to FORMAT and
separates with commas. RECURSE is the recursion (nesting) level. separates with commas. RECURSE is the recursion (nesting) level.
If PRETTY, uses "prettier" format. TYPE must have been decoded (as If PRETTY, uses "prettier" format. TYPE must have been decoded (as
by ada_coerce_to_simple_array). */ by ada_coerce_to_simple_array). */
static void static void
val_print_packed_array_elements (struct type *type, char *valaddr, val_print_packed_array_elements (struct type *type, char *valaddr,
@ -147,8 +151,8 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
/* Number of repetitions we have detected so far. */ /* Number of repetitions we have detected so far. */
unsigned int reps; unsigned int reps;
unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0); unsigned long bitsize = TYPE_FIELD_BITSIZE (type, 0);
struct value* mark = value_mark (); struct value *mark = value_mark ();
elttype = TYPE_TARGET_TYPE (type); elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (check_typedef (elttype)); eltlen = TYPE_LENGTH (check_typedef (elttype));
@ -183,7 +187,7 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
wrap_here (n_spaces (2 + 2 * recurse)); wrap_here (n_spaces (2 + 2 * recurse));
i0 = i; i0 = i;
v0 = ada_value_primitive_packed_val (NULL, valaddr, v0 = ada_value_primitive_packed_val (NULL, valaddr,
(i0 * bitsize) / HOST_CHAR_BIT, (i0 * bitsize) / HOST_CHAR_BIT,
(i0 * bitsize) % HOST_CHAR_BIT, (i0 * bitsize) % HOST_CHAR_BIT,
bitsize, elttype); bitsize, elttype);
@ -192,12 +196,11 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
i += 1; i += 1;
if (i >= len) if (i >= len)
break; break;
v1 = ada_value_primitive_packed_val (NULL, valaddr, v1 = ada_value_primitive_packed_val (NULL, valaddr,
(i * bitsize) / HOST_CHAR_BIT, (i * bitsize) / HOST_CHAR_BIT,
(i * bitsize) % HOST_CHAR_BIT, (i * bitsize) % HOST_CHAR_BIT,
bitsize, elttype); bitsize, elttype);
if (memcmp (VALUE_CONTENTS (v0), VALUE_CONTENTS (v1), eltlen) if (memcmp (VALUE_CONTENTS (v0), VALUE_CONTENTS (v1), eltlen) != 0)
!= 0)
break; break;
} }
@ -215,7 +218,7 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
int j; int j;
for (j = i0; j < i; j += 1) for (j = i0; j < i; j += 1)
{ {
if (j > i0) if (j > i0)
{ {
if (prettyprint_arrays) if (prettyprint_arrays)
{ {
@ -244,8 +247,8 @@ val_print_packed_array_elements (struct type *type, char *valaddr,
value_free_to_mark (mark); value_free_to_mark (mark);
} }
static struct type* static struct type *
printable_val_type (struct type* type, char* valaddr) printable_val_type (struct type *type, char *valaddr)
{ {
return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL); return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL);
} }
@ -270,19 +273,19 @@ ada_emit_char (int c, struct ui_file *stream, int quoter, int type_len)
fprintf_filtered (stream, "%c", c); fprintf_filtered (stream, "%c", c);
} }
else else
fprintf_filtered (stream, "[\"%0*x\"]", type_len*2, c); fprintf_filtered (stream, "[\"%0*x\"]", type_len * 2, c);
} }
/* Character #I of STRING, given that TYPE_LEN is the size in bytes (1 /* Character #I of STRING, given that TYPE_LEN is the size in bytes (1
or 2) of a character. */ or 2) of a character. */
static int static int
char_at (char* string, int i, int type_len) char_at (char *string, int i, int type_len)
{ {
if (type_len == 1) if (type_len == 1)
return string[i]; return string[i];
else else
return (int) extract_unsigned_integer (string + 2*i, 2); return (int) extract_unsigned_integer (string + 2 * i, 2);
} }
void void
@ -390,7 +393,7 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
for (i = 0; i < length && things_printed < print_max; i += 1) for (i = 0; i < length && things_printed < print_max; i += 1)
{ {
/* Position of the character we are examining /* Position of the character we are examining
to see whether it is repeated. */ to see whether it is repeated. */
unsigned int rep1; unsigned int rep1;
/* Number of repetitions we have detected so far. */ /* Number of repetitions we have detected so far. */
unsigned int reps; unsigned int reps;
@ -405,8 +408,9 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
rep1 = i + 1; rep1 = i + 1;
reps = 1; reps = 1;
while (rep1 < length && while (rep1 < length &&
char_at(string, rep1, type_len) == char_at (string, i, type_len)) char_at (string, rep1, type_len) == char_at (string, i,
type_len))
{ {
rep1 += 1; rep1 += 1;
reps += 1; reps += 1;
@ -423,7 +427,8 @@ printstr (struct ui_file *stream, char *string, unsigned int length,
in_quotes = 0; in_quotes = 0;
} }
fputs_filtered ("'", stream); fputs_filtered ("'", stream);
ada_emit_char (char_at (string, i, type_len), stream, '\'', type_len); ada_emit_char (char_at (string, i, type_len), stream, '\'',
type_len);
fputs_filtered ("'", stream); fputs_filtered ("'", stream);
fprintf_filtered (stream, " <repeats %u times>", reps); fprintf_filtered (stream, " <repeats %u times>", reps);
i = rep1 - 1; i = rep1 - 1;
@ -487,12 +492,13 @@ ada_printstr (struct ui_file *stream, char *string, unsigned int length,
arrays.) */ arrays.) */
int int
ada_val_print (struct type* type, char* valaddr0, int embedded_offset, ada_val_print (struct type *type, char *valaddr0, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format, CORE_ADDR address, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty) int deref_ref, int recurse, enum val_prettyprint pretty)
{ {
struct ada_val_print_args args; struct ada_val_print_args args;
args.type = type; args.valaddr0 = valaddr0; args.type = type;
args.valaddr0 = valaddr0;
args.embedded_offset = embedded_offset; args.embedded_offset = embedded_offset;
args.address = address; args.address = address;
args.stream = stream; args.stream = stream;
@ -509,18 +515,18 @@ ada_val_print (struct type* type, char* valaddr0, int embedded_offset,
static int static int
ada_val_print_stub (PTR args0) ada_val_print_stub (PTR args0)
{ {
struct ada_val_print_args* argsp = (struct ada_val_print_args*) args0; struct ada_val_print_args *argsp = (struct ada_val_print_args *) args0;
return ada_val_print_1 (argsp->type, argsp->valaddr0, argsp->embedded_offset, return ada_val_print_1 (argsp->type, argsp->valaddr0,
argsp->address, argsp->stream, argsp->format, argsp->embedded_offset, argsp->address,
argsp->deref_ref, argsp->recurse, argsp->stream, argsp->format, argsp->deref_ref,
argsp->pretty); argsp->recurse, argsp->pretty);
} }
/* See the comment on ada_val_print. This function differs in that it /* See the comment on ada_val_print. This function differs in that it
* does not catch evaluation errors (leaving that to ada_val_print). */ * does not catch evaluation errors (leaving that to ada_val_print). */
static int static int
ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset, ada_val_print_1 (struct type *type, char *valaddr0, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format, CORE_ADDR address, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty) int deref_ref, int recurse, enum val_prettyprint pretty)
{ {
@ -530,15 +536,15 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
unsigned int eltlen; unsigned int eltlen;
LONGEST val; LONGEST val;
CORE_ADDR addr; CORE_ADDR addr;
char* valaddr = valaddr0 + embedded_offset; char *valaddr = valaddr0 + embedded_offset;
CHECK_TYPEDEF (type); CHECK_TYPEDEF (type);
if (ada_is_array_descriptor (type) || ada_is_packed_array_type (type)) if (ada_is_array_descriptor (type) || ada_is_packed_array_type (type))
{ {
int retn; int retn;
struct value* mark = value_mark (); struct value *mark = value_mark ();
struct value* val; struct value *val;
val = value_from_contents_and_address (type, valaddr, address); val = value_from_contents_and_address (type, valaddr, address);
val = ada_coerce_to_simple_array_ptr (val); val = ada_coerce_to_simple_array_ptr (val);
if (val == NULL) if (val == NULL)
@ -548,7 +554,7 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
} }
else else
retn = ada_val_print_1 (VALUE_TYPE (val), VALUE_CONTENTS (val), 0, retn = ada_val_print_1 (VALUE_TYPE (val), VALUE_CONTENTS (val), 0,
VALUE_ADDRESS (val), stream, format, VALUE_ADDRESS (val), stream, format,
deref_ref, recurse, pretty); deref_ref, recurse, pretty);
value_free_to_mark (mark); value_free_to_mark (mark);
return retn; return retn;
@ -561,7 +567,7 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
switch (TYPE_CODE (type)) switch (TYPE_CODE (type))
{ {
default: default:
return c_val_print (type, valaddr0, embedded_offset, address, stream, return c_val_print (type, valaddr0, embedded_offset, address, stream,
format, deref_ref, recurse, pretty); format, deref_ref, recurse, pretty);
case TYPE_CODE_INT: case TYPE_CODE_INT:
@ -577,26 +583,26 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
} }
else if (ada_is_vax_floating_type (type)) else if (ada_is_vax_floating_type (type))
{ {
struct value* val = struct value *val =
value_from_contents_and_address (type, valaddr, address); value_from_contents_and_address (type, valaddr, address);
struct value* func = ada_vax_float_print_function (type); struct value *func = ada_vax_float_print_function (type);
if (func != 0) if (func != 0)
{ {
static struct type* parray_of_char = NULL; static struct type *parray_of_char = NULL;
struct value* printable_val; struct value *printable_val;
if (parray_of_char == NULL) if (parray_of_char == NULL)
parray_of_char = parray_of_char =
make_pointer_type make_pointer_type
(create_array_type (create_array_type
(NULL, builtin_type_char, (NULL, builtin_type_char,
create_range_type (NULL, builtin_type_int, 0, 32)), create_range_type (NULL, builtin_type_int, 0, 32)), NULL);
NULL);
printable_val = printable_val =
value_ind (value_cast (parray_of_char, value_ind (value_cast (parray_of_char,
call_function_by_hand (func, 1, &val))); call_function_by_hand (func, 1,
&val)));
fprintf_filtered (stream, "%s", VALUE_CONTENTS (printable_val)); fprintf_filtered (stream, "%s", VALUE_CONTENTS (printable_val));
return 0; return 0;
} }
@ -604,26 +610,26 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
} }
else if (TYPE_CODE (type) == TYPE_CODE_RANGE) else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
{ {
struct type* target_type = TYPE_TARGET_TYPE (type); struct type *target_type = TYPE_TARGET_TYPE (type);
if (TYPE_LENGTH (type) != TYPE_LENGTH (target_type)) if (TYPE_LENGTH (type) != TYPE_LENGTH (target_type))
{ {
/* Obscure case of range type that has different length from /* Obscure case of range type that has different length from
its base type. Perform a conversion, or we will get a its base type. Perform a conversion, or we will get a
nonsense value. Actually, we could use the same nonsense value. Actually, we could use the same
code regardless of lengths; I'm just avoiding a cast. */ code regardless of lengths; I'm just avoiding a cast. */
struct value* v = struct value *v = value_cast (target_type,
value_cast (target_type, value_from_contents_and_address
value_from_contents_and_address (type, valaddr, 0)); (type, valaddr, 0));
return ada_val_print_1 (target_type, VALUE_CONTENTS (v), 0, 0, return ada_val_print_1 (target_type, VALUE_CONTENTS (v), 0, 0,
stream, format, 0, recurse + 1, pretty); stream, format, 0, recurse + 1, pretty);
} }
else else
return ada_val_print_1 (TYPE_TARGET_TYPE (type), return ada_val_print_1 (TYPE_TARGET_TYPE (type),
valaddr0, embedded_offset, valaddr0, embedded_offset,
address, stream, format, deref_ref, address, stream, format, deref_ref,
recurse, pretty); recurse, pretty);
} }
else else
{ {
format = format ? format : output_format; format = format ? format : output_format;
if (format) if (format)
@ -661,8 +667,8 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
} }
if (i < len) if (i < len)
{ {
const char* name = ada_enum_name (TYPE_FIELD_NAME (type, i)); const char *name = ada_enum_name (TYPE_FIELD_NAME (type, i));
if (name[0] == '\'') if (name[0] == '\'')
fprintf_filtered (stream, "%ld %s", (long) val, name); fprintf_filtered (stream, "%ld %s", (long) val, name);
else else
fputs_filtered (name, stream); fputs_filtered (name, stream);
@ -672,18 +678,17 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
print_longest (stream, 'd', 0, val); print_longest (stream, 'd', 0, val);
} }
break; break;
case TYPE_CODE_UNION: case TYPE_CODE_UNION:
case TYPE_CODE_STRUCT: case TYPE_CODE_STRUCT:
if (ada_is_bogus_array_descriptor (type)) if (ada_is_bogus_array_descriptor (type))
{ {
fprintf_filtered (stream, "(...?)"); fprintf_filtered (stream, "(...?)");
return 0; return 0;
} }
else else
{ {
print_record (type, valaddr, stream, format, print_record (type, valaddr, stream, format, recurse, pretty);
recurse, pretty);
return 0; return 0;
} }
@ -693,21 +698,20 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
elttype = TYPE_TARGET_TYPE (type); elttype = TYPE_TARGET_TYPE (type);
eltlen = TYPE_LENGTH (elttype); eltlen = TYPE_LENGTH (elttype);
len = TYPE_LENGTH (type) / eltlen; len = TYPE_LENGTH (type) / eltlen;
/* For an array of chars, print with string syntax. */ /* For an array of chars, print with string syntax. */
if (ada_is_string_type (type) if (ada_is_string_type (type) && (format == 0 || format == 's'))
&& (format == 0 || format == 's'))
{ {
if (prettyprint_arrays) if (prettyprint_arrays)
{ {
print_spaces_filtered (2 + 2 * recurse, stream); print_spaces_filtered (2 + 2 * recurse, stream);
} }
/* If requested, look for the first null char and only print /* If requested, look for the first null char and only print
elements up to it. */ elements up to it. */
if (stop_print_at_null) if (stop_print_at_null)
{ {
int temp_len; int temp_len;
/* Look for a NULL char. */ /* Look for a NULL char. */
for (temp_len = 0; for (temp_len = 0;
temp_len < len && temp_len < print_max temp_len < len && temp_len < print_max
@ -715,7 +719,7 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
temp_len += 1); temp_len += 1);
len = temp_len; len = temp_len;
} }
printstr (stream, valaddr, len, 0, eltlen); printstr (stream, valaddr, len, 0, eltlen);
} }
else else
@ -723,10 +727,9 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
len = 0; len = 0;
fprintf_filtered (stream, "("); fprintf_filtered (stream, "(");
print_optional_low_bound (stream, type); print_optional_low_bound (stream, type);
if (TYPE_FIELD_BITSIZE (type, 0) > 0) if (TYPE_FIELD_BITSIZE (type, 0) > 0)
val_print_packed_array_elements (type, valaddr, 0, stream, val_print_packed_array_elements (type, valaddr, 0, stream,
format, recurse, format, recurse, pretty);
pretty);
else else
val_print_array_elements (type, valaddr, address, stream, val_print_array_elements (type, valaddr, address, stream,
format, deref_ref, recurse, format, deref_ref, recurse,
@ -740,27 +743,27 @@ ada_val_print_1 (struct type* type, char* valaddr0, int embedded_offset,
case TYPE_CODE_REF: case TYPE_CODE_REF:
elttype = check_typedef (TYPE_TARGET_TYPE (type)); elttype = check_typedef (TYPE_TARGET_TYPE (type));
if (addressprint) if (addressprint)
{ {
fprintf_filtered (stream, "@"); fprintf_filtered (stream, "@");
print_address_numeric print_address_numeric
(extract_address (valaddr, (extract_address (valaddr,
TARGET_PTR_BIT / HOST_CHAR_BIT), 1, stream); TARGET_PTR_BIT / HOST_CHAR_BIT), 1, stream);
if (deref_ref) if (deref_ref)
fputs_filtered (": ", stream); fputs_filtered (": ", stream);
} }
/* De-reference the reference */ /* De-reference the reference */
if (deref_ref) if (deref_ref)
{ {
if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
{ {
LONGEST deref_val_int = (LONGEST) LONGEST deref_val_int = (LONGEST)
unpack_pointer (lookup_pointer_type (builtin_type_void), unpack_pointer (lookup_pointer_type (builtin_type_void),
valaddr); valaddr);
if (deref_val_int != 0) if (deref_val_int != 0)
{ {
struct value* deref_val = struct value *deref_val =
ada_value_ind (value_from_longest ada_value_ind (value_from_longest
(lookup_pointer_type (elttype), (lookup_pointer_type (elttype),
deref_val_int)); deref_val_int));
val_print (VALUE_TYPE (deref_val), val_print (VALUE_TYPE (deref_val),
VALUE_CONTENTS (deref_val), 0, VALUE_CONTENTS (deref_val), 0,
@ -785,13 +788,12 @@ print_variant_part (struct type *type, int field_num, char *valaddr,
struct type *outer_type, char *outer_valaddr) struct type *outer_type, char *outer_valaddr)
{ {
struct type *var_type = TYPE_FIELD_TYPE (type, field_num); struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
int which = int which = ada_which_variant_applies (var_type, outer_type, outer_valaddr);
ada_which_variant_applies (var_type, outer_type, outer_valaddr);
if (which < 0) if (which < 0)
return 0; return 0;
else else
return print_field_values return print_field_values
(TYPE_FIELD_TYPE (var_type, which), (TYPE_FIELD_TYPE (var_type, which),
valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT valaddr + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
+ TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT, + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
@ -800,23 +802,23 @@ print_variant_part (struct type *type, int field_num, char *valaddr,
} }
int int
ada_value_print (struct value* val0, struct ui_file *stream, int format, ada_value_print (struct value *val0, struct ui_file *stream, int format,
enum val_prettyprint pretty) enum val_prettyprint pretty)
{ {
char* valaddr = VALUE_CONTENTS (val0); char *valaddr = VALUE_CONTENTS (val0);
CORE_ADDR address = VALUE_ADDRESS (val0) + VALUE_OFFSET (val0); CORE_ADDR address = VALUE_ADDRESS (val0) + VALUE_OFFSET (val0);
struct type* type = struct type *type =
ada_to_fixed_type (VALUE_TYPE (val0), valaddr, address, NULL); ada_to_fixed_type (VALUE_TYPE (val0), valaddr, address, NULL);
struct value* val = value_from_contents_and_address (type, valaddr, address); struct value *val =
value_from_contents_and_address (type, valaddr, address);
/* If it is a pointer, indicate what it points to. */ /* If it is a pointer, indicate what it points to. */
if (TYPE_CODE (type) == TYPE_CODE_PTR || if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_CODE (type) == TYPE_CODE_REF)
TYPE_CODE (type) == TYPE_CODE_REF)
{ {
/* Hack: remove (char *) for char strings. Their /* Hack: remove (char *) for char strings. Their
type is indicated by the quoted string anyway. */ type is indicated by the quoted string anyway. */
if (TYPE_CODE (type) == TYPE_CODE_PTR && if (TYPE_CODE (type) == TYPE_CODE_PTR &&
TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char) && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof (char) &&
TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT &&
!TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type)))
{ {
@ -829,7 +831,7 @@ ada_value_print (struct value* val0, struct ui_file *stream, int format,
fprintf_filtered (stream, ") "); fprintf_filtered (stream, ") ");
} }
} }
else if (ada_is_array_descriptor (type)) else if (ada_is_array_descriptor (type))
{ {
fprintf_filtered (stream, "("); fprintf_filtered (stream, "(");
type_print (type, "", stream, -1); type_print (type, "", stream, -1);
@ -842,10 +844,10 @@ ada_value_print (struct value* val0, struct ui_file *stream, int format,
fprintf_filtered (stream, ") (...?)"); fprintf_filtered (stream, ") (...?)");
return 0; return 0;
} }
return (val_print (type, VALUE_CONTENTS (val), 0, address, return (val_print (type, VALUE_CONTENTS (val), 0, address,
stream, format, 1, 0, pretty)); stream, format, 1, 0, pretty));
} }
static void static void
print_record (struct type *type, char *valaddr, struct ui_file *stream, print_record (struct type *type, char *valaddr, struct ui_file *stream,
int format, int recurse, enum val_prettyprint pretty) int format, int recurse, enum val_prettyprint pretty)
@ -855,8 +857,7 @@ print_record (struct type *type, char *valaddr, struct ui_file *stream,
fprintf_filtered (stream, "("); fprintf_filtered (stream, "(");
if (print_field_values (type, valaddr, stream, format, recurse, pretty, if (print_field_values (type, valaddr, stream, format, recurse, pretty,
0, type, valaddr) != 0 0, type, valaddr) != 0 && pretty)
&& pretty)
{ {
fprintf_filtered (stream, "\n"); fprintf_filtered (stream, "\n");
print_spaces_filtered (2 * recurse, stream); print_spaces_filtered (2 * recurse, stream);
@ -892,13 +893,13 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
for (i = 0; i < len; i += 1) for (i = 0; i < len; i += 1)
{ {
if (ada_is_ignored_field (type, i)) if (ada_is_ignored_field (type, i))
continue; continue;
if (ada_is_wrapper_field (type, i)) if (ada_is_wrapper_field (type, i))
{ {
comma_needed = comma_needed =
print_field_values (TYPE_FIELD_TYPE (type, i), print_field_values (TYPE_FIELD_TYPE (type, i),
valaddr valaddr
+ TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT, + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
stream, format, recurse, pretty, stream, format, recurse, pretty,
comma_needed, type, valaddr); comma_needed, type, valaddr);
@ -922,7 +923,7 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
fprintf_filtered (stream, "\n"); fprintf_filtered (stream, "\n");
print_spaces_filtered (2 + 2 * recurse, stream); print_spaces_filtered (2 + 2 * recurse, stream);
} }
else else
{ {
wrap_here (n_spaces (2 + 2 * recurse)); wrap_here (n_spaces (2 + 2 * recurse));
} }
@ -942,7 +943,7 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
else else
{ {
annotate_field_begin (TYPE_FIELD_TYPE (type, i)); annotate_field_begin (TYPE_FIELD_TYPE (type, i));
fprintf_filtered (stream, "%.*s", fprintf_filtered (stream, "%.*s",
ada_name_prefix_len (TYPE_FIELD_NAME (type, i)), ada_name_prefix_len (TYPE_FIELD_NAME (type, i)),
TYPE_FIELD_NAME (type, i)); TYPE_FIELD_NAME (type, i));
annotate_field_name_end (); annotate_field_name_end ();
@ -952,7 +953,7 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
if (TYPE_FIELD_PACKED (type, i)) if (TYPE_FIELD_PACKED (type, i))
{ {
struct value* v; struct value *v;
/* Bitfields require special handling, especially due to byte /* Bitfields require special handling, especially due to byte
order problems. */ order problems. */
@ -965,21 +966,21 @@ print_field_values (struct type *type, char *valaddr, struct ui_file *stream,
{ {
int bit_pos = TYPE_FIELD_BITPOS (type, i); int bit_pos = TYPE_FIELD_BITPOS (type, i);
int bit_size = TYPE_FIELD_BITSIZE (type, i); int bit_size = TYPE_FIELD_BITSIZE (type, i);
adjust_type_signedness (TYPE_FIELD_TYPE (type, i)); adjust_type_signedness (TYPE_FIELD_TYPE (type, i));
v = ada_value_primitive_packed_val (NULL, valaddr, v = ada_value_primitive_packed_val (NULL, valaddr,
bit_pos / HOST_CHAR_BIT, bit_pos / HOST_CHAR_BIT,
bit_pos % HOST_CHAR_BIT, bit_pos % HOST_CHAR_BIT,
bit_size, bit_size,
TYPE_FIELD_TYPE (type, i)); TYPE_FIELD_TYPE (type, i));
val_print (TYPE_FIELD_TYPE(type, i), VALUE_CONTENTS (v), 0, 0, val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, 0,
stream, format, 0, recurse + 1, pretty); stream, format, 0, recurse + 1, pretty);
} }
} }
else else
ada_val_print (TYPE_FIELD_TYPE (type, i), ada_val_print (TYPE_FIELD_TYPE (type, i),
valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT, valaddr + TYPE_FIELD_BITPOS (type, i) / HOST_CHAR_BIT,
0, 0, stream, format, 0, recurse + 1, pretty); 0, 0, stream, format, 0, recurse + 1, pretty);
annotate_field_end (); annotate_field_end ();
} }