blob: c0c9dcbb4a62e7b9895b1a580968c2e6dc2d0159 [file] [log] [blame]
Enrico Granatacaaf0102012-09-04 18:48:21 +00001//===-- CXXFormatterFunctions.cpp---------------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
Daniel Malead891f9b2012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Enrico Granataf509c5e2013-01-28 23:47:25 +000012#include "lldb/DataFormatters/CXXFormatterFunctions.h"
Enrico Granatacaaf0102012-09-04 18:48:21 +000013
Dmitri Gribenko2a64f9a2013-01-30 15:05:59 +000014#include "llvm/Support/ConvertUTF.h"
Enrico Granatacaaf0102012-09-04 18:48:21 +000015
Enrico Granataf91e78f2012-09-13 18:27:09 +000016#include "lldb/Core/DataBufferHeap.h"
17#include "lldb/Core/Error.h"
Enrico Granatacaaf0102012-09-04 18:48:21 +000018#include "lldb/Core/Stream.h"
19#include "lldb/Core/ValueObject.h"
Enrico Granataf91e78f2012-09-13 18:27:09 +000020#include "lldb/Core/ValueObjectConstResult.h"
21#include "lldb/Host/Endian.h"
Enrico Granatadb054912012-10-29 21:18:03 +000022#include "lldb/Symbol/ClangASTContext.h"
Enrico Granatacaaf0102012-09-04 18:48:21 +000023#include "lldb/Target/ObjCLanguageRuntime.h"
24#include "lldb/Target/Target.h"
25
26using namespace lldb;
27using namespace lldb_private;
28using namespace lldb_private::formatters;
29
30bool
Enrico Granataf91e78f2012-09-13 18:27:09 +000031lldb_private::formatters::ExtractValueFromObjCExpression (ValueObject &valobj,
32 const char* target_type,
33 const char* selector,
34 uint64_t &value)
Enrico Granatacaaf0102012-09-04 18:48:21 +000035{
36 if (!target_type || !*target_type)
37 return false;
38 if (!selector || !*selector)
39 return false;
Enrico Granatacaaf0102012-09-04 18:48:21 +000040 StreamString expr;
Daniel Maleab9db9d52012-12-07 22:21:08 +000041 expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
Enrico Granatacaaf0102012-09-04 18:48:21 +000042 ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
43 lldb::ValueObjectSP result_sp;
44 Target* target = exe_ctx.GetTargetPtr();
45 StackFrame* stack_frame = exe_ctx.GetFramePtr();
46 if (!target || !stack_frame)
47 return false;
Enrico Granatad27026e2012-09-05 20:41:26 +000048
Jim Ingham47beabb2012-10-16 21:41:58 +000049 EvaluateExpressionOptions options;
Enrico Granatad27026e2012-09-05 20:41:26 +000050 options.SetCoerceToId(false)
51 .SetUnwindOnError(true)
Sean Callanan99611fe2012-12-04 20:56:04 +000052 .SetKeepInMemory(true);
Enrico Granatad27026e2012-09-05 20:41:26 +000053
Enrico Granatacaaf0102012-09-04 18:48:21 +000054 target->EvaluateExpression(expr.GetData(),
55 stack_frame,
Enrico Granatad27026e2012-09-05 20:41:26 +000056 result_sp,
57 options);
Enrico Granatacaaf0102012-09-04 18:48:21 +000058 if (!result_sp)
59 return false;
60 value = result_sp->GetValueAsUnsigned(0);
61 return true;
62}
63
Enrico Granataea687532013-02-15 23:38:37 +000064bool
65lldb_private::formatters::ExtractSummaryFromObjCExpression (ValueObject &valobj,
66 const char* target_type,
67 const char* selector,
68 Stream &stream)
69{
70 if (!target_type || !*target_type)
71 return false;
72 if (!selector || !*selector)
73 return false;
74 StreamString expr;
Enrico Granata04d3bb22013-02-19 01:14:06 +000075 expr.Printf("(%s)[(id)0x%" PRIx64 " %s]",target_type,valobj.GetPointerValue(),selector);
Enrico Granataea687532013-02-15 23:38:37 +000076 ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
77 lldb::ValueObjectSP result_sp;
78 Target* target = exe_ctx.GetTargetPtr();
79 StackFrame* stack_frame = exe_ctx.GetFramePtr();
80 if (!target || !stack_frame)
81 return false;
82
83 EvaluateExpressionOptions options;
84 options.SetCoerceToId(false)
85 .SetUnwindOnError(true)
86 .SetKeepInMemory(true)
87 .SetUseDynamic(lldb::eDynamicCanRunTarget);
88
89 target->EvaluateExpression(expr.GetData(),
90 stack_frame,
91 result_sp,
92 options);
93 if (!result_sp)
94 return false;
95 stream.Printf("%s",result_sp->GetSummaryAsCString());
96 return true;
97}
98
Enrico Granataf91e78f2012-09-13 18:27:09 +000099lldb::ValueObjectSP
100lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
101 const char* return_type,
102 const char* selector,
103 uint64_t index)
104{
105 lldb::ValueObjectSP valobj_sp;
106 if (!return_type || !*return_type)
107 return valobj_sp;
108 if (!selector || !*selector)
109 return valobj_sp;
110 StreamString expr_path_stream;
111 valobj.GetExpressionPath(expr_path_stream, false);
112 StreamString expr;
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000113 expr.Printf("(%s)[%s %s:%" PRId64 "]",return_type,expr_path_stream.GetData(),selector,index);
Enrico Granataf91e78f2012-09-13 18:27:09 +0000114 ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
115 lldb::ValueObjectSP result_sp;
116 Target* target = exe_ctx.GetTargetPtr();
117 StackFrame* stack_frame = exe_ctx.GetFramePtr();
118 if (!target || !stack_frame)
119 return valobj_sp;
120
Jim Ingham47beabb2012-10-16 21:41:58 +0000121 EvaluateExpressionOptions options;
Enrico Granataf91e78f2012-09-13 18:27:09 +0000122 options.SetCoerceToId(false)
123 .SetUnwindOnError(true)
124 .SetKeepInMemory(true)
125 .SetUseDynamic(lldb::eDynamicCanRunTarget);
126
127 target->EvaluateExpression(expr.GetData(),
128 stack_frame,
129 valobj_sp,
130 options);
131 return valobj_sp;
132}
133
134lldb::ValueObjectSP
135lldb_private::formatters::CallSelectorOnObject (ValueObject &valobj,
136 const char* return_type,
137 const char* selector,
138 const char* key)
139{
140 lldb::ValueObjectSP valobj_sp;
141 if (!return_type || !*return_type)
142 return valobj_sp;
143 if (!selector || !*selector)
144 return valobj_sp;
145 if (!key || !*key)
146 return valobj_sp;
147 StreamString expr_path_stream;
148 valobj.GetExpressionPath(expr_path_stream, false);
149 StreamString expr;
150 expr.Printf("(%s)[%s %s:%s]",return_type,expr_path_stream.GetData(),selector,key);
151 ExecutionContext exe_ctx (valobj.GetExecutionContextRef());
152 lldb::ValueObjectSP result_sp;
153 Target* target = exe_ctx.GetTargetPtr();
154 StackFrame* stack_frame = exe_ctx.GetFramePtr();
155 if (!target || !stack_frame)
156 return valobj_sp;
157
Jim Ingham47beabb2012-10-16 21:41:58 +0000158 EvaluateExpressionOptions options;
Enrico Granataf91e78f2012-09-13 18:27:09 +0000159 options.SetCoerceToId(false)
160 .SetUnwindOnError(true)
161 .SetKeepInMemory(true)
162 .SetUseDynamic(lldb::eDynamicCanRunTarget);
163
164 target->EvaluateExpression(expr.GetData(),
165 stack_frame,
166 valobj_sp,
167 options);
168 return valobj_sp;
169}
170
Enrico Granatacd8cd612013-01-14 23:53:26 +0000171// use this call if you already have an LLDB-side buffer for the data
172template<typename SourceDataType>
Enrico Granataf5545f92013-01-10 22:08:35 +0000173static bool
Enrico Granatacd8cd612013-01-14 23:53:26 +0000174DumpUTFBufferToStream (ConversionResult (*ConvertFunction) (const SourceDataType**,
175 const SourceDataType*,
176 UTF8**,
177 UTF8*,
178 ConversionFlags),
179 DataExtractor& data,
180 Stream& stream,
181 char prefix_token = '@',
182 char quote = '"',
183 int sourceSize = 0)
Enrico Granataf5545f92013-01-10 22:08:35 +0000184{
Enrico Granatacd8cd612013-01-14 23:53:26 +0000185 if (prefix_token != 0)
186 stream.Printf("%c",prefix_token);
187 if (quote != 0)
188 stream.Printf("%c",quote);
189 if (data.GetByteSize() && data.GetDataStart() && data.GetDataEnd())
Enrico Granataf5545f92013-01-10 22:08:35 +0000190 {
Enrico Granatacd8cd612013-01-14 23:53:26 +0000191 const int bufferSPSize = data.GetByteSize();
192 if (sourceSize == 0)
193 {
194 const int origin_encoding = 8*sizeof(SourceDataType);
Greg Clayton0cd33402013-02-08 21:59:34 +0000195 sourceSize = bufferSPSize/(origin_encoding / 4);
Enrico Granatacd8cd612013-01-14 23:53:26 +0000196 }
197
198 SourceDataType *data_ptr = (SourceDataType*)data.GetDataStart();
Enrico Granataf5545f92013-01-10 22:08:35 +0000199 SourceDataType *data_end_ptr = data_ptr + sourceSize;
200
201 while (data_ptr < data_end_ptr)
202 {
203 if (!*data_ptr)
204 {
205 data_end_ptr = data_ptr;
206 break;
207 }
208 data_ptr++;
209 }
210
Enrico Granatacd8cd612013-01-14 23:53:26 +0000211 data_ptr = (SourceDataType*)data.GetDataStart();
Enrico Granataf5545f92013-01-10 22:08:35 +0000212
Enrico Granata06d58b02013-01-11 02:44:00 +0000213 lldb::DataBufferSP utf8_data_buffer_sp;
214 UTF8* utf8_data_ptr = nullptr;
215 UTF8* utf8_data_end_ptr = nullptr;
Enrico Granatacd8cd612013-01-14 23:53:26 +0000216
Enrico Granataf5545f92013-01-10 22:08:35 +0000217 if (ConvertFunction)
Enrico Granata06d58b02013-01-11 02:44:00 +0000218 {
219 utf8_data_buffer_sp.reset(new DataBufferHeap(bufferSPSize,0));
220 utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes();
221 utf8_data_end_ptr = utf8_data_ptr + bufferSPSize;
Enrico Granataf5545f92013-01-10 22:08:35 +0000222 ConvertFunction ( (const SourceDataType**)&data_ptr, data_end_ptr, &utf8_data_ptr, utf8_data_end_ptr, lenientConversion );
Enrico Granata06d58b02013-01-11 02:44:00 +0000223 utf8_data_ptr = (UTF8*)utf8_data_buffer_sp->GetBytes(); // needed because the ConvertFunction will change the value of the data_ptr
224 }
Enrico Granataf5545f92013-01-10 22:08:35 +0000225 else
226 {
227 // just copy the pointers - the cast is necessary to make the compiler happy
228 // but this should only happen if we are reading UTF8 data
229 utf8_data_ptr = (UTF8*)data_ptr;
230 utf8_data_end_ptr = (UTF8*)data_end_ptr;
231 }
232
Enrico Granatab6985792013-01-12 01:00:22 +0000233 // since we tend to accept partial data (and even partially malformed data)
234 // we might end up with no NULL terminator before the end_ptr
235 // hence we need to take a slower route and ensure we stay within boundaries
Enrico Granataf5545f92013-01-10 22:08:35 +0000236 for (;utf8_data_ptr != utf8_data_end_ptr; utf8_data_ptr++)
237 {
238 if (!*utf8_data_ptr)
239 break;
240 stream.Printf("%c",*utf8_data_ptr);
241 }
Enrico Granatacd8cd612013-01-14 23:53:26 +0000242 }
243 if (quote != 0)
244 stream.Printf("%c",quote);
245 return true;
246}
247
248template<typename SourceDataType>
249static bool
250ReadUTFBufferAndDumpToStream (ConversionResult (*ConvertFunction) (const SourceDataType**,
251 const SourceDataType*,
252 UTF8**,
253 UTF8*,
254 ConversionFlags),
255 uint64_t location,
256 const ProcessSP& process_sp,
257 Stream& stream,
258 char prefix_token = '@',
259 char quote = '"',
260 int sourceSize = 0)
261{
262 if (location == 0 || location == LLDB_INVALID_ADDRESS)
263 return false;
264 if (!process_sp)
265 return false;
266
267 const int origin_encoding = 8*sizeof(SourceDataType);
268 if (origin_encoding != 8 && origin_encoding != 16 && origin_encoding != 32)
269 return false;
270 // if not UTF8, I need a conversion function to return proper UTF8
271 if (origin_encoding != 8 && !ConvertFunction)
272 return false;
273
274 if (sourceSize == 0)
275 sourceSize = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
276 const int bufferSPSize = sourceSize * (origin_encoding >> 2);
277
278 Error error;
279 lldb::DataBufferSP buffer_sp(new DataBufferHeap(bufferSPSize,0));
280
281 if (!buffer_sp->GetBytes())
282 return false;
283
284 size_t data_read = process_sp->ReadMemoryFromInferior(location, (char*)buffer_sp->GetBytes(), bufferSPSize, error);
285 if (error.Fail() || data_read == 0)
286 {
287 stream.Printf("unable to read data");
Enrico Granataf5545f92013-01-10 22:08:35 +0000288 return true;
289 }
Enrico Granatacd8cd612013-01-14 23:53:26 +0000290
291 DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize());
292
293 return DumpUTFBufferToStream(ConvertFunction, data, stream, prefix_token, quote, sourceSize);
Enrico Granataf5545f92013-01-10 22:08:35 +0000294}
295
296bool
297lldb_private::formatters::Char16StringSummaryProvider (ValueObject& valobj, Stream& stream)
298{
299 ProcessSP process_sp = valobj.GetProcessSP();
300 if (!process_sp)
301 return false;
302
303 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
304
305 if (!valobj_addr)
306 return false;
307
Enrico Granatacd8cd612013-01-14 23:53:26 +0000308 if (!ReadUTFBufferAndDumpToStream<UTF16>(ConvertUTF16toUTF8,valobj_addr,
Enrico Granataf5545f92013-01-10 22:08:35 +0000309 process_sp,
310 stream,
Enrico Granatacd8cd612013-01-14 23:53:26 +0000311 'u'))
Enrico Granataf5545f92013-01-10 22:08:35 +0000312 {
313 stream.Printf("Summary Unavailable");
314 return true;
315 }
316
317 return true;
318}
319
320bool
321lldb_private::formatters::Char32StringSummaryProvider (ValueObject& valobj, Stream& stream)
322{
323 ProcessSP process_sp = valobj.GetProcessSP();
324 if (!process_sp)
325 return false;
326
327 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
328
329 if (!valobj_addr)
330 return false;
331
Enrico Granatacd8cd612013-01-14 23:53:26 +0000332 if (!ReadUTFBufferAndDumpToStream<UTF32>(ConvertUTF32toUTF8,valobj_addr,
Enrico Granataf5545f92013-01-10 22:08:35 +0000333 process_sp,
334 stream,
Enrico Granatacd8cd612013-01-14 23:53:26 +0000335 'U'))
Enrico Granataf5545f92013-01-10 22:08:35 +0000336 {
337 stream.Printf("Summary Unavailable");
338 return true;
339 }
340
341 return true;
342}
343
344bool
345lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Stream& stream)
346{
Enrico Granata06d58b02013-01-11 02:44:00 +0000347 ProcessSP process_sp = valobj.GetProcessSP();
348 if (!process_sp)
349 return false;
350
Enrico Granatab6985792013-01-12 01:00:22 +0000351 lldb::addr_t data_addr = 0;
352
353 if (valobj.IsPointerType())
354 data_addr = valobj.GetValueAsUnsigned(0);
355 else if (valobj.IsArrayType())
356 data_addr = valobj.GetAddressOf();
Enrico Granata06d58b02013-01-11 02:44:00 +0000357
Enrico Granatab6985792013-01-12 01:00:22 +0000358 if (data_addr == 0 || data_addr == LLDB_INVALID_ADDRESS)
Enrico Granata06d58b02013-01-11 02:44:00 +0000359 return false;
360
361 clang::ASTContext* ast = valobj.GetClangAST();
362
363 if (!ast)
364 return false;
365
366 uint32_t wchar_size = ClangASTType::GetClangTypeBitWidth(ast, ClangASTType::GetBasicType(ast, lldb::eBasicTypeWChar).GetOpaqueQualType());
367
368 switch (wchar_size)
369 {
370 case 8:
371 // utf 8
Enrico Granatacd8cd612013-01-14 23:53:26 +0000372 return ReadUTFBufferAndDumpToStream<UTF8>(nullptr, data_addr,
Enrico Granata06d58b02013-01-11 02:44:00 +0000373 process_sp,
374 stream,
Enrico Granatacd8cd612013-01-14 23:53:26 +0000375 'L');
Enrico Granata06d58b02013-01-11 02:44:00 +0000376 case 16:
377 // utf 16
Enrico Granatacd8cd612013-01-14 23:53:26 +0000378 return ReadUTFBufferAndDumpToStream<UTF16>(ConvertUTF16toUTF8, data_addr,
Enrico Granata06d58b02013-01-11 02:44:00 +0000379 process_sp,
380 stream,
Enrico Granatacd8cd612013-01-14 23:53:26 +0000381 'L');
Enrico Granata06d58b02013-01-11 02:44:00 +0000382 case 32:
383 // utf 32
Enrico Granatacd8cd612013-01-14 23:53:26 +0000384 return ReadUTFBufferAndDumpToStream<UTF32>(ConvertUTF32toUTF8, data_addr,
Enrico Granata06d58b02013-01-11 02:44:00 +0000385 process_sp,
386 stream,
Enrico Granatacd8cd612013-01-14 23:53:26 +0000387 'L');
388 default:
389 stream.Printf("size for wchar_t is not valid");
390 return true;
391 }
392 return true;
393}
394
395bool
396lldb_private::formatters::Char16SummaryProvider (ValueObject& valobj, Stream& stream)
397{
398 DataExtractor data;
399 valobj.GetData(data);
400
401 std::string value;
402 valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
403 if (!value.empty())
404 stream.Printf("%s ", value.c_str());
405
406 return DumpUTFBufferToStream<UTF16>(ConvertUTF16toUTF8,data,stream, 'u','\'',1);
407}
408
409bool
410lldb_private::formatters::Char32SummaryProvider (ValueObject& valobj, Stream& stream)
411{
412 DataExtractor data;
413 valobj.GetData(data);
414
415 std::string value;
416 valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
417 if (!value.empty())
418 stream.Printf("%s ", value.c_str());
419
420 return DumpUTFBufferToStream<UTF32>(ConvertUTF32toUTF8,data,stream, 'U','\'',1);
421}
422
423bool
424lldb_private::formatters::WCharSummaryProvider (ValueObject& valobj, Stream& stream)
425{
426 DataExtractor data;
427 valobj.GetData(data);
428
429 clang::ASTContext* ast = valobj.GetClangAST();
430
431 if (!ast)
432 return false;
433
434 std::string value;
435
436 uint32_t wchar_size = ClangASTType::GetClangTypeBitWidth(ast, ClangASTType::GetBasicType(ast, lldb::eBasicTypeWChar).GetOpaqueQualType());
437
438 switch (wchar_size)
439 {
440 case 8:
441 // utf 8
442 valobj.GetValueAsCString(lldb::eFormatChar, value);
443 if (!value.empty())
444 stream.Printf("%s ", value.c_str());
445 return DumpUTFBufferToStream<UTF8>(nullptr,
446 data,
447 stream,
448 'L',
449 '\'',
450 1);
451 case 16:
452 // utf 16
453 valobj.GetValueAsCString(lldb::eFormatUnicode16, value);
454 if (!value.empty())
455 stream.Printf("%s ", value.c_str());
456 return DumpUTFBufferToStream<UTF16>(ConvertUTF16toUTF8,
457 data,
458 stream,
459 'L',
460 '\'',
461 1);
462 case 32:
463 // utf 32
464 valobj.GetValueAsCString(lldb::eFormatUnicode32, value);
465 if (!value.empty())
466 stream.Printf("%s ", value.c_str());
467 return DumpUTFBufferToStream<UTF32>(ConvertUTF32toUTF8,
468 data,
469 stream,
470 'L',
471 '\'',
472 1);
Enrico Granata06d58b02013-01-11 02:44:00 +0000473 default:
474 stream.Printf("size for wchar_t is not valid");
475 return true;
476 }
477 return true;
Enrico Granataf5545f92013-01-10 22:08:35 +0000478}
479
Enrico Granatab6985792013-01-12 01:00:22 +0000480// this function extracts information from a libcxx std::basic_string<>
481// irregardless of template arguments. it reports the size (in item count not bytes)
482// and the location in memory where the string data can be found
483static bool
484ExtractLibcxxStringInfo (ValueObject& valobj,
485 ValueObjectSP &location_sp,
486 uint64_t& size)
487{
488 ValueObjectSP D(valobj.GetChildAtIndexPath({0,0,0,0}));
489 if (!D)
490 return false;
491
492 ValueObjectSP size_mode(D->GetChildAtIndexPath({1,0,0}));
493 if (!size_mode)
494 return false;
495
496 uint64_t size_mode_value(size_mode->GetValueAsUnsigned(0));
497
498 if ((size_mode_value & 1) == 0) // this means the string is in short-mode and the data is stored inline
499 {
500 ValueObjectSP s(D->GetChildAtIndex(1, true));
501 if (!s)
502 return false;
503 size = ((size_mode_value >> 1) % 256);
504 location_sp = s->GetChildAtIndex(1, true);
505 return (location_sp.get() != nullptr);
506 }
507 else
508 {
509 ValueObjectSP l(D->GetChildAtIndex(0, true));
510 if (!l)
511 return false;
512 location_sp = l->GetChildAtIndex(2, true);
513 ValueObjectSP size_vo(l->GetChildAtIndex(1, true));
514 if (!size_vo || !location_sp)
515 return false;
516 size = size_vo->GetValueAsUnsigned(0);
517 return true;
518 }
519}
520
521bool
522lldb_private::formatters::LibcxxWStringSummaryProvider (ValueObject& valobj, Stream& stream)
523{
524 uint64_t size = 0;
525 ValueObjectSP location_sp((ValueObject*)nullptr);
526 if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
527 return false;
528 if (size == 0)
529 {
530 stream.Printf("L\"\"");
531 return true;
532 }
533 if (!location_sp)
534 return false;
535 return WCharStringSummaryProvider(*location_sp.get(), stream);
536}
537
538bool
539lldb_private::formatters::LibcxxStringSummaryProvider (ValueObject& valobj, Stream& stream)
540{
541 uint64_t size = 0;
542 ValueObjectSP location_sp((ValueObject*)nullptr);
543 if (!ExtractLibcxxStringInfo(valobj, location_sp, size))
544 return false;
545 if (size == 0)
546 {
547 stream.Printf("\"\"");
548 return true;
549 }
550 if (!location_sp)
551 return false;
552 Error error;
Enrico Granata32d7ee32013-02-21 19:57:10 +0000553 if (location_sp->ReadPointedString(stream,
554 error,
555 0, // max length is decided by the settings
556 false) == 0) // do not honor array (terminates on first 0 byte even for a char[])
557 stream.Printf("\"\""); // if nothing was read, print an empty string
Enrico Granatab6985792013-01-12 01:00:22 +0000558 return error.Success();
559}
560
Enrico Granata280b30f2013-03-15 18:55:30 +0000561bool
562lldb_private::formatters::ObjCClassSummaryProvider (ValueObject& valobj, Stream& stream)
563{
564 ProcessSP process_sp = valobj.GetProcessSP();
565 if (!process_sp)
566 return false;
567
568 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
569
570 if (!runtime)
571 return false;
572
573 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj.GetValueAsUnsigned(0)));
574
575 if (!descriptor.get() || !descriptor->IsValid())
576 return false;
577
578 const char* class_name = descriptor->GetClassName().GetCString();
579
580 if (!class_name || !*class_name)
581 return false;
582
583 stream.Printf("%s",class_name);
584 return true;
585}
586
Enrico Granatacaaf0102012-09-04 18:48:21 +0000587template<bool needs_at>
588bool
Enrico Granataf91e78f2012-09-13 18:27:09 +0000589lldb_private::formatters::NSDataSummaryProvider (ValueObject& valobj, Stream& stream)
Enrico Granatacaaf0102012-09-04 18:48:21 +0000590{
591 ProcessSP process_sp = valobj.GetProcessSP();
592 if (!process_sp)
593 return false;
594
595 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
596
597 if (!runtime)
598 return false;
599
600 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
601
602 if (!descriptor.get() || !descriptor->IsValid())
603 return false;
604
605 bool is_64bit = (process_sp->GetAddressByteSize() == 8);
606 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
607
608 if (!valobj_addr)
609 return false;
610
611 uint64_t value = 0;
612
613 const char* class_name = descriptor->GetClassName().GetCString();
Enrico Granata7685a562012-09-29 00:47:43 +0000614
615 if (!class_name || !*class_name)
616 return false;
617
Enrico Granatacaaf0102012-09-04 18:48:21 +0000618 if (!strcmp(class_name,"NSConcreteData") ||
619 !strcmp(class_name,"NSConcreteMutableData") ||
620 !strcmp(class_name,"__NSCFData"))
621 {
622 uint32_t offset = (is_64bit ? 16 : 8);
623 Error error;
624 value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + offset, is_64bit ? 8 : 4, 0, error);
625 if (error.Fail())
626 return false;
627 }
628 else
629 {
Enrico Granataf91e78f2012-09-13 18:27:09 +0000630 if (!ExtractValueFromObjCExpression(valobj, "int", "length", value))
Enrico Granatacaaf0102012-09-04 18:48:21 +0000631 return false;
632 }
633
Daniel Malea5f35a4b2012-11-29 21:49:15 +0000634 stream.Printf("%s%" PRIu64 " byte%s%s",
Enrico Granatacaaf0102012-09-04 18:48:21 +0000635 (needs_at ? "@\"" : ""),
636 value,
637 (value > 1 ? "s" : ""),
638 (needs_at ? "\"" : ""));
639
640 return true;
641}
642
643bool
Enrico Granatab70c6ef2013-03-15 18:44:08 +0000644lldb_private::formatters::NSBundleSummaryProvider (ValueObject& valobj, Stream& stream)
645{
646 ProcessSP process_sp = valobj.GetProcessSP();
647 if (!process_sp)
648 return false;
649
650 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
651
652 if (!runtime)
653 return false;
654
655 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
656
657 if (!descriptor.get() || !descriptor->IsValid())
658 return false;
659
660 uint32_t ptr_size = process_sp->GetAddressByteSize();
661
662 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
663
664 if (!valobj_addr)
665 return false;
666
667 const char* class_name = descriptor->GetClassName().GetCString();
668
669 if (!class_name || !*class_name)
670 return false;
671
672 if (!strcmp(class_name,"NSBundle"))
673 {
674 uint64_t offset = 5 * ptr_size;
675 ClangASTType type(valobj.GetClangAST(),valobj.GetClangType());
676 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, type, true));
677 StreamString summary_stream;
678 bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream);
679 if (was_nsstring_ok && summary_stream.GetSize() > 0)
680 {
681 stream.Printf("%s",summary_stream.GetData());
682 return true;
683 }
684 }
685 // this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
686 // which is encoded differently and needs to be handled by running code
687 return ExtractSummaryFromObjCExpression(valobj, "NSString*", "bundlePath", stream);
688}
689
690bool
Enrico Granata5782dae2013-03-16 01:50:07 +0000691lldb_private::formatters::NSTimeZoneSummaryProvider (ValueObject& valobj, Stream& stream)
692{
693 ProcessSP process_sp = valobj.GetProcessSP();
694 if (!process_sp)
695 return false;
696
697 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
698
699 if (!runtime)
700 return false;
701
702 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
703
704 if (!descriptor.get() || !descriptor->IsValid())
705 return false;
706
707 uint32_t ptr_size = process_sp->GetAddressByteSize();
708
709 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
710
711 if (!valobj_addr)
712 return false;
713
714 const char* class_name = descriptor->GetClassName().GetCString();
715
716 if (!class_name || !*class_name)
717 return false;
718
719 if (!strcmp(class_name,"__NSTimeZone"))
720 {
721 uint64_t offset = ptr_size;
722 ClangASTType type(valobj.GetClangAST(),valobj.GetClangType());
723 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, type, true));
724 StreamString summary_stream;
725 bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream);
726 if (was_nsstring_ok && summary_stream.GetSize() > 0)
727 {
728 stream.Printf("%s",summary_stream.GetData());
729 return true;
730 }
731 }
732 return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream);
733}
734
735bool
Enrico Granatadc1df6b2013-03-16 00:50:25 +0000736lldb_private::formatters::NSNotificationSummaryProvider (ValueObject& valobj, Stream& stream)
737{
738 ProcessSP process_sp = valobj.GetProcessSP();
739 if (!process_sp)
740 return false;
741
742 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
743
744 if (!runtime)
745 return false;
746
747 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
748
749 if (!descriptor.get() || !descriptor->IsValid())
750 return false;
751
752 uint32_t ptr_size = process_sp->GetAddressByteSize();
753
754 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
755
756 if (!valobj_addr)
757 return false;
758
759 const char* class_name = descriptor->GetClassName().GetCString();
760
761 if (!class_name || !*class_name)
762 return false;
763
764 if (!strcmp(class_name,"NSConcreteNotification"))
765 {
766 uint64_t offset = ptr_size;
767 ClangASTType type(valobj.GetClangAST(),valobj.GetClangType());
768 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset, type, true));
769 StreamString summary_stream;
770 bool was_nsstring_ok = NSStringSummaryProvider(*text.get(), summary_stream);
771 if (was_nsstring_ok && summary_stream.GetSize() > 0)
772 {
773 stream.Printf("%s",summary_stream.GetData());
774 return true;
775 }
776 }
777 // this is either an unknown subclass or an NSBundle that comes from [NSBundle mainBundle]
778 // which is encoded differently and needs to be handled by running code
779 return ExtractSummaryFromObjCExpression(valobj, "NSString*", "name", stream);
780}
781
782bool
783lldb_private::formatters::NSMachPortSummaryProvider (ValueObject& valobj, Stream& stream)
784{
785 ProcessSP process_sp = valobj.GetProcessSP();
786 if (!process_sp)
787 return false;
788
789 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
790
791 if (!runtime)
792 return false;
793
794 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
795
796 if (!descriptor.get() || !descriptor->IsValid())
797 return false;
798
799 uint32_t ptr_size = process_sp->GetAddressByteSize();
800
801 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
802
803 if (!valobj_addr)
804 return false;
805
806 const char* class_name = descriptor->GetClassName().GetCString();
807
808 if (!class_name || !*class_name)
809 return false;
810
811 uint64_t port_number = 0;
812
813 do
814 {
815 if (!strcmp(class_name,"NSMachPort"))
816 {
817 uint64_t offset = (ptr_size == 4 ? 12 : 20);
818 Error error;
819 port_number = process_sp->ReadUnsignedIntegerFromMemory(offset+valobj_addr, 4, 0, error);
820 if (error.Success())
821 break;
822 }
823 if (!ExtractValueFromObjCExpression(valobj, "int", "machPort", port_number))
824 return false;
825 } while (false);
826
827 stream.Printf("mach port: %u",(uint32_t)(port_number & 0x00000000FFFFFFFF));
828 return true;
829}
830
831bool
Enrico Granatab70c6ef2013-03-15 18:44:08 +0000832lldb_private::formatters::CFBagSummaryProvider (ValueObject& valobj, Stream& stream)
833{
834 ProcessSP process_sp = valobj.GetProcessSP();
835 if (!process_sp)
836 return false;
837
838 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
839
840 if (!runtime)
841 return false;
842
843 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
844
845 if (!descriptor.get() || !descriptor->IsValid())
846 return false;
847
848 uint32_t ptr_size = process_sp->GetAddressByteSize();
849
850 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
851
852 if (!valobj_addr)
853 return false;
854
855 uint32_t count = 0;
856
857 bool is_type_ok = false; // check to see if this is a CFBag we know about
858 if (descriptor->IsCFType())
859 {
860 ConstString type_name(valobj.GetTypeName());
861 if (type_name == ConstString("__CFBag") || type_name == ConstString("const struct __CFBag"))
862 {
863 if (valobj.IsPointerType())
864 is_type_ok = true;
865 }
866 }
867
868 if (is_type_ok == false)
869 {
Enrico Granatab70c6ef2013-03-15 18:44:08 +0000870 StackFrameSP frame_sp(valobj.GetFrameSP());
871 if (!frame_sp)
872 return false;
873 ValueObjectSP count_sp;
874 StreamString expr;
875 expr.Printf("(int)CFBagGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue());
876 if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExecutionCompleted)
877 return false;
878 if (!count_sp)
879 return false;
880 count = count_sp->GetValueAsUnsigned(0);
881 }
882 else
883 {
884 uint32_t offset = 2*ptr_size+4 + valobj_addr;
885 Error error;
886 count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
887 if (error.Fail())
888 return false;
889 }
890 stream.Printf("@\"%u value%s\"",
891 count,(count == 1 ? "" : "s"));
892 return true;
893}
894
895bool
Enrico Granata5782dae2013-03-16 01:50:07 +0000896lldb_private::formatters::CFBitVectorSummaryProvider (ValueObject& valobj, Stream& stream)
897{
898 ProcessSP process_sp = valobj.GetProcessSP();
899 if (!process_sp)
900 return false;
901
902 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
903
904 if (!runtime)
905 return false;
906
907 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
908
909 if (!descriptor.get() || !descriptor->IsValid())
910 return false;
911
912 uint32_t ptr_size = process_sp->GetAddressByteSize();
913
914 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
915
916 if (!valobj_addr)
917 return false;
918
919 uint32_t count = 0;
920
921 bool is_type_ok = false; // check to see if this is a CFBag we know about
922 if (descriptor->IsCFType())
923 {
924 ConstString type_name(valobj.GetTypeName());
925 if (type_name == ConstString("__CFMutableBitVector") || type_name == ConstString("__CFBitVector") || type_name == ConstString("CFMutableBitVectorRef") || type_name == ConstString("CFBitVectorRef"))
926 {
927 if (valobj.IsPointerType())
928 is_type_ok = true;
929 }
930 }
931
932 if (is_type_ok == false)
933 return false;
934
935 Error error;
936 count = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+2*ptr_size, ptr_size, 0, error);
937 if (error.Fail())
938 return false;
939 uint64_t num_bytes = count / 8 + ((count & 7) ? 1 : 0);
940 addr_t data_ptr = process_sp->ReadPointerFromMemory(valobj_addr+2*ptr_size+2*ptr_size, error);
941 if (error.Fail())
942 return false;
943 // make sure we do not try to read huge amounts of data
944 if (num_bytes > 1024)
945 num_bytes = 1024;
946 DataBufferSP buffer_sp(new DataBufferHeap(num_bytes,0));
947 num_bytes = process_sp->ReadMemory(data_ptr, buffer_sp->GetBytes(), num_bytes, error);
948 if (error.Fail())
949 return false;
950 for (int byte_idx = 0; byte_idx < num_bytes-1; byte_idx++)
951 {
952 uint8_t byte = buffer_sp->GetBytes()[byte_idx];
953 bool bit0 = (byte & 1) == 1;
954 bool bit1 = (byte & 2) == 2;
955 bool bit2 = (byte & 4) == 4;
956 bool bit3 = (byte & 8) == 8;
957 bool bit4 = (byte & 16) == 16;
958 bool bit5 = (byte & 32) == 32;
959 bool bit6 = (byte & 64) == 64;
960 bool bit7 = (byte & 128) == 128;
961 stream.Printf("%c%c%c%c %c%c%c%c ",
962 (bit7 ? '1' : '0'),
963 (bit6 ? '1' : '0'),
964 (bit5 ? '1' : '0'),
965 (bit4 ? '1' : '0'),
966 (bit3 ? '1' : '0'),
967 (bit2 ? '1' : '0'),
968 (bit1 ? '1' : '0'),
969 (bit0 ? '1' : '0'));
970 count -= 8;
971 }
972 {
973 // print the last byte ensuring we do not print spurious bits
974 uint8_t byte = buffer_sp->GetBytes()[num_bytes-1];
975 bool bit0 = (byte & 1) == 1;
976 bool bit1 = (byte & 2) == 2;
977 bool bit2 = (byte & 4) == 4;
978 bool bit3 = (byte & 8) == 8;
979 bool bit4 = (byte & 16) == 16;
980 bool bit5 = (byte & 32) == 32;
981 bool bit6 = (byte & 64) == 64;
982 bool bit7 = (byte & 128) == 128;
983 if (count)
984 {
985 stream.Printf("%c",bit7 ? '1' : '0');
986 count -= 1;
987 }
988 if (count)
989 {
990 stream.Printf("%c",bit6 ? '1' : '0');
991 count -= 1;
992 }
993 if (count)
994 {
995 stream.Printf("%c",bit5 ? '1' : '0');
996 count -= 1;
997 }
998 if (count)
999 {
1000 stream.Printf("%c",bit4 ? '1' : '0');
1001 count -= 1;
1002 }
1003 if (count)
1004 {
1005 stream.Printf("%c",bit3 ? '1' : '0');
1006 count -= 1;
1007 }
1008 if (count)
1009 {
1010 stream.Printf("%c",bit2 ? '1' : '0');
1011 count -= 1;
1012 }
1013 if (count)
1014 {
1015 stream.Printf("%c",bit1 ? '1' : '0');
1016 count -= 1;
1017 }
1018 if (count)
1019 {
1020 stream.Printf("%c",bit0 ? '1' : '0');
1021 count -= 1;
1022 }
1023 }
1024 return true;
1025}
1026
1027bool
Enrico Granatadc1df6b2013-03-16 00:50:25 +00001028lldb_private::formatters::CFBinaryHeapSummaryProvider (ValueObject& valobj, Stream& stream)
1029{
1030 ProcessSP process_sp = valobj.GetProcessSP();
1031 if (!process_sp)
1032 return false;
1033
1034 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
1035
1036 if (!runtime)
1037 return false;
1038
1039 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
1040
1041 if (!descriptor.get() || !descriptor->IsValid())
1042 return false;
1043
1044 uint32_t ptr_size = process_sp->GetAddressByteSize();
1045
1046 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
1047
1048 if (!valobj_addr)
1049 return false;
1050
1051 uint32_t count = 0;
1052
1053 bool is_type_ok = false; // check to see if this is a CFBinaryHeap we know about
1054 if (descriptor->IsCFType())
1055 {
1056 ConstString type_name(valobj.GetTypeName());
1057 if (type_name == ConstString("__CFBinaryHeap") || type_name == ConstString("const struct __CFBinaryHeap"))
1058 {
1059 if (valobj.IsPointerType())
1060 is_type_ok = true;
1061 }
1062 }
1063
1064 if (is_type_ok == false)
1065 {
1066 StackFrameSP frame_sp(valobj.GetFrameSP());
1067 if (!frame_sp)
1068 return false;
1069 ValueObjectSP count_sp;
1070 StreamString expr;
1071 expr.Printf("(int)CFBinaryHeapGetCount((void*)0x%" PRIx64 ")",valobj.GetPointerValue());
1072 if (process_sp->GetTarget().EvaluateExpression(expr.GetData(), frame_sp.get(), count_sp) != eExecutionCompleted)
1073 return false;
1074 if (!count_sp)
1075 return false;
1076 count = count_sp->GetValueAsUnsigned(0);
1077 }
1078 else
1079 {
1080 uint32_t offset = 2*ptr_size;
1081 Error error;
1082 count = process_sp->ReadUnsignedIntegerFromMemory(offset, 4, 0, error);
1083 if (error.Fail())
1084 return false;
1085 }
1086 stream.Printf("@\"%u item%s\"",
1087 count,(count == 1 ? "" : "s"));
1088 return true;
1089}
1090
1091bool
Enrico Granata3818e6a2013-03-16 01:18:00 +00001092lldb_private::formatters::NSIndexSetSummaryProvider (ValueObject& valobj, Stream& stream)
1093{
1094 ProcessSP process_sp = valobj.GetProcessSP();
1095 if (!process_sp)
1096 return false;
1097
1098 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
1099
1100 if (!runtime)
1101 return false;
1102
1103 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
1104
1105 if (!descriptor.get() || !descriptor->IsValid())
1106 return false;
1107
1108 uint32_t ptr_size = process_sp->GetAddressByteSize();
1109
1110 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
1111
1112 if (!valobj_addr)
1113 return false;
1114
1115 const char* class_name = descriptor->GetClassName().GetCString();
1116
1117 if (!class_name || !*class_name)
1118 return false;
1119
1120 uint64_t count = 0;
1121
1122 do {
1123 if (!strcmp(class_name,"NSIndexSet") || !strcmp(class_name,"NSMutableIndexSet"))
1124 {
1125 Error error;
1126 uint32_t mode = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+ptr_size, 4, 0, error);
1127 if (error.Fail())
1128 return false;
1129 // this means the set is empty - count = 0
1130 if ((mode & 1) == 1)
1131 {
1132 count = 0;
1133 break;
1134 }
1135 if ((mode & 2) == 2)
1136 mode = 1; // this means the set only has one range
1137 else
1138 mode = 2; // this means the set has multiple ranges
1139 if (mode == 1)
1140 {
1141 count = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+3*ptr_size, ptr_size, 0, error);
1142 if (error.Fail())
1143 return false;
1144 }
1145 else
1146 {
1147 // read a pointer to the data at 2*ptr_size
1148 count = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr+2*ptr_size, ptr_size, 0, error);
1149 if (error.Fail())
1150 return false;
1151 // read the data at 2*ptr_size from the first location
1152 count = process_sp->ReadUnsignedIntegerFromMemory(count+2*ptr_size, ptr_size, 0, error);
1153 if (error.Fail())
1154 return false;
1155 }
1156 }
1157 else
1158 {
1159 if (!ExtractValueFromObjCExpression(valobj, "unsigned long long int", "count", count))
1160 return false;
1161 }
1162 } while (false);
1163 stream.Printf("%llu index%s",
1164 count,
1165 (count == 1 ? "" : "es"));
1166 return true;
1167}
1168
1169bool
Enrico Granataf91e78f2012-09-13 18:27:09 +00001170lldb_private::formatters::NSNumberSummaryProvider (ValueObject& valobj, Stream& stream)
Enrico Granatacaaf0102012-09-04 18:48:21 +00001171{
1172 ProcessSP process_sp = valobj.GetProcessSP();
1173 if (!process_sp)
1174 return false;
1175
1176 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
1177
1178 if (!runtime)
1179 return false;
1180
1181 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
1182
1183 if (!descriptor.get() || !descriptor->IsValid())
1184 return false;
1185
1186 uint32_t ptr_size = process_sp->GetAddressByteSize();
1187
1188 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
1189
1190 if (!valobj_addr)
1191 return false;
1192
1193 const char* class_name = descriptor->GetClassName().GetCString();
1194
Enrico Granata7685a562012-09-29 00:47:43 +00001195 if (!class_name || !*class_name)
1196 return false;
1197
Enrico Granatacaaf0102012-09-04 18:48:21 +00001198 if (!strcmp(class_name,"NSNumber") || !strcmp(class_name,"__NSCFNumber"))
1199 {
1200 if (descriptor->IsTagged())
1201 {
1202 // we have a call to get info and value bits in the tagged descriptor. but we prefer not to cast and replicate them
1203 int64_t value = (valobj_addr & ~0x0000000000000000FFL) >> 8;
1204 uint64_t i_bits = (valobj_addr & 0xF0) >> 4;
1205
1206 switch (i_bits)
1207 {
1208 case 0:
1209 stream.Printf("(char)%hhd",(char)value);
1210 break;
1211 case 4:
1212 stream.Printf("(short)%hd",(short)value);
1213 break;
1214 case 8:
1215 stream.Printf("(int)%d",(int)value);
1216 break;
1217 case 12:
Daniel Malea5f35a4b2012-11-29 21:49:15 +00001218 stream.Printf("(long)%" PRId64,value);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001219 break;
1220 default:
Enrico Granata3ca24b42012-12-10 19:23:00 +00001221 stream.Printf("unexpected value:(info=%" PRIu64 ", value=%" PRIu64,i_bits,value);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001222 break;
1223 }
1224 return true;
1225 }
1226 else
1227 {
1228 Error error;
1229 uint8_t data_type = (process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 1, 0, error) & 0x1F);
1230 uint64_t data_location = valobj_addr + 2*ptr_size;
1231 uint64_t value = 0;
1232 if (error.Fail())
1233 return false;
1234 switch (data_type)
1235 {
1236 case 1: // 0B00001
1237 value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 1, 0, error);
1238 if (error.Fail())
1239 return false;
1240 stream.Printf("(char)%hhd",(char)value);
1241 break;
1242 case 2: // 0B0010
1243 value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 2, 0, error);
1244 if (error.Fail())
1245 return false;
1246 stream.Printf("(short)%hd",(short)value);
1247 break;
1248 case 3: // 0B0011
1249 value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
1250 if (error.Fail())
1251 return false;
1252 stream.Printf("(int)%d",(int)value);
1253 break;
1254 case 17: // 0B10001
1255 data_location += 8;
1256 case 4: // 0B0100
1257 value = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
1258 if (error.Fail())
1259 return false;
Daniel Malea5f35a4b2012-11-29 21:49:15 +00001260 stream.Printf("(long)%" PRId64,value);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001261 break;
1262 case 5: // 0B0101
1263 {
1264 uint32_t flt_as_int = process_sp->ReadUnsignedIntegerFromMemory(data_location, 4, 0, error);
1265 if (error.Fail())
1266 return false;
1267 float flt_value = *((float*)&flt_as_int);
1268 stream.Printf("(float)%f",flt_value);
1269 break;
1270 }
1271 case 6: // 0B0110
1272 {
1273 uint64_t dbl_as_lng = process_sp->ReadUnsignedIntegerFromMemory(data_location, 8, 0, error);
1274 if (error.Fail())
1275 return false;
1276 double dbl_value = *((double*)&dbl_as_lng);
1277 stream.Printf("(double)%g",dbl_value);
1278 break;
1279 }
1280 default:
1281 stream.Printf("absurd: dt=%d",data_type);
1282 break;
1283 }
1284 return true;
1285 }
1286 }
1287 else
1288 {
Enrico Granataea687532013-02-15 23:38:37 +00001289 return ExtractSummaryFromObjCExpression(valobj, "NSString*", "stringValue", stream);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001290 }
1291}
1292
Enrico Granataf3a217e2013-02-21 20:31:18 +00001293static bool
1294ReadAsciiBufferAndDumpToStream (lldb::addr_t location,
1295 lldb::ProcessSP& process_sp,
1296 Stream& dest,
1297 size_t size = 0,
1298 Error* error = NULL,
1299 size_t *data_read = NULL,
1300 char prefix_token = '@',
1301 char quote = '"')
1302{
1303 Error my_error;
1304 size_t my_data_read;
1305 if (!process_sp || location == 0)
1306 return false;
1307
1308 if (size == 0)
1309 size = process_sp->GetTarget().GetMaximumSizeOfStringSummary();
1310
1311 lldb::DataBufferSP buffer_sp(new DataBufferHeap(size,0));
1312
1313 my_data_read = process_sp->ReadCStringFromMemory(location, (char*)buffer_sp->GetBytes(), size, my_error);
1314
1315 if (error)
1316 *error = my_error;
1317 if (data_read)
1318 *data_read = my_data_read;
1319
1320 if (my_error.Fail())
1321 return false;
1322 if (my_data_read)
1323 dest.Printf("%c%c%s%c",prefix_token,quote,(char*)buffer_sp->GetBytes(),quote);
1324
1325 return true;
1326}
1327
Enrico Granatacaaf0102012-09-04 18:48:21 +00001328bool
Enrico Granataf91e78f2012-09-13 18:27:09 +00001329lldb_private::formatters::NSStringSummaryProvider (ValueObject& valobj, Stream& stream)
Enrico Granatacaaf0102012-09-04 18:48:21 +00001330{
1331 ProcessSP process_sp = valobj.GetProcessSP();
1332 if (!process_sp)
1333 return false;
1334
1335 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
1336
1337 if (!runtime)
1338 return false;
1339
1340 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
1341
1342 if (!descriptor.get() || !descriptor->IsValid())
1343 return false;
1344
1345 uint32_t ptr_size = process_sp->GetAddressByteSize();
1346
1347 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
1348
1349 if (!valobj_addr)
1350 return false;
1351
1352 const char* class_name = descriptor->GetClassName().GetCString();
1353
Enrico Granata25c9ade2012-09-29 00:45:53 +00001354 if (!class_name || !*class_name)
1355 return false;
1356
Enrico Granatacaaf0102012-09-04 18:48:21 +00001357 uint64_t info_bits_location = valobj_addr + ptr_size;
1358 if (process_sp->GetByteOrder() != lldb::eByteOrderLittle)
1359 info_bits_location += 3;
1360
Enrico Granataf3a217e2013-02-21 20:31:18 +00001361 Error error;
Enrico Granatacaaf0102012-09-04 18:48:21 +00001362
1363 uint8_t info_bits = process_sp->ReadUnsignedIntegerFromMemory(info_bits_location, 1, 0, error);
1364 if (error.Fail())
1365 return false;
1366
1367 bool is_mutable = (info_bits & 1) == 1;
1368 bool is_inline = (info_bits & 0x60) == 0;
1369 bool has_explicit_length = (info_bits & (1 | 4)) != 4;
1370 bool is_unicode = (info_bits & 0x10) == 0x10;
1371 bool is_special = strcmp(class_name,"NSPathStore2") == 0;
1372
1373 if (strcmp(class_name,"NSString") &&
1374 strcmp(class_name,"CFStringRef") &&
1375 strcmp(class_name,"CFMutableStringRef") &&
1376 strcmp(class_name,"__NSCFConstantString") &&
1377 strcmp(class_name,"__NSCFString") &&
1378 strcmp(class_name,"NSCFConstantString") &&
1379 strcmp(class_name,"NSCFString") &&
1380 strcmp(class_name,"NSPathStore2"))
1381 {
Enrico Granataf3a217e2013-02-21 20:31:18 +00001382 // not one of us - but tell me class name
1383 stream.Printf("class name = %s",class_name);
1384 return true;
Enrico Granatacaaf0102012-09-04 18:48:21 +00001385 }
1386
1387 if (is_mutable)
1388 {
1389 uint64_t location = 2 * ptr_size + valobj_addr;
1390 location = process_sp->ReadPointerFromMemory(location, error);
1391 if (error.Fail())
1392 return false;
1393 if (has_explicit_length and is_unicode)
Enrico Granatacd8cd612013-01-14 23:53:26 +00001394 return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8,location, process_sp, stream, '@');
Enrico Granatacaaf0102012-09-04 18:48:21 +00001395 else
Enrico Granataf3a217e2013-02-21 20:31:18 +00001396 return ReadAsciiBufferAndDumpToStream(location+1,process_sp,stream);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001397 }
1398 else if (is_inline && has_explicit_length && !is_unicode && !is_special && !is_mutable)
1399 {
1400 uint64_t location = 3 * ptr_size + valobj_addr;
Enrico Granataf3a217e2013-02-21 20:31:18 +00001401 return ReadAsciiBufferAndDumpToStream(location,process_sp,stream);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001402 }
1403 else if (is_unicode)
1404 {
Enrico Granataf3a217e2013-02-21 20:31:18 +00001405 uint64_t location = valobj_addr + 2*ptr_size;
Enrico Granatacaaf0102012-09-04 18:48:21 +00001406 if (is_inline)
1407 {
1408 if (!has_explicit_length)
1409 {
1410 stream.Printf("found new combo");
1411 return true;
1412 }
1413 else
1414 location += ptr_size;
1415 }
1416 else
1417 {
1418 location = process_sp->ReadPointerFromMemory(location, error);
1419 if (error.Fail())
1420 return false;
1421 }
Enrico Granatacd8cd612013-01-14 23:53:26 +00001422 return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8, location, process_sp, stream, '@');
Enrico Granatacaaf0102012-09-04 18:48:21 +00001423 }
1424 else if (is_special)
1425 {
1426 uint64_t location = valobj_addr + (ptr_size == 8 ? 12 : 8);
Enrico Granatacd8cd612013-01-14 23:53:26 +00001427 return ReadUTFBufferAndDumpToStream<UTF16> (ConvertUTF16toUTF8, location, process_sp, stream, '@');
Enrico Granatacaaf0102012-09-04 18:48:21 +00001428 }
1429 else if (is_inline)
1430 {
Enrico Granataf3a217e2013-02-21 20:31:18 +00001431 uint64_t location = valobj_addr + 2*ptr_size;
Enrico Granatacaaf0102012-09-04 18:48:21 +00001432 if (!has_explicit_length)
1433 location++;
Enrico Granataf3a217e2013-02-21 20:31:18 +00001434 return ReadAsciiBufferAndDumpToStream(location,process_sp,stream);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001435 }
1436 else
1437 {
Enrico Granataf3a217e2013-02-21 20:31:18 +00001438 uint64_t location = valobj_addr + 2*ptr_size;
Enrico Granatacaaf0102012-09-04 18:48:21 +00001439 location = process_sp->ReadPointerFromMemory(location, error);
1440 if (error.Fail())
1441 return false;
Enrico Granataf3a217e2013-02-21 20:31:18 +00001442 return ReadAsciiBufferAndDumpToStream(location,process_sp,stream);
Enrico Granatacaaf0102012-09-04 18:48:21 +00001443 }
1444
1445 stream.Printf("class name = %s",class_name);
1446 return true;
1447
1448}
1449
Enrico Granata9abbfba2012-10-03 23:53:45 +00001450bool
Enrico Granatadcffc1a2013-02-08 01:55:46 +00001451lldb_private::formatters::NSAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream)
1452{
1453 TargetSP target_sp(valobj.GetTargetSP());
1454 if (!target_sp)
1455 return false;
1456 uint32_t addr_size = target_sp->GetArchitecture().GetAddressByteSize();
1457 uint64_t pointee = valobj.GetValueAsUnsigned(0);
1458 if (!pointee)
1459 return false;
1460 pointee += addr_size;
1461 ClangASTType type(valobj.GetClangAST(),valobj.GetClangType());
1462 ExecutionContext exe_ctx(target_sp,false);
1463 ValueObjectSP child_ptr_sp(valobj.CreateValueObjectFromAddress("string_ptr", pointee, exe_ctx, type));
1464 if (!child_ptr_sp)
1465 return false;
1466 DataExtractor data;
1467 child_ptr_sp->GetData(data);
1468 ValueObjectSP child_sp(child_ptr_sp->CreateValueObjectFromData("string_data", data, exe_ctx, type));
1469 child_sp->GetValueAsUnsigned(0);
1470 if (child_sp)
1471 return NSStringSummaryProvider(*child_sp, stream);
1472 return false;
1473}
1474
1475bool
1476lldb_private::formatters::NSMutableAttributedStringSummaryProvider (ValueObject& valobj, Stream& stream)
1477{
1478 return NSAttributedStringSummaryProvider(valobj, stream);
1479}
1480
1481bool
Enrico Granata9abbfba2012-10-03 23:53:45 +00001482lldb_private::formatters::RuntimeSpecificDescriptionSummaryProvider (ValueObject& valobj, Stream& stream)
1483{
1484 stream.Printf("%s",valobj.GetObjectDescription());
1485 return true;
1486}
1487
Enrico Granatadb054912012-10-29 21:18:03 +00001488bool
Enrico Granata979c4b52013-02-08 19:28:04 +00001489lldb_private::formatters::NSURLSummaryProvider (ValueObject& valobj, Stream& stream)
1490{
1491 ProcessSP process_sp = valobj.GetProcessSP();
1492 if (!process_sp)
1493 return false;
1494
1495 ObjCLanguageRuntime* runtime = (ObjCLanguageRuntime*)process_sp->GetLanguageRuntime(lldb::eLanguageTypeObjC);
1496
1497 if (!runtime)
1498 return false;
1499
1500 ObjCLanguageRuntime::ClassDescriptorSP descriptor(runtime->GetClassDescriptor(valobj));
1501
1502 if (!descriptor.get() || !descriptor->IsValid())
1503 return false;
1504
1505 uint32_t ptr_size = process_sp->GetAddressByteSize();
1506
1507 lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
1508
1509 if (!valobj_addr)
1510 return false;
1511
1512 const char* class_name = descriptor->GetClassName().GetCString();
1513
1514 if (!class_name || !*class_name)
1515 return false;
1516
1517 if (strcmp(class_name, "NSURL") == 0)
1518 {
1519 uint64_t offset_text = ptr_size + ptr_size + 8; // ISA + pointer + 8 bytes of data (even on 32bit)
1520 uint64_t offset_base = offset_text + ptr_size;
1521 ClangASTType type(valobj.GetClangAST(),valobj.GetClangType());
1522 ValueObjectSP text(valobj.GetSyntheticChildAtOffset(offset_text, type, true));
1523 ValueObjectSP base(valobj.GetSyntheticChildAtOffset(offset_base, type, true));
Enrico Granata2fd26152013-02-08 23:54:46 +00001524 if (!text)
Enrico Granata979c4b52013-02-08 19:28:04 +00001525 return false;
1526 if (text->GetValueAsUnsigned(0) == 0)
1527 return false;
1528 StreamString summary;
1529 if (!NSStringSummaryProvider(*text, summary))
1530 return false;
Enrico Granata2fd26152013-02-08 23:54:46 +00001531 if (base && base->GetValueAsUnsigned(0))
Enrico Granata979c4b52013-02-08 19:28:04 +00001532 {
1533 if (summary.GetSize() > 0)
1534 summary.GetString().resize(summary.GetSize()-1);
1535 summary.Printf(" -- ");
1536 StreamString base_summary;
Enrico Granata2fd26152013-02-08 23:54:46 +00001537 if (NSURLSummaryProvider(*base, base_summary) && base_summary.GetSize() > 0)
Enrico Granata979c4b52013-02-08 19:28:04 +00001538 summary.Printf("%s",base_summary.GetSize() > 2 ? base_summary.GetData() + 2 : base_summary.GetData());
1539 }
1540 if (summary.GetSize())
1541 {
1542 stream.Printf("%s",summary.GetData());
1543 return true;
1544 }
1545 }
1546 else
1547 {
Enrico Granataea687532013-02-15 23:38:37 +00001548 return ExtractSummaryFromObjCExpression(valobj, "NSString*", "description", stream);
Enrico Granata979c4b52013-02-08 19:28:04 +00001549 }
1550 return false;
1551}
1552
1553bool
Enrico Granatadb054912012-10-29 21:18:03 +00001554lldb_private::formatters::ObjCBOOLSummaryProvider (ValueObject& valobj, Stream& stream)
1555{
1556 const uint32_t type_info = ClangASTContext::GetTypeInfo(valobj.GetClangType(),
1557 valobj.GetClangAST(),
1558 NULL);
1559
1560 ValueObjectSP real_guy_sp = valobj.GetSP();
1561
1562 if (type_info & ClangASTContext::eTypeIsPointer)
1563 {
1564 Error err;
1565 real_guy_sp = valobj.Dereference(err);
1566 if (err.Fail() || !real_guy_sp)
1567 return false;
1568 }
1569 else if (type_info & ClangASTContext::eTypeIsReference)
1570 {
1571 real_guy_sp = valobj.GetChildAtIndex(0, true);
1572 if (!real_guy_sp)
1573 return false;
1574 }
1575 uint64_t value = real_guy_sp->GetValueAsUnsigned(0);
1576 if (value == 0)
1577 {
1578 stream.Printf("NO");
1579 return true;
1580 }
1581 stream.Printf("YES");
1582 return true;
1583}
1584
1585template <bool is_sel_ptr>
1586bool
1587lldb_private::formatters::ObjCSELSummaryProvider (ValueObject& valobj, Stream& stream)
1588{
Enrico Granata1f9df782013-02-15 00:06:04 +00001589 lldb::ValueObjectSP valobj_sp;
Enrico Granatadb054912012-10-29 21:18:03 +00001590
Enrico Granata1f9df782013-02-15 00:06:04 +00001591 if (!valobj.GetClangAST())
Enrico Granatadb054912012-10-29 21:18:03 +00001592 return false;
Enrico Granata1f9df782013-02-15 00:06:04 +00001593 void* char_opaque_type = valobj.GetClangAST()->CharTy.getAsOpaquePtr();
1594 if (!char_opaque_type)
1595 return false;
1596 ClangASTType charstar(valobj.GetClangAST(),ClangASTType::GetPointerType(valobj.GetClangAST(), char_opaque_type));
1597
Enrico Granatadb054912012-10-29 21:18:03 +00001598 ExecutionContext exe_ctx(valobj.GetExecutionContextRef());
1599
Enrico Granata1f9df782013-02-15 00:06:04 +00001600 if (is_sel_ptr)
1601 {
1602 lldb::addr_t data_address = valobj.GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
1603 if (data_address == LLDB_INVALID_ADDRESS)
1604 return false;
1605 valobj_sp = ValueObject::CreateValueObjectFromAddress("text", data_address, exe_ctx, charstar);
1606 }
1607 else
1608 {
1609 DataExtractor data;
1610 valobj.GetData(data);
1611 valobj_sp = ValueObject::CreateValueObjectFromData("text", data, exe_ctx, charstar);
1612 }
Enrico Granatadb054912012-10-29 21:18:03 +00001613
Enrico Granata1f9df782013-02-15 00:06:04 +00001614 if (!valobj_sp)
1615 return false;
Enrico Granatadb054912012-10-29 21:18:03 +00001616
1617 stream.Printf("%s",valobj_sp->GetSummaryAsCString());
1618 return true;
1619}
1620
Greg Clayton36da2aa2013-01-25 18:06:21 +00001621size_t
Enrico Granataea687532013-02-15 23:38:37 +00001622lldb_private::formatters::ExtractIndexFromString (const char* item_name)
Enrico Granataf91e78f2012-09-13 18:27:09 +00001623{
1624 if (!item_name || !*item_name)
1625 return UINT32_MAX;
1626 if (*item_name != '[')
1627 return UINT32_MAX;
1628 item_name++;
Enrico Granataea687532013-02-15 23:38:37 +00001629 char* endptr = NULL;
1630 unsigned long int idx = ::strtoul(item_name, &endptr, 0);
1631 if (idx == 0 && endptr == item_name)
Enrico Granataf91e78f2012-09-13 18:27:09 +00001632 return UINT32_MAX;
Enrico Granataea687532013-02-15 23:38:37 +00001633 if (idx == ULONG_MAX)
Enrico Granataf91e78f2012-09-13 18:27:09 +00001634 return UINT32_MAX;
1635 return idx;
1636}
1637
Enrico Granata32d7ee32013-02-21 19:57:10 +00001638lldb_private::formatters::VectorIteratorSyntheticFrontEnd::VectorIteratorSyntheticFrontEnd (lldb::ValueObjectSP valobj_sp,
1639 ConstString item_name) :
Enrico Granata689696c2013-02-04 22:54:42 +00001640SyntheticChildrenFrontEnd(*valobj_sp.get()),
1641m_exe_ctx_ref(),
Enrico Granata32d7ee32013-02-21 19:57:10 +00001642m_item_name(item_name),
1643m_item_sp()
Enrico Granata689696c2013-02-04 22:54:42 +00001644{
1645 if (valobj_sp)
1646 Update();
Enrico Granata689696c2013-02-04 22:54:42 +00001647}
1648
Enrico Granata689696c2013-02-04 22:54:42 +00001649bool
Enrico Granata32d7ee32013-02-21 19:57:10 +00001650lldb_private::formatters::VectorIteratorSyntheticFrontEnd::Update()
Enrico Granata689696c2013-02-04 22:54:42 +00001651{
1652 ValueObjectSP valobj_sp = m_backend.GetSP();
1653 if (!valobj_sp)
1654 return false;
Enrico Granata32d7ee32013-02-21 19:57:10 +00001655
Enrico Granata689696c2013-02-04 22:54:42 +00001656 if (!valobj_sp)
1657 return false;
Enrico Granata32d7ee32013-02-21 19:57:10 +00001658
1659 ValueObjectSP item_ptr(valobj_sp->GetChildMemberWithName(m_item_name,true));
1660 if (!item_ptr)
1661 return false;
1662 if (item_ptr->GetValueAsUnsigned(0) == 0)
1663 return false;
1664 Error err;
Enrico Granata689696c2013-02-04 22:54:42 +00001665 m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
Enrico Granata32d7ee32013-02-21 19:57:10 +00001666 m_item_sp = ValueObject::CreateValueObjectFromAddress("item", item_ptr->GetValueAsUnsigned(0), m_exe_ctx_ref, ClangASTType(item_ptr->GetClangAST(),ClangASTType::GetPointeeType(item_ptr->GetClangType())));
1667 if (err.Fail())
1668 m_item_sp.reset();
1669 return (m_item_sp.get() != NULL);
1670}
Enrico Granata689696c2013-02-04 22:54:42 +00001671
Enrico Granata32d7ee32013-02-21 19:57:10 +00001672size_t
1673lldb_private::formatters::VectorIteratorSyntheticFrontEnd::CalculateNumChildren ()
1674{
1675 return 1;
1676}
Enrico Granata689696c2013-02-04 22:54:42 +00001677
Enrico Granata32d7ee32013-02-21 19:57:10 +00001678lldb::ValueObjectSP
1679lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetChildAtIndex (size_t idx)
1680{
1681 if (idx == 0)
1682 return m_item_sp;
1683 return lldb::ValueObjectSP();
Enrico Granata689696c2013-02-04 22:54:42 +00001684}
1685
1686bool
Enrico Granata32d7ee32013-02-21 19:57:10 +00001687lldb_private::formatters::VectorIteratorSyntheticFrontEnd::MightHaveChildren ()
Enrico Granata689696c2013-02-04 22:54:42 +00001688{
1689 return true;
1690}
1691
1692size_t
Enrico Granata32d7ee32013-02-21 19:57:10 +00001693lldb_private::formatters::VectorIteratorSyntheticFrontEnd::GetIndexOfChildWithName (const ConstString &name)
Enrico Granata689696c2013-02-04 22:54:42 +00001694{
Enrico Granata32d7ee32013-02-21 19:57:10 +00001695 if (name == ConstString("item"))
1696 return 0;
1697 return UINT32_MAX;
Enrico Granata689696c2013-02-04 22:54:42 +00001698}
1699
Enrico Granata32d7ee32013-02-21 19:57:10 +00001700lldb_private::formatters::VectorIteratorSyntheticFrontEnd::~VectorIteratorSyntheticFrontEnd ()
Enrico Granata689696c2013-02-04 22:54:42 +00001701{
Enrico Granata689696c2013-02-04 22:54:42 +00001702}
1703
Enrico Granatacaaf0102012-09-04 18:48:21 +00001704template bool
Enrico Granataf91e78f2012-09-13 18:27:09 +00001705lldb_private::formatters::NSDataSummaryProvider<true> (ValueObject&, Stream&) ;
1706
1707template bool
1708lldb_private::formatters::NSDataSummaryProvider<false> (ValueObject&, Stream&) ;
Enrico Granatadb054912012-10-29 21:18:03 +00001709
1710template bool
1711lldb_private::formatters::ObjCSELSummaryProvider<true> (ValueObject&, Stream&) ;
1712
1713template bool
1714lldb_private::formatters::ObjCSELSummaryProvider<false> (ValueObject&, Stream&) ;