blob: 9dc842e87c29b98ea7f87059dee064547c343388 [file] [log] [blame]
Johnny Chenfdc4a862011-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 Chenad4fe1b2011-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 Chenfdc4a862011-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
Greg Clayton44d93782014-01-27 23:43:24 +000081 const char *
82 GetIOHandlerControlSequence(char ch);
83
Johnny Chenfdc4a862011-07-19 22:41:47 +000084 bool
85 CommandExists (const char *cmd);
86
87 bool
88 AliasExists (const char *cmd);
89
90 lldb::SBBroadcaster
91 GetBroadcaster ();
92
Jim Ingham4bddaeb2012-02-16 06:50:00 +000093 static const char *
94 GetBroadcasterClass ();
95
Johnny Chenfdc4a862011-07-19 22:41:47 +000096 bool
97 HasCommands ();
98
99 bool
100 HasAliases ();
101
102 bool
103 HasAliasOptions ();
104
105 lldb::SBProcess
106 GetProcess ();
Enrico Granata21dfcd92012-09-28 23:57:51 +0000107
108 lldb::SBDebugger
109 GetDebugger ();
Johnny Chenfdc4a862011-07-19 22:41:47 +0000110
Johnny Chenfdc4a862011-07-19 22:41:47 +0000111 void
112 SourceInitFileInHomeDirectory (lldb::SBCommandReturnObject &result);
113
114 void
115 SourceInitFileInCurrentWorkingDirectory (lldb::SBCommandReturnObject &result);
116
117 lldb::ReturnStatus
118 HandleCommand (const char *command_line, lldb::SBCommandReturnObject &result, bool add_to_history = false);
119
120 int
121 HandleCompletion (const char *current_line,
Jim Ingham969795f2011-09-21 01:17:13 +0000122 uint32_t cursor_pos,
Johnny Chenfdc4a862011-07-19 22:41:47 +0000123 int match_start_point,
124 int max_return_elements,
125 lldb::SBStringList &matches);
Greg Clayton44d93782014-01-27 23:43:24 +0000126
127 bool
128 IsActive ();
129
Johnny Chenfdc4a862011-07-19 22:41:47 +0000130};
131
132} // namespace lldb