forked from OSchip/llvm-project
Fixing some of the new Python formatters to report '1 object' instead of '1 objects'
llvm-svn: 152186
This commit is contained in:
parent
8db462042c
commit
eb06e25242
|
@ -160,12 +160,14 @@ def CFArray_SummaryProvider (valobj,dict):
|
|||
provider = NSArray_SynthProvider(valobj,dict);
|
||||
if provider.invalid == False:
|
||||
try:
|
||||
summary = str(provider.num_children());
|
||||
summary = int(provider.num_children());
|
||||
except:
|
||||
summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid array here'
|
||||
return summary + " objects"
|
||||
else:
|
||||
summary = str(summary) + (" objects" if summary > 1 else " object")
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
|
|
|
@ -119,9 +119,11 @@ def CFBag_SummaryProvider (valobj,dict):
|
|||
else:
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x1fff000000000000
|
||||
if summary == 1:
|
||||
return '1 item'
|
||||
return str(summary) + " items"
|
||||
if summary == 1:
|
||||
summary = '1 item'
|
||||
else:
|
||||
summary = str(summary) + ' items'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
|
|
|
@ -113,9 +113,11 @@ def CFBinaryHeap_SummaryProvider (valobj,dict):
|
|||
else:
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x1fff000000000000
|
||||
if summary == 1:
|
||||
return '1 item'
|
||||
return str(summary) + " items"
|
||||
if summary == 1:
|
||||
return '1 item'
|
||||
else:
|
||||
summary = str(summary) + ' items'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
|
|
|
@ -176,12 +176,12 @@ def CFDictionary_SummaryProvider (valobj,dict):
|
|||
provider = GetSummary_Impl(valobj);
|
||||
if provider != None:
|
||||
try:
|
||||
summary = str(provider.num_children());
|
||||
summary = provider.num_children();
|
||||
except:
|
||||
summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid dictionary here'
|
||||
return summary + " key/value pairs"
|
||||
return str(summary) + (" key/value pairs" if summary > 1 else " key/value pair")
|
||||
return ''
|
||||
|
||||
def CFDictionary_SummaryProvider2 (valobj,dict):
|
||||
|
@ -193,10 +193,12 @@ def CFDictionary_SummaryProvider2 (valobj,dict):
|
|||
summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid dictionary here'
|
||||
else:
|
||||
# needed on OSX Mountain Lion
|
||||
elif provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x0f1f000000000000
|
||||
return str(summary) + " key/value pairs"
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = summary & ~0x0f1f000000000000
|
||||
summary = str(summary) + (" key/value pairs" if summary > 1 else " key/value pair")
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
|
|
|
@ -103,9 +103,12 @@ def NSData_SummaryProvider (valobj,dict):
|
|||
summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid data here'
|
||||
if summary == 1:
|
||||
return '1 byte'
|
||||
return str(summary) + " bytes"
|
||||
else:
|
||||
if summary == 1:
|
||||
summary = '1 byte'
|
||||
else:
|
||||
summary = str(summary) + ' bytes'
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def __lldb_init_module(debugger,dict):
|
||||
|
|
|
@ -121,7 +121,7 @@ def NSIndexSet_SummaryProvider (valobj,dict):
|
|||
if summary == None:
|
||||
summary = 'no valid set here'
|
||||
else:
|
||||
summary = str(summary) + ' objects'
|
||||
summary = str(summary) + (' objects' if summary > 1 else ' object')
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
|
|
@ -203,7 +203,9 @@ def NSSet_SummaryProvider (valobj,dict):
|
|||
# summary = None
|
||||
if summary == None:
|
||||
summary = 'no valid set here'
|
||||
return str(summary) + ' objects'
|
||||
else:
|
||||
summary = str(summary) + (' objects' if summary > 1 else ' object')
|
||||
return summary
|
||||
return ''
|
||||
|
||||
def NSSet_SummaryProvider2 (valobj,dict):
|
||||
|
@ -222,8 +224,9 @@ def NSSet_SummaryProvider2 (valobj,dict):
|
|||
summary = 'no valid set here'
|
||||
else:
|
||||
if provider.sys_params.is_64_bit:
|
||||
summary = int(summary) & ~0x1fff000000000000
|
||||
return str(summary) + ' objects'
|
||||
summary = summary & ~0x1fff000000000000
|
||||
summary = str(summary) + (' objects' if summary > 1 else ' object')
|
||||
return summary
|
||||
return ''
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
OBJC_SOURCES := main.m
|
||||
|
||||
CFLAGS_EXTRAS += -w
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
||||
|
||||
LDFLAGS += -framework Foundation
|
|
@ -0,0 +1,107 @@
|
|||
"""
|
||||
Test lldb data formatter subsystem.
|
||||
"""
|
||||
|
||||
import os, time
|
||||
import unittest2
|
||||
import lldb
|
||||
from lldbtest import *
|
||||
import datetime
|
||||
|
||||
class DataFormatterOneIsSingularTestCase(TestBase):
|
||||
|
||||
mydir = os.path.join("functionalities", "data-formatter", "rdar-3534688")
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
def test_one_is_singular_with_dsym_and_run_command(self):
|
||||
"""Test that 1 item is not as reported as 1 items."""
|
||||
self.buildDsym()
|
||||
self.oneness_data_formatter_commands()
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
def test_one_is_singular_with_dwarf_and_run_command(self):
|
||||
"""Test that 1 item is not as reported as 1 items."""
|
||||
self.buildDwarf()
|
||||
self.oneness_data_formatter_commands()
|
||||
|
||||
def setUp(self):
|
||||
# Call super's setUp().
|
||||
TestBase.setUp(self)
|
||||
# Find the line number to break at.
|
||||
self.line = line_number('main.m', '// Set break point at this line.')
|
||||
|
||||
def oneness_data_formatter_commands(self):
|
||||
"""Test that 1 item is not as reported as 1 items."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
self.expect("breakpoint set -f main.m -l %d" % self.line,
|
||||
BREAKPOINT_CREATED,
|
||||
startstr = "Breakpoint created: 1: file ='main.m', line = %d, locations = 1" %
|
||||
self.line)
|
||||
|
||||
self.runCmd("run", RUN_SUCCEEDED)
|
||||
|
||||
# The stop reason of the thread should be breakpoint.
|
||||
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
|
||||
substrs = ['stopped',
|
||||
'stop reason = breakpoint'])
|
||||
|
||||
# This is the function to remove the custom formats in order to have a
|
||||
# clean slate for the next test case.
|
||||
def cleanup():
|
||||
self.runCmd('type format clear', check=False)
|
||||
self.runCmd('type summary clear', check=False)
|
||||
self.runCmd('type synth clear', check=False)
|
||||
self.runCmd('type category disable CoreFoundation', check=False)
|
||||
self.runCmd('type category disable CoreGraphics', check=False)
|
||||
self.runCmd('type category disable CoreServices', check=False)
|
||||
self.runCmd('type category disable AppKit', check=False)
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
# Now enable AppKit and check we are displaying Cocoa classes correctly
|
||||
self.runCmd("type category enable AppKit")
|
||||
self.expect('frame variable key',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable key', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable value',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable value', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable dict',
|
||||
substrs = ['1 key/value pair'])
|
||||
self.expect('frame variable dict', matching=False,
|
||||
substrs = ['1 key/value pairs'])
|
||||
self.expect('frame variable mutable_bag_ref',
|
||||
substrs = ['1 item'])
|
||||
self.expect('frame variable mutable_bag_ref', matching=False,
|
||||
substrs = ['1 items'])
|
||||
self.expect('frame variable nscounted_set',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable nscounted_set', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable imset',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable imset', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable binheap_ref',
|
||||
substrs = ['1 item'])
|
||||
self.expect('frame variable binheap_ref', matching=False,
|
||||
substrs = ['1 items'])
|
||||
self.expect('frame variable nsset',
|
||||
substrs = ['1 object'])
|
||||
self.expect('frame variable nsset', matching=False,
|
||||
substrs = ['1 objects'])
|
||||
self.expect('frame variable immutableData',
|
||||
substrs = ['1 byte'])
|
||||
self.expect('frame variable immutableData', matching=False,
|
||||
substrs = ['1 bytes'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
|
@ -0,0 +1,42 @@
|
|||
//===-- main.m ------------------------------------------------*- ObjC -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
||||
NSArray* key = [NSArray arrayWithObjects:@"foo",nil];
|
||||
NSArray* value = [NSArray arrayWithObjects:@"key",nil];
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObjects:value forKeys:key];
|
||||
|
||||
CFMutableBagRef mutable_bag_ref = CFBagCreateMutable(NULL, 15, NULL);
|
||||
CFBagSetValue(mutable_bag_ref, CFSTR("Hello world"));
|
||||
|
||||
NSCountedSet *nscounted_set = [[NSCountedSet alloc] initWithCapacity:5];
|
||||
[nscounted_set addObject:@"foo"];
|
||||
|
||||
NSMutableIndexSet *imset = [[NSMutableIndexSet alloc] init];
|
||||
[imset addIndex:4];
|
||||
|
||||
CFBinaryHeapRef binheap_ref = CFBinaryHeapCreate(NULL, 15, &kCFStringBinaryHeapCallBacks, NULL);
|
||||
CFBinaryHeapAddValue(binheap_ref, CFSTR("Hello world"));
|
||||
|
||||
NSSet* nsset = [[NSSet alloc] initWithObjects:@"foo",nil];
|
||||
|
||||
NSData *immutableData = [[NSData alloc] initWithBytes:"HELLO" length:1];
|
||||
|
||||
|
||||
[pool drain];// Set break point at this line.
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue