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

Side by Side Diff: runtime/bin/dbg_message.cc

Issue 27397002: Handle recursive list structures in debugger (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dbg_connection.h" 5 #include "bin/dbg_connection.h"
6 #include "bin/dbg_message.h" 6 #include "bin/dbg_message.h"
7 #include "bin/dartutils.h" 7 #include "bin/dartutils.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 160
161 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) { 161 static void FormatEncodedString(dart::TextBuffer* buf, Dart_Handle str) {
162 buf->AddChar('\"'); 162 buf->AddChar('\"');
163 FormatEncodedChars(buf, str); 163 FormatEncodedChars(buf, str);
164 buf->AddChar('\"'); 164 buf->AddChar('\"');
165 } 165 }
166 166
167 167
168 static void FormatTextualValue(dart::TextBuffer* buf, 168 static void FormatTextualValue(dart::TextBuffer* buf,
169 Dart_Handle object, 169 Dart_Handle object,
170 intptr_t max_chars); 170 intptr_t max_chars,
171 bool expand_list);
171 172
172 173
173 static void FormatTextualListValue(dart::TextBuffer* buf, 174 static void FormatTextualListValue(dart::TextBuffer* buf,
174 Dart_Handle list, 175 Dart_Handle list,
175 intptr_t max_chars) { 176 intptr_t max_chars) {
176 intptr_t len = 0; 177 intptr_t len = 0;
177 Dart_Handle res = Dart_ListLength(list, &len); 178 Dart_Handle res = Dart_ListLength(list, &len);
178 ASSERT_NOT_ERROR(res); 179 ASSERT_NOT_ERROR(res);
179 const intptr_t initial_buffer_length = buf->length(); 180 const intptr_t initial_buffer_length = buf->length();
180 // Maximum number of characters we print for array elements. 181 // Maximum number of characters we print for array elements.
181 const intptr_t max_buffer_length = initial_buffer_length + max_chars; 182 const intptr_t max_buffer_length = initial_buffer_length + max_chars;
182 buf->Printf("["); 183 buf->Printf("[");
183 for (int i = 0; i < len; i++) { 184 for (int i = 0; i < len; i++) {
184 if (i > 0) { 185 if (i > 0) {
185 buf->Printf(", "); 186 buf->Printf(", ");
186 } 187 }
187 Dart_Handle elem = Dart_ListGetAt(list, i); 188 Dart_Handle elem = Dart_ListGetAt(list, i);
188 const intptr_t max_element_chars = 50; 189 const intptr_t max_element_chars = 50;
189 FormatTextualValue(buf, elem, max_element_chars); 190 FormatTextualValue(buf, elem, max_element_chars, false);
190 if (buf->length() > max_buffer_length) { 191 if (buf->length() > max_buffer_length) {
191 buf->Printf(", ..."); 192 buf->Printf(", ...");
192 break; 193 break;
193 } 194 }
194 } 195 }
195 buf->Printf("]"); 196 buf->Printf("]");
196 } 197 }
197 198
198 199
199 static void FormatTextualValue(dart::TextBuffer* buf, 200 static void FormatTextualValue(dart::TextBuffer* buf,
200 Dart_Handle object, 201 Dart_Handle object,
201 intptr_t max_chars) { 202 intptr_t max_chars,
203 bool expand_list) {
202 if (Dart_IsList(object)) { 204 if (Dart_IsList(object)) {
203 FormatTextualListValue(buf, object, max_chars); 205 if (expand_list) {
206 FormatTextualListValue(buf, object, max_chars);
207 } else {
208 buf->Printf("[...]");
209 }
204 } else if (Dart_IsNull(object)) { 210 } else if (Dart_IsNull(object)) {
205 buf->Printf("null"); 211 buf->Printf("null");
206 } else if (Dart_IsString(object)) { 212 } else if (Dart_IsString(object)) {
207 buf->Printf("\\\""); 213 buf->Printf("\\\"");
208 FormatEncodedCharsTrunc(buf, object, max_chars); 214 FormatEncodedCharsTrunc(buf, object, max_chars);
209 buf->Printf("\\\""); 215 buf->Printf("\\\"");
210 } else { 216 } else {
211 Dart_Handle text = Dart_ToString(object); 217 Dart_Handle text = Dart_ToString(object);
212 if (Dart_IsNull(text)) { 218 if (Dart_IsNull(text)) {
213 buf->Printf("null"); 219 buf->Printf("null");
(...skipping 21 matching lines...) Expand all
235 } else { 241 } else {
236 buf->Printf("\"kind\":\"object\","); 242 buf->Printf("\"kind\":\"object\",");
237 intptr_t class_id = 0; 243 intptr_t class_id = 0;
238 Dart_Handle res = Dart_GetObjClassId(object, &class_id); 244 Dart_Handle res = Dart_GetObjClassId(object, &class_id);
239 if (!Dart_IsError(res)) { 245 if (!Dart_IsError(res)) {
240 buf->Printf("\"classId\":%" Pd ",", class_id); 246 buf->Printf("\"classId\":%" Pd ",", class_id);
241 } 247 }
242 } 248 }
243 buf->Printf("\"text\":\""); 249 buf->Printf("\"text\":\"");
244 const intptr_t max_chars = 250; 250 const intptr_t max_chars = 250;
245 FormatTextualValue(buf, object, max_chars); 251 FormatTextualValue(buf, object, max_chars, true);
246 buf->Printf("\""); 252 buf->Printf("\"");
247 } 253 }
248 254
249 255
250 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) { 256 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) {
251 buf->Printf("{"); 257 buf->Printf("{");
252 FormatValue(buf, object); 258 FormatValue(buf, object);
253 buf->Printf("}"); 259 buf->Printf("}");
254 } 260 }
255 261
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 } else { 1306 } else {
1301 ASSERT(kind == kShutdown); 1307 ASSERT(kind == kShutdown);
1302 RemoveIsolateMsgQueue(isolate_id); 1308 RemoveIsolateMsgQueue(isolate_id);
1303 } 1309 }
1304 } 1310 }
1305 Dart_ExitScope(); 1311 Dart_ExitScope();
1306 } 1312 }
1307 1313
1308 } // namespace bin 1314 } // namespace bin
1309 } // namespace dart 1315 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698