forked from OSchip/llvm-project
<rdar://problem/11773899> Formatters for BOOL* and BOOL&
llvm-svn: 160181
This commit is contained in:
parent
4ed7ef1f72
commit
4b7b5aa0bc
lldb
examples/summaries
source/Core
test/functionalities/data-formatter/rdar-11773899
|
@ -2,8 +2,15 @@
|
|||
# to be generated fit into this file
|
||||
|
||||
def BOOL_SummaryProvider (valobj,dict):
|
||||
if not (valobj.IsValid()):
|
||||
return "<invalid>"
|
||||
if valobj.GetValueAsUnsigned() == 0:
|
||||
return "NO"
|
||||
else:
|
||||
return "YES"
|
||||
|
||||
|
||||
def BOOLRef_SummaryProvider (valobj, dict):
|
||||
return BOOL_SummaryProvider (valobj.GetChildAtIndex(0),dict)
|
||||
|
||||
def BOOLPtr_SummaryProvider (valobj,dict):
|
||||
return BOOL_SummaryProvider (valobj.Dereference(),dict)
|
||||
|
|
|
@ -884,8 +884,8 @@ FormatManager::LoadObjCFormatters()
|
|||
{
|
||||
TypeSummaryImpl::Flags objc_flags;
|
||||
objc_flags.SetCascades(false)
|
||||
.SetSkipPointers(false)
|
||||
.SetSkipReferences(false)
|
||||
.SetSkipPointers(true)
|
||||
.SetSkipReferences(true)
|
||||
.SetDontShowChildren(true)
|
||||
.SetDontShowValue(true)
|
||||
.SetShowMembersOneLiner(false)
|
||||
|
@ -897,6 +897,18 @@ FormatManager::LoadObjCFormatters()
|
|||
TypeCategoryImpl::SharedPointer objc_category_sp = GetCategory(m_objc_category_name);
|
||||
objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL"),
|
||||
ObjC_BOOL_summary);
|
||||
|
||||
lldb::TypeSummaryImplSP ObjC_BOOLRef_summary(new ScriptSummaryFormat(objc_flags,
|
||||
"lldb.formatters.objc.objc.BOOLRef_SummaryProvider",
|
||||
""));
|
||||
objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL &"),
|
||||
ObjC_BOOLRef_summary);
|
||||
lldb::TypeSummaryImplSP ObjC_BOOLPtr_summary(new ScriptSummaryFormat(objc_flags,
|
||||
"lldb.formatters.objc.objc.BOOLPtr_SummaryProvider",
|
||||
""));
|
||||
objc_category_sp->GetSummaryNavigator()->Add(ConstString("BOOL *"),
|
||||
ObjC_BOOLPtr_summary);
|
||||
|
||||
|
||||
// we need to skip pointers here since we are special casing a SEL* when retrieving its value
|
||||
objc_flags.SetSkipPointers(true);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
LEVEL = ../../../make
|
||||
|
||||
OBJCXX_SOURCES := main.mm
|
||||
|
||||
CFLAGS_EXTRAS += -w
|
||||
|
||||
include $(LEVEL)/Makefile.rules
|
||||
|
||||
LDFLAGS += -framework Foundation
|
|
@ -0,0 +1,86 @@
|
|||
"""
|
||||
Test lldb data formatter subsystem.
|
||||
"""
|
||||
|
||||
import os, time
|
||||
import unittest2
|
||||
import lldb
|
||||
from lldbtest import *
|
||||
import datetime
|
||||
|
||||
class DataFormatterBoolRefPtr(TestBase):
|
||||
|
||||
mydir = os.path.join("functionalities", "data-formatter", "rdar-11773899")
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
@dsym_test
|
||||
def test_boolrefptr_with_dsym_and_run_command(self):
|
||||
"""Test the formatters we use for BOOL& and BOOL* in Objective-C."""
|
||||
self.buildDsym()
|
||||
self.boolrefptr_data_formatter_commands()
|
||||
|
||||
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
||||
@dwarf_test
|
||||
def test_boolrefptr_with_dwarf_and_run_command(self):
|
||||
"""Test the formatters we use for BOOL& and BOOL* in Objective-C."""
|
||||
self.buildDwarf()
|
||||
self.boolrefptr_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.mm', '// Set break point at this line.')
|
||||
|
||||
def boolrefptr_data_formatter_commands(self):
|
||||
"""Test the formatters we use for BOOL& and BOOL* in Objective-C."""
|
||||
self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
|
||||
|
||||
self.expect("breakpoint set -f main.mm -l %d" % self.line,
|
||||
BREAKPOINT_CREATED,
|
||||
startstr = "Breakpoint created: 1: file ='main.mm', 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)
|
||||
|
||||
# Execute the cleanup function during test case tear down.
|
||||
self.addTearDownHook(cleanup)
|
||||
|
||||
# Now check that we use the right summary for BOOL&
|
||||
self.expect('frame variable yes_ref',
|
||||
substrs = ['YES'])
|
||||
self.expect('frame variable no_ref',
|
||||
substrs = ['NO'])
|
||||
|
||||
|
||||
# Now check that we use the right summary for BOOL*
|
||||
self.expect('frame variable yes_ptr',
|
||||
substrs = ['YES'])
|
||||
self.expect('frame variable no_ptr',
|
||||
substrs = ['NO'])
|
||||
|
||||
|
||||
# Now check that we use the right summary for BOOL
|
||||
self.expect('frame variable yes',
|
||||
substrs = ['YES'])
|
||||
self.expect('frame variable no',
|
||||
substrs = ['NO'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
lldb.SBDebugger.Initialize()
|
||||
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
||||
unittest2.main()
|
|
@ -0,0 +1,29 @@
|
|||
//===-- 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];
|
||||
|
||||
BOOL yes = YES;
|
||||
BOOL no = NO;
|
||||
|
||||
BOOL &yes_ref = yes;
|
||||
BOOL &no_ref = no;
|
||||
|
||||
BOOL* yes_ptr = &yes;
|
||||
BOOL* no_ptr = &no;
|
||||
|
||||
[pool drain];// Set break point at this line.
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue