GDB (xrefs)
/tmp/gdb-7.10/gdb/jv-lang.c
Go to the documentation of this file.
1 /* Java language support routines for GDB, the GNU debugger.
2 
3  Copyright (C) 1997-2015 Free Software Foundation, Inc.
4 
5  This file is part of GDB.
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 #include "defs.h"
21 #include "symtab.h"
22 #include "gdbtypes.h"
23 #include "expression.h"
24 #include "parser-defs.h"
25 #include "language.h"
26 #include "symfile.h"
27 #include "objfiles.h"
28 #include "value.h"
29 #include "c-lang.h"
30 #include "jv-lang.h"
31 #include "varobj.h"
32 #include "gdbcore.h"
33 #include "block.h"
34 #include "demangle.h"
35 #include "dictionary.h"
36 #include <ctype.h>
37 #include "charset.h"
38 #include "valprint.h"
39 #include "cp-support.h"
40 
41 /* Local functions */
42 
43 extern void _initialize_java_language (void);
44 
45 static int java_demangled_signature_length (const char *);
46 static void java_demangled_signature_copy (char *, const char *);
47 
48 static struct compunit_symtab *get_java_class_symtab (struct gdbarch *gdbarch);
49 static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
50 static int java_class_is_primitive (struct value *clas);
51 static struct value *java_value_string (char *ptr, int len);
52 
53 static void java_emit_char (int c, struct type *type,
54  struct ui_file * stream, int quoter);
55 
56 static char *java_class_name_from_physname (const char *physname);
57 
58 static const struct objfile_data *jv_dynamics_objfile_data_key;
59 
60 /* The dynamic objfile is kept per-program-space. This key lets us
61  associate the objfile with the program space. */
62 
63 static const struct program_space_data *jv_dynamics_progspace_key;
64 
65 static struct type *java_link_class_type (struct gdbarch *,
66  struct type *, struct value *);
67 
68 /* An instance of this structure is used to store some data that must
69  be freed. */
70 
72 {
73  /* The expandable dictionary we use. */
74  struct dictionary *dict;
75 };
76 
77 /* A function called when the dynamics_objfile is freed. We use this
78  to clean up some internal state. */
79 static void
81 {
82  struct jv_per_objfile_data *jv_data = data;
83  struct objfile *dynamics_objfile;
84 
85  dynamics_objfile = program_space_data (current_program_space,
87  gdb_assert (objfile == dynamics_objfile);
88 
89  if (jv_data->dict)
90  dict_free (jv_data->dict);
91  xfree (jv_data);
92 
93  set_program_space_data (current_program_space,
95  NULL);
96 }
97 
98 /* FIXME: carlton/2003-02-04: This is the main or only caller of
99  allocate_objfile with first argument NULL; as a result, this code
100  breaks every so often. Somebody should write a test case that
101  exercises GDB in various ways (e.g. something involving loading a
102  dynamic library) after this code has been called. */
103 
104 static struct objfile *
106 {
107  struct objfile *dynamics_objfile;
108 
109  dynamics_objfile = program_space_data (current_program_space,
111 
112  if (dynamics_objfile == NULL)
113  {
114  struct jv_per_objfile_data *data;
115 
116  /* Mark it as shared so that it is cleared when the inferior is
117  re-run. */
118  dynamics_objfile = allocate_objfile (NULL, NULL,
120  dynamics_objfile->per_bfd->gdbarch = gdbarch;
121 
122  data = XCNEW (struct jv_per_objfile_data);
123  set_objfile_data (dynamics_objfile, jv_dynamics_objfile_data_key, data);
124 
125  set_program_space_data (current_program_space,
127  dynamics_objfile);
128  }
129  return dynamics_objfile;
130 }
131 
132 static struct compunit_symtab *
134 {
135  struct objfile *objfile = get_dynamics_objfile (gdbarch);
136  struct compunit_symtab *class_symtab = objfile->compunit_symtabs;
137 
138  if (class_symtab == NULL)
139  {
140  struct blockvector *bv;
141  struct block *bl;
142  struct jv_per_objfile_data *jv_data;
143 
144  class_symtab = allocate_compunit_symtab (objfile, "<java-classes>");
145  add_compunit_symtab_to_objfile (class_symtab);
146  allocate_symtab (class_symtab, "<java-classes>");
147 
148  COMPUNIT_FILETABS (class_symtab)->language = language_java;
149  bv = (struct blockvector *)
150  obstack_alloc (&objfile->objfile_obstack,
151  sizeof (struct blockvector) + sizeof (struct block *));
152  BLOCKVECTOR_NBLOCKS (bv) = 1;
153  COMPUNIT_BLOCKVECTOR (class_symtab) = bv;
154 
155  /* Allocate dummy STATIC_BLOCK. */
156  bl = allocate_block (&objfile->objfile_obstack);
158  NULL);
159  BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
160 
161  /* Allocate GLOBAL_BLOCK. */
162  bl = allocate_global_block (&objfile->objfile_obstack);
164  set_block_compunit_symtab (bl, class_symtab);
165  BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
166 
167  /* Arrange to free the dict. */
168  jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key);
169  jv_data->dict = BLOCK_DICT (bl);
170  }
171  return class_symtab;
172 }
173 
174 static void
176 {
177  struct compunit_symtab *cust = get_java_class_symtab (symbol_arch (sym));
178  const struct blockvector *bv = COMPUNIT_BLOCKVECTOR (cust);
179 
181 }
182 
183 static struct symbol *
185 {
186  struct symbol *sym;
188 
189  sym = allocate_symbol (objfile);
193  /* SYMBOL_VALUE (sym) = valu; */
194  SYMBOL_TYPE (sym) = type;
196  SYMBOL_VALUE_ADDRESS (sym) = addr;
197  return sym;
198 }
199 
200 struct type *
202 {
203  struct symbol *sym;
204 
206  if (sym != NULL)
207  return SYMBOL_TYPE (sym);
208  /* FIXME - should search inferior's symbol table. */
209  return NULL;
210 }
211 
212 /* Return a nul-terminated string (allocated on OBSTACK) for
213  a name given by NAME (which has type Utf8Const*). */
214 
215 char *
216 get_java_utf8_name (struct obstack *obstack, struct value *name)
217 {
218  char *chrs;
219  struct value *temp = name;
220  int name_length;
221  CORE_ADDR data_addr;
222 
223  temp = value_struct_elt (&temp, NULL, "length", NULL, "structure");
224  name_length = (int) value_as_long (temp);
225  data_addr = value_address (temp) + TYPE_LENGTH (value_type (temp));
226  chrs = obstack_alloc (obstack, name_length + 1);
227  chrs[name_length] = '\0';
228  read_memory (data_addr, (gdb_byte *) chrs, name_length);
229  return chrs;
230 }
231 
232 struct value *
233 java_class_from_object (struct value *obj_val)
234 {
235  /* This is all rather inefficient, since the offsets of vtable and
236  class are fixed. FIXME */
237  struct value *vtable_val;
238 
239  if (TYPE_CODE (value_type (obj_val)) == TYPE_CODE_PTR
240  && TYPE_LENGTH (TYPE_TARGET_TYPE (value_type (obj_val))) == 0)
241  obj_val = value_at (get_java_object_type (),
242  value_as_address (obj_val));
243 
244  vtable_val = value_struct_elt (&obj_val, NULL, "vtable", NULL, "structure");
245  return value_struct_elt (&vtable_val, NULL, "class", NULL, "structure");
246 }
247 
248 /* Check if CLASS_IS_PRIMITIVE(value of clas): */
249 static int
251 {
252  struct value *vtable = value_struct_elt (&clas, NULL, "vtable",
253  NULL, "struct");
254  CORE_ADDR i = value_as_address (vtable);
255 
256  return (int) (i & 0x7fffffff) == (int) 0x7fffffff;
257 }
258 
259 /* Read a GCJ Class object, and generated a gdb (TYPE_CODE_STRUCT) type. */
260 
261 struct type *
262 type_from_class (struct gdbarch *gdbarch, struct value *clas)
263 {
264  struct type *type;
265  char *name;
266  struct value *temp;
267  struct objfile *objfile;
268  struct value *utf8_name;
269  char *nptr;
270  CORE_ADDR addr;
271 
272  type = check_typedef (value_type (clas));
273  if (TYPE_CODE (type) == TYPE_CODE_PTR)
274  {
275  if (value_logical_not (clas))
276  return NULL;
277  clas = value_ind (clas);
278  }
279  addr = value_address (clas);
280 
281  objfile = get_dynamics_objfile (gdbarch);
282  if (java_class_is_primitive (clas))
283  {
284  struct value *sig;
285 
286  temp = clas;
287  sig = value_struct_elt (&temp, NULL, "method_count", NULL, "structure");
288  return java_primitive_type (gdbarch, value_as_long (sig));
289  }
290 
291  /* Get Class name. */
292  /* If clasloader non-null, prepend loader address. FIXME */
293  temp = clas;
294  utf8_name = value_struct_elt (&temp, NULL, "name", NULL, "structure");
295  name = get_java_utf8_name (&objfile->objfile_obstack, utf8_name);
296  for (nptr = name; *nptr != 0; nptr++)
297  {
298  if (*nptr == '/')
299  *nptr = '.';
300  }
301 
302  type = java_lookup_class (name);
303  if (type != NULL)
304  return type;
305 
306  type = alloc_type (objfile);
307  TYPE_CODE (type) = TYPE_CODE_STRUCT;
308  INIT_CPLUS_SPECIFIC (type);
309 
310  if (name[0] == '[')
311  {
312  char *signature = name;
313  int namelen = java_demangled_signature_length (signature);
314 
315  if (namelen > strlen (name))
316  name = obstack_alloc (&objfile->objfile_obstack, namelen + 1);
317  java_demangled_signature_copy (name, signature);
318  name[namelen] = '\0';
319  temp = clas;
320  /* Set array element type. */
321  temp = value_struct_elt (&temp, NULL, "methods", NULL, "structure");
324  TYPE_TARGET_TYPE (type) = type_from_class (gdbarch, temp);
325  }
326 
328  TYPE_TAG_NAME (type) = name;
329 
331  return java_link_class_type (gdbarch, type, clas);
332 }
333 
334 /* Fill in class TYPE with data from the CLAS value. */
335 
336 static struct type *
338  struct type *type, struct value *clas)
339 {
340  struct value *temp;
341  const char *unqualified_name;
342  const char *name = TYPE_TAG_NAME (type);
343  int ninterfaces, nfields, nmethods;
344  int type_is_object = 0;
345  struct fn_field *fn_fields;
346  struct fn_fieldlist *fn_fieldlists;
347  struct value *fields;
348  struct value *methods;
349  struct value *method = NULL;
350  struct value *field = NULL;
351  int i, j;
352  struct objfile *objfile = get_dynamics_objfile (gdbarch);
353  struct type *tsuper;
354 
355  gdb_assert (name != NULL);
356  unqualified_name = strrchr (name, '.');
357  if (unqualified_name == NULL)
358  unqualified_name = name;
359 
360  temp = clas;
361  temp = value_struct_elt (&temp, NULL, "superclass", NULL, "structure");
362  if (strcmp (name, "java.lang.Object") == 0)
363  {
364  tsuper = get_java_object_type ();
365  if (tsuper && TYPE_CODE (tsuper) == TYPE_CODE_PTR)
366  tsuper = TYPE_TARGET_TYPE (tsuper);
367  type_is_object = 1;
368  }
369  else
370  tsuper = type_from_class (gdbarch, temp);
371 
372 #if 1
373  ninterfaces = 0;
374 #else
375  temp = clas;
376  ninterfaces = value_as_long (value_struct_elt (&temp, NULL, "interface_len",
377  NULL, "structure"));
378 #endif
379  TYPE_N_BASECLASSES (type) = (tsuper == NULL ? 0 : 1) + ninterfaces;
380  temp = clas;
381  nfields = value_as_long (value_struct_elt (&temp, NULL, "field_count",
382  NULL, "structure"));
383  nfields += TYPE_N_BASECLASSES (type);
384  nfields++; /* Add one for dummy "class" field. */
385  TYPE_NFIELDS (type) = nfields;
386  TYPE_FIELDS (type) = (struct field *)
387  TYPE_ALLOC (type, sizeof (struct field) * nfields);
388 
389  memset (TYPE_FIELDS (type), 0, sizeof (struct field) * nfields);
390 
391  TYPE_FIELD_PRIVATE_BITS (type) =
392  (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
393  B_CLRALL (TYPE_FIELD_PRIVATE_BITS (type), nfields);
394 
396  (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
397  B_CLRALL (TYPE_FIELD_PROTECTED_BITS (type), nfields);
398 
399  TYPE_FIELD_IGNORE_BITS (type) =
400  (B_TYPE *) TYPE_ALLOC (type, B_BYTES (nfields));
401  B_CLRALL (TYPE_FIELD_IGNORE_BITS (type), nfields);
402 
403  TYPE_FIELD_VIRTUAL_BITS (type) = (B_TYPE *)
404  TYPE_ALLOC (type, B_BYTES (TYPE_N_BASECLASSES (type)));
406 
407  if (tsuper != NULL)
408  {
409  TYPE_BASECLASS (type, 0) = tsuper;
410  if (type_is_object)
411  SET_TYPE_FIELD_PRIVATE (type, 0);
412  }
413 
414  i = strlen (name);
415  if (i > 2 && name[i - 1] == ']' && tsuper != NULL)
416  {
417  /* FIXME */
418  TYPE_LENGTH (type) = TYPE_LENGTH (tsuper) + 4; /* size with "length" */
419  }
420  else
421  {
422  temp = clas;
423  temp = value_struct_elt (&temp, NULL, "size_in_bytes",
424  NULL, "structure");
425  TYPE_LENGTH (type) = value_as_long (temp);
426  }
427 
428  fields = NULL;
429  nfields--; /* First set up dummy "class" field. */
430  SET_FIELD_PHYSADDR (TYPE_FIELD (type, nfields), value_address (clas));
431  TYPE_FIELD_NAME (type, nfields) = "class";
432  TYPE_FIELD_TYPE (type, nfields) = value_type (clas);
433  SET_TYPE_FIELD_PRIVATE (type, nfields);
434 
435  for (i = TYPE_N_BASECLASSES (type); i < nfields; i++)
436  {
437  int accflags;
438  int boffset;
439 
440  if (fields == NULL)
441  {
442  temp = clas;
443  fields = value_struct_elt (&temp, NULL, "fields", NULL, "structure");
444  field = value_ind (fields);
445  }
446  else
447  { /* Re-use field value for next field. */
448  CORE_ADDR addr
449  = value_address (field) + TYPE_LENGTH (value_type (field));
450 
451  set_value_address (field, addr);
452  set_value_lazy (field, 1);
453  }
454  temp = field;
455  temp = value_struct_elt (&temp, NULL, "name", NULL, "structure");
456  TYPE_FIELD_NAME (type, i) =
457  get_java_utf8_name (&objfile->objfile_obstack, temp);
458  temp = field;
459  accflags = value_as_long (value_struct_elt (&temp, NULL, "accflags",
460  NULL, "structure"));
461  temp = field;
462  temp = value_struct_elt (&temp, NULL, "info", NULL, "structure");
463  boffset = value_as_long (value_struct_elt (&temp, NULL, "boffset",
464  NULL, "structure"));
465  if (accflags & 0x0001) /* public access */
466  {
467  /* ??? */
468  }
469  if (accflags & 0x0002) /* private access */
470  {
471  SET_TYPE_FIELD_PRIVATE (type, i);
472  }
473  if (accflags & 0x0004) /* protected access */
474  {
475  SET_TYPE_FIELD_PROTECTED (type, i);
476  }
477  if (accflags & 0x0008) /* ACC_STATIC */
478  SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset);
479  else
480  SET_FIELD_BITPOS (TYPE_FIELD (type, i), 8 * boffset);
481  if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */
482  {
483  TYPE_FIELD_TYPE (type, i) = get_java_object_type (); /* FIXME */
484  }
485  else
486  {
487  struct type *ftype;
488 
489  temp = field;
490  temp = value_struct_elt (&temp, NULL, "type", NULL, "structure");
491  ftype = type_from_class (gdbarch, temp);
492  if (TYPE_CODE (ftype) == TYPE_CODE_STRUCT)
493  ftype = lookup_pointer_type (ftype);
494  TYPE_FIELD_TYPE (type, i) = ftype;
495  }
496  }
497 
498  temp = clas;
499  nmethods = value_as_long (value_struct_elt (&temp, NULL, "method_count",
500  NULL, "structure"));
501  j = nmethods * sizeof (struct fn_field);
502  fn_fields = (struct fn_field *)
503  obstack_alloc (&objfile->objfile_obstack, j);
504  memset (fn_fields, 0, j);
505  fn_fieldlists = (struct fn_fieldlist *)
506  alloca (nmethods * sizeof (struct fn_fieldlist));
507 
508  methods = NULL;
509  for (i = 0; i < nmethods; i++)
510  {
511  const char *mname;
512  int k;
513 
514  if (methods == NULL)
515  {
516  temp = clas;
517  methods = value_struct_elt (&temp, NULL, "methods",
518  NULL, "structure");
519  method = value_ind (methods);
520  }
521  else
522  { /* Re-use method value for next method. */
523  CORE_ADDR addr
524  = value_address (method) + TYPE_LENGTH (value_type (method));
525 
526  set_value_address (method, addr);
527  set_value_lazy (method, 1);
528  }
529 
530  /* Get method name. */
531  temp = method;
532  temp = value_struct_elt (&temp, NULL, "name", NULL, "structure");
533  mname = get_java_utf8_name (&objfile->objfile_obstack, temp);
534  if (strcmp (mname, "<init>") == 0)
535  mname = unqualified_name;
536 
537  /* Check for an existing method with the same name.
538  * This makes building the fn_fieldslists an O(nmethods**2)
539  * operation. That could be using hashing, but I doubt it
540  * is worth it. Note that we do maintain the order of methods
541  * in the inferior's Method table (as long as that is grouped
542  * by method name), which I think is desirable. --PB */
543  for (k = 0, j = TYPE_NFN_FIELDS (type);;)
544  {
545  if (--j < 0)
546  { /* No match - new method name. */
547  j = TYPE_NFN_FIELDS (type)++;
548  fn_fieldlists[j].name = mname;
549  fn_fieldlists[j].length = 1;
550  fn_fieldlists[j].fn_fields = &fn_fields[i];
551  k = i;
552  break;
553  }
554  if (strcmp (mname, fn_fieldlists[j].name) == 0)
555  { /* Found an existing method with the same name. */
556  int l;
557 
558  if (mname != unqualified_name)
559  obstack_free (&objfile->objfile_obstack, mname);
560  mname = fn_fieldlists[j].name;
561  fn_fieldlists[j].length++;
562  k = i - k; /* Index of new slot. */
563  /* Shift intervening fn_fields (between k and i) down. */
564  for (l = i; l > k; l--)
565  fn_fields[l] = fn_fields[l - 1];
566  for (l = TYPE_NFN_FIELDS (type); --l > j;)
567  fn_fieldlists[l].fn_fields++;
568  break;
569  }
570  k += fn_fieldlists[j].length;
571  }
572  fn_fields[k].physname = "";
573  fn_fields[k].is_stub = 1;
574  /* FIXME */
575  fn_fields[k].type = lookup_function_type
576  (builtin_java_type (gdbarch)->builtin_void);
577  TYPE_CODE (fn_fields[k].type) = TYPE_CODE_METHOD;
578  }
579 
580  j = TYPE_NFN_FIELDS (type) * sizeof (struct fn_fieldlist);
581  TYPE_FN_FIELDLISTS (type) = (struct fn_fieldlist *)
582  obstack_alloc (&objfile->objfile_obstack, j);
583  memcpy (TYPE_FN_FIELDLISTS (type), fn_fieldlists, j);
584 
585  return type;
586 }
587 
588 struct type *
590 {
591  struct symbol *sym;
592 
593  sym = lookup_symbol ("java.lang.Object", NULL, STRUCT_DOMAIN, NULL);
594  if (sym == NULL)
595  error (_("cannot find java.lang.Object"));
596  return SYMBOL_TYPE (sym);
597 }
598 
599 int
601 {
602  struct type *objtype = get_java_object_type ();
603 
604  if (objtype == NULL)
605  return (2 * gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
606  else
607  return TYPE_LENGTH (objtype);
608 }
609 
610 int
612 {
613  CHECK_TYPEDEF (type);
614  if (TYPE_CODE (type) == TYPE_CODE_PTR)
615  {
616  struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type));
617  const char *name;
618  if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT)
619  return 0;
620  while (TYPE_N_BASECLASSES (ttype) > 0)
621  ttype = TYPE_BASECLASS (ttype, 0);
622  name = TYPE_TAG_NAME (ttype);
623  if (name != NULL && strcmp (name, "java.lang.Object") == 0)
624  return 1;
625  name
626  = TYPE_NFIELDS (ttype) > 0 ? TYPE_FIELD_NAME (ttype, 0) : (char *) 0;
627  if (name != NULL && strcmp (name, "vtable") == 0)
628  return 1;
629  }
630  return 0;
631 }
632 
633 struct type *
634 java_primitive_type (struct gdbarch *gdbarch, int signature)
635 {
636  const struct builtin_java_type *builtin = builtin_java_type (gdbarch);
637 
638  switch (signature)
639  {
640  case 'B':
641  return builtin->builtin_byte;
642  case 'S':
643  return builtin->builtin_short;
644  case 'I':
645  return builtin->builtin_int;
646  case 'J':
647  return builtin->builtin_long;
648  case 'Z':
649  return builtin->builtin_boolean;
650  case 'C':
651  return builtin->builtin_char;
652  case 'F':
653  return builtin->builtin_float;
654  case 'D':
655  return builtin->builtin_double;
656  case 'V':
657  return builtin->builtin_void;
658  }
659  error (_("unknown signature '%c' for primitive type"), (char) signature);
660 }
661 
662 /* If name[0 .. namelen-1] is the name of a primitive Java type,
663  return that type. Otherwise, return NULL. */
664 
665 struct type *
667  const char *name, int namelen)
668 {
669  const struct builtin_java_type *builtin = builtin_java_type (gdbarch);
670 
671  switch (name[0])
672  {
673  case 'b':
674  if (namelen == 4 && memcmp (name, "byte", 4) == 0)
675  return builtin->builtin_byte;
676  if (namelen == 7 && memcmp (name, "boolean", 7) == 0)
677  return builtin->builtin_boolean;
678  break;
679  case 'c':
680  if (namelen == 4 && memcmp (name, "char", 4) == 0)
681  return builtin->builtin_char;
682  break;
683  case 'd':
684  if (namelen == 6 && memcmp (name, "double", 6) == 0)
685  return builtin->builtin_double;
686  break;
687  case 'f':
688  if (namelen == 5 && memcmp (name, "float", 5) == 0)
689  return builtin->builtin_float;
690  break;
691  case 'i':
692  if (namelen == 3 && memcmp (name, "int", 3) == 0)
693  return builtin->builtin_int;
694  break;
695  case 'l':
696  if (namelen == 4 && memcmp (name, "long", 4) == 0)
697  return builtin->builtin_long;
698  break;
699  case 's':
700  if (namelen == 5 && memcmp (name, "short", 5) == 0)
701  return builtin->builtin_short;
702  break;
703  case 'v':
704  if (namelen == 4 && memcmp (name, "void", 4) == 0)
705  return builtin->builtin_void;
706  break;
707  }
708  return NULL;
709 }
710 
711 static char *
713 {
714  switch (signature)
715  {
716  case 'B':
717  return "byte";
718  case 'S':
719  return "short";
720  case 'I':
721  return "int";
722  case 'J':
723  return "long";
724  case 'Z':
725  return "boolean";
726  case 'C':
727  return "char";
728  case 'F':
729  return "float";
730  case 'D':
731  return "double";
732  case 'V':
733  return "void";
734  }
735  error (_("unknown signature '%c' for primitive type"), (char) signature);
736 }
737 
738 /* Return the length (in bytes) of demangled name of the Java type
739  signature string SIGNATURE. */
740 
741 static int
742 java_demangled_signature_length (const char *signature)
743 {
744  int array = 0;
745 
746  for (; *signature == '['; signature++)
747  array += 2; /* Two chars for "[]". */
748  switch (signature[0])
749  {
750  case 'L':
751  /* Subtract 2 for 'L' and ';'. */
752  return strlen (signature) - 2 + array;
753  default:
754  return strlen (java_primitive_type_name (signature[0])) + array;
755  }
756 }
757 
758 /* Demangle the Java type signature SIGNATURE, leaving the result in
759  RESULT. */
760 
761 static void
762 java_demangled_signature_copy (char *result, const char *signature)
763 {
764  int array = 0;
765  char *ptr;
766  int i;
767 
768  while (*signature == '[')
769  {
770  array++;
771  signature++;
772  }
773  switch (signature[0])
774  {
775  case 'L':
776  /* Subtract 2 for 'L' and ';', but add 1 for final nul. */
777  signature++;
778  ptr = result;
779  for (; *signature != ';' && *signature != '\0'; signature++)
780  {
781  if (*signature == '/')
782  *ptr++ = '.';
783  else
784  *ptr++ = *signature;
785  }
786  break;
787  default:
788  ptr = java_primitive_type_name (signature[0]);
789  i = strlen (ptr);
790  strcpy (result, ptr);
791  ptr = result + i;
792  break;
793  }
794  while (--array >= 0)
795  {
796  *ptr++ = '[';
797  *ptr++ = ']';
798  }
799 }
800 
801 /* Return the demangled name of the Java type signature string SIGNATURE,
802  as a freshly allocated copy. */
803 
804 char *
805 java_demangle_type_signature (const char *signature)
806 {
807  int length = java_demangled_signature_length (signature);
808  char *result = xmalloc (length + 1);
809 
810  java_demangled_signature_copy (result, signature);
811  result[length] = '\0';
812  return result;
813 }
814 
815 /* Return the type of TYPE followed by DIMS pairs of [ ].
816  If DIMS == 0, TYPE is returned. */
817 
818 struct type *
819 java_array_type (struct type *type, int dims)
820 {
821  while (dims-- > 0)
822  {
823  /* FIXME This is bogus! Java arrays are not gdb arrays! */
824  type = lookup_array_range_type (type, 0, 0);
825  }
826 
827  return type;
828 }
829 
830 /* Create a Java string in the inferior from a (Utf8) literal. */
831 
832 static struct value *
833 java_value_string (char *ptr, int len)
834 {
835  error (_("not implemented - java_value_string")); /* FIXME */
836 }
837 
838 /* Return the encoding that should be used for the character type
839  TYPE. */
840 
841 static const char *
843 {
844  struct gdbarch *arch = get_type_arch (type);
845  const char *encoding;
846 
847  if (type == builtin_java_type (arch)->builtin_char)
848  {
849  if (gdbarch_byte_order (arch) == BFD_ENDIAN_BIG)
850  encoding = "UTF-16BE";
851  else
852  encoding = "UTF-16LE";
853  }
854  else
855  encoding = target_charset (arch);
856 
857  return encoding;
858 }
859 
860 /* Print the character C on STREAM as part of the contents of a literal
861  string whose delimiter is QUOTER. Note that that format for printing
862  characters and strings is language specific. */
863 
864 static void
865 java_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
866 {
867  const char *encoding = java_get_encoding (type);
868 
869  generic_emit_char (c, type, stream, quoter, encoding);
870 }
871 
872 /* Implementation of la_printchar method. */
873 
874 static void
875 java_printchar (int c, struct type *type, struct ui_file *stream)
876 {
877  fputs_filtered ("'", stream);
878  LA_EMIT_CHAR (c, type, stream, '\'');
879  fputs_filtered ("'", stream);
880 }
881 
882 /* Implementation of la_printstr method. */
883 
884 static void
885 java_printstr (struct ui_file *stream, struct type *type,
886  const gdb_byte *string,
887  unsigned int length, const char *encoding, int force_ellipses,
888  const struct value_print_options *options)
889 {
890  const char *type_encoding = java_get_encoding (type);
891 
892  if (!encoding || !*encoding)
893  encoding = type_encoding;
894 
895  generic_printstr (stream, type, string, length, encoding,
896  force_ellipses, '"', 0, options);
897 }
898 
899 static struct value *
900 evaluate_subexp_java (struct type *expect_type, struct expression *exp,
901  int *pos, enum noside noside)
902 {
903  int pc = *pos;
904  int i;
905  const char *name;
906  enum exp_opcode op = exp->elts[*pos].opcode;
907  struct value *arg1;
908  struct value *arg2;
909  struct type *type;
910 
911  switch (op)
912  {
913  case UNOP_IND:
914  if (noside == EVAL_SKIP)
915  goto standard;
916  (*pos)++;
917  arg1 = evaluate_subexp_java (NULL_TYPE, exp, pos, EVAL_NORMAL);
918  if (is_object_type (value_type (arg1)))
919  {
920  struct type *type;
921 
922  type = type_from_class (exp->gdbarch, java_class_from_object (arg1));
923  arg1 = value_cast (lookup_pointer_type (type), arg1);
924  }
925  return value_ind (arg1);
926 
927  case BINOP_SUBSCRIPT:
928  (*pos)++;
929  arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
930  arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
931  if (noside == EVAL_SKIP)
932  goto nosideret;
933  /* If the user attempts to subscript something that is not an
934  array or pointer type (like a plain int variable for example),
935  then report this as an error. */
936 
937  arg1 = coerce_ref (arg1);
938  type = check_typedef (value_type (arg1));
939  if (TYPE_CODE (type) == TYPE_CODE_PTR)
940  type = check_typedef (TYPE_TARGET_TYPE (type));
941  name = TYPE_NAME (type);
942  if (name == NULL)
943  name = TYPE_TAG_NAME (type);
944  i = name == NULL ? 0 : strlen (name);
945  if (TYPE_CODE (type) == TYPE_CODE_STRUCT
946  && i > 2 && name[i - 1] == ']')
947  {
948  enum bfd_endian byte_order = gdbarch_byte_order (exp->gdbarch);
949  CORE_ADDR address;
950  long length, index;
951  struct type *el_type;
952  gdb_byte buf4[4];
953 
954  struct value *clas = java_class_from_object (arg1);
955  struct value *temp = clas;
956  /* Get CLASS_ELEMENT_TYPE of the array type. */
957  temp = value_struct_elt (&temp, NULL, "methods",
958  NULL, "structure");
959  deprecated_set_value_type (temp, value_type (clas));
960  el_type = type_from_class (exp->gdbarch, temp);
961  if (TYPE_CODE (el_type) == TYPE_CODE_STRUCT)
962  el_type = lookup_pointer_type (el_type);
963 
964  if (noside == EVAL_AVOID_SIDE_EFFECTS)
965  return value_zero (el_type, VALUE_LVAL (arg1));
966  address = value_as_address (arg1);
967  address += get_java_object_header_size (exp->gdbarch);
968  read_memory (address, buf4, 4);
969  length = (long) extract_signed_integer (buf4, 4, byte_order);
970  index = (long) value_as_long (arg2);
971  if (index >= length || index < 0)
972  error (_("array index (%ld) out of bounds (length: %ld)"),
973  index, length);
974  address = (address + 4) + index * TYPE_LENGTH (el_type);
975  return value_at (el_type, address);
976  }
977  else if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
978  {
979  if (noside == EVAL_AVOID_SIDE_EFFECTS)
980  return value_zero (TYPE_TARGET_TYPE (type), VALUE_LVAL (arg1));
981  else
982  return value_subscript (arg1, value_as_long (arg2));
983  }
984  if (name)
985  error (_("cannot subscript something of type `%s'"), name);
986  else
987  error (_("cannot subscript requested type"));
988 
989  case OP_STRING:
990  (*pos)++;
991  i = longest_to_int (exp->elts[pc + 1].longconst);
992  (*pos) += 3 + BYTES_TO_EXP_ELEM (i + 1);
993  if (noside == EVAL_SKIP)
994  goto nosideret;
995  return java_value_string (&exp->elts[pc + 2].string, i);
996 
997  case STRUCTOP_PTR:
998  arg1 = evaluate_subexp_standard (expect_type, exp, pos, noside);
999  /* Convert object field (such as TYPE.class) to reference. */
1000  if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_STRUCT)
1001  arg1 = value_addr (arg1);
1002  return arg1;
1003  default:
1004  break;
1005  }
1006 standard:
1007  return evaluate_subexp_standard (expect_type, exp, pos, noside);
1008 nosideret:
1009  return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
1010 }
1011 
1012 static char *java_demangle (const char *mangled, int options)
1013 {
1014  return gdb_demangle (mangled, options | DMGL_JAVA);
1015 }
1016 
1017 /* Find the member function name of the demangled name NAME. NAME
1018  must be a method name including arguments, in order to correctly
1019  locate the last component.
1020 
1021  This function return a pointer to the first dot before the
1022  member function name, or NULL if the name was not of the
1023  expected form. */
1024 
1025 static const char *
1027 {
1028  const char *p;
1029 
1030  /* Find argument list. */
1031  p = strchr (name, '(');
1032 
1033  if (p == NULL)
1034  return NULL;
1035 
1036  /* Back up and find first dot prior to argument list. */
1037  while (p > name && *p != '.')
1038  p--;
1039 
1040  if (p == name)
1041  return NULL;
1042 
1043  return p;
1044 }
1045 
1046 /* Return the name of the class containing method PHYSNAME. */
1047 
1048 static char *
1049 java_class_name_from_physname (const char *physname)
1050 {
1051  char *ret = NULL;
1052  const char *end;
1053  char *demangled_name = java_demangle (physname, DMGL_PARAMS | DMGL_ANSI);
1054 
1055  if (demangled_name == NULL)
1056  return NULL;
1057 
1058  end = java_find_last_component (demangled_name);
1059  if (end != NULL)
1060  {
1061  ret = xmalloc (end - demangled_name + 1);
1062  memcpy (ret, demangled_name, end - demangled_name);
1063  ret[end - demangled_name] = '\0';
1064  }
1065 
1066  xfree (demangled_name);
1067  return ret;
1068 }
1069 
1070 /* Table mapping opcodes into strings for printing operators
1071  and precedences of the operators. */
1072 
1073 const struct op_print java_op_print_tab[] =
1074 {
1075  {",", BINOP_COMMA, PREC_COMMA, 0},
1076  {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
1077  {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1078  {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1079  {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
1080  {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
1081  {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
1082  {"==", BINOP_EQUAL, PREC_EQUAL, 0},
1083  {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1084  {"<=", BINOP_LEQ, PREC_ORDER, 0},
1085  {">=", BINOP_GEQ, PREC_ORDER, 0},
1086  {">", BINOP_GTR, PREC_ORDER, 0},
1087  {"<", BINOP_LESS, PREC_ORDER, 0},
1088  {">>", BINOP_RSH, PREC_SHIFT, 0},
1089  {"<<", BINOP_LSH, PREC_SHIFT, 0},
1090  {"+", BINOP_ADD, PREC_ADD, 0},
1091  {"-", BINOP_SUB, PREC_ADD, 0},
1092  {"*", BINOP_MUL, PREC_MUL, 0},
1093  {"/", BINOP_DIV, PREC_MUL, 0},
1094  {"%", BINOP_REM, PREC_MUL, 0},
1095  {"-", UNOP_NEG, PREC_PREFIX, 0},
1096  {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1097  {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
1098  {"*", UNOP_IND, PREC_PREFIX, 0},
1099  {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
1100  {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
1101  {NULL, 0, 0, 0}
1102 };
1103 
1105 {
1116 };
1117 
1118 static void
1120  struct language_arch_info *lai)
1121 {
1122  const struct builtin_java_type *builtin = builtin_java_type (gdbarch);
1123 
1124  lai->string_char_type = builtin->builtin_char;
1127  struct type *);
1129  = builtin->builtin_int;
1131  = builtin->builtin_short;
1133  = builtin->builtin_long;
1135  = builtin->builtin_byte;
1137  = builtin->builtin_boolean;
1139  = builtin->builtin_char;
1141  = builtin->builtin_float;
1143  = builtin->builtin_double;
1145  = builtin->builtin_void;
1146 
1147  lai->bool_type_symbol = "boolean";
1148  lai->bool_type_default = builtin->builtin_boolean;
1149 }
1150 
1151 const struct exp_descriptor exp_descriptor_java =
1152 {
1159 };
1160 
1161 const struct language_defn java_language_defn =
1162 {
1163  "java", /* Language name */
1164  "Java",
1165  language_java,
1171  java_parse,
1172  java_error,
1174  java_printchar, /* Print a character constant */
1175  java_printstr, /* Function to print string constant */
1176  java_emit_char, /* Function to print a single character */
1177  java_print_type, /* Print a type using appropriate syntax */
1178  default_print_typedef, /* Print a typedef using appropriate syntax */
1179  java_val_print, /* Print a value using appropriate syntax */
1180  java_value_print, /* Print a top-level value */
1181  default_read_var_value, /* la_read_var_value */
1182  NULL, /* Language specific skip_trampoline */
1183  "this", /* name_of_this */
1184  basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
1185  basic_lookup_transparent_type,/* lookup_transparent_type */
1186  java_demangle, /* Language specific symbol demangler */
1187  java_class_name_from_physname,/* Language specific class name */
1188  java_op_print_tab, /* expression operators for printing */
1189  0, /* not c-style arrays */
1190  0, /* String lower bound */
1192  default_make_symbol_completion_list,
1197  NULL, /* la_get_symbol_name_cmp */
1199  &java_varobj_ops,
1200  NULL,
1201  NULL,
1202  LANG_MAGIC
1203 };
1204 
1205 static void *
1207 {
1209  = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_java_type);
1210 
1211  builtin_java_type->builtin_int
1212  = arch_integer_type (gdbarch, 32, 0, "int");
1213  builtin_java_type->builtin_short
1214  = arch_integer_type (gdbarch, 16, 0, "short");
1215  builtin_java_type->builtin_long
1216  = arch_integer_type (gdbarch, 64, 0, "long");
1217  builtin_java_type->builtin_byte
1218  = arch_integer_type (gdbarch, 8, 0, "byte");
1219  builtin_java_type->builtin_boolean
1220  = arch_boolean_type (gdbarch, 8, 0, "boolean");
1221  builtin_java_type->builtin_char
1222  = arch_character_type (gdbarch, 16, 1, "char");
1223  builtin_java_type->builtin_float
1224  = arch_float_type (gdbarch, 32, "float", NULL);
1225  builtin_java_type->builtin_double
1226  = arch_float_type (gdbarch, 64, "double", NULL);
1227  builtin_java_type->builtin_void
1228  = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
1229 
1230  return builtin_java_type;
1231 }
1232 
1234 
1235 const struct builtin_java_type *
1237 {
1238  return gdbarch_data (gdbarch, java_type_data);
1239 }
1240 
1241 void
1243 {
1245  = register_objfile_data_with_cleanup (NULL, jv_per_objfile_free);
1246  jv_dynamics_progspace_key = register_program_space_data ();
1247 
1249 
1250  add_language (&java_language_defn);
1251 }
struct value * value_zero(struct type *type, enum lval_type lv)
Definition: valops.c:842
union exp_element elts[1]
Definition: expression.h:85
const char * target_charset(struct gdbarch *gdbarch)
Definition: charset.c:407
static struct symbol * add_class_symbol(struct type *type, CORE_ADDR addr)
Definition: jv-lang.c:184
#define OBJF_SHARED
Definition: objfiles.h:432
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
Definition: gdbtypes.c:1128
#define B_TYPE
Definition: gdbtypes.h:78
static void java_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
Definition: jv-lang.c:1119
struct value * value_addr(struct value *arg1)
Definition: valops.c:1472
struct type * builtin_void
Definition: jv-lang.h:41
struct type * builtin_short
Definition: jv-lang.h:35
enum exp_opcode opcode
Definition: expression.h:65
struct value * value_subscript(struct value *array, LONGEST index)
Definition: valarith.c:146
#define TYPE_FIELD_PRIVATE_BITS(thistype)
Definition: gdbtypes.h:1380
struct type * java_primitive_type_from_name(struct gdbarch *gdbarch, const char *name, int namelen)
Definition: jv-lang.c:666
bfd_vma CORE_ADDR
Definition: common-types.h:41
noside
Definition: expression.h:122
static struct type * java_link_class_type(struct gdbarch *, struct type *, struct value *)
Definition: jv-lang.c:337
struct fn_field * fn_fields
Definition: gdbtypes.h:831
void dict_free(struct dictionary *dict)
Definition: dictionary.c:487
#define TYPE_FIELD_NAME(thistype, n)
Definition: gdbtypes.h:1369
#define TYPE_N_BASECLASSES(thistype)
Definition: gdbtypes.h:1327
static struct value * java_value_string(char *ptr, int len)
Definition: jv-lang.c:833
struct type * java_array_type(struct type *type, int dims)
Definition: jv-lang.c:819
void xfree(void *)
Definition: common-utils.c:97
#define TYPE_NFN_FIELDS(thistype)
Definition: gdbtypes.h:1307
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, char *name)
Definition: gdbtypes.c:4588
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE)
Definition: gdbarch.h:1614
struct type * builtin_boolean
Definition: jv-lang.h:37
LONGEST value_as_long(struct value *val)
Definition: value.c:2654
void java_val_print(struct type *, const gdb_byte *, int, CORE_ADDR, struct ui_file *, int, const struct value *, const struct value_print_options *)
Definition: jv-valprint.c:455
static struct gdbarch_data * java_type_data
Definition: jv-lang.c:1233
struct value * evaluate_subexp_with_coercion(struct expression *exp, int *pos, enum noside noside)
Definition: eval.c:2958
#define TYPE_NAME(thistype)
Definition: gdbtypes.h:1227
#define INIT_CPLUS_SPECIFIC(type)
Definition: gdbtypes.h:1195
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1690
struct value * value_at(struct type *type, CORE_ADDR addr)
Definition: valops.c:940
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, char *name, const struct floatformat **floatformats)
Definition: gdbtypes.c:4606
static void java_demangled_signature_copy(char *, const char *)
Definition: jv-lang.c:762
void * gdbarch_data(struct gdbarch *gdbarch, struct gdbarch_data *data)
Definition: gdbarch.c:4845
struct compunit_symtab * allocate_compunit_symtab(struct objfile *objfile, const char *name)
Definition: symfile.c:2954
#define TYPE_FIELD_VIRTUAL_BITS(thistype)
Definition: gdbtypes.h:1386
#define SYMBOL_SET_LINKAGE_NAME(symbol, linkage_name)
Definition: symtab.h:207
const struct builtin_java_type * builtin_java_type(struct gdbarch *gdbarch)
Definition: jv-lang.c:1236
static int java_class_is_primitive(struct value *clas)
Definition: jv-lang.c:250
#define TYPE_FIELD_PROTECTED_BITS(thistype)
Definition: gdbtypes.h:1382
struct value * default_read_var_value(struct symbol *var, struct frame_info *frame)
Definition: findvar.c:416
struct value * coerce_ref(struct value *arg)
Definition: value.c:3688
static struct value * evaluate_subexp_java(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
Definition: jv-lang.c:900
struct gdbarch * symbol_arch(const struct symbol *symbol)
Definition: symtab.c:6240
void set_value_lazy(struct value *value, int val)
Definition: value.c:1311
struct value * value_ind(struct value *arg1)
Definition: valops.c:1533
#define SET_FIELD_PHYSADDR(thisfld, addr)
Definition: gdbtypes.h:1358
#define BLOCKVECTOR_BLOCK(blocklist, n)
Definition: block.h:136
#define OBJF_NOT_FILENAME
Definition: objfiles.h:460
static struct objfile * get_dynamics_objfile(struct gdbarch *gdbarch)
Definition: jv-lang.c:105
void default_print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream)
Definition: typeprint.c:346
#define _(String)
Definition: gdb_locale.h:40
#define TYPE_FIELD_IGNORE_BITS(thistype)
Definition: gdbtypes.h:1384
struct type * string_char_type
Definition: language.h:120
void java_print_type(struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *)
Definition: jv-typeprint.c:335
#define SET_FIELD_BITPOS(thisfld, bitpos)
Definition: gdbtypes.h:1349
#define TYPE_FIELD(thistype, n)
Definition: gdbtypes.h:1367
#define BYTES_TO_EXP_ELEM(bytes)
Definition: expression.h:93
#define TYPE_FIELD_TYPE(thistype, n)
Definition: gdbtypes.h:1368
#define VALUE_LVAL(val)
Definition: value.h:411
struct objfile_per_bfd_storage * per_bfd
Definition: objfiles.h:318
void add_language(const struct language_defn *lang)
Definition: language.c:518
struct type * type_from_class(struct gdbarch *gdbarch, struct value *clas)
Definition: jv-lang.c:262
int longest_to_int(LONGEST)
Definition: valprint.c:1054
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE)
Definition: gdbarch.h:1615
static const struct objfile_data * jv_dynamics_objfile_data_key
Definition: jv-lang.c:58
void deprecated_set_value_type(struct value *value, struct type *type)
Definition: value.c:1026
void set_value_address(struct value *value, CORE_ADDR addr)
Definition: value.c:1463
struct type * arch_character_type(struct gdbarch *gdbarch, int bit, int unsigned_p, char *name)
Definition: gdbtypes.c:4571
struct obstack objfile_obstack
Definition: objfiles.h:328
static void add_class_symtab_symbol(struct symbol *sym)
Definition: jv-lang.c:175
const char *const name
Definition: aarch64-tdep.c:68
char * gdb_demangle(const char *name, int options)
Definition: cp-support.c:1529
static const struct program_space_data * jv_dynamics_progspace_key
Definition: jv-lang.c:63
char * default_word_break_characters(void)
Definition: language.c:669
struct value * value_struct_elt(struct value **argp, struct value **args, const char *name, int *static_memfuncp, const char *err)
Definition: valops.c:2128
#define LA_EMIT_CHAR(ch, type, stream, quoter)
Definition: language.h:499
static void * build_java_types(struct gdbarch *gdbarch)
Definition: jv-lang.c:1206
#define SYMBOL_ACLASS_INDEX(symbol)
Definition: symtab.h:792
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2217
#define SYMBOL_VALUE_ADDRESS(symbol)
Definition: symtab.h:182
void generic_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, int quote_char, int c_style_terminator, const struct value_print_options *options)
Definition: valprint.c:2380
struct type * bool_type_default
Definition: language.h:125
void null_post_parser(struct expression **exp, int void_context_p)
Definition: parse.c:1358
#define SYMBOL_DOMAIN(symbol)
Definition: symtab.h:790
#define SYMBOL_SET_LANGUAGE(symbol, language, obstack)
Definition: symtab.h:196
static void java_emit_char(int c, struct type *type, struct ui_file *stream, int quoter)
Definition: jv-lang.c:865
static char * get_java_utf8_name(struct obstack *obstack, struct value *name)
Definition: jv-lang.c:216
static void jv_per_objfile_free(struct objfile *objfile, void *data)
Definition: jv-lang.c:80
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
Definition: utils.c:2145
const char * bool_type_symbol
Definition: language.h:123
#define ALLOCATE_CPLUS_STRUCT_TYPE(type)
Definition: gdbtypes.h:1200
const char * name
Definition: gdbtypes.h:823
int default_pass_by_reference(struct type *type)
Definition: language.c:659
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
Definition: gdbarch.c:1420
static char * java_demangle(const char *mangled, int options)
Definition: jv-lang.c:1012
struct type * basic_lookup_transparent_type(const char *name)
Definition: symtab.c:2851
#define TARGET_CHAR_BIT
Definition: host-defs.h:29
#define B_BYTES(x)
Definition: gdbtypes.h:79
void add_compunit_symtab_to_objfile(struct compunit_symtab *cu)
Definition: symfile.c:2985
Definition: gdbtypes.h:749
struct dictionary * dict_create_linear(struct obstack *obstack, const struct pending *symbol_list)
Definition: dictionary.c:420
const struct lang_varobj_ops java_varobj_ops
Definition: jv-varobj.c:95
static int java_demangled_signature_length(const char *)
Definition: jv-lang.c:742
#define SET_TYPE_FIELD_PRIVATE(thistype, n)
Definition: gdbtypes.h:1388
char string
Definition: expression.h:72
struct gdbarch * get_type_arch(const struct type *type)
Definition: gdbtypes.c:232
struct type * alloc_type(struct objfile *objfile)
Definition: gdbtypes.c:165
static const char * type
Definition: language.c:103
int dump_subexp_body_standard(struct expression *exp, struct ui_file *stream, int elt)
Definition: expprint.c:762
#define gdb_assert(expr)
Definition: gdb_assert.h:33
struct value * value_from_longest(struct type *type, LONGEST num)
Definition: value.c:3464
void iterate_over_symbols(const struct block *block, const char *name, const domain_enum domain, symbol_found_callback_ftype *callback, void *data)
Definition: symtab.c:2912
struct compunit_symtab * compunit_symtabs
Definition: objfiles.h:291
struct value * value_cast(struct type *type, struct value *arg2)
Definition: valops.c:351
#define B_CLRALL(a, x)
Definition: gdbtypes.h:80
static const char * java_find_last_component(const char *name)
Definition: jv-lang.c:1026
void default_print_array_index(struct value *index_value, struct ui_file *stream, const struct value_print_options *options)
Definition: language.c:677
struct type * java_primitive_type(struct gdbarch *gdbarch, int signature)
Definition: jv-lang.c:634
struct block * allocate_block(struct obstack *obstack)
Definition: block.c:401
#define TYPE_BASECLASS(thistype, index)
Definition: gdbtypes.h:1326
#define BLOCK_DICT(bl)
Definition: block.h:120
struct value * java_class_from_object(struct value *obj_val)
Definition: jv-lang.c:233
#define NULL_TYPE
Definition: gdbtypes.h:814
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, char *name)
Definition: gdbtypes.c:4552
int get_java_object_header_size(struct gdbarch *gdbarch)
Definition: jv-lang.c:600
#define TYPE_FIELDS(thistype)
Definition: gdbtypes.h:1242
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
Definition: corefile.c:244
char * op_name_standard(enum exp_opcode opcode)
Definition: expprint.c:662
static char * java_class_name_from_physname(const char *physname)
Definition: jv-lang.c:1049
static char encoding[]
Definition: remote-mips.c:2988
union dictionary::@50 data
void * xmalloc(YYSIZE_T)
static char * java_primitive_type_name(int signature)
Definition: jv-lang.c:712
struct type * builtin_float
Definition: jv-lang.h:39
struct type * builtin_double
Definition: jv-lang.h:40
char * java_demangle_type_signature(const char *signature)
Definition: jv-lang.c:805
Definition: block.h:60
Definition: value.c:172
struct type * builtin_int
Definition: jv-lang.h:33
#define COMPUNIT_BLOCKVECTOR(cust)
Definition: symtab.h:1099
const char const char int
Definition: command.h:229
bfd_byte gdb_byte
Definition: common-types.h:38
unsigned length
Definition: gdbtypes.h:807
#define TYPE_TARGET_TYPE(thistype)
Definition: gdbtypes.h:1229
const char * physname
Definition: gdbtypes.h:848
struct symbol * allocate_symbol(struct objfile *objfile)
Definition: symtab.c:6204
void java_error(char *)
void print_subexp_standard(struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec)
Definition: expprint.c:58
void default_get_string(struct value *value, gdb_byte **buffer, int *length, struct type **char_type, const char **charset)
Definition: language.c:686
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1240
static struct compunit_symtab * get_java_class_symtab(struct gdbarch *gdbarch)
Definition: jv-lang.c:133
struct type * java_lookup_class(char *name)
Definition: jv-lang.c:201
void dict_add_symbol(struct dictionary *dict, struct symbol *sym)
Definition: dictionary.c:495
struct gdbarch * gdbarch
Definition: objfiles.h:191
int operator_check_standard(struct expression *exp, int pos, int(*objfile_func)(struct objfile *objfile, void *data), void *data)
Definition: parse.c:1782
struct symbol * lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1967
const struct exp_descriptor exp_descriptor_java
Definition: jv-lang.c:1151
struct dictionary * dict_create_hashed_expandable(void)
Definition: dictionary.c:400
const struct op_print java_op_print_tab[]
Definition: jv-lang.c:1073
struct symtab * allocate_symtab(struct compunit_symtab *cust, const char *filename)
Definition: symfile.c:2898
#define TYPE_NFIELDS(thistype)
Definition: gdbtypes.h:1241
void generic_emit_char(int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding)
Definition: valprint.c:2051
static void java_printchar(int c, struct type *type, struct ui_file *stream)
Definition: jv-lang.c:875
static void java_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options)
Definition: jv-lang.c:885
exp_opcode
Definition: expression.h:43
#define COMPUNIT_FILETABS(cust)
Definition: symtab.h:1095
struct type * builtin_byte
Definition: jv-lang.h:34
#define CHECK_TYPEDEF(TYPE)
Definition: gdbtypes.h:1817
void java_value_print(struct value *, struct ui_file *, const struct value_print_options *)
Definition: jv-valprint.c:35
#define BLOCKVECTOR_NBLOCKS(blocklist)
Definition: block.h:135
int value_logical_not(struct value *arg1)
Definition: valarith.c:1513
#define SET_TYPE_FIELD_PROTECTED(thistype, n)
Definition: gdbtypes.h:1390
struct value * evaluate_subexp_standard(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
Definition: eval.c:699
struct objfile * allocate_objfile(bfd *abfd, const char *name, int flags)
Definition: objfiles.c:285
#define TYPE_TAG_NAME(type)
Definition: gdbtypes.h:1228
LONGEST longconst
Definition: expression.h:67
int is_object_type(struct type *type)
Definition: jv-lang.c:611
void operator_length_standard(const struct expression *expr, int endpos, int *oplenp, int *argsp)
Definition: parse.c:859
void set_block_compunit_symtab(struct block *block, struct compunit_symtab *cu)
Definition: block.c:421
const struct block * expression_context_block
Definition: parse.c:67
struct program_space * current_program_space
Definition: progspace.c:35
static const char * java_get_encoding(struct type *type)
Definition: jv-lang.c:842
struct type * builtin_char
Definition: jv-lang.h:38
struct gdbarch * gdbarch
Definition: expression.h:83
struct symbol * basic_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
Definition: symtab.c:2481
struct type * value_type(const struct value *value)
Definition: value.c:1021
#define TYPE_ALLOC(t, size)
Definition: gdbtypes.h:1631
#define SYMBOL_TYPE(symbol)
Definition: symtab.h:799
Definition: symtab.h:703
CORE_ADDR value_as_address(struct value *val)
Definition: value.c:2679
#define TYPE_FN_FIELDLISTS(thistype)
Definition: gdbtypes.h:1409
java_primitive_types
Definition: jv-lang.c:1104
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1237
struct type * builtin_long
Definition: jv-lang.h:36
struct block * allocate_global_block(struct obstack *obstack)
Definition: block.c:411
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int length, char *name)
Definition: gdbtypes.c:4532
struct type * type
Definition: gdbtypes.h:856
#define LANG_MAGIC
Definition: language.h:402
LONGEST extract_signed_integer(const gdb_byte *, int, enum bfd_endian)
Definition: findvar.c:49
CORE_ADDR value_address(const struct value *value)
Definition: value.c:1440
struct type ** primitive_type_vector
Definition: language.h:113
void _initialize_java_language(void)
Definition: jv-lang.c:1242
void error(const char *fmt,...)
Definition: errors.c:38
struct gdbarch_data * gdbarch_data_register_post_init(gdbarch_data_post_init_ftype *post_init)
Definition: gdbarch.c:4812
unsigned int is_stub
Definition: gdbtypes.h:880
struct dictionary * dict
Definition: jv-lang.c:74
struct type * lookup_pointer_type(struct type *type)
Definition: gdbtypes.c:368
int java_parse(struct parser_state *par_state)
Definition: jv-exp.c:2872
struct type * lookup_function_type(struct type *type)
Definition: gdbtypes.c:482
struct type * builtin_int
Definition: gdbtypes.h:1483
const ULONGEST const LONGEST len
Definition: target.h:309
struct type * get_java_object_type(void)
Definition: jv-lang.c:589