1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
/* -*- mode: C; c-basic-offset: 2 -*-
C# language support for Mono.
Copyright 2002 Ximian, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "expression.h"
#include "parser-defs.h"
#include "language.h"
#include "gdbtypes.h"
#include "symtab.h"
#include "symfile.h"
#include "objfiles.h"
#include "gdb_string.h"
#include "value.h"
#include "csharp-lang.h"
#include "c-lang.h"
#include "gdbcore.h"
#include <ctype.h>
/* Print the character C on STREAM as part of the contents of a literal
string whose delimiter is QUOTER. Note that that format for printing
characters and strings is language specific. */
void
csharp_emit_char (int c, struct ui_file *stream, int quoter)
{
switch (c)
{
case '\\':
case '\'':
fprintf_filtered (stream, "\\%c", c);
break;
case '\b':
fputs_filtered ("\\b", stream);
break;
case '\t':
fputs_filtered ("\\t", stream);
break;
case '\n':
fputs_filtered ("\\n", stream);
break;
case '\f':
fputs_filtered ("\\f", stream);
break;
case '\r':
fputs_filtered ("\\r", stream);
break;
default:
if (isprint (c))
fputc_filtered (c, stream);
else
fprintf_filtered (stream, "\\u%.4x", (unsigned int) c);
break;
}
}
int
csharp_value_print (struct value *val, struct ui_file *stream, int format,
enum val_prettyprint pretty)
{
struct type *type;
CORE_ADDR address;
int i;
char *name;
type = VALUE_TYPE (val);
address = VALUE_ADDRESS (val) + VALUE_OFFSET (val);
/* If it's type String, print it */
if (TYPE_CODE (type) == TYPE_CODE_PTR
&& TYPE_TARGET_TYPE (type)
&& TYPE_TAG_NAME (TYPE_TARGET_TYPE (type))
&& strcmp (TYPE_TAG_NAME (TYPE_TARGET_TYPE (type)), "MonoString") == 0
&& (format == 0 || format == 's')
&& address != 0
&& value_as_address (val) != 0)
{
struct value *data_val;
CORE_ADDR data;
struct value *count_val;
unsigned long count;
struct value *mark;
mark = value_mark (); /* Remember start of new values */
data_val = value_struct_elt (&val, NULL, "Chars", NULL, NULL);
data = VALUE_ADDRESS (data_val) + VALUE_OFFSET (data_val);
count_val = value_struct_elt (&val, NULL, "Length", NULL, NULL);
count = value_as_address (count_val);
value_free_to_mark (mark); /* Release unnecessary values */
val_print_string (data, count, 2, stream);
return 0;
}
return (val_print (type, VALUE_CONTENTS (val), 0, address,
stream, format, 1, 0, pretty));
}
/* Print data of type TYPE located at VALADDR (within GDB), which came from
the inferior at address ADDRESS, onto stdio stream STREAM according to
FORMAT (a letter or 0 for natural format). The data at VALADDR is in
target byte order.
If the data are a string pointer, returns the number of string characters
printed.
If DEREF_REF is nonzero, then dereference references, otherwise just print
them like pointers.
The PRETTY parameter controls prettyprinting. */
int
csharp_val_print (struct type *type, char *valaddr, int embedded_offset,
CORE_ADDR address, struct ui_file *stream, int format,
int deref_ref, int recurse, enum val_prettyprint pretty)
{
register unsigned int i = 0; /* Number of characters printed */
struct type *target_type;
LONGEST length;
CORE_ADDR addr;
CHECK_TYPEDEF (type);
switch (TYPE_CODE (type))
{
#if 0
case TYPE_CODE_CSHARP_STRING:
addr = address + TYPE_CSHARP_STRING_LENGTH_OFFSET (type);
length = read_memory_integer (addr, TYPE_CSHARP_STRING_LENGTH_BYTESIZE (type));
addr = address + TYPE_CSHARP_STRING_DATA_OFFSET (type);
return val_print_string (addr, length, 2, stream);
case TYPE_CODE_PTR:
addr = unpack_pointer (type, valaddr);
target_type = check_typedef (TYPE_TARGET_TYPE (type));
if (deref_ref && addr != 0)
{
if (TYPE_CODE (target_type) == TYPE_CODE_CSHARP_STRING)
return csharp_val_print (target_type, NULL, 0, addr, stream,
format, deref_ref, recurse, pretty);
else
return 0;
}
return c_val_print (type, valaddr, embedded_offset, address, stream,
format, deref_ref, recurse, pretty);
#endif
default:
return c_val_print (type, valaddr, embedded_offset, address, stream,
format, deref_ref, recurse, pretty);
}
return 0;
}
/* Table mapping opcodes into strings for printing operators
and precedences of the operators. */
const struct op_print csharp_op_print_tab[] =
{
{NULL, 0, 0, 0}
};
|