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

Side by Side Diff: gdb/jv-valprint.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-typeprint.c ('k') | gdb/language.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Support for printing Java values for GDB, the GNU debugger. 1 /* Support for printing Java values for GDB, the GNU debugger.
2 2
3 Copyright (C) 1997-2005, 2007-2012 Free Software Foundation, Inc. 3 Copyright (C) 1997-2005, 2007-2012 Free Software Foundation, Inc.
4 4
5 This file is part of GDB. 5 This file is part of GDB.
6 6
7 This program is free software; you can redistribute it and/or modify 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 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 9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
(...skipping 15 matching lines...) Expand all
26 #include "demangle.h" 26 #include "demangle.h"
27 #include "valprint.h" 27 #include "valprint.h"
28 #include "language.h" 28 #include "language.h"
29 #include "jv-lang.h" 29 #include "jv-lang.h"
30 #include "c-lang.h" 30 #include "c-lang.h"
31 #include "annotate.h" 31 #include "annotate.h"
32 #include "gdb_string.h" 32 #include "gdb_string.h"
33 33
34 /* Local functions */ 34 /* Local functions */
35 35
36 int 36 void
37 java_value_print (struct value *val, struct ui_file *stream, 37 java_value_print (struct value *val, struct ui_file *stream,
38 const struct value_print_options *options) 38 const struct value_print_options *options)
39 { 39 {
40 struct gdbarch *gdbarch = get_type_arch (value_type (val)); 40 struct gdbarch *gdbarch = get_type_arch (value_type (val));
41 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); 41 enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
42 struct type *type; 42 struct type *type;
43 CORE_ADDR address; 43 CORE_ADDR address;
44 int i; 44 int i;
45 char *name; 45 const char *name;
46 struct value_print_options opts; 46 struct value_print_options opts;
47 47
48 type = value_type (val); 48 type = value_type (val);
49 address = value_address (val); 49 address = value_address (val);
50 50
51 if (is_object_type (type)) 51 if (is_object_type (type))
52 { 52 {
53 CORE_ADDR obj_addr; 53 CORE_ADDR obj_addr;
54 struct value *tem = val;
54 55
55 /* Get the run-time type, and cast the object into that. */ 56 /* Get the run-time type, and cast the object into that. */
57 while (TYPE_CODE (value_type (tem)) == TYPE_CODE_PTR)
58 tem = value_ind (tem);
56 59
57 obj_addr = unpack_pointer (type, value_contents (val)); 60 obj_addr = value_address (tem);
58 61
59 if (obj_addr != 0) 62 if (obj_addr != 0)
60 { 63 {
61 type = type_from_class (gdbarch, java_class_from_object (val)); 64 type = type_from_class (gdbarch, java_class_from_object (val));
62 type = lookup_pointer_type (type); 65 type = lookup_pointer_type (type);
63 66
64 val = value_at (type, address); 67 val = value_at (type, address);
65 } 68 }
66 } 69 }
67 70
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 things_printed++; 201 things_printed++;
199 i += reps; 202 i += reps;
200 } 203 }
201 } 204 }
202 205
203 if (i < length) 206 if (i < length)
204 fprintf_filtered (stream, "..."); 207 fprintf_filtered (stream, "...");
205 208
206 fprintf_filtered (stream, "}"); 209 fprintf_filtered (stream, "}");
207 210
208 return 0; 211 return;
209 } 212 }
210 213
211 /* If it's type String, print it. */ 214 /* If it's type String, print it. */
212 215
213 if (TYPE_CODE (type) == TYPE_CODE_PTR 216 if (TYPE_CODE (type) == TYPE_CODE_PTR
214 && TYPE_TARGET_TYPE (type) 217 && TYPE_TARGET_TYPE (type)
215 && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)) 218 && TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
216 && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)), 219 && strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)),
217 "java.lang.String") == 0 220 "java.lang.String") == 0
218 && (options->format == 0 || options->format == 's') 221 && (options->format == 0 || options->format == 's')
219 && address != 0 222 && address != 0
220 && value_as_address (val) != 0) 223 && value_as_address (val) != 0)
221 { 224 {
222 struct type *char_type; 225 struct type *char_type;
223 struct value *data_val; 226 struct value *data_val;
224 CORE_ADDR data; 227 CORE_ADDR data;
225 struct value *boffset_val; 228 struct value *boffset_val;
226 unsigned long boffset; 229 unsigned long boffset;
227 struct value *count_val; 230 struct value *count_val;
228 unsigned long count; 231 unsigned long count;
229 struct value *mark; 232 struct value *mark;
230 233
234 fputs_filtered (" ", stream);
235
231 mark = value_mark (); /* Remember start of new values. */ 236 mark = value_mark (); /* Remember start of new values. */
232 237
233 data_val = value_struct_elt (&val, NULL, "data", NULL, NULL); 238 data_val = value_struct_elt (&val, NULL, "data", NULL, NULL);
234 data = value_as_address (data_val); 239 data = value_as_address (data_val);
235 240
236 boffset_val = value_struct_elt (&val, NULL, "boffset", NULL, NULL); 241 boffset_val = value_struct_elt (&val, NULL, "boffset", NULL, NULL);
237 boffset = value_as_address (boffset_val); 242 boffset = value_as_address (boffset_val);
238 243
239 count_val = value_struct_elt (&val, NULL, "count", NULL, NULL); 244 count_val = value_struct_elt (&val, NULL, "count", NULL, NULL);
240 count = value_as_address (count_val); 245 count = value_as_address (count_val);
241 246
242 value_free_to_mark (mark); /* Release unnecessary values. */ 247 value_free_to_mark (mark); /* Release unnecessary values. */
243 248
244 char_type = builtin_java_type (gdbarch)->builtin_char; 249 char_type = builtin_java_type (gdbarch)->builtin_char;
245 val_print_string (char_type, NULL, data + boffset, count, stream, 250 val_print_string (char_type, NULL, data + boffset, count, stream,
246 options); 251 options);
247 252
248 return 0; 253 return;
249 } 254 }
250 255
251 opts = *options; 256 opts = *options;
252 opts.deref_ref = 1; 257 opts.deref_ref = 1;
253 return common_val_print (val, stream, 0, &opts, current_language); 258 common_val_print (val, stream, 0, &opts, current_language);
254 } 259 }
255 260
256 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the 261 /* TYPE, VALADDR, ADDRESS, STREAM, RECURSE, and OPTIONS have the
257 same meanings as in cp_print_value and c_val_print. 262 same meanings as in cp_print_value and c_val_print.
258 263
259 DONT_PRINT is an array of baseclass types that we 264 DONT_PRINT is an array of baseclass types that we
260 should not print, or zero if called from top level. */ 265 should not print, or zero if called from top level. */
261 266
262 static void 267 static void
263 java_print_value_fields (struct type *type, const gdb_byte *valaddr, 268 java_print_value_fields (struct type *type, const gdb_byte *valaddr,
(...skipping 12 matching lines...) Expand all
276 n_baseclasses = TYPE_N_BASECLASSES (type); 281 n_baseclasses = TYPE_N_BASECLASSES (type);
277 282
278 if (n_baseclasses > 0) 283 if (n_baseclasses > 0)
279 { 284 {
280 int i, n_baseclasses = TYPE_N_BASECLASSES (type); 285 int i, n_baseclasses = TYPE_N_BASECLASSES (type);
281 286
282 for (i = 0; i < n_baseclasses; i++) 287 for (i = 0; i < n_baseclasses; i++)
283 { 288 {
284 int boffset; 289 int boffset;
285 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); 290 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
286 » char *basename = TYPE_NAME (baseclass); 291 » const char *basename = TYPE_NAME (baseclass);
287 const gdb_byte *base_valaddr; 292 const gdb_byte *base_valaddr;
288 293
289 if (BASETYPE_VIA_VIRTUAL (type, i)) 294 if (BASETYPE_VIA_VIRTUAL (type, i))
290 continue; 295 continue;
291 296
292 if (basename != NULL && strcmp (basename, "java.lang.Object") == 0) 297 if (basename != NULL && strcmp (basename, "java.lang.Object") == 0)
293 continue; 298 continue;
294 299
295 boffset = 0; 300 boffset = 0;
296 301
(...skipping 21 matching lines...) Expand all
318 fprintf_filtered (stream, "<No data fields>"); 323 fprintf_filtered (stream, "<No data fields>");
319 else 324 else
320 { 325 {
321 int fields_seen = 0; 326 int fields_seen = 0;
322 327
323 for (i = n_baseclasses; i < len; i++) 328 for (i = n_baseclasses; i < len; i++)
324 { 329 {
325 /* If requested, skip printing of static fields. */ 330 /* If requested, skip printing of static fields. */
326 if (field_is_static (&TYPE_FIELD (type, i))) 331 if (field_is_static (&TYPE_FIELD (type, i)))
327 { 332 {
328 » char *name = TYPE_FIELD_NAME (type, i); 333 » const char *name = TYPE_FIELD_NAME (type, i);
329 334
330 if (!options->static_field_print) 335 if (!options->static_field_print)
331 continue; 336 continue;
332 if (name != NULL && strcmp (name, "class") == 0) 337 if (name != NULL && strcmp (name, "class") == 0)
333 continue; 338 continue;
334 } 339 }
335 if (fields_seen) 340 if (fields_seen)
336 fprintf_filtered (stream, ", "); 341 fprintf_filtered (stream, ", ");
337 else if (n_baseclasses > 0) 342 else if (n_baseclasses > 0)
338 { 343 {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 if (options->pretty) 473 if (options->pretty)
469 { 474 {
470 fprintf_filtered (stream, "\n"); 475 fprintf_filtered (stream, "\n");
471 print_spaces_filtered (2 * recurse, stream); 476 print_spaces_filtered (2 * recurse, stream);
472 } 477 }
473 } 478 }
474 fprintf_filtered (stream, "}"); 479 fprintf_filtered (stream, "}");
475 } 480 }
476 481
477 /* See val_print for a description of the various parameters of this 482 /* See val_print for a description of the various parameters of this
478 function; they are identical. The semantics of the return value is 483 function; they are identical. */
479 also identical to val_print. */
480 484
481 int 485 void
482 java_val_print (struct type *type, const gdb_byte *valaddr, 486 java_val_print (struct type *type, const gdb_byte *valaddr,
483 int embedded_offset, CORE_ADDR address, 487 int embedded_offset, CORE_ADDR address,
484 struct ui_file *stream, int recurse, 488 struct ui_file *stream, int recurse,
485 const struct value *val, 489 const struct value *val,
486 const struct value_print_options *options) 490 const struct value_print_options *options)
487 { 491 {
488 struct gdbarch *gdbarch = get_type_arch (type); 492 struct gdbarch *gdbarch = get_type_arch (type);
489 unsigned int i = 0; /* Number of characters printed. */ 493 unsigned int i = 0; /* Number of characters printed. */
490 struct type *target_type; 494 struct type *target_type;
491 CORE_ADDR addr; 495 CORE_ADDR addr;
492 496
493 CHECK_TYPEDEF (type); 497 CHECK_TYPEDEF (type);
494 switch (TYPE_CODE (type)) 498 switch (TYPE_CODE (type))
495 { 499 {
496 case TYPE_CODE_PTR: 500 case TYPE_CODE_PTR:
497 if (options->format && options->format != 's') 501 if (options->format && options->format != 's')
498 { 502 {
499 val_print_scalar_formatted (type, valaddr, embedded_offset, 503 val_print_scalar_formatted (type, valaddr, embedded_offset,
500 val, options, 0, stream); 504 val, options, 0, stream);
501 break; 505 break;
502 } 506 }
503 #if 0
504 if (options->vtblprint && cp_is_vtbl_ptr_type (type))
505 {
506 /* Print the unmangled name if desired. */
507 /* Print vtable entry - we only get here if we ARE using
508 -fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
509 /* Extract an address, assume that it is unsigned. */
510 print_address_demangle
511 (gdbarch,
512 extract_unsigned_integer (valaddr + embedded_offset,
513 TYPE_LENGTH (type)),
514 stream, demangle);
515 break;
516 }
517 #endif
518 addr = unpack_pointer (type, valaddr + embedded_offset); 507 addr = unpack_pointer (type, valaddr + embedded_offset);
519 if (addr == 0) 508 if (addr == 0)
520 { 509 {
521 fputs_filtered ("null", stream); 510 fputs_filtered ("null", stream);
522 » return i; 511 » return;
523 } 512 }
524 target_type = check_typedef (TYPE_TARGET_TYPE (type)); 513 target_type = check_typedef (TYPE_TARGET_TYPE (type));
525 514
526 if (TYPE_CODE (target_type) == TYPE_CODE_FUNC) 515 if (TYPE_CODE (target_type) == TYPE_CODE_FUNC)
527 { 516 {
528 /* Try to print what function it points to. */ 517 /* Try to print what function it points to. */
529 » print_address_demangle (gdbarch, addr, stream, demangle); 518 » print_address_demangle (options, gdbarch, addr, stream, demangle);
530 » /* Return value is irrelevant except for string pointers. */ 519 » return;
531 » return (0);
532 } 520 }
533 521
534 if (options->addressprint && options->format != 's') 522 if (options->addressprint && options->format != 's')
535 { 523 {
536 fputs_filtered ("@", stream); 524 fputs_filtered ("@", stream);
537 print_longest (stream, 'x', 0, (ULONGEST) addr); 525 print_longest (stream, 'x', 0, (ULONGEST) addr);
538 } 526 }
539 527
540 return i; 528 return;
541 529
542 case TYPE_CODE_CHAR: 530 case TYPE_CODE_CHAR:
543 case TYPE_CODE_INT: 531 case TYPE_CODE_INT:
544 /* Can't just call c_val_print because that prints bytes as C 532 /* Can't just call c_val_print because that prints bytes as C
545 chars. */ 533 chars. */
546 if (options->format || options->output_format) 534 if (options->format || options->output_format)
547 { 535 {
548 struct value_print_options opts = *options; 536 struct value_print_options opts = *options;
549 537
550 opts.format = (options->format ? options->format 538 opts.format = (options->format ? options->format
(...skipping 10 matching lines...) Expand all
561 else 549 else
562 val_print_type_code_int (type, valaddr + embedded_offset, stream); 550 val_print_type_code_int (type, valaddr + embedded_offset, stream);
563 break; 551 break;
564 552
565 case TYPE_CODE_STRUCT: 553 case TYPE_CODE_STRUCT:
566 java_print_value_fields (type, valaddr, embedded_offset, 554 java_print_value_fields (type, valaddr, embedded_offset,
567 address, stream, recurse, val, options); 555 address, stream, recurse, val, options);
568 break; 556 break;
569 557
570 default: 558 default:
571 return c_val_print (type, valaddr, embedded_offset, address, stream, 559 c_val_print (type, valaddr, embedded_offset, address, stream,
572 » » » recurse, val, options); 560 » » recurse, val, options);
561 break;
573 } 562 }
574
575 return 0;
576 } 563 }
OLDNEW
« no previous file with comments | « gdb/jv-typeprint.c ('k') | gdb/language.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698