Johnny Chen | 7f5f280 | 2010-08-02 21:26:00 +0000 | [diff] [blame] | 1 | """ |
Johnny Chen | 65045f2 | 2010-10-08 17:21:27 +0000 | [diff] [blame] | 2 | Test some lldb help commands. |
Johnny Chen | 7f5f280 | 2010-08-02 21:26:00 +0000 | [diff] [blame] | 3 | |
| 4 | See also CommandInterpreter::OutputFormattedHelpText(). |
| 5 | """ |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 6 | |
Zachary Turner | 35d017f | 2015-10-23 17:04:29 +0000 | [diff] [blame] | 7 | from __future__ import print_function |
| 8 | |
Zachary Turner | 0a0490b | 2015-10-27 20:12:05 +0000 | [diff] [blame] | 9 | import use_lldb_suite |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame] | 10 | |
Johnny Chen | 8c3f918 | 2010-07-01 00:18:39 +0000 | [diff] [blame] | 11 | import os, time |
Johnny Chen | bf6ffa3 | 2010-07-03 03:41:59 +0000 | [diff] [blame] | 12 | import lldb |
Zachary Turner | 95c453a | 2015-11-03 02:06:18 +0000 | [diff] [blame^] | 13 | from lldbsuite.test.lldbtest import * |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 14 | |
Johnny Chen | cbb4be0 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 15 | class HelpCommandTestCase(TestBase): |
Johnny Chen | 119b53e | 2010-07-01 22:52:57 +0000 | [diff] [blame] | 16 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 17 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 18 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 19 | @no_debug_info_test |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 20 | def test_simplehelp(self): |
| 21 | """A simple test of 'help' command and its output.""" |
Johnny Chen | 74f26b8 | 2010-08-20 19:17:39 +0000 | [diff] [blame] | 22 | self.expect("help", |
Ed Maste | 135f6ab | 2015-01-20 15:13:01 +0000 | [diff] [blame] | 23 | startstr = 'Debugger commands:') |
Johnny Chen | 7e363f5 | 2010-06-28 20:55:57 +0000 | [diff] [blame] | 24 | |
Ed Maste | 135f6ab | 2015-01-20 15:13:01 +0000 | [diff] [blame] | 25 | self.expect("help -a", matching=False, |
Enrico Granata | 08633ee | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 26 | substrs = ['next']) |
| 27 | |
Ed Maste | 135f6ab | 2015-01-20 15:13:01 +0000 | [diff] [blame] | 28 | self.expect("help", matching=True, |
Enrico Granata | 08633ee | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 29 | substrs = ['next']) |
| 30 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 31 | @no_debug_info_test |
Enrico Granata | 08633ee | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 32 | def test_help_on_help(self): |
| 33 | """Testing the help on the help facility.""" |
| 34 | self.expect("help help", matching=True, |
Ed Maste | 135f6ab | 2015-01-20 15:13:01 +0000 | [diff] [blame] | 35 | substrs = ['--hide-aliases', |
Enrico Granata | 08633ee | 2011-09-09 17:49:36 +0000 | [diff] [blame] | 36 | '--hide-user-commands']) |
| 37 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 38 | @no_debug_info_test |
Johnny Chen | 8493989 | 2011-01-06 00:03:01 +0000 | [diff] [blame] | 39 | def version_number_string(self): |
| 40 | """Helper function to find the version number string of lldb.""" |
Peter Collingbourne | d6824de | 2011-06-20 19:06:45 +0000 | [diff] [blame] | 41 | plist = os.path.join(os.environ["LLDB_SRC"], "resources", "LLDB-Info.plist") |
Johnny Chen | 8493989 | 2011-01-06 00:03:01 +0000 | [diff] [blame] | 42 | try: |
| 43 | CFBundleVersionSegFound = False |
| 44 | with open(plist, 'r') as f: |
| 45 | for line in f: |
| 46 | if CFBundleVersionSegFound: |
| 47 | version_line = line.strip() |
| 48 | import re |
| 49 | m = re.match("<string>(.*)</string>", version_line) |
| 50 | if m: |
| 51 | version = m.group(1) |
| 52 | return version |
| 53 | else: |
| 54 | # Unsuccessful, let's juts break out of the for loop. |
| 55 | break |
| 56 | |
| 57 | if line.find("<key>CFBundleVersion</key>") != -1: |
| 58 | # Found our match. The next line contains our version |
| 59 | # string, for example: |
| 60 | # |
| 61 | # <string>38</string> |
| 62 | CFBundleVersionSegFound = True |
| 63 | |
| 64 | except: |
| 65 | # Just fallthrough... |
Johnny Chen | b13ee84 | 2011-01-07 00:17:44 +0000 | [diff] [blame] | 66 | import traceback |
| 67 | traceback.print_exc() |
Johnny Chen | 8493989 | 2011-01-06 00:03:01 +0000 | [diff] [blame] | 68 | pass |
| 69 | |
| 70 | # Use None to signify that we are not able to grok the version number. |
| 71 | return None |
| 72 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 73 | @no_debug_info_test |
Johnny Chen | ca7835c | 2012-05-26 00:32:39 +0000 | [diff] [blame] | 74 | def test_help_arch(self): |
| 75 | """Test 'help arch' which should list of supported architectures.""" |
| 76 | self.expect("help arch", |
| 77 | substrs = ['arm', 'x86_64', 'i386']) |
| 78 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 79 | @no_debug_info_test |
Johnny Chen | 31c39da | 2010-12-23 20:21:44 +0000 | [diff] [blame] | 80 | def test_help_version(self): |
| 81 | """Test 'help version' and 'version' commands.""" |
| 82 | self.expect("help version", |
| 83 | substrs = ['Show version of LLDB debugger.']) |
Johnny Chen | 8493989 | 2011-01-06 00:03:01 +0000 | [diff] [blame] | 84 | version_str = self.version_number_string() |
Johnny Chen | 4cd2a8e | 2011-08-26 23:50:10 +0000 | [diff] [blame] | 85 | import re |
| 86 | match = re.match('[0-9]+', version_str) |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 87 | if sys.platform.startswith("darwin"): |
Greg Clayton | 1a400cf | 2013-04-03 00:04:27 +0000 | [diff] [blame] | 88 | search_regexp = ['lldb-' + (version_str if match else '[0-9]+')] |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 89 | else: |
| 90 | search_regexp = ['lldb version (\d|\.)+.*$'] |
| 91 | |
Johnny Chen | 31c39da | 2010-12-23 20:21:44 +0000 | [diff] [blame] | 92 | self.expect("version", |
Daniel Malea | 3b92f00 | 2013-02-28 16:51:15 +0000 | [diff] [blame] | 93 | patterns = search_regexp) |
Johnny Chen | 31c39da | 2010-12-23 20:21:44 +0000 | [diff] [blame] | 94 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 95 | @no_debug_info_test |
Johnny Chen | 331eff3 | 2011-07-14 22:20:12 +0000 | [diff] [blame] | 96 | def test_help_should_not_crash_lldb(self): |
| 97 | """Command 'help disasm' should not crash lldb.""" |
| 98 | self.runCmd("help disasm", check=False) |
| 99 | self.runCmd("help unsigned-integer") |
| 100 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 101 | @no_debug_info_test |
Johnny Chen | 7e363f5 | 2010-06-28 20:55:57 +0000 | [diff] [blame] | 102 | def test_help_should_not_hang_emacsshell(self): |
Johnny Chen | ecf9ded | 2010-09-07 16:19:35 +0000 | [diff] [blame] | 103 | """Command 'settings set term-width 0' should not hang the help command.""" |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 104 | self.expect("settings set term-width 0", |
| 105 | COMMAND_FAILED_AS_EXPECTED, error=True, |
| 106 | substrs = ['error: 0 is out of range, valid values must be between']) |
| 107 | # self.runCmd("settings set term-width 0") |
Johnny Chen | 74f26b8 | 2010-08-20 19:17:39 +0000 | [diff] [blame] | 108 | self.expect("help", |
Ed Maste | 135f6ab | 2015-01-20 15:13:01 +0000 | [diff] [blame] | 109 | startstr = 'Debugger commands:') |
Johnny Chen | 9320d4a | 2010-06-25 23:15:47 +0000 | [diff] [blame] | 110 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 111 | @no_debug_info_test |
Johnny Chen | 5ec8fcb | 2012-05-07 23:04:49 +0000 | [diff] [blame] | 112 | def test_help_breakpoint_set(self): |
| 113 | """Test that 'help breakpoint set' does not print out redundant lines of: |
| 114 | 'breakpoint set [-s <shlib-name>] ...'.""" |
| 115 | self.expect("help breakpoint set", matching=False, |
| 116 | substrs = ['breakpoint set [-s <shlib-name>]']) |
| 117 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 118 | @no_debug_info_test |
Johnny Chen | 65045f2 | 2010-10-08 17:21:27 +0000 | [diff] [blame] | 119 | def test_help_image_dump_symtab_should_not_crash(self): |
| 120 | """Command 'help image dump symtab' should not crash lldb.""" |
Johnny Chen | 24f3490 | 2011-05-03 23:55:05 +0000 | [diff] [blame] | 121 | # 'image' is an alias for 'target modules'. |
Johnny Chen | 65045f2 | 2010-10-08 17:21:27 +0000 | [diff] [blame] | 122 | self.expect("help image dump symtab", |
Johnny Chen | 5aceec3 | 2011-05-03 23:18:45 +0000 | [diff] [blame] | 123 | substrs = ['dump symtab', |
Johnny Chen | 65045f2 | 2010-10-08 17:21:27 +0000 | [diff] [blame] | 124 | 'sort-order']) |
| 125 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 126 | @no_debug_info_test |
Johnny Chen | 5237e90 | 2010-12-01 19:10:59 +0000 | [diff] [blame] | 127 | def test_help_image_du_sym_is_ambiguous(self): |
| 128 | """Command 'help image du sym' is ambiguous and spits out the list of candidates.""" |
| 129 | self.expect("help image du sym", |
| 130 | COMMAND_FAILED_AS_EXPECTED, error=True, |
| 131 | substrs = ['error: ambiguous command image du sym', |
| 132 | 'symfile', |
| 133 | 'symtab']) |
| 134 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 135 | @no_debug_info_test |
Johnny Chen | 5237e90 | 2010-12-01 19:10:59 +0000 | [diff] [blame] | 136 | def test_help_image_du_line_should_work(self): |
| 137 | """Command 'help image du line' is not ambiguous and should work.""" |
Johnny Chen | 24f3490 | 2011-05-03 23:55:05 +0000 | [diff] [blame] | 138 | # 'image' is an alias for 'target modules'. |
Johnny Chen | 5237e90 | 2010-12-01 19:10:59 +0000 | [diff] [blame] | 139 | self.expect("help image du line", |
Daniel Malea | e7322b3 | 2013-07-03 19:29:46 +0000 | [diff] [blame] | 140 | substrs = ['Dump the line table for one or more compilation units']) |
Johnny Chen | 5237e90 | 2010-12-01 19:10:59 +0000 | [diff] [blame] | 141 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 142 | @no_debug_info_test |
Johnny Chen | 81ab3f5 | 2011-08-22 22:22:00 +0000 | [diff] [blame] | 143 | def test_help_target_variable_syntax(self): |
| 144 | """Command 'help target variable' should display <variable-name> ...""" |
| 145 | self.expect("help target variable", |
| 146 | substrs = ['<variable-name> [<variable-name> [...]]']) |
| 147 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 148 | @no_debug_info_test |
Johnny Chen | 84128e6 | 2011-09-23 17:57:49 +0000 | [diff] [blame] | 149 | def test_help_watchpoint_and_its_args(self): |
| 150 | """Command 'help watchpoint', 'help watchpt-id', and 'help watchpt-id-list' should work.""" |
| 151 | self.expect("help watchpoint", |
| 152 | substrs = ['delete', 'disable', 'enable', 'list']) |
| 153 | self.expect("help watchpt-id", |
| 154 | substrs = ['<watchpt-id>']) |
| 155 | self.expect("help watchpt-id-list", |
| 156 | substrs = ['<watchpt-id-list>']) |
| 157 | |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 158 | @no_debug_info_test |
Johnny Chen | 34ddc8d | 2012-02-08 01:13:31 +0000 | [diff] [blame] | 159 | def test_help_watchpoint_set(self): |
Johnny Chen | 2ffa754 | 2012-02-08 22:37:48 +0000 | [diff] [blame] | 160 | """Test that 'help watchpoint set' prints out 'expression' and 'variable' |
| 161 | as the possible subcommands.""" |
Johnny Chen | 34ddc8d | 2012-02-08 01:13:31 +0000 | [diff] [blame] | 162 | self.expect("help watchpoint set", |
Johnny Chen | 2ffa754 | 2012-02-08 22:37:48 +0000 | [diff] [blame] | 163 | substrs = ['The following subcommands are supported:'], |
| 164 | patterns = ['expression +--', |
| 165 | 'variable +--']) |