llvm-project/lldb/test/lang/c/forward/TestForwardDeclaration.py
Greg Clayton 3bcdfc0ec1 <rdar://problem/12798131>
Cleaned up the option parsing code to always pass around the short options as integers. Previously we cast this down to "char" and lost some information. I recently added an assert that would detect duplicate short character options which was firing during the test suite.

This fix does the following:
- make sure all short options are treated as "int"
- make sure that short options can be non-printable values when a short option is not required or when an option group is mixed into many commands and a short option is not desired
- fix the help printing to "do the right thing" in all cases. Previously if there were duplicate short character options, it would just not emit help for the duplicates
- fix option parsing when there are duplicates to parse options correctly. Previously the option parsing, when done for an OptionGroup, would just start parsing options incorrectly by omitting table entries and it would end up setting the wrong option value

llvm-svn: 169189
2012-12-04 00:32:51 +00:00

68 lines
2.4 KiB
Python

"""Test that forward declaration of a data structure gets resolved correctly."""
import os, time
import unittest2
import lldb
from lldbtest import *
import lldbutil
class ForwardDeclarationTestCase(TestBase):
mydir = os.path.join("lang", "c", "forward")
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
@dsym_test
def test_with_dsym_and_run_command(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
self.buildDsym()
self.forward_declaration()
# rdar://problem/8648070
# 'expression *bar_ptr' seg faults
# rdar://problem/8546815
# './dotest.py -v -t forward' fails for test_with_dwarf_and_run_command
@dwarf_test
def test_with_dwarf_and_run_command(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
self.buildDwarf()
self.forward_declaration()
def forward_declaration(self):
"""Display *bar_ptr when stopped on a function with forward declaration of struct bar."""
exe = os.path.join(os.getcwd(), "a.out")
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
# Break inside the foo function which takes a bar_ptr argument.
lldbutil.run_break_set_by_symbol (self, "foo", num_expected_locations=1, sym_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'])
# The breakpoint should have a hit count of 1.
self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
substrs = [' resolved, hit count = 1'])
# This should display correctly.
# Note that the member fields of a = 1 and b = 2 is by design.
self.expect("frame variable --show-types *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['(bar) *bar_ptr = ',
'(int) a = 1',
'(int) b = 2'])
# And so should this.
self.expect("expression *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY,
substrs = ['(bar)',
'(int) a = 1',
'(int) b = 2'])
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()