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

Side by Side Diff: gdb/d-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/d-lang.c ('k') | gdb/darwin-nat.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 D values for GDB, the GNU debugger. 1 /* Support for printing D values for GDB, the GNU debugger.
2 2
3 Copyright (C) 2008-2012 Free Software Foundation, Inc. 3 Copyright (C) 2008-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.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 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/>. */ 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 #include "defs.h" 20 #include "defs.h"
21 #include "gdbtypes.h" 21 #include "gdbtypes.h"
22 #include "gdbcore.h" 22 #include "gdbcore.h"
23 #include "d-lang.h" 23 #include "d-lang.h"
24 #include "c-lang.h" 24 #include "c-lang.h"
25 25
26 /* Assuming that TYPE is a TYPE_CODE_STRUCT, verify that TYPE is 26 /* Assuming that TYPE is a TYPE_CODE_STRUCT, verify that TYPE is a
27 a dynamic array, and then print its value to STREAM. Return 27 dynamic array, and then print its value to STREAM. Return zero if
28 the number of string characters printed, or -1 if TYPE is not 28 TYPE is a dynamic array, non-zero otherwise. */
29 a dynamic array. */ 29
30 static int 30 static int
31 dynamic_array_type (struct type *type, const gdb_byte *valaddr, 31 dynamic_array_type (struct type *type, const gdb_byte *valaddr,
32 int embedded_offset, CORE_ADDR address, 32 int embedded_offset, CORE_ADDR address,
33 struct ui_file *stream, int recurse, 33 struct ui_file *stream, int recurse,
34 const struct value *val, 34 const struct value *val,
35 const struct value_print_options *options) 35 const struct value_print_options *options)
36 { 36 {
37 if (TYPE_NFIELDS (type) == 2 37 if (TYPE_NFIELDS (type) == 2
38 && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_INT 38 && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_INT
39 && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 39 && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
(...skipping 13 matching lines...) Expand all
53 ptr_type = TYPE_FIELD_TYPE (type, 1); 53 ptr_type = TYPE_FIELD_TYPE (type, 1);
54 elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type)); 54 elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
55 addr = unpack_pointer (ptr_type, 55 addr = unpack_pointer (ptr_type,
56 valaddr + TYPE_FIELD_BITPOS (type, 1) / 8 56 valaddr + TYPE_FIELD_BITPOS (type, 1) / 8
57 + embedded_offset); 57 + embedded_offset);
58 true_type = check_typedef (elttype); 58 true_type = check_typedef (elttype);
59 59
60 true_type = lookup_array_range_type (true_type, 0, length - 1); 60 true_type = lookup_array_range_type (true_type, 0, length - 1);
61 ival = value_at (true_type, addr); 61 ival = value_at (true_type, addr);
62 62
63 return d_val_print (true_type, 63 d_val_print (true_type,
64 » » » value_contents_for_printing (ival), 64 » » value_contents_for_printing (ival),
65 » » » value_embedded_offset (ival), addr, 65 » » value_embedded_offset (ival), addr,
66 » » » stream, recurse + 1, ival, options); 66 » » stream, recurse + 1, ival, options);
67 return 0;
67 } 68 }
68 return -1; 69 return 1;
69 } 70 }
70 71
71 /* Implements the la_val_print routine for language D. */ 72 /* Implements the la_val_print routine for language D. */
72 int 73 void
73 d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, 74 d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
74 CORE_ADDR address, struct ui_file *stream, int recurse, 75 CORE_ADDR address, struct ui_file *stream, int recurse,
75 const struct value *val, 76 const struct value *val,
76 const struct value_print_options *options) 77 const struct value_print_options *options)
77 { 78 {
78 int ret; 79 int ret;
79 80
80 CHECK_TYPEDEF (type); 81 CHECK_TYPEDEF (type);
81 switch (TYPE_CODE (type)) 82 switch (TYPE_CODE (type))
82 { 83 {
83 case TYPE_CODE_STRUCT: 84 case TYPE_CODE_STRUCT:
84 ret = dynamic_array_type (type, valaddr, embedded_offset, address, 85 ret = dynamic_array_type (type, valaddr, embedded_offset, address,
85 stream, recurse, val, options); 86 stream, recurse, val, options);
86 » if (ret != -1) 87 » if (ret == 0)
87 » break; 88 » break;
88 default: 89 default:
89 » ret = c_val_print (type, valaddr, embedded_offset, address, stream, 90 » c_val_print (type, valaddr, embedded_offset, address, stream,
90 » » » recurse, val, options); 91 » » recurse, val, options);
91 } 92 }
92
93 return ret;
94 } 93 }
OLDNEW
« no previous file with comments | « gdb/d-lang.c ('k') | gdb/darwin-nat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698