blob: 1f15a98e49a39af78fb244863bf66133eae431c6 [file] [log] [blame]
Johnny Chen5cb6cab2011-07-19 22:41:47 +00001//===-- SWIG Interface for SBCommandInterpreter -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10namespace lldb {
11
Johnny Chendca40972011-07-20 22:50:58 +000012%feature("docstring",
13"SBCommandInterpreter handles/interprets commands for lldb. You get the
14command interpreter from the SBDebugger instance. For example (from test/
15python_api/interpreter/TestCommandInterpreterAPI.py),
16
17 def command_interpreter_api(self):
18 '''Test the SBCommandInterpreter APIs.'''
19 exe = os.path.join(os.getcwd(), 'a.out')
20
21 # Create a target by the debugger.
22 target = self.dbg.CreateTarget(exe)
23 self.assertTrue(target, VALID_TARGET)
24
25 # Retrieve the associated command interpreter from our debugger.
26 ci = self.dbg.GetCommandInterpreter()
27 self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
28
29 # Exercise some APIs....
30
31 self.assertTrue(ci.HasCommands())
32 self.assertTrue(ci.HasAliases())
33 self.assertTrue(ci.HasAliasOptions())
34 self.assertTrue(ci.CommandExists('breakpoint'))
35 self.assertTrue(ci.CommandExists('target'))
36 self.assertTrue(ci.CommandExists('platform'))
37 self.assertTrue(ci.AliasExists('file'))
38 self.assertTrue(ci.AliasExists('run'))
39 self.assertTrue(ci.AliasExists('bt'))
40
41 res = lldb.SBCommandReturnObject()
42 ci.HandleCommand('breakpoint set -f main.c -l %d' % self.line, res)
43 self.assertTrue(res.Succeeded())
44 ci.HandleCommand('process launch', res)
45 self.assertTrue(res.Succeeded())
46
47 process = ci.GetProcess()
48 self.assertTrue(process)
49
50 ...
51
52The HandleCommand() instance method takes two args: the command string and
53an SBCommandReturnObject instance which encapsulates the result of command
54execution.
55") SBCommandInterpreter;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000056class SBCommandInterpreter
57{
58public:
59 enum
60 {
61 eBroadcastBitThreadShouldExit = (1 << 0),
62 eBroadcastBitResetPrompt = (1 << 1),
63 eBroadcastBitQuitCommandReceived = (1 << 2), // User entered quit
64 eBroadcastBitAsynchronousOutputData = (1 << 3),
65 eBroadcastBitAsynchronousErrorData = (1 << 4)
66 };
67
68 SBCommandInterpreter (const lldb::SBCommandInterpreter &rhs);
69
70 ~SBCommandInterpreter ();
71
72 static const char *
73 GetArgumentTypeAsCString (const lldb::CommandArgumentType arg_type);
74
75 static const char *
76 GetArgumentDescriptionAsCString (const lldb::CommandArgumentType arg_type);
77
78 bool
79 IsValid() const;
80
81 bool
82 CommandExists (const char *cmd);
83
84 bool
85 AliasExists (const char *cmd);
86
87 lldb::SBBroadcaster
88 GetBroadcaster ();
89
90 bool
91 HasCommands ();
92
93 bool
94 HasAliases ();
95
96 bool
97 HasAliasOptions ();
98
99 lldb::SBProcess
100 GetProcess ();
101
Johnny Chen5cb6cab2011-07-19 22:41:47 +0000102 void
103 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
104
105 void
106 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
107
108 lldb::ReturnStatus
109 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
110
111 int
112 HandleCompletion (const char *current_line,
Jim Ingham03c8ee52011-09-21 01:17:13 +0000113 uint32_t cursor_pos,
Johnny Chen5cb6cab2011-07-19 22:41:47 +0000114 int match_start_point,
115 int max_return_elements,
116 lldb::SBStringList &matches);
117};
118
119} // namespace lldb