This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi, I've put together a small set of patches (against the 4.16.98 snapshot) to enable gdb to handle the STRUCTURE extension common in many f77 implementations. Practically every line of the code was taken directly from the C/C++ side of the fence, so printing the type or value of a Fortran structure results in something that looks like a C statement, but I think the aesthetics (for Fortran trained eyes at least) are easily upgradeable. The copyright paperwork is in the mail. Honestly. Dave Here's the ChangeLog entry: Wed Apr 22 19:26:02 1998 Dave Morrison <dave@bnl.gov> * f-exp.y: Spliced in code taken directly from c-exp.y to recognize Fortran structures. * f-typeprint.c (f_type_print_base): Spliced in code taken from c_type_print_base to support Fortran structures. * f-valprint.c (f_val_print): Added call to cp_print_value_fields to print values for Fortran structures. And the patch itself: diff -c3rp gdb-4.16.98/gdb/f-exp.y gdb-4.16.98-modified/gdb/f-exp.y *** gdb-4.16.98/gdb/f-exp.y Tue Nov 12 18:32:41 1996 --- gdb-4.16.98-modified/gdb/f-exp.y Tue Apr 21 14:17:42 1998 *************** exp : SIZEOF exp %prec UNARY *** 255,260 **** --- 255,266 ---- { write_exp_elt_opcode (UNOP_SIZEOF); } ; + exp : exp '.' name + { write_exp_elt_opcode (STRUCTOP_STRUCT); + write_exp_string ($3); + write_exp_elt_opcode (STRUCTOP_STRUCT); } + ; + /* No more explicit array operators, we treat everything in F77 as a function call. The disambiguation as to whether we are doing a subscript operation or a function call is done diff -c3rp gdb-4.16.98/gdb/f-typeprint.c gdb-4.16.98-modified/gdb/f-typeprint.c *** gdb-4.16.98/gdb/f-typeprint.c Thu Jul 25 22:59:23 1996 --- gdb-4.16.98-modified/gdb/f-typeprint.c Thu Apr 23 14:16:31 1998 *************** f_type_print_base (type, stream, show, l *** 343,348 **** --- 343,350 ---- { int retcode; int upper_bound; + register int i; + register int len; QUIT; *************** f_type_print_base (type, stream, show, l *** 377,382 **** --- 379,426 ---- case TYPE_CODE_ARRAY: case TYPE_CODE_FUNC: f_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); + break; + + case TYPE_CODE_STRUCT: + fprintf_filtered (stream, "struct "); + if (TYPE_TAG_NAME (type) != NULL) + { + fputs_filtered (TYPE_TAG_NAME (type), stream); + if (show > 0) + fputs_filtered (" ", stream); + } + wrap_here (" "); + if (show < 0) + { + /* If we just printed a tag name, no need to print anything else. */ + if (TYPE_TAG_NAME (type) == NULL) + fprintf_filtered (stream, "{...}"); + } + else if (show > 0 || TYPE_TAG_NAME (type) == NULL) + { + fprintf_filtered (stream, "{\n"); + if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) + { + if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) + fprintfi_filtered (level + 4, stream, "<incomplete type>\n"); + else + fprintfi_filtered (level + 4, stream, "<no data fields>\n"); + } + + len = TYPE_NFIELDS (type); + for (i = TYPE_N_BASECLASSES (type); i < len; i++) + { + QUIT; + + print_spaces_filtered (level + 4, stream); + c_print_type (TYPE_FIELD_TYPE (type, i), + TYPE_FIELD_NAME (type, i), + stream, show - 1, level + 4); + fprintf_filtered (stream, ";\n"); + } + + fprintfi_filtered (level, stream, "}"); + } break; case TYPE_CODE_PTR: diff -c3rp gdb-4.16.98/gdb/f-valprint.c gdb-4.16.98-modified/gdb/f-valprint.c *** gdb-4.16.98/gdb/f-valprint.c Thu Jul 25 22:59:25 1996 --- gdb-4.16.98-modified/gdb/f-valprint.c Tue Apr 21 15:02:41 1998 *************** f_val_print (type, valaddr, address, str *** 497,502 **** --- 497,507 ---- fprintf_filtered (stream, "<range type>"); break; + case TYPE_CODE_STRUCT: + cp_print_value_fields (type, valaddr, address, stream, format, + recurse, pretty, NULL, 0); + break; + case TYPE_CODE_BOOL: format = format ? format : output_format; if (format) -- David Morrison Brookhaven National Laboratory phone: 516-344-5840 Physics Department, Bldg 510 C fax: 516-344-3253 Upton, NY 11973-5000 email: dave@bnl.gov