Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: gdb/jv-lang.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gdb/jv-lang.h ('k') | gdb/jv-typeprint.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Java language support routines for GDB, the GNU debugger. 1 /* Java language support routines for GDB, the GNU debugger.
2 2
3 Copyright (C) 1997-2000, 2003-2005, 2007-2012 Free Software 3 Copyright (C) 1997-2000, 2003-2005, 2007-2012 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 5
6 This file is part of GDB. 6 This file is part of GDB.
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or 10 the Free Software Foundation; either version 3 of the License, or
(...skipping 27 matching lines...) Expand all
38 #include "dictionary.h" 38 #include "dictionary.h"
39 #include <ctype.h> 39 #include <ctype.h>
40 #include "gdb_assert.h" 40 #include "gdb_assert.h"
41 #include "charset.h" 41 #include "charset.h"
42 #include "valprint.h" 42 #include "valprint.h"
43 43
44 /* Local functions */ 44 /* Local functions */
45 45
46 extern void _initialize_java_language (void); 46 extern void _initialize_java_language (void);
47 47
48 static int java_demangled_signature_length (char *); 48 static int java_demangled_signature_length (const char *);
49 static void java_demangled_signature_copy (char *, char *); 49 static void java_demangled_signature_copy (char *, const char *);
50 50
51 static struct symtab *get_java_class_symtab (struct gdbarch *gdbarch); 51 static struct symtab *get_java_class_symtab (struct gdbarch *gdbarch);
52 static char *get_java_utf8_name (struct obstack *obstack, struct value *name); 52 static char *get_java_utf8_name (struct obstack *obstack, struct value *name);
53 static int java_class_is_primitive (struct value *clas); 53 static int java_class_is_primitive (struct value *clas);
54 static struct value *java_value_string (char *ptr, int len); 54 static struct value *java_value_string (char *ptr, int len);
55 55
56 static void java_emit_char (int c, struct type *type, 56 static void java_emit_char (int c, struct type *type,
57 struct ui_file * stream, int quoter); 57 struct ui_file * stream, int quoter);
58 58
59 static char *java_class_name_from_physname (const char *physname); 59 static char *java_class_name_from_physname (const char *physname);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 BLOCKVECTOR_NBLOCKS (bv) = 1; 151 BLOCKVECTOR_NBLOCKS (bv) = 1;
152 BLOCKVECTOR (class_symtab) = bv; 152 BLOCKVECTOR (class_symtab) = bv;
153 153
154 /* Allocate dummy STATIC_BLOCK. */ 154 /* Allocate dummy STATIC_BLOCK. */
155 bl = allocate_block (&objfile->objfile_obstack); 155 bl = allocate_block (&objfile->objfile_obstack);
156 BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack, 156 BLOCK_DICT (bl) = dict_create_linear (&objfile->objfile_obstack,
157 NULL); 157 NULL);
158 BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl; 158 BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK) = bl;
159 159
160 /* Allocate GLOBAL_BLOCK. */ 160 /* Allocate GLOBAL_BLOCK. */
161 bl = allocate_block (&objfile->objfile_obstack); 161 bl = allocate_global_block (&objfile->objfile_obstack);
162 BLOCK_DICT (bl) = dict_create_hashed_expandable (); 162 BLOCK_DICT (bl) = dict_create_hashed_expandable ();
163 set_block_symtab (bl, class_symtab);
163 BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl; 164 BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK) = bl;
164 165
165 /* Arrange to free the dict. */ 166 /* Arrange to free the dict. */
166 jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key); 167 jv_data = objfile_data (objfile, jv_dynamics_objfile_data_key);
167 jv_data->dict = BLOCK_DICT (bl); 168 jv_data->dict = BLOCK_DICT (bl);
168 } 169 }
169 return class_symtab; 170 return class_symtab;
170 } 171 }
171 172
172 static void 173 static void
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return java_link_class_type (gdbarch, type, clas); 335 return java_link_class_type (gdbarch, type, clas);
335 } 336 }
336 337
337 /* Fill in class TYPE with data from the CLAS value. */ 338 /* Fill in class TYPE with data from the CLAS value. */
338 339
339 static struct type * 340 static struct type *
340 java_link_class_type (struct gdbarch *gdbarch, 341 java_link_class_type (struct gdbarch *gdbarch,
341 struct type *type, struct value *clas) 342 struct type *type, struct value *clas)
342 { 343 {
343 struct value *temp; 344 struct value *temp;
344 char *unqualified_name; 345 const char *unqualified_name;
345 char *name = TYPE_TAG_NAME (type); 346 const char *name = TYPE_TAG_NAME (type);
346 int ninterfaces, nfields, nmethods; 347 int ninterfaces, nfields, nmethods;
347 int type_is_object = 0; 348 int type_is_object = 0;
348 struct fn_field *fn_fields; 349 struct fn_field *fn_fields;
349 struct fn_fieldlist *fn_fieldlists; 350 struct fn_fieldlist *fn_fieldlists;
350 struct value *fields; 351 struct value *fields;
351 struct value *methods; 352 struct value *methods;
352 struct value *method = NULL; 353 struct value *method = NULL;
353 struct value *field = NULL; 354 struct value *field = NULL;
354 int i, j; 355 int i, j;
355 struct objfile *objfile = get_dynamics_objfile (gdbarch); 356 struct objfile *objfile = get_dynamics_objfile (gdbarch);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 { 474 {
474 SET_TYPE_FIELD_PRIVATE (type, i); 475 SET_TYPE_FIELD_PRIVATE (type, i);
475 } 476 }
476 if (accflags & 0x0004) /* protected access */ 477 if (accflags & 0x0004) /* protected access */
477 { 478 {
478 SET_TYPE_FIELD_PROTECTED (type, i); 479 SET_TYPE_FIELD_PROTECTED (type, i);
479 } 480 }
480 if (accflags & 0x0008) /* ACC_STATIC */ 481 if (accflags & 0x0008) /* ACC_STATIC */
481 SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset); 482 SET_FIELD_PHYSADDR (TYPE_FIELD (type, i), boffset);
482 else 483 else
483 » TYPE_FIELD_BITPOS (type, i) = 8 * boffset; 484 » SET_FIELD_BITPOS (TYPE_FIELD (type, i), 8 * boffset);
484 if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */ 485 if (accflags & 0x8000) /* FIELD_UNRESOLVED_FLAG */
485 { 486 {
486 TYPE_FIELD_TYPE (type, i) = get_java_object_type (); /* FIXME */ 487 TYPE_FIELD_TYPE (type, i) = get_java_object_type (); /* FIXME */
487 } 488 }
488 else 489 else
489 { 490 {
490 struct type *ftype; 491 struct type *ftype;
491 492
492 temp = field; 493 temp = field;
493 temp = value_struct_elt (&temp, NULL, "type", NULL, "structure"); 494 temp = value_struct_elt (&temp, NULL, "type", NULL, "structure");
494 ftype = type_from_class (gdbarch, temp); 495 ftype = type_from_class (gdbarch, temp);
495 if (TYPE_CODE (ftype) == TYPE_CODE_STRUCT) 496 if (TYPE_CODE (ftype) == TYPE_CODE_STRUCT)
496 ftype = lookup_pointer_type (ftype); 497 ftype = lookup_pointer_type (ftype);
497 TYPE_FIELD_TYPE (type, i) = ftype; 498 TYPE_FIELD_TYPE (type, i) = ftype;
498 } 499 }
499 } 500 }
500 501
501 temp = clas; 502 temp = clas;
502 nmethods = value_as_long (value_struct_elt (&temp, NULL, "method_count", 503 nmethods = value_as_long (value_struct_elt (&temp, NULL, "method_count",
503 NULL, "structure")); 504 NULL, "structure"));
504 TYPE_NFN_FIELDS_TOTAL (type) = nmethods;
505 j = nmethods * sizeof (struct fn_field); 505 j = nmethods * sizeof (struct fn_field);
506 fn_fields = (struct fn_field *) 506 fn_fields = (struct fn_field *)
507 obstack_alloc (&objfile->objfile_obstack, j); 507 obstack_alloc (&objfile->objfile_obstack, j);
508 memset (fn_fields, 0, j); 508 memset (fn_fields, 0, j);
509 fn_fieldlists = (struct fn_fieldlist *) 509 fn_fieldlists = (struct fn_fieldlist *)
510 alloca (nmethods * sizeof (struct fn_fieldlist)); 510 alloca (nmethods * sizeof (struct fn_fieldlist));
511 511
512 methods = NULL; 512 methods = NULL;
513 for (i = 0; i < nmethods; i++) 513 for (i = 0; i < nmethods; i++)
514 { 514 {
515 char *mname; 515 const char *mname;
516 int k; 516 int k;
517 517
518 if (methods == NULL) 518 if (methods == NULL)
519 { 519 {
520 temp = clas; 520 temp = clas;
521 methods = value_struct_elt (&temp, NULL, "methods", 521 methods = value_struct_elt (&temp, NULL, "methods",
522 NULL, "structure"); 522 NULL, "structure");
523 method = value_ind (methods); 523 method = value_ind (methods);
524 } 524 }
525 else 525 else
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 return TYPE_LENGTH (objtype); 611 return TYPE_LENGTH (objtype);
612 } 612 }
613 613
614 int 614 int
615 is_object_type (struct type *type) 615 is_object_type (struct type *type)
616 { 616 {
617 CHECK_TYPEDEF (type); 617 CHECK_TYPEDEF (type);
618 if (TYPE_CODE (type) == TYPE_CODE_PTR) 618 if (TYPE_CODE (type) == TYPE_CODE_PTR)
619 { 619 {
620 struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type)); 620 struct type *ttype = check_typedef (TYPE_TARGET_TYPE (type));
621 char *name; 621 const char *name;
622 if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT) 622 if (TYPE_CODE (ttype) != TYPE_CODE_STRUCT)
623 return 0; 623 return 0;
624 while (TYPE_N_BASECLASSES (ttype) > 0) 624 while (TYPE_N_BASECLASSES (ttype) > 0)
625 ttype = TYPE_BASECLASS (ttype, 0); 625 ttype = TYPE_BASECLASS (ttype, 0);
626 name = TYPE_TAG_NAME (ttype); 626 name = TYPE_TAG_NAME (ttype);
627 if (name != NULL && strcmp (name, "java.lang.Object") == 0) 627 if (name != NULL && strcmp (name, "java.lang.Object") == 0)
628 return 1; 628 return 1;
629 name 629 name
630 = TYPE_NFIELDS (ttype) > 0 ? TYPE_FIELD_NAME (ttype, 0) : (char *) 0; 630 = TYPE_NFIELDS (ttype) > 0 ? TYPE_FIELD_NAME (ttype, 0) : (char *) 0;
631 if (name != NULL && strcmp (name, "vtable") == 0) 631 if (name != NULL && strcmp (name, "vtable") == 0)
(...skipping 29 matching lines...) Expand all
661 return builtin->builtin_void; 661 return builtin->builtin_void;
662 } 662 }
663 error (_("unknown signature '%c' for primitive type"), (char) signature); 663 error (_("unknown signature '%c' for primitive type"), (char) signature);
664 } 664 }
665 665
666 /* If name[0 .. namelen-1] is the name of a primitive Java type, 666 /* If name[0 .. namelen-1] is the name of a primitive Java type,
667 return that type. Otherwise, return NULL. */ 667 return that type. Otherwise, return NULL. */
668 668
669 struct type * 669 struct type *
670 java_primitive_type_from_name (struct gdbarch *gdbarch, 670 java_primitive_type_from_name (struct gdbarch *gdbarch,
671 » » » char *name, int namelen) 671 » » » const char *name, int namelen)
672 { 672 {
673 const struct builtin_java_type *builtin = builtin_java_type (gdbarch); 673 const struct builtin_java_type *builtin = builtin_java_type (gdbarch);
674 674
675 switch (name[0]) 675 switch (name[0])
676 { 676 {
677 case 'b': 677 case 'b':
678 if (namelen == 4 && memcmp (name, "byte", 4) == 0) 678 if (namelen == 4 && memcmp (name, "byte", 4) == 0)
679 return builtin->builtin_byte; 679 return builtin->builtin_byte;
680 if (namelen == 7 && memcmp (name, "boolean", 7) == 0) 680 if (namelen == 7 && memcmp (name, "boolean", 7) == 0)
681 return builtin->builtin_boolean; 681 return builtin->builtin_boolean;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 case 'V': 736 case 'V':
737 return "void"; 737 return "void";
738 } 738 }
739 error (_("unknown signature '%c' for primitive type"), (char) signature); 739 error (_("unknown signature '%c' for primitive type"), (char) signature);
740 } 740 }
741 741
742 /* Return the length (in bytes) of demangled name of the Java type 742 /* Return the length (in bytes) of demangled name of the Java type
743 signature string SIGNATURE. */ 743 signature string SIGNATURE. */
744 744
745 static int 745 static int
746 java_demangled_signature_length (char *signature) 746 java_demangled_signature_length (const char *signature)
747 { 747 {
748 int array = 0; 748 int array = 0;
749 749
750 for (; *signature == '['; signature++) 750 for (; *signature == '['; signature++)
751 array += 2; /* Two chars for "[]". */ 751 array += 2; /* Two chars for "[]". */
752 switch (signature[0]) 752 switch (signature[0])
753 { 753 {
754 case 'L': 754 case 'L':
755 /* Subtract 2 for 'L' and ';'. */ 755 /* Subtract 2 for 'L' and ';'. */
756 return strlen (signature) - 2 + array; 756 return strlen (signature) - 2 + array;
757 default: 757 default:
758 return strlen (java_primitive_type_name (signature[0])) + array; 758 return strlen (java_primitive_type_name (signature[0])) + array;
759 } 759 }
760 } 760 }
761 761
762 /* Demangle the Java type signature SIGNATURE, leaving the result in 762 /* Demangle the Java type signature SIGNATURE, leaving the result in
763 RESULT. */ 763 RESULT. */
764 764
765 static void 765 static void
766 java_demangled_signature_copy (char *result, char *signature) 766 java_demangled_signature_copy (char *result, const char *signature)
767 { 767 {
768 int array = 0; 768 int array = 0;
769 char *ptr; 769 char *ptr;
770 int i; 770 int i;
771 771
772 while (*signature == '[') 772 while (*signature == '[')
773 { 773 {
774 array++; 774 array++;
775 signature++; 775 signature++;
776 } 776 }
(...skipping 22 matching lines...) Expand all
799 { 799 {
800 *ptr++ = '['; 800 *ptr++ = '[';
801 *ptr++ = ']'; 801 *ptr++ = ']';
802 } 802 }
803 } 803 }
804 804
805 /* Return the demangled name of the Java type signature string SIGNATURE, 805 /* Return the demangled name of the Java type signature string SIGNATURE,
806 as a freshly allocated copy. */ 806 as a freshly allocated copy. */
807 807
808 char * 808 char *
809 java_demangle_type_signature (char *signature) 809 java_demangle_type_signature (const char *signature)
810 { 810 {
811 int length = java_demangled_signature_length (signature); 811 int length = java_demangled_signature_length (signature);
812 char *result = xmalloc (length + 1); 812 char *result = xmalloc (length + 1);
813 813
814 java_demangled_signature_copy (result, signature); 814 java_demangled_signature_copy (result, signature);
815 result[length] = '\0'; 815 result[length] = '\0';
816 return result; 816 return result;
817 } 817 }
818 818
819 /* Return the type of TYPE followed by DIMS pairs of [ ]. 819 /* Return the type of TYPE followed by DIMS pairs of [ ].
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 generic_printstr (stream, type, string, length, encoding, 899 generic_printstr (stream, type, string, length, encoding,
900 force_ellipses, '"', 0, options); 900 force_ellipses, '"', 0, options);
901 } 901 }
902 902
903 static struct value * 903 static struct value *
904 evaluate_subexp_java (struct type *expect_type, struct expression *exp, 904 evaluate_subexp_java (struct type *expect_type, struct expression *exp,
905 int *pos, enum noside noside) 905 int *pos, enum noside noside)
906 { 906 {
907 int pc = *pos; 907 int pc = *pos;
908 int i; 908 int i;
909 char *name; 909 const char *name;
910 enum exp_opcode op = exp->elts[*pos].opcode; 910 enum exp_opcode op = exp->elts[*pos].opcode;
911 struct value *arg1; 911 struct value *arg1;
912 struct value *arg2; 912 struct value *arg2;
913 struct type *type; 913 struct type *type;
914 914
915 switch (op) 915 switch (op)
916 { 916 {
917 case UNOP_IND: 917 case UNOP_IND:
918 if (noside == EVAL_SKIP) 918 if (noside == EVAL_SKIP)
919 goto standard; 919 goto standard;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 java_parse, 1175 java_parse,
1176 java_error, 1176 java_error,
1177 null_post_parser, 1177 null_post_parser,
1178 java_printchar, /* Print a character constant */ 1178 java_printchar, /* Print a character constant */
1179 java_printstr, /* Function to print string constant */ 1179 java_printstr, /* Function to print string constant */
1180 java_emit_char, /* Function to print a single character */ 1180 java_emit_char, /* Function to print a single character */
1181 java_print_type, /* Print a type using appropriate syntax */ 1181 java_print_type, /* Print a type using appropriate syntax */
1182 default_print_typedef, /* Print a typedef using appropriate syntax */ 1182 default_print_typedef, /* Print a typedef using appropriate syntax */
1183 java_val_print, /* Print a value using appropriate syntax */ 1183 java_val_print, /* Print a value using appropriate syntax */
1184 java_value_print, /* Print a top-level value */ 1184 java_value_print, /* Print a top-level value */
1185 default_read_var_value, /* la_read_var_value */
1185 NULL, /* Language specific skip_trampoline */ 1186 NULL, /* Language specific skip_trampoline */
1186 "this", /* name_of_this */ 1187 "this", /* name_of_this */
1187 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ 1188 basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
1188 basic_lookup_transparent_type,/* lookup_transparent_type */ 1189 basic_lookup_transparent_type,/* lookup_transparent_type */
1189 java_demangle, /* Language specific symbol demangler */ 1190 java_demangle, /* Language specific symbol demangler */
1190 java_class_name_from_physname,/* Language specific class name */ 1191 java_class_name_from_physname,/* Language specific class name */
1191 java_op_print_tab, /* expression operators for printing */ 1192 java_op_print_tab, /* expression operators for printing */
1192 0, /* not c-style arrays */ 1193 0, /* not c-style arrays */
1193 0, /* String lower bound */ 1194 0, /* String lower bound */
1194 default_word_break_characters, 1195 default_word_break_characters,
1195 default_make_symbol_completion_list, 1196 default_make_symbol_completion_list,
1196 java_language_arch_info, 1197 java_language_arch_info,
1197 default_print_array_index, 1198 default_print_array_index,
1198 default_pass_by_reference, 1199 default_pass_by_reference,
1199 default_get_string, 1200 default_get_string,
1200 strcmp_iw_ordered, 1201 NULL,»» » » /* la_get_symbol_name_cmp */
1201 iterate_over_symbols, 1202 iterate_over_symbols,
1202 LANG_MAGIC 1203 LANG_MAGIC
1203 }; 1204 };
1204 1205
1205 static void * 1206 static void *
1206 build_java_types (struct gdbarch *gdbarch) 1207 build_java_types (struct gdbarch *gdbarch)
1207 { 1208 {
1208 struct builtin_java_type *builtin_java_type 1209 struct builtin_java_type *builtin_java_type
1209 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_java_type); 1210 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_java_type);
1210 1211
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 _initialize_java_language (void) 1243 _initialize_java_language (void)
1243 { 1244 {
1244 jv_dynamics_objfile_data_key 1245 jv_dynamics_objfile_data_key
1245 = register_objfile_data_with_cleanup (NULL, jv_per_objfile_free); 1246 = register_objfile_data_with_cleanup (NULL, jv_per_objfile_free);
1246 jv_dynamics_progspace_key = register_program_space_data (); 1247 jv_dynamics_progspace_key = register_program_space_data ();
1247 1248
1248 java_type_data = gdbarch_data_register_post_init (build_java_types); 1249 java_type_data = gdbarch_data_register_post_init (build_java_types);
1249 1250
1250 add_language (&java_language_defn); 1251 add_language (&java_language_defn);
1251 } 1252 }
OLDNEW
« no previous file with comments | « gdb/jv-lang.h ('k') | gdb/jv-typeprint.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698