diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:26:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:26:05 +0000 |
commit | 14f1b3e8826ce43b978db93a62d1166055db5394 (patch) | |
tree | 0a00ad8d3498783fe0193f3b656bca17c4c8697d /packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval | |
parent | 4ee8c119c71a06dcad1e0fecc8c675e480e59337 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval')
3 files changed, 81 insertions, 36 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py index e7a34647a6de..6e7ac2c13f31 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/TestDataFormatterSynthVal.py @@ -5,13 +5,14 @@ Test lldb data formatter subsystem. from __future__ import print_function - -import os, time +import os +import time import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil + class DataFormatterSynthValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -22,21 +23,24 @@ class DataFormatterSynthValueTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', 'break here') - @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") + @skipIfFreeBSD # llvm.org/pr20545 bogus output confuses buildbot parser + @expectedFailureAll( + oslist=["windows"], + bugnumber="llvm.org/pr24462, Data formatters have problems on Windows") def test_with_run_command(self): """Test using Python synthetic children provider to provide a value.""" self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line( + self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) 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']) + 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. @@ -48,43 +52,64 @@ class DataFormatterSynthValueTestCase(TestBase): # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) - + x = self.frame().FindVariable("x") x.SetPreferSyntheticValue(True) y = self.frame().FindVariable("y") y.SetPreferSyntheticValue(True) z = self.frame().FindVariable("z") z.SetPreferSyntheticValue(True) + q = self.frame().FindVariable("q") + z.SetPreferSyntheticValue(True) x_val = x.GetValueAsUnsigned y_val = y.GetValueAsUnsigned z_val = z.GetValueAsUnsigned - + q_val = q.GetValueAsUnsigned + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val())) + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) self.assertFalse(x_val() == 3, "x == 3 before synthetics") self.assertFalse(y_val() == 4, "y == 4 before synthetics") self.assertFalse(z_val() == 7, "z == 7 before synthetics") + self.assertFalse(q_val() == 8, "q == 8 before synthetics") # now set up the synth self.runCmd("script from myIntSynthProvider import *") self.runCmd("type synth add -l myIntSynthProvider myInt") self.runCmd("type synth add -l myArraySynthProvider myArray") - + self.runCmd("type synth add -l myIntSynthProvider myIntAndStuff") + if self.TraceOn(): - print("x_val = %s; y_val = %s; z_val = %s" % (x_val(),y_val(),z_val())) - + print( + "x_val = %s; y_val = %s; z_val = %s; q_val = %s" % + (x_val(), y_val(), z_val(), q_val())) + self.assertTrue(x_val() == 3, "x != 3 after synthetics") self.assertTrue(y_val() == 4, "y != 4 after synthetics") self.assertTrue(z_val() == 7, "z != 7 after synthetics") - + self.assertTrue(q_val() == 8, "q != 8 after synthetics") + self.expect("frame variable x", substrs=['3']) - self.expect("frame variable x", substrs=['theValue = 3'], matching=False) - - # check that an aptly defined synthetic provider does not affect one-lining - self.expect("expression struct S { myInt theInt{12}; }; S()", substrs = ['(theInt = 12)']) - + self.expect( + "frame variable x", + substrs=['theValue = 3'], + matching=False) + self.expect("frame variable q", substrs=['8']) + self.expect( + "frame variable q", + substrs=['theValue = 8'], + matching=False) + + # check that an aptly defined synthetic provider does not affect + # one-lining + self.expect( + "expression struct S { myInt theInt{12}; }; S()", + substrs=['(theInt = 12)']) + # check that we can use a synthetic value in a summary self.runCmd("type summary add hasAnInt -s ${var.theInt}") hi = self.frame().FindVariable("hi") diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp index accbf0a5a578..1a5925a05a65 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/main.cpp @@ -5,6 +5,16 @@ class myInt { int val() { return theValue; } }; +class myIntAndStuff { +private: + int theValue; + double theExtraFluff; +public: + myIntAndStuff() : theValue(0), theExtraFluff(1.25) {} + myIntAndStuff(int _x) : theValue(_x), theExtraFluff(1.25) {} + int val() { return theValue; } +}; + class myArray { public: int array[16]; @@ -17,11 +27,13 @@ class hasAnInt { }; myInt operator + (myInt x, myInt y) { return myInt(x.val() + y.val()); } +myInt operator + (myInt x, myIntAndStuff y) { return myInt(x.val() + y.val()); } int main() { myInt x{3}; myInt y{4}; myInt z {x+y}; + myIntAndStuff q {z.val()+1}; hasAnInt hi; myArray ma; diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py index c8517a442932..82da6f9da928 100644 --- a/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py +++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-synthval/myIntSynthProvider.py @@ -1,22 +1,30 @@ class myIntSynthProvider(object): - def __init__(self, valobj, dict): - self.valobj = valobj; - self.val = self.valobj.GetChildMemberWithName("theValue") - def num_children(self): - return 0; - def get_child_at_index(self, index): - return None - def get_child_index(self, name): - return None - def update(self): - return False - def has_children(self): - return False - def get_value(self): - return self.val + + def __init__(self, valobj, dict): + self.valobj = valobj + self.val = self.valobj.GetChildMemberWithName("theValue") + + def num_children(self): + return 0 + + def get_child_at_index(self, index): + return None + + def get_child_index(self, name): + return None + + def update(self): + return False + + def has_children(self): + return False + + def get_value(self): + return self.val class myArraySynthProvider(object): + def __init__(self, valobj, dict): self.valobj = valobj self.array = self.valobj.GetChildMemberWithName("array") @@ -27,10 +35,10 @@ class myArraySynthProvider(object): return max_count def get_child_at_index(self, index): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def get_child_index(self, name): - return None # Keep it simple when this is not tested here. + return None # Keep it simple when this is not tested here. def has_children(self): return True |