From 166606b71e0050bee27b631f1517e99db3f9cd71 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Thu, 31 Jul 1997 22:39:34 +0000 Subject: [PATCH] * java-*: Renamed to jv-*, to make fit within 14 characters. * jv-lang.h (java_type_print): Added declaration. * jv-typeprint.c: New file. Provides java_print_type. * jv-lang.c (java_link_class_type): New function. (java_language_defn): Replace c_print_type by java_print_type. * Makefile.in: Update accordingly. --- gdb/.Sanitize | 9 ++-- gdb/ChangeLog | 9 ++++ gdb/Makefile.in | 30 +++++------ gdb/{java-exp.y => jv-exp.y} | 2 +- gdb/{java-lang.c => jv-lang.c} | 75 +++++++++++++++++++------- gdb/{java-lang.h => jv-lang.h} | 7 ++- gdb/jv-typeprint.c | 36 +++++++++++++ gdb/{java-valprint.c => jv-valprint.c} | 2 +- 8 files changed, 127 insertions(+), 43 deletions(-) rename gdb/{java-exp.y => jv-exp.y} (99%) rename gdb/{java-lang.c => jv-lang.c} (94%) rename gdb/{java-lang.h => jv-lang.h} (90%) create mode 100644 gdb/jv-typeprint.c rename gdb/{java-valprint.c => jv-valprint.c} (98%) diff --git a/gdb/.Sanitize b/gdb/.Sanitize index 06d8765c5d4..08d0b238c08 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -263,10 +263,11 @@ inftarg.c irix4-nat.c irix5-nat.c isi-xdep.c -java-exp.y -java-lang.c -java-lang.h -java-valprint.c +jv-exp.y +jv-lang.c +jv-lang.h +jv-valprint.c +jv-typeprint.c kdb-start.c language.c language.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a3e16a93dcf..6dd60eec376 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +Wed Jul 30 14:04:18 1997 Per Bothner + + * java-*: Renamed to jv-*, to make fit within 14 characters. + * jv-lang.h (java_type_print): Added declaration. + * jv-typeprint.c: New file. Provides java_print_type. + * jv-lang.c (java_link_class_type): New function. + (java_language_defn): Replace c_print_type by java_print_type. + * Makefile.in: Update accordingly. + Tue Jul 29 10:12:44 1997 Felix Lee * Makefile.in (init.c): except some mswin files do need to be diff --git a/gdb/Makefile.in b/gdb/Makefile.in index bec9aa8276d..0637f5bef7c 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -381,7 +381,7 @@ SFILES = bcache.c blockframe.c breakpoint.c buildsym.c c-exp.y \ elfread.c environ.c eval.c expprint.c \ f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c \ gdbtypes.c infcmd.c inflow.c infrun.c language.c \ - java-exp.y java-lang.c java-valprint.c \ + jv-exp.y jv-lang.c jv-valprint.c jv-typeprint.c \ m2-exp.y m2-lang.c m2-typeprint.c m2-valprint.c main.c maint.c \ mem-break.c minsyms.c mipsread.c nlmread.c objfiles.c parse.c \ printcmd.c remote.c remote-nrom.c scm-exp.c scm-lang.c scm-valprint.c \ @@ -451,7 +451,7 @@ HFILES_NO_SRCDIR = bcache.h buildsym.h call-cmds.h coff-solib.h defs.h \ gdb-stabs.h $(inferior_h) language.h minimon.h monitor.h \ objfiles.h parser-defs.h partial-stab.h serial.h signals.h solib.h \ symfile.h stabsread.h target.h terminal.h typeprint.h xcoffsolib.h \ - c-lang.h ch-lang.h f-lang.h java-lang.h m2-lang.h \ + c-lang.h ch-lang.h f-lang.h jv-lang.h m2-lang.h \ complaints.h valprint.h \ 29k-share/udi/udiids.h 29k-share/udi_soc nindy-share/b.out.h \ nindy-share/block_io.h nindy-share/coff.h \ @@ -498,7 +498,7 @@ COMMON_OBS = version.o blockframe.o breakpoint.o findvar.o stack.o thread.o \ dbxread.o coffread.o elfread.o \ dwarfread.o dwarf2read.o mipsread.o stabsread.o corefile.o \ c-lang.o ch-exp.o ch-lang.o f-lang.o \ - java-lang.o java-valprint.o m2-lang.o \ + jv-lang.o jv-valprint.o jv-typeprint.o m2-lang.o \ scm-exp.o scm-lang.o scm-valprint.o complaints.o typeprint.o \ c-typeprint.o ch-typeprint.o f-typeprint.o m2-typeprint.o \ c-valprint.o cp-valprint.o ch-valprint.o f-valprint.o m2-valprint.o \ @@ -517,8 +517,8 @@ NTSSTART = kdb-start.o SUBDIRS = doc testsuite nlm mswin # For now, shortcut the "configure GDB for fewer languages" stuff. -YYFILES = c-exp.tab.c java-exp.tab.c f-exp.tab.c m2-exp.tab.c -YYOBJ = c-exp.tab.o java-exp.tab.o f-exp.tab.o m2-exp.tab.o +YYFILES = c-exp.tab.c jv-exp.tab.c f-exp.tab.c m2-exp.tab.c +YYOBJ = c-exp.tab.o jv-exp.tab.o f-exp.tab.o m2-exp.tab.o # Things which need to be built when making a distribution. @@ -666,10 +666,10 @@ libgdb-files: $(LIBGDBDEPS) Makefile.in saber_gdb: $(SFILES) $(DEPFILES) copying.c version.c #setopt load_flags $(CFLAGS) $(BFD_CFLAGS) -DHOST_SYS=SUN4_SYS #load ./init.c $(SFILES) - #unload $(srcdir)/c-exp.y $(srcdir)/java-exp.y $(srcdir)/m2-exp.y + #unload $(srcdir)/c-exp.y $(srcdir)/jv-exp.y $(srcdir)/m2-exp.y #unload vx-share/*.h #unload nindy-share/[A-Z]* - #load c-exp.tab.c java-exp.tab.c m2-exp.tab.c + #load c-exp.tab.c jv-exp.tab.c m2-exp.tab.c #load copying.c version.c #load ../opcodes/libopcodes.a #load ../libiberty/libiberty.a @@ -773,7 +773,7 @@ maintainer-clean realclean: distclean clean @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." @$(MAKE) $(FLAGS_TO_PASS) DO=maintainer-clean "DODIRS=$(SUBDIRS)" subdir_do - rm -f c-exp.tab.c java-exp.tab.c f-exp.tab.c m2-exp.tab.c + rm -f c-exp.tab.c jv-exp.tab.c f-exp.tab.c m2-exp.tab.c rm -f TAGS $(INFOFILES) rm -f nm.h tm.h xm.h config.status @@ -850,9 +850,9 @@ c-exp.tab.c: c-exp.y -rm y.tab.c mv c-exp.new ./c-exp.tab.c -java-exp.tab.o: java-exp.tab.c -java-exp.tab.c: java-exp.y - $(YACC) $(YFLAGS) $(srcdir)/java-exp.y +jv-exp.tab.o: jv-exp.tab.c +jv-exp.tab.c: jv-exp.y + $(YACC) $(YFLAGS) $(srcdir)/jv-exp.y -sed -e '/extern.*malloc/d' \ -e '/extern.*realloc/d' \ -e '/extern.*free/d' \ @@ -860,9 +860,9 @@ java-exp.tab.c: java-exp.y -e 's/malloc/xmalloc/g' \ -e 's/realloc/xrealloc/g' \ -e '/^#line.*y.tab.c/d' \ - < y.tab.c > java-exp.new + < y.tab.c > jv-exp.new -rm y.tab.c - mv java-exp.new ./java-exp.tab.c + mv jv-exp.new ./jv-exp.tab.c f-exp.tab.o: f-exp.tab.c f-exp.tab.c: f-exp.y c-exp.tab.c @@ -897,7 +897,7 @@ m2-exp.tab.c: m2-exp.y mv m2-exp.new ./m2-exp.tab.c # These files are updated atomically, so make never has to remove them -.PRECIOUS: m2-exp.tab.c java-exp.tab.c f-exp.tab.c c-exp.tab.c +.PRECIOUS: m2-exp.tab.c jv-exp.tab.c f-exp.tab.c c-exp.tab.c lint: $(LINTFILES) $(LINT) $(INCLUDE_CFLAGS) $(LINTFLAGS) $(LINTFILES) \ @@ -1631,7 +1631,7 @@ c-exp.tab.o: c-exp.tab.c c-lang.h $(defs_h) $(expression_h) \ $(gdbtypes_h) language.h parser-defs.h $(symtab_h) $(value_h) \ $(bfd_h) objfiles.h symfile.h -java-exp.tab.o: java-exp.tab.c java-lang.h $(defs_h) $(expression_h) \ +jv-exp.tab.o: jv-exp.tab.c jv-lang.h $(defs_h) $(expression_h) \ $(gdbtypes_h) language.h parser-defs.h $(symtab_h) $(value_h) \ $(bfd_h) objfiles.h symfile.h diff --git a/gdb/java-exp.y b/gdb/jv-exp.y similarity index 99% rename from gdb/java-exp.y rename to gdb/jv-exp.y index 0e9ac4776ee..d2049938546 100644 --- a/gdb/java-exp.y +++ b/gdb/jv-exp.y @@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "value.h" #include "parser-defs.h" #include "language.h" -#include "java-lang.h" +#include "jv-lang.h" #include "bfd.h" /* Required by objfiles.h. */ #include "symfile.h" /* Required by objfiles.h. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ diff --git a/gdb/java-lang.c b/gdb/jv-lang.c similarity index 94% rename from gdb/java-lang.c rename to gdb/jv-lang.c index 66cf392ae18..2e722f8d839 100644 --- a/gdb/java-lang.c +++ b/gdb/jv-lang.c @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gdb_string.h" #include "value.h" #include "c-lang.h" -#include "java-lang.h" +#include "jv-lang.h" #include "gdbcore.h" struct type *java_int_type; @@ -50,6 +50,8 @@ struct type *java_object_type; compiled java methods. */ struct objfile *dynamics_objfile = NULL; +struct type *java_link_class_type PARAMS((struct type*, value_ptr)); + struct objfile * get_dynamics_objfile () { @@ -158,12 +160,31 @@ java_lookup_class (name) struct symbol *sym; sym = lookup_symbol (name, expression_context_block, STRUCT_NAMESPACE, (int *) 0, (struct symtab **) NULL); - if (sym == NULL) + if (sym != NULL) + return SYMBOL_TYPE (sym); +#if 0 + CORE_ADDR addr; + if (called from parser) { - /* FIXME - should search inferior's symbol table. */ - return NULL; + call lookup_class (or similar) in inferior; + if not found: + return NULL; + addr = found in inferior; } - return SYMBOL_TYPE (sym); + else + addr = 0; + struct type *type; + type = alloc_type (objfile); + TYPE_CODE (type) = TYPE_CODE_STRUCT; + INIT_CPLUS_SPECIFIC (type); + TYPE_NAME (type) = obsavestring (name, strlen(name), &objfile->type_obstack); + TYPE_FLAGS (type) |= TYPE_FLAG_STUB; + TYPE ? = addr; + return type; +#else + /* FIXME - should search inferior's symbol table. */ + return NULL; +#endif } /* Return a nul-terminated string (allocated on OBSTACK) for @@ -212,22 +233,15 @@ type_from_class (clas) value_ptr clas; { struct type *type; - struct type *tsuper; - int ninterfaces, nfields; char *name; value_ptr temp; struct objfile *objfile = get_dynamics_objfile(); - value_ptr utf8_name, fields, field, method, methods; + value_ptr utf8_name; char *nptr; CORE_ADDR addr; struct block *bl; - int i, j; - int type_is_object = 0; + int i; int is_array = 0; - int nmethods; - struct fn_field *fn_fields; - struct fn_fieldlist *fn_fieldlists; - char *unqualified_name; type = check_typedef (VALUE_TYPE (clas)); if (TYPE_CODE (type) == TYPE_CODE_PTR) @@ -274,20 +288,41 @@ type_from_class (clas) VALUE_TYPE (temp) = lookup_pointer_type (VALUE_TYPE (clas)); TYPE_TARGET_TYPE (type) = type_from_class (temp); } - unqualified_name = name; for (nptr = name; *nptr != 0; nptr++) { if (*nptr == '/') - { - *nptr = '.'; - unqualified_name = nptr+1; - } + *nptr = '.'; } ALLOCATE_CPLUS_STRUCT_TYPE (type); TYPE_NAME (type) = name; add_class_symtab_symbol (add_class_symbol (type, addr)); + return java_link_class_type (type, clas); +} + +/* Fill in class TYPE with data from the CLAS value. */ + +struct type * +java_link_class_type (type, clas) + struct type *type; + value_ptr clas; +{ + value_ptr temp; + char *unqualified_name; + char *name = TYPE_NAME (type); + int ninterfaces, nfields, nmethods; + int type_is_object = 0; + struct fn_field *fn_fields; + struct fn_fieldlist *fn_fieldlists; + value_ptr fields, field, method, methods; + int i, j; + struct objfile *objfile = get_dynamics_objfile(); + struct type *tsuper; + + unqualified_name = strrchr (name, '.'); + if (unqualified_name == NULL) + unqualified_name = name; temp = clas; temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure"); @@ -677,7 +712,7 @@ const struct language_defn java_language_defn = { c_printchar, /* Print a character constant */ c_printstr, /* Function to print string constant */ java_create_fundamental_type, /* Create fundamental type in this language */ - c_print_type, /* Print a type using appropriate syntax */ + java_print_type, /* Print a type using appropriate syntax */ java_val_print, /* Print a value using appropriate syntax */ java_value_print, /* Print a top-level value */ {"", "", "", ""}, /* Binary format info */ diff --git a/gdb/java-lang.h b/gdb/jv-lang.h similarity index 90% rename from gdb/java-lang.h rename to gdb/jv-lang.h index 20f8b409c75..814fb4a0c0b 100644 --- a/gdb/java-lang.h +++ b/gdb/jv-lang.h @@ -18,10 +18,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ extern int -java_parse PARAMS ((void)); /* Defined in java-exp.y */ +java_parse PARAMS ((void)); /* Defined in jv-exp.y */ extern void -java_error PARAMS ((char *)); /* Defined in java-exp.y */ +java_error PARAMS ((char *)); /* Defined in jv-exp.y */ #define JAVA_OBJECT_SIZE (6 * 4) /* sizeof (struct Object) FIXME ! */ @@ -61,3 +61,6 @@ extern struct type *get_java_object_type (); extern struct type * java_lookup_class PARAMS((char *)); extern int is_object_type PARAMS ((struct type*)); + +extern void /* Defined in jv-typeprint.c */ +java_print_type PARAMS ((struct type *, char *, GDB_FILE *, int, int)); diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c new file mode 100644 index 00000000000..2f31214d60c --- /dev/null +++ b/gdb/jv-typeprint.c @@ -0,0 +1,36 @@ +/* Support for printing Java types for GDB, the GNU debugger. + Copyright 1997 Free Software Foundation, Inc. + +This file is part of GDB. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + +#include "defs.h" +#include "symtab.h" +#include "gdbtypes.h" + +/* LEVEL is the depth to indent lines by. */ + +void +java_print_type (type, varstring, stream, show, level) + struct type *type; + char *varstring; + GDB_FILE *stream; + int show; + int level; +{ + c_print_type (type, varstring, stream, show, level); +} diff --git a/gdb/java-valprint.c b/gdb/jv-valprint.c similarity index 98% rename from gdb/java-valprint.c rename to gdb/jv-valprint.c index 511ac08bb68..af60b1754af 100644 --- a/gdb/java-valprint.c +++ b/gdb/jv-valprint.c @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "demangle.h" #include "valprint.h" #include "language.h" -#include "java-lang.h" +#include "jv-lang.h" #include "c-lang.h" int -- 2.30.2