static const cst_val *find_rewrite_rule(const cst_val *LC, const cst_val *RC, const cst_lts_rewrites *r) { /* Search through rewrite rules to find matching one */ const cst_val *i, *RLC, *RA, *RRC; for (i=r->rules; i; i=val_cdr(i)) { /* val_print(stdout, val_car(i)); printf("\n"); */ RLC = val_car(val_car(i)); RA = val_car(val_cdr(val_car(i))); RRC = val_car(val_cdr(val_cdr(val_car(i)))); if (rule_matches(LC,RC,RLC,RA,RRC,r->sets)) return val_car(i); } fprintf(stderr,"LTS_REWRITES: unable to find a matching rules for:\n"); fprintf(stderr,"CL: "); val_print(stderr,LC); fprintf(stderr,"\n"); fprintf(stderr,"RC: "); val_print(stderr,RC); fprintf(stderr,"\n"); return NULL; }
/** $print : any* -> void <doc>Can print any value</doc> **/ static value builtin_print( value *args, int nargs ) { buffer b; int i; if( nargs == 1 && val_is_string(*args) ) { val_print(*args); return neko_builtins[1]; } b = alloc_buffer(NULL); for(i=0;i<nargs;i++) val_buffer(b,args[i]); val_print(buffer_to_string(b)); return neko_builtins[1]; }
/* Evaluate the value of the argument. The argument is an expression. If the expression contains spaces it needs to be included in double quotes. */ enum mi_cmd_result mi_cmd_data_evaluate_expression (char *command, char **argv, int argc) { struct expression *expr; struct cleanup *old_chain = NULL; struct value *val; struct ui_stream *stb = NULL; stb = ui_out_stream_new (uiout); if (argc != 1) { mi_error_message = xstrprintf ("mi_cmd_data_evaluate_expression: Usage: -data-evaluate-expression expression"); return MI_CMD_ERROR; } expr = parse_expression (argv[0]); old_chain = make_cleanup (free_current_contents, &expr); val = evaluate_expression (expr); /* Print the result of the expression evaluation. */ val_print (value_type (val), value_contents (val), value_embedded_offset (val), VALUE_ADDRESS (val), stb->stream, 0, 0, 0, 0); ui_out_field_stream (uiout, "value", stb); ui_out_stream_delete (stb); do_cleanups (old_chain); return MI_CMD_DONE; }
int flite_voice_add_lex_addenda(cst_voice *v, const cst_string *lexfile) { /* Add addenda in lexfile to current voice */ cst_lexicon *lex; const cst_val *lex_addenda = NULL; cst_val *new_addenda; lex = val_lexicon(feat_val(v->features,"lexicon")); if (feat_present(v->features, "lex_addenda")) lex_addenda = feat_val(v->features, "lex_addenda"); new_addenda = cst_lex_load_addenda(lex,lexfile); #if 0 printf("\naddenda: "); val_print(stdout,new_addenda); printf("\n"); #endif new_addenda = val_append(new_addenda,(cst_val *)lex_addenda); if (lex->lex_addenda) delete_val(lex->lex_addenda); lex->lex_addenda = new_addenda; return 0; }
static void ada_val_print_gnat_array (struct type *type, const gdb_byte *valaddr, int offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { struct value *mark = value_mark (); struct value *val; val = value_from_contents_and_address (type, valaddr + offset, address); /* If this is a reference, coerce it now. This helps taking care of the case where ADDRESS is meaningless because original_value was not an lval. */ val = coerce_ref (val); if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) /* array access type. */ val = ada_coerce_to_simple_array_ptr (val); else val = ada_coerce_to_simple_array (val); if (val == NULL) { gdb_assert (TYPE_CODE (type) == TYPE_CODE_TYPEDEF); fprintf_filtered (stream, "0x0"); } else val_print (value_type (val), value_embedded_offset (val), value_address (val), stream, recurse, val, options, language); value_free_to_mark (mark); }
void val_print(cst_file fd,const cst_val *v) { const cst_val *p; if (v == NULL) cst_fprintf(fd,"[null]"); else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_INT) cst_fprintf(fd,"%d",val_int(v)); else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_FLOAT) cst_fprintf(fd,"%f",val_float(v)); else if (CST_VAL_TYPE(v) == CST_VAL_TYPE_STRING) cst_fprintf(fd,"%s",val_string(v)); else if (cst_val_consp(v)) { cst_fprintf(fd,"("); for (p=v; p; ) { val_print(fd,val_car(p)); p=val_cdr(p); if (p) cst_fprintf(fd," "); } cst_fprintf(fd,")"); } else cst_fprintf(fd,"[Val %s 0x%p]", cst_val_defs[CST_VAL_TYPE(v)/2].name,CST_VAL_VOID(v)); }
static void ada_val_print_ref (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { /* For references, the debugger is expected to print the value as an address if DEREF_REF is null. But printing an address in place of the object value would be confusing to an Ada programmer. So, for Ada values, we print the actual dereferenced value regardless. */ struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type)); struct value *deref_val; CORE_ADDR deref_val_int; if (TYPE_CODE (elttype) == TYPE_CODE_UNDEF) { fputs_filtered ("<ref to undefined type>", stream); return; } deref_val = coerce_ref_if_computed (original_value); if (deref_val) { if (ada_is_tagged_type (value_type (deref_val), 1)) deref_val = ada_tag_value_at_base_address (deref_val); common_val_print (deref_val, stream, recurse + 1, options, language); return; } deref_val_int = unpack_pointer (type, valaddr + offset_aligned); if (deref_val_int == 0) { fputs_filtered ("(null)", stream); return; } deref_val = ada_value_ind (value_from_pointer (lookup_pointer_type (elttype), deref_val_int)); if (ada_is_tagged_type (value_type (deref_val), 1)) deref_val = ada_tag_value_at_base_address (deref_val); /* Make sure that the object does not have an unreasonable size before trying to print it. This can happen for instance with references to dynamic objects whose contents is uninitialized (Eg: an array whose bounds are not set yet). */ ada_ensure_varsize_limit (value_type (deref_val)); val_print (value_type (deref_val), value_contents_for_printing (deref_val), value_embedded_offset (deref_val), value_address (deref_val), stream, recurse + 1, deref_val, options, language); }
int ada_value_print (struct value *val0, struct ui_file *stream, int format, enum val_prettyprint pretty) { char *valaddr = VALUE_CONTENTS (val0); CORE_ADDR address = VALUE_ADDRESS (val0) + VALUE_OFFSET (val0); struct type *type = ada_to_fixed_type (VALUE_TYPE (val0), valaddr, address, NULL); struct value *val = value_from_contents_and_address (type, valaddr, address); /* If it is a pointer, indicate what it points to. */ if (TYPE_CODE (type) == TYPE_CODE_PTR) { /* Hack: don't print (char *) for char strings. Their type is indicated by the quoted string anyway. */ if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) != sizeof (char) || TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_INT || TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); } } else if (ada_is_array_descriptor_type (type)) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); } else if (ada_is_bogus_array_descriptor (type)) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") (...?)"); return 0; } if (TYPE_CODE (type) == TYPE_CODE_ARRAY && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == 0 && TYPE_CODE (TYPE_INDEX_TYPE (type)) == TYPE_CODE_RANGE) { /* This is an array of zero-length elements, that is an array of null records. This array needs to be printed by hand, as the standard routine to print arrays relies on the size of the array elements to be nonzero. This is because it computes the number of elements in the array by dividing the array size by the array element size. */ fprintf_filtered (stream, "(%d .. %d => ())", TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)), TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type))); return 0; } return (val_print (type, VALUE_CONTENTS (val), 0, address, stream, format, 1, 0, pretty)); }
int feat_print(cst_file fd,const cst_features *f) { cst_featvalpair *p; for (p=f->head; p; p=p->next) { cst_fprintf(fd, "%s ",p->name); val_print(fd,p->val); cst_fprintf(fd,"\n"); } return 0; }
/* Output one register's contents in the desired format. */ static int get_register (int regnum, int format) { gdb_byte buffer[MAX_REGISTER_SIZE]; int optim; int realnum; CORE_ADDR addr; enum lval_type lval; static struct ui_stream *stb = NULL; stb = ui_out_stream_new (uiout); if (format == 'N') format = 0; frame_register (get_selected_frame (NULL), regnum, &optim, &lval, &addr, &realnum, buffer); if (optim) { mi_error_message = xstrprintf ("Optimized out"); return -1; } if (format == 'r') { int j; char *ptr, buf[1024]; strcpy (buf, "0x"); ptr = buf + 2; for (j = 0; j < register_size (current_gdbarch, regnum); j++) { int idx = TARGET_BYTE_ORDER == BFD_ENDIAN_BIG ? j : register_size (current_gdbarch, regnum) - 1 - j; sprintf (ptr, "%02x", (unsigned char) buffer[idx]); ptr += 2; } ui_out_field_string (uiout, "value", buf); /*fputs_filtered (buf, gdb_stdout); */ } else { val_print (register_type (current_gdbarch, regnum), buffer, 0, 0, stb->stream, format, 1, 0, Val_pretty_default); ui_out_field_stream (uiout, "value", stb); ui_out_stream_delete (stb); } return 1; }
static void profile_details( const char *name, neko_module *m, int *tot ) { unsigned int i; value *dbg = val_is_null(m->debuginf)?NULL:val_array_ptr(m->debuginf); printf("Details for : %s[%d]\n",name,m->codesize); for(i=0;i<m->codesize;i++) { int c = (int)m->code[PROF_SIZE+i]; if( c > 0 ) { if( dbg ) val_print(dbg[i]); printf(" %-4X %d\n",i,c); } } printf("\n"); }
void ada_value_print (struct value *val0, struct ui_file *stream, const struct value_print_options *options) { struct value *val = ada_to_fixed_value (val0); CORE_ADDR address = value_address (val); struct type *type = ada_check_typedef (value_enclosing_type (val)); struct value_print_options opts; /* If it is a pointer, indicate what it points to. */ if (TYPE_CODE (type) == TYPE_CODE_PTR) { /* Hack: don't print (char *) for char strings. Their type is indicated by the quoted string anyway. */ if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) != sizeof (char) || TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_INT || TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); } } else if (ada_is_array_descriptor_type (type)) { /* We do not print the type description unless TYPE is an array access type (this is encoded by the compiler as a typedef to a fat pointer - hence the check against TYPE_CODE_TYPEDEF). */ if (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); } } else if (ada_is_bogus_array_descriptor (type)) { fprintf_filtered (stream, "("); type_print (type, "", stream, -1); fprintf_filtered (stream, ") (...?)"); return; } opts = *options; opts.deref_ref = 1; val_print (type, value_embedded_offset (val), address, stream, 0, val, &opts, current_language); }
int deck_print(Deck * deck){ int i; deck->realign(deck); for(i=0;i<deck->cards->n_items;i++){ val_print( (((Card*)(deck->cards->data))[i]).val); suit_print( (((Card*)(deck->cards->data))[i]).suit); printf(" "); } printf("\n"); return 0; }
int hand_print(Hand * hand){ int i; for(i=0;i<hand->size;i++){ val_print((hand->cards)[i].val); suit_print((hand->cards)[i].suit); printf(" "); if(hand->cards[i].val != _10) printf(" "); } printf("\n"); return 0; }
static void profile_functions( const char *name, neko_module *m, int *tot ) { unsigned int i; value *dbg = val_is_null(m->debuginf)?NULL:val_array_ptr(m->debuginf); for(i=0;i<m->nglobals;i++) { value v = m->globals[i]; if( val_is_function(v) && val_type(v) == VAL_FUNCTION && ((vfunction*)v)->module == m ) { int pos = (int)(((int_val)((vfunction*)v)->addr - (int_val)m->code) / sizeof(int_val)); if( m->code[PROF_SIZE+pos] > 0 ) { printf("%-8d %-4d %-20s %X ",m->code[PROF_SIZE+pos],i,name,pos); if( dbg ) val_print(dbg[pos]); printf("\n"); } } } }
static void ada_val_print_flt (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { if (options->format) { val_print (type, offset, address, stream, recurse, original_value, options, language_def (language_c)); return; } ada_print_floating (valaddr + offset, type, stream); }
static void cart_print_node(int n, const cst_cart *tree) { printf("%s ",cst_cart_node_feat(n,tree)); if (cst_cart_node_op(n,tree) == CST_CART_OP_IS) printf("IS "); else if (cst_cart_node_op(n,tree) == CST_CART_OP_LESS) printf("< "); else if (cst_cart_node_op(n,tree) == CST_CART_OP_GREATER) printf("> "); else if (cst_cart_node_op(n,tree) == CST_CART_OP_IN) printf("IN "); else if (cst_cart_node_op(n,tree) == CST_CART_OP_MATCHES) printf("MATCHES "); else printf("*%d* ",cst_cart_node_op(n,tree)); val_print(stdout,cst_cart_node_val(n,tree)); printf("\n"); }
static void f77_print_array_1 (int nss, int ndimensions, struct type *type, const gdb_byte *valaddr, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, int *elts) { int i; if (nss != ndimensions) { for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < options->print_max); i++) { fprintf_filtered (stream, "( "); f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type), valaddr + i * F77_DIM_OFFSET (nss), address + i * F77_DIM_OFFSET (nss), stream, recurse, val, options, elts); fprintf_filtered (stream, ") "); } if (*elts >= options->print_max && i < F77_DIM_SIZE (nss)) fprintf_filtered (stream, "..."); } else { for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < options->print_max; i++, (*elts)++) { val_print (TYPE_TARGET_TYPE (type), valaddr + i * F77_DIM_OFFSET (ndimensions), 0, address + i * F77_DIM_OFFSET (ndimensions), stream, recurse, val, options, current_language); if (i != (F77_DIM_SIZE (nss) - 1)) fprintf_filtered (stream, ", "); if ((*elts == options->print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1))) fprintf_filtered (stream, "..."); } } }
static void f77_print_array_1 (int nss, int ndimensions, struct type *type, const gdb_byte *valaddr, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty, int *elts) { int i; if (nss != ndimensions) { for (i = 0; (i < F77_DIM_SIZE (nss) && (*elts) < print_max); i++) { fprintf_filtered (stream, "( "); f77_print_array_1 (nss + 1, ndimensions, TYPE_TARGET_TYPE (type), valaddr + i * F77_DIM_OFFSET (nss), address + i * F77_DIM_OFFSET (nss), stream, format, deref_ref, recurse, pretty, elts); fprintf_filtered (stream, ") "); } if (*elts >= print_max && i < F77_DIM_SIZE (nss)) fprintf_filtered (stream, "..."); } else { for (i = 0; i < F77_DIM_SIZE (nss) && (*elts) < print_max; i++, (*elts)++) { val_print (TYPE_TARGET_TYPE (type), valaddr + i * F77_DIM_OFFSET (ndimensions), 0, address + i * F77_DIM_OFFSET (ndimensions), stream, format, deref_ref, recurse, pretty); if (i != (F77_DIM_SIZE (nss) - 1)) fprintf_filtered (stream, ", "); if ((*elts == print_max - 1) && (i != (F77_DIM_SIZE (nss) - 1))) fprintf_filtered (stream, "..."); } } }
cst_val *cmu_grapheme_lex_lts_function(const struct lexicon_struct *l, const char *word, const char *pos, const cst_features *feats) { cst_val *phones = 0; cst_val *utflets = 0; const cst_val *v; char ord[10]; int i,phindex; /* string to utf8 chars */ utflets = cst_utf8_explode(word); for (v=utflets; v; v=val_cdr(v)) { /* We will add the found phones in reverse order and reverse then */ /* afterwards */ cst_utf8_as_hex(val_string(val_car(v)),ord); phindex = cst_find_u2sampa(ord); if (phindex < 0) printf("awb_debug no sampa %s %s\n",val_string(val_car(v)),ord); for (i=4; (phindex>=0) && (i>0); i--) { if (unicode_sampa_mapping[phindex][i]) phones = cons_val(string_val(unicode_sampa_mapping[phindex][i]), phones); } } phones = val_reverse(phones); #if 1 printf("cmu_grapheme_lex.c: word \"%s\" ",word); val_print(stdout,phones); printf("\n"); #endif delete_val(utflets); return phones; }
static void ada_val_print_ptr (struct type *type, const gdb_byte *valaddr, int offset, int offset_aligned, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options, const struct language_defn *language) { val_print (type, offset, address, stream, recurse, original_value, options, language_def (language_c)); if (ada_is_tag_type (type)) { struct value *val = value_from_contents_and_address (type, valaddr + offset_aligned, address + offset_aligned); const char *name = ada_tag_name (val); if (name != NULL) fprintf_filtered (stream, " (%s)", name); } }
int f_val_print (struct type *type, char *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int format, int deref_ref, int recurse, enum val_prettyprint pretty) { unsigned int i = 0; /* Number of characters printed */ struct type *elttype; LONGEST val; CORE_ADDR addr; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_STRING: f77_get_dynamic_length_of_aggregate (type); LA_PRINT_STRING (stream, valaddr, TYPE_LENGTH (type), 1, 0); break; case TYPE_CODE_ARRAY: fprintf_filtered (stream, "("); f77_print_array (type, valaddr, address, stream, format, deref_ref, recurse, pretty); fprintf_filtered (stream, ")"); break; case TYPE_CODE_PTR: if (format && format != 's') { print_scalar_formatted (valaddr, type, format, 0, stream); break; } else { addr = unpack_pointer (type, valaddr); elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_address_demangle (addr, stream, demangle); /* Return value is irrelevant except for string pointers. */ return 0; } if (addressprint && format != 's') print_address_numeric (addr, 1, stream); /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ if (TYPE_LENGTH (elttype) == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT && (format == 0 || format == 's') && addr != 0) i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream); /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ return i; } break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (addressprint) { CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); fprintf_filtered (stream, "@"); print_address_numeric (addr, 1, stream); if (deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (lookup_pointer_type (builtin_type_void), valaddr + embedded_offset), NULL); val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val), 0, VALUE_ADDRESS (deref_val), stream, format, deref_ref, recurse, pretty); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_FUNC: if (format) { print_scalar_formatted (valaddr, type, format, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (address, stream, demangle); break; case TYPE_CODE_INT: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr, type, format, 0, stream); else { val_print_type_code_int (type, valaddr, stream); /* C and C++ has no single byte int type, char is used instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ if (TYPE_LENGTH (type) == 1) { fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr), stream); } } break; case TYPE_CODE_FLT: if (format) print_scalar_formatted (valaddr, type, format, 0, stream); else print_floating (valaddr, type, stream); break; case TYPE_CODE_VOID: fprintf_filtered (stream, "VOID"); break; case TYPE_CODE_ERROR: fprintf_filtered (stream, "<error type>"); break; case TYPE_CODE_RANGE: /* FIXME, we should not ever have to print one of these yet. */ fprintf_filtered (stream, "<range type>"); break; case TYPE_CODE_BOOL: format = format ? format : output_format; if (format) print_scalar_formatted (valaddr, type, format, 0, stream); else { val = 0; switch (TYPE_LENGTH (type)) { case 1: val = unpack_long (builtin_type_f_logical_s1, valaddr); break; case 2: val = unpack_long (builtin_type_f_logical_s2, valaddr); break; case 4: val = unpack_long (builtin_type_f_logical, valaddr); break; default: error ("Logicals of length %d bytes not supported", TYPE_LENGTH (type)); } if (val == 0) fprintf_filtered (stream, ".FALSE."); else if (val == 1) fprintf_filtered (stream, ".TRUE."); else /* Not a legitimate logical type, print as an integer. */ { /* Bash the type code temporarily. */ TYPE_CODE (type) = TYPE_CODE_INT; f_val_print (type, valaddr, 0, address, stream, format, deref_ref, recurse, pretty); /* Restore the type code so later uses work as intended. */ TYPE_CODE (type) = TYPE_CODE_BOOL; } } break; case TYPE_CODE_COMPLEX: switch (TYPE_LENGTH (type)) { case 8: type = builtin_type_f_real; break; case 16: type = builtin_type_f_real_s8; break; case 32: type = builtin_type_f_real_s16; break; default: error ("Cannot print out complex*%d variables", TYPE_LENGTH (type)); } fputs_filtered ("(", stream); print_floating (valaddr, type, stream); fputs_filtered (",", stream); print_floating (valaddr + TYPE_LENGTH (type), type, stream); fputs_filtered (")", stream); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, "<incomplete type>"); break; default: error ("Invalid F77 type code %d in symbol table.", TYPE_CODE (type)); } gdb_flush (stream); return 0; }
void c_value_print (struct value *val, struct ui_file *stream, const struct value_print_options *options) { struct type *type, *real_type, *val_type; int full, top, using_enc; struct value_print_options opts = *options; opts.deref_ref = 1; /* If it is a pointer, indicate what it points to. Print type also if it is a reference. C++: if it is a member pointer, we will take care of that when we print it. */ /* Preserve the original type before stripping typedefs. We prefer to pass down the original type when possible, but for local checks it is better to look past the typedefs. */ val_type = value_type (val); type = check_typedef (val_type); if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_CODE (type) == TYPE_CODE_REF) { /* Hack: remove (char *) for char strings. Their type is indicated by the quoted string anyway. (Don't use c_textual_element_type here; quoted strings are always exactly (char *), (wchar_t *), or the like. */ if (TYPE_CODE (val_type) == TYPE_CODE_PTR && TYPE_NAME (val_type) == NULL && TYPE_NAME (TYPE_TARGET_TYPE (val_type)) != NULL && (strcmp (TYPE_NAME (TYPE_TARGET_TYPE (val_type)), "char") == 0 || textual_name (TYPE_NAME (TYPE_TARGET_TYPE (val_type))))) { /* Print nothing. */ } else if (options->objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS)) { int is_ref = TYPE_CODE (type) == TYPE_CODE_REF; if (is_ref) val = value_addr (val); /* Pointer to class, check real type of object. */ fprintf_filtered (stream, "("); if (value_entirely_available (val)) { real_type = value_rtti_indirect_type (val, &full, &top, &using_enc); if (real_type) { /* RTTI entry found. */ type = real_type; /* Need to adjust pointer value. */ val = value_from_pointer (real_type, value_as_address (val) - top); if (is_ref) { val = value_ref (value_ind (val)); type = value_type (val); } /* Note: When we look up RTTI entries, we don't get any information on const or volatile attributes. */ } } type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); val_type = type; } else { /* normal case */ fprintf_filtered (stream, "("); type_print (value_type (val), "", stream, -1); fprintf_filtered (stream, ") "); } } if (!value_initialized (val)) fprintf_filtered (stream, " [uninitialized] "); if (options->objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS)) { /* Attempt to determine real type of object. */ real_type = value_rtti_type (val, &full, &top, &using_enc); if (real_type) { /* We have RTTI information, so use it. */ val = value_full_object (val, real_type, full, top, using_enc); fprintf_filtered (stream, "(%s%s) ", TYPE_NAME (real_type), full ? "" : _(" [incomplete object]")); /* Print out object: enclosing type is same as real_type if full. */ val_print (value_enclosing_type (val), value_contents_for_printing (val), 0, value_address (val), stream, 0, val, &opts, current_language); return; /* Note: When we look up RTTI entries, we don't get any information on const or volatile attributes. */ } else if (type != check_typedef (value_enclosing_type (val))) { /* No RTTI information, so let's do our best. */ fprintf_filtered (stream, "(%s ?) ", TYPE_NAME (value_enclosing_type (val))); val_print (value_enclosing_type (val), value_contents_for_printing (val), 0, value_address (val), stream, 0, val, &opts, current_language); return; } /* Otherwise, we end up at the return outside this "if". */ } val_print (val_type, value_contents_for_printing (val), value_embedded_offset (val), value_address (val), stream, 0, val, &opts, current_language); }
void pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, int offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *val, const struct value_print_options *options, struct type **dont_print_vb, int dont_print_statmem) { int i, len, n_baseclasses; char *last_dont_print = (char *) obstack_next_free (&dont_print_statmem_obstack); type = check_typedef (type); fprintf_filtered (stream, "{"); len = TYPE_NFIELDS (type); n_baseclasses = TYPE_N_BASECLASSES (type); /* Print out baseclasses such that we don't print duplicates of virtual baseclasses. */ if (n_baseclasses > 0) pascal_object_print_value (type, valaddr, offset, address, stream, recurse + 1, val, options, dont_print_vb); if (!len && n_baseclasses == 1) fprintf_filtered (stream, "<No data fields>"); else { struct obstack tmp_obstack = dont_print_statmem_obstack; int fields_seen = 0; if (dont_print_statmem == 0) { /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ obstack_finish (&dont_print_statmem_obstack); } for (i = n_baseclasses; i < len; i++) { /* If requested, skip printing of static fields. */ if (!options->pascal_static_field_print && field_is_static (&TYPE_FIELD (type, i))) continue; if (fields_seen) fprintf_filtered (stream, ", "); else if (n_baseclasses > 0) { if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); fputs_filtered ("members of ", stream); fputs_filtered (type_name_no_tag (type), stream); fputs_filtered (": ", stream); } } fields_seen = 1; if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } else { wrap_here (n_spaces (2 + 2 * recurse)); } annotate_field_begin (TYPE_FIELD_TYPE (type, i)); if (field_is_static (&TYPE_FIELD (type, i))) fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); annotate_field_name_end (); fputs_filtered (" = ", stream); annotate_field_value (); if (!field_is_static (&TYPE_FIELD (type, i)) && TYPE_FIELD_PACKED (type, i)) { struct value *v; /* Bitfields require special handling, especially due to byte order problems. */ if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else if (value_bits_synthetic_pointer (val, TYPE_FIELD_BITPOS (type, i), TYPE_FIELD_BITSIZE (type, i))) { fputs_filtered (_("<synthetic pointer>"), stream); } else { struct value_print_options opts = *options; v = value_field_bitfield (type, i, valaddr, offset, val); opts.deref_ref = 0; common_val_print (v, stream, recurse + 1, &opts, current_language); } } else { if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else if (field_is_static (&TYPE_FIELD (type, i))) { /* struct value *v = value_static_field (type, i); v4.17 specific. */ struct value *v; v = value_field_bitfield (type, i, valaddr, offset, val); if (v == NULL) val_print_optimized_out (NULL, stream); else pascal_object_print_static_field (v, stream, recurse + 1, options); } else { struct value_print_options opts = *options; opts.deref_ref = 0; /* val_print (TYPE_FIELD_TYPE (type, i), valaddr + TYPE_FIELD_BITPOS (type, i) / 8, address + TYPE_FIELD_BITPOS (type, i) / 8, 0, stream, format, 0, recurse + 1, pretty); */ val_print (TYPE_FIELD_TYPE (type, i), valaddr, offset + TYPE_FIELD_BITPOS (type, i) / 8, address, stream, recurse + 1, val, &opts, current_language); } } annotate_field_end (); } if (dont_print_statmem == 0) { /* Free the space used to deal with the printing of the members from top level. */ obstack_free (&dont_print_statmem_obstack, last_dont_print); dont_print_statmem_obstack = tmp_obstack; } if (options->prettyformat) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * recurse, stream); } } fprintf_filtered (stream, "}"); }
const cst_val *cart_interpret(cst_item *item, const cst_cart *tree) { /* Tree interpretation */ const cst_val *v=0; const cst_val *tree_val; const char *tree_feat = ""; cst_features *fcache; int r=0; int node=0; fcache = new_features_local(item_utt(item)->ctx); while (cst_cart_node_op(node,tree) != CST_CART_OP_LEAF) { #if CART_DEBUG cart_print_node(node,tree); #endif tree_feat = cst_cart_node_feat(node,tree); v = get_param_val(fcache,tree_feat,0); if (v == 0) { v = ffeature(item,tree_feat); feat_set(fcache,tree_feat,v); } #if CART_DEBUG val_print(stdout,v); printf("\n"); #endif tree_val = cst_cart_node_val(node,tree); if (cst_cart_node_op(node,tree) == CST_CART_OP_IS) r = val_equal(v,tree_val); else if (cst_cart_node_op(node,tree) == CST_CART_OP_LESS) r = val_less(v,tree_val); else if (cst_cart_node_op(node,tree) == CST_CART_OP_GREATER) r = val_greater(v,tree_val); else if (cst_cart_node_op(node,tree) == CST_CART_OP_IN) r = val_member(v,tree_val); else if (cst_cart_node_op(node,tree) == CST_CART_OP_MATCHES) r = cst_regex_match(cst_regex_table[val_int(tree_val)], val_string(v)); else { cst_errmsg("cart_interpret_question: unknown op type %d\n", cst_cart_node_op(node,tree)); cst_error(); } if (r) { /* Oh yes it is */ #if CART_DEBUG printf(" YES\n"); #endif node = cst_cart_node_yes(node,tree); } else { /* Oh no it isn't */ #if CART_DEBUG printf(" NO\n"); #endif node = cst_cart_node_no(node,tree); } } delete_features(fcache); return cst_cart_node_val(node,tree); }
void pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr, CORE_ADDR address, struct ui_file *stream, int format, int recurse, enum val_prettyprint pretty, struct type **dont_print_vb, int dont_print_statmem) { int i, len, n_baseclasses; char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack); CHECK_TYPEDEF (type); fprintf_filtered (stream, "{"); len = TYPE_NFIELDS (type); n_baseclasses = TYPE_N_BASECLASSES (type); /* Print out baseclasses such that we don't print duplicates of virtual baseclasses. */ if (n_baseclasses > 0) pascal_object_print_value (type, valaddr, address, stream, format, recurse + 1, pretty, dont_print_vb); if (!len && n_baseclasses == 1) fprintf_filtered (stream, "<No data fields>"); else { struct obstack tmp_obstack = dont_print_statmem_obstack; int fields_seen = 0; if (dont_print_statmem == 0) { /* If we're at top level, carve out a completely fresh chunk of the obstack and use that until this particular invocation returns. */ obstack_finish (&dont_print_statmem_obstack); } for (i = n_baseclasses; i < len; i++) { /* If requested, skip printing of static fields. */ if (!pascal_static_field_print && TYPE_FIELD_STATIC (type, i)) continue; if (fields_seen) fprintf_filtered (stream, ", "); else if (n_baseclasses > 0) { if (pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); fputs_filtered ("members of ", stream); fputs_filtered (type_name_no_tag (type), stream); fputs_filtered (": ", stream); } } fields_seen = 1; if (pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } else { wrap_here (n_spaces (2 + 2 * recurse)); } if (inspect_it) { if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR) fputs_filtered ("\"( ptr \"", stream); else fputs_filtered ("\"( nodef \"", stream); if (TYPE_FIELD_STATIC (type, i)) fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); fputs_filtered ("\" \"", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); fputs_filtered ("\") \"", stream); } else { annotate_field_begin (TYPE_FIELD_TYPE (type, i)); if (TYPE_FIELD_STATIC (type, i)) fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); annotate_field_name_end (); fputs_filtered (" = ", stream); annotate_field_value (); } if (!TYPE_FIELD_STATIC (type, i) && TYPE_FIELD_PACKED (type, i)) { struct value *v; /* Bitfields require special handling, especially due to byte order problems. */ if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else { v = value_from_longest (TYPE_FIELD_TYPE (type, i), unpack_field_as_long (type, valaddr, i)); common_val_print (v, stream, format, 0, recurse + 1, pretty); } } else { if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else if (TYPE_FIELD_STATIC (type, i)) { /* struct value *v = value_static_field (type, i); v4.17 specific */ struct value *v; v = value_from_longest (TYPE_FIELD_TYPE (type, i), unpack_field_as_long (type, valaddr, i)); if (v == NULL) fputs_filtered ("<optimized out>", stream); else pascal_object_print_static_field (v, stream, format, recurse + 1, pretty); } else { /* val_print (TYPE_FIELD_TYPE (type, i), valaddr + TYPE_FIELD_BITPOS (type, i) / 8, address + TYPE_FIELD_BITPOS (type, i) / 8, 0, stream, format, 0, recurse + 1, pretty); */ val_print (TYPE_FIELD_TYPE (type, i), valaddr, TYPE_FIELD_BITPOS (type, i) / 8, address + TYPE_FIELD_BITPOS (type, i) / 8, stream, format, 0, recurse + 1, pretty); } } annotate_field_end (); } if (dont_print_statmem == 0) { /* Free the space used to deal with the printing of the members from top level. */ obstack_free (&dont_print_statmem_obstack, last_dont_print); dont_print_statmem_obstack = tmp_obstack; } if (pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * recurse, stream); } } fprintf_filtered (stream, "}"); }
cst_val *cst_lex_make_entry(const cst_lexicon *lex, const cst_string *entry) { /* if replace then replace entry in addenda of lex with entry */ /* else append entry to addenda of lex */ cst_tokenstream *e; cst_val *phones = NULL; cst_val *ventry; const cst_string *w, *p; cst_string *word; cst_string *pos; int i; e = ts_open_string(entry, cst_ts_default_whitespacesymbols, "","",""); w = ts_get(e); if (w[0] == '"') /* it was a quoted entry */ { /* so reparse it */ ts_close(e); e = ts_open_string(entry, cst_ts_default_whitespacesymbols, "","",""); w = ts_get_quoted_token(e,'"','\\'); } word = cst_strdup(w); p = ts_get(e); if (!cst_streq(":",p)) /* there is a real pos */ { pos = cst_strdup(p); p = ts_get(e); if (!cst_streq(":",p)) /* there is a real pos */ { cst_fprintf(stdout,"add_addenda: lex %s: expected \":\" in %s\n", lex->name, word); cst_free(word); cst_free(pos); ts_close(e); return NULL; } } else pos = cst_strdup("nil"); while (!ts_eof(e)) { p = ts_get(e); /* Check its a legal phone */ for (i=0; lex->phone_table[i]; i++) { if (cst_streq(p,lex->phone_table[i])) break; } if (cst_streq("#",p)) /* comment to end of line */ break; else if (cst_streq("",p)) /* trailing ws at eoln causes this */ break; else if (lex->phone_table[i]) /* Only add it if its a valid phone */ phones = cons_val(string_val(p),phones); else { cst_fprintf(stdout,"add_addenda: lex: %s word %s phone %s not in lexicon phoneset\n", lex->name, word, p); } } ventry = cons_val(string_val(word),cons_val(string_val(pos), val_reverse(phones))); cst_free(word); cst_free(pos); ts_close(e); #if 0 printf("entry: "); val_print(stdout,ventry); printf("\n"); #endif return ventry; }
static void java_print_value_fields (struct type *type, const gdb_byte *valaddr, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value_print_options *options) { int i, len, n_baseclasses; CHECK_TYPEDEF (type); fprintf_filtered (stream, "{"); len = TYPE_NFIELDS (type); n_baseclasses = TYPE_N_BASECLASSES (type); if (n_baseclasses > 0) { int i, n_baseclasses = TYPE_N_BASECLASSES (type); for (i = 0; i < n_baseclasses; i++) { int boffset; struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); char *basename = TYPE_NAME (baseclass); const gdb_byte *base_valaddr; if (BASETYPE_VIA_VIRTUAL (type, i)) continue; if (basename != NULL && strcmp (basename, "java.lang.Object") == 0) continue; boffset = 0; if (options->pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * (recurse + 1), stream); } fputs_filtered ("<", stream); /* Not sure what the best notation is in the case where there is no baseclass name. */ fputs_filtered (basename ? basename : "", stream); fputs_filtered ("> = ", stream); base_valaddr = valaddr; java_print_value_fields (baseclass, base_valaddr, address + boffset, stream, recurse + 1, options); fputs_filtered (", ", stream); } } if (!len && n_baseclasses == 1) fprintf_filtered (stream, "<No data fields>"); else { int fields_seen = 0; for (i = n_baseclasses; i < len; i++) { /* If requested, skip printing of static fields. */ if (field_is_static (&TYPE_FIELD (type, i))) { char *name = TYPE_FIELD_NAME (type, i); if (!options->static_field_print) continue; if (name != NULL && strcmp (name, "class") == 0) continue; } if (fields_seen) fprintf_filtered (stream, ", "); else if (n_baseclasses > 0) { if (options->pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); fputs_filtered ("members of ", stream); fputs_filtered (type_name_no_tag (type), stream); fputs_filtered (": ", stream); } } fields_seen = 1; if (options->pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 + 2 * recurse, stream); } else { wrap_here (n_spaces (2 + 2 * recurse)); } if (options->inspect_it) { if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR) fputs_filtered ("\"( ptr \"", stream); else fputs_filtered ("\"( nodef \"", stream); if (field_is_static (&TYPE_FIELD (type, i))) fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); fputs_filtered ("\" \"", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); fputs_filtered ("\") \"", stream); } else { annotate_field_begin (TYPE_FIELD_TYPE (type, i)); if (field_is_static (&TYPE_FIELD (type, i))) fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, TYPE_FIELD_NAME (type, i), language_cplus, DMGL_PARAMS | DMGL_ANSI); annotate_field_name_end (); fputs_filtered (": ", stream); annotate_field_value (); } if (!field_is_static (&TYPE_FIELD (type, i)) && TYPE_FIELD_PACKED (type, i)) { struct value *v; /* Bitfields require special handling, especially due to byte order problems. */ if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else { struct value_print_options opts; v = value_from_longest (TYPE_FIELD_TYPE (type, i), unpack_field_as_long (type, valaddr, i)); opts = *options; opts.deref_ref = 0; common_val_print (v, stream, recurse + 1, &opts, current_language); } } else { if (TYPE_FIELD_IGNORE (type, i)) { fputs_filtered ("<optimized out or zero length>", stream); } else if (field_is_static (&TYPE_FIELD (type, i))) { struct value *v = value_static_field (type, i); if (v == NULL) fputs_filtered ("<optimized out>", stream); else { struct value_print_options opts; struct type *t = check_typedef (value_type (v)); if (TYPE_CODE (t) == TYPE_CODE_STRUCT) v = value_addr (v); opts = *options; opts.deref_ref = 0; common_val_print (v, stream, recurse + 1, &opts, current_language); } } else if (TYPE_FIELD_TYPE (type, i) == NULL) fputs_filtered ("<unknown type>", stream); else { struct value_print_options opts = *options; opts.deref_ref = 0; val_print (TYPE_FIELD_TYPE (type, i), valaddr + TYPE_FIELD_BITPOS (type, i) / 8, 0, address + TYPE_FIELD_BITPOS (type, i) / 8, stream, recurse + 1, &opts, current_language); } } annotate_field_end (); } if (options->pretty) { fprintf_filtered (stream, "\n"); print_spaces_filtered (2 * recurse, stream); } } fprintf_filtered (stream, "}"); }
int c_value_print (struct value *val, struct ui_file *stream, int format, enum val_prettyprint pretty) { struct type *type, *real_type; int full, top, using_enc; /* If it is a pointer, indicate what it points to. Print type also if it is a reference. C++: if it is a member pointer, we will take care of that when we print it. */ type = check_typedef (value_type (val)); if (TYPE_CODE (type) == TYPE_CODE_PTR || TYPE_CODE (type) == TYPE_CODE_REF) { /* Hack: remove (char *) for char strings. Their type is indicated by the quoted string anyway. */ if (TYPE_CODE (type) == TYPE_CODE_PTR && TYPE_NAME (type) == NULL && TYPE_NAME (TYPE_TARGET_TYPE (type)) != NULL && strcmp (TYPE_NAME (TYPE_TARGET_TYPE (type)), "char") == 0) { /* Print nothing */ } else if (objectprint && (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CLASS)) { if (TYPE_CODE(type) == TYPE_CODE_REF) { /* Copy value, change to pointer, so we don't get an * error about a non-pointer type in value_rtti_target_type */ struct value *temparg; temparg=value_copy(val); deprecated_set_value_type (temparg, lookup_pointer_type (TYPE_TARGET_TYPE(type))); val=temparg; } /* Pointer to class, check real type of object */ fprintf_filtered (stream, "("); real_type = value_rtti_target_type (val, &full, &top, &using_enc); if (real_type) { /* RTTI entry found */ if (TYPE_CODE (type) == TYPE_CODE_PTR) { /* create a pointer type pointing to the real type */ type = lookup_pointer_type (real_type); } else { /* create a reference type referencing the real type */ type = lookup_reference_type (real_type); } /* JYG: Need to adjust pointer value. */ /* NOTE: cagney/2005-01-02: THIS IS BOGUS. */ value_contents_writeable (val)[0] -= top; /* Note: When we look up RTTI entries, we don't get any information on const or volatile attributes */ } type_print (type, "", stream, -1); fprintf_filtered (stream, ") "); } else { /* normal case */ fprintf_filtered (stream, "("); type_print (value_type (val), "", stream, -1); fprintf_filtered (stream, ") "); } } /* APPLE LOCAL begin variable initialized status. */ if (value_var_status (val) == 0) fprintf_filtered (stream, " [uninitialized] "); /* APPLE LOCAL end variable initialized status. */ if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS)) { /* Attempt to determine real type of object */ real_type = value_rtti_type (val, &full, &top, &using_enc); if (real_type) { /* We have RTTI information, so use it */ val = value_full_object (val, real_type, full, top, using_enc); fprintf_filtered (stream, "(%s%s) ", TYPE_NAME (real_type), full ? "" : _(" [incomplete object]")); /* Print out object: enclosing type is same as real_type if full */ return val_print (value_enclosing_type (val), value_contents_all (val), 0, VALUE_ADDRESS (val), stream, format, 1, 0, pretty); /* Note: When we look up RTTI entries, we don't get any information on const or volatile attributes */ } else if (type != check_typedef (value_enclosing_type (val))) { /* No RTTI information, so let's do our best */ fprintf_filtered (stream, "(%s ?) ", TYPE_NAME (value_enclosing_type (val))); return val_print (value_enclosing_type (val), value_contents_all (val), 0, VALUE_ADDRESS (val), stream, format, 1, 0, pretty); } /* Otherwise, we end up at the return outside this "if" */ } real_type = get_closure_dynamic_type (val); if (real_type) type = real_type; return val_print (type, value_contents_all (val), value_embedded_offset (val), VALUE_ADDRESS (val) + value_offset (val), stream, format, 1, 0, pretty); }
int f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, const struct value *original_value, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); unsigned int i = 0; /* Number of characters printed */ struct type *elttype; LONGEST val; CORE_ADDR addr; int index; CHECK_TYPEDEF (type); switch (TYPE_CODE (type)) { case TYPE_CODE_STRING: f77_get_dynamic_length_of_aggregate (type); LA_PRINT_STRING (stream, builtin_type (gdbarch)->builtin_char, valaddr, TYPE_LENGTH (type), NULL, 0, options); break; case TYPE_CODE_ARRAY: fprintf_filtered (stream, "("); f77_print_array (type, valaddr, address, stream, recurse, original_value, options); fprintf_filtered (stream, ")"); break; case TYPE_CODE_PTR: if (options->format && options->format != 's') { print_scalar_formatted (valaddr, type, options, 0, stream); break; } else { addr = unpack_pointer (type, valaddr); elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) { /* Try to print what function it points to. */ print_address_demangle (gdbarch, addr, stream, demangle); /* Return value is irrelevant except for string pointers. */ return 0; } if (options->addressprint && options->format != 's') fputs_filtered (paddress (gdbarch, addr), stream); /* For a pointer to char or unsigned char, also print the string pointed to, unless pointer is null. */ if (TYPE_LENGTH (elttype) == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT && (options->format == 0 || options->format == 's') && addr != 0) i = val_print_string (TYPE_TARGET_TYPE (type), addr, -1, stream, options); /* Return number of characters printed, including the terminating '\0' if we reached the end. val_print_string takes care including the terminating '\0' if necessary. */ return i; } break; case TYPE_CODE_REF: elttype = check_typedef (TYPE_TARGET_TYPE (type)); if (options->addressprint) { CORE_ADDR addr = extract_typed_address (valaddr + embedded_offset, type); fprintf_filtered (stream, "@"); fputs_filtered (paddress (gdbarch, addr), stream); if (options->deref_ref) fputs_filtered (": ", stream); } /* De-reference the reference. */ if (options->deref_ref) { if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF) { struct value *deref_val = value_at (TYPE_TARGET_TYPE (type), unpack_pointer (type, valaddr + embedded_offset)); common_val_print (deref_val, stream, recurse, options, current_language); } else fputs_filtered ("???", stream); } break; case TYPE_CODE_FUNC: if (options->format) { print_scalar_formatted (valaddr, type, options, 0, stream); break; } /* FIXME, we should consider, at least for ANSI C language, eliminating the distinction made between FUNCs and POINTERs to FUNCs. */ fprintf_filtered (stream, "{"); type_print (type, "", stream, -1); fprintf_filtered (stream, "} "); /* Try to print what function it points to, and its address. */ print_address_demangle (gdbarch, address, stream, demangle); break; case TYPE_CODE_INT: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); print_scalar_formatted (valaddr, type, &opts, 0, stream); } else { val_print_type_code_int (type, valaddr, stream); /* C and C++ has no single byte int type, char is used instead. Since we don't know whether the value is really intended to be used as an integer or a character, print the character equivalent as well. */ if (TYPE_LENGTH (type) == 1) { fputs_filtered (" ", stream); LA_PRINT_CHAR ((unsigned char) unpack_long (type, valaddr), type, stream); } } break; case TYPE_CODE_FLAGS: if (options->format) print_scalar_formatted (valaddr, type, options, 0, stream); else val_print_type_code_flags (type, valaddr, stream); break; case TYPE_CODE_FLT: if (options->format) print_scalar_formatted (valaddr, type, options, 0, stream); else print_floating (valaddr, type, stream); break; case TYPE_CODE_VOID: fprintf_filtered (stream, "VOID"); break; case TYPE_CODE_ERROR: fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); break; case TYPE_CODE_RANGE: /* FIXME, we should not ever have to print one of these yet. */ fprintf_filtered (stream, "<range type>"); break; case TYPE_CODE_BOOL: if (options->format || options->output_format) { struct value_print_options opts = *options; opts.format = (options->format ? options->format : options->output_format); print_scalar_formatted (valaddr, type, &opts, 0, stream); } else { val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type), byte_order); if (val == 0) fprintf_filtered (stream, ".FALSE."); else if (val == 1) fprintf_filtered (stream, ".TRUE."); else /* Not a legitimate logical type, print as an integer. */ { /* Bash the type code temporarily. */ TYPE_CODE (type) = TYPE_CODE_INT; val_print (type, valaddr, 0, address, stream, recurse, original_value, options, current_language); /* Restore the type code so later uses work as intended. */ TYPE_CODE (type) = TYPE_CODE_BOOL; } } break; case TYPE_CODE_COMPLEX: type = TYPE_TARGET_TYPE (type); fputs_filtered ("(", stream); print_floating (valaddr, type, stream); fputs_filtered (",", stream); print_floating (valaddr + TYPE_LENGTH (type), type, stream); fputs_filtered (")", stream); break; case TYPE_CODE_UNDEF: /* This happens (without TYPE_FLAG_STUB set) on systems which don't use dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" and no complete type for struct foo in that file. */ fprintf_filtered (stream, "<incomplete type>"); break; case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: /* Starting from the Fortran 90 standard, Fortran supports derived types. */ fprintf_filtered (stream, "( "); for (index = 0; index < TYPE_NFIELDS (type); index++) { int offset = TYPE_FIELD_BITPOS (type, index) / 8; val_print (TYPE_FIELD_TYPE (type, index), valaddr + offset, embedded_offset, address, stream, recurse + 1, original_value, options, current_language); if (index != TYPE_NFIELDS (type) - 1) fputs_filtered (", ", stream); } fprintf_filtered (stream, " )"); break; default: error (_("Invalid F77 type code %d in symbol table."), TYPE_CODE (type)); } gdb_flush (stream); return 0; }