blob: a7ddd64b4c007470b412ef77ce1b0a5102e753fa [file] [log] [blame]
Johnny Chenebd63b22011-07-16 21:15:39 +00001//===-- SWIG Interface for SBTarget -----------------------------*- 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
12%feature("docstring",
13"Represents the target program running under the debugger.
14
15SBTarget supports module and breakpoint iterations. For example,
16
17 for m in target.module_iter():
18 print m
19
20produces:
21
22(x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out
23(x86_64) /usr/lib/dyld
24(x86_64) /usr/lib/libstdc++.6.dylib
25(x86_64) /usr/lib/libSystem.B.dylib
26(x86_64) /usr/lib/system/libmathCommon.A.dylib
27(x86_64) /usr/lib/libSystem.B.dylib(__commpage)
28
29and,
30
31 for b in target.breakpoint_iter():
32 print b
33
34produces:
35
36SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1
37SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1
38"
39 ) SBTarget;
40class SBTarget
41{
42 %feature("autodoc", "1");
43public:
44 //------------------------------------------------------------------
45 // Broadcaster bits.
46 //------------------------------------------------------------------
47 enum
48 {
49 eBroadcastBitBreakpointChanged = (1 << 0),
50 eBroadcastBitModulesLoaded = (1 << 1),
51 eBroadcastBitModulesUnloaded = (1 << 2)
52 };
53
54 //------------------------------------------------------------------
55 // Constructors
56 //------------------------------------------------------------------
57 SBTarget ();
58
59 SBTarget (const lldb::SBTarget& rhs);
60
61#ifndef SWIG
62 const lldb::SBTarget&
63 operator = (const lldb::SBTarget& rhs);
64#endif
65
66 //------------------------------------------------------------------
67 // Destructor
68 //------------------------------------------------------------------
69 ~SBTarget();
70
71 bool
72 IsValid() const;
73
74 lldb::SBProcess
75 GetProcess ();
76
77 %feature("docstring", "
78 //------------------------------------------------------------------
79 /// Launch a new process.
80 ///
81 /// Launch a new process by spawning a new process using the
82 /// target object's executable module's file as the file to launch.
83 /// Arguments are given in \a argv, and the environment variables
84 /// are in \a envp. Standard input and output files can be
85 /// optionally re-directed to \a stdin_path, \a stdout_path, and
86 /// \a stderr_path.
87 ///
88 /// @param[in] listener
89 /// An optional listener that will receive all process events.
90 /// If \a listener is valid then \a listener will listen to all
91 /// process events. If not valid, then this target's debugger
92 /// (SBTarget::GetDebugger()) will listen to all process events.
93 ///
94 /// @param[in] argv
95 /// The argument array.
96 ///
97 /// @param[in] envp
98 /// The environment array.
99 ///
100 /// @param[in] launch_flags
101 /// Flags to modify the launch (@see lldb::LaunchFlags)
102 ///
103 /// @param[in] stdin_path
104 /// The path to use when re-directing the STDIN of the new
105 /// process. If all stdXX_path arguments are NULL, a pseudo
106 /// terminal will be used.
107 ///
108 /// @param[in] stdout_path
109 /// The path to use when re-directing the STDOUT of the new
110 /// process. If all stdXX_path arguments are NULL, a pseudo
111 /// terminal will be used.
112 ///
113 /// @param[in] stderr_path
114 /// The path to use when re-directing the STDERR of the new
115 /// process. If all stdXX_path arguments are NULL, a pseudo
116 /// terminal will be used.
117 ///
118 /// @param[in] working_directory
119 /// The working directory to have the child process run in
120 ///
121 /// @param[in] launch_flags
122 /// Some launch options specified by logical OR'ing
123 /// lldb::LaunchFlags enumeration values together.
124 ///
125 /// @param[in] stop_at_endtry
126 /// If false do not stop the inferior at the entry point.
127 ///
128 /// @param[out]
129 /// An error object. Contains the reason if there is some failure.
130 ///
131 /// @return
132 /// A process object for the newly created process.
133 //------------------------------------------------------------------
134
135 For example,
136
137 process = target.Launch(self.dbg.GetListener(), None, None,
138 None, '/tmp/stdout.txt', None,
139 None, 0, False, error)
140
141 launches a new process by passing nothing for both the args and the envs
142 and redirect the standard output of the inferior to the /tmp/stdout.txt
143 file. It does not specify a working directory so that the debug server
144 will use its idea of what the current working directory is for the
145 inferior. Also, we ask the debugger not to stop the inferior at the
146 entry point. If no breakpoint is specified for the inferior, it should
147 run to completion if no user interaction is required.
148 ") Launch;
149 lldb::SBProcess
150 Launch (SBListener &listener,
151 char const **argv,
152 char const **envp,
153 const char *stdin_path,
154 const char *stdout_path,
155 const char *stderr_path,
156 const char *working_directory,
157 uint32_t launch_flags, // See LaunchFlags
158 bool stop_at_entry,
159 lldb::SBError& error);
160
161 %feature("docstring", "
162 //------------------------------------------------------------------
163 /// Launch a new process with sensible defaults.
164 ///
165 /// @param[in] argv
166 /// The argument array.
167 ///
168 /// @param[in] envp
169 /// The environment array.
170 ///
171 /// @param[in] working_directory
172 /// The working directory to have the child process run in
173 ///
174 /// Default: listener
175 /// Set to the target's debugger (SBTarget::GetDebugger())
176 ///
177 /// Default: launch_flags
178 /// Empty launch flags
179 ///
180 /// Default: stdin_path
181 /// Default: stdout_path
182 /// Default: stderr_path
183 /// A pseudo terminal will be used.
184 ///
185 /// @return
186 /// A process object for the newly created process.
187 //------------------------------------------------------------------
188
189 For example,
190
191 process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd())
192
193 launches a new process by passing 'X', 'Y', 'Z' as the args to the
194 executable.
195 ") LaunchSimple;
196 lldb::SBProcess
197 LaunchSimple (const char **argv,
198 const char **envp,
199 const char *working_directory);
200
201 %feature("docstring", "
202 //------------------------------------------------------------------
203 /// Attach to process with pid.
204 ///
205 /// @param[in] listener
206 /// An optional listener that will receive all process events.
207 /// If \a listener is valid then \a listener will listen to all
208 /// process events. If not valid, then this target's debugger
209 /// (SBTarget::GetDebugger()) will listen to all process events.
210 ///
211 /// @param[in] pid
212 /// The process ID to attach to.
213 ///
214 /// @param[out]
215 /// An error explaining what went wrong if attach fails.
216 ///
217 /// @return
218 /// A process object for the attached process.
219 //------------------------------------------------------------------
220 ") AttachToProcessWithID;
221 lldb::SBProcess
222 AttachToProcessWithID (SBListener &listener,
223 lldb::pid_t pid,
224 lldb::SBError& error);
225
226 %feature("docstring", "
227 //------------------------------------------------------------------
228 /// Attach to process with name.
229 ///
230 /// @param[in] listener
231 /// An optional listener that will receive all process events.
232 /// If \a listener is valid then \a listener will listen to all
233 /// process events. If not valid, then this target's debugger
234 /// (SBTarget::GetDebugger()) will listen to all process events.
235 ///
236 /// @param[in] name
237 /// Basename of process to attach to.
238 ///
239 /// @param[in] wait_for
240 /// If true wait for a new instance of 'name' to be launched.
241 ///
242 /// @param[out]
243 /// An error explaining what went wrong if attach fails.
244 ///
245 /// @return
246 /// A process object for the attached process.
247 //------------------------------------------------------------------
248 ") AttachToProcessWithName;
249 lldb::SBProcess
250 AttachToProcessWithName (SBListener &listener,
251 const char *name,
252 bool wait_for,
253 lldb::SBError& error);
254
255 %feature("docstring", "
256 //------------------------------------------------------------------
257 /// Connect to a remote debug server with url.
258 ///
259 /// @param[in] listener
260 /// An optional listener that will receive all process events.
261 /// If \a listener is valid then \a listener will listen to all
262 /// process events. If not valid, then this target's debugger
263 /// (SBTarget::GetDebugger()) will listen to all process events.
264 ///
265 /// @param[in] url
266 /// The url to connect to, e.g., 'connect://localhost:12345'.
267 ///
268 /// @param[in] plugin_name
269 /// The plugin name to be used; can be NULL.
270 ///
271 /// @param[out]
272 /// An error explaining what went wrong if the connect fails.
273 ///
274 /// @return
275 /// A process object for the connected process.
276 //------------------------------------------------------------------
277 ") ConnectRemote;
278 lldb::SBProcess
279 ConnectRemote (SBListener &listener,
280 const char *url,
281 const char *plugin_name,
282 SBError& error);
283
284 lldb::SBFileSpec
285 GetExecutable ();
286
287 uint32_t
288 GetNumModules () const;
289
290 lldb::SBModule
291 GetModuleAtIndex (uint32_t idx);
292
293 lldb::SBDebugger
294 GetDebugger() const;
295
296 lldb::SBModule
297 FindModule (const lldb::SBFileSpec &file_spec);
298
299 %feature("docstring", "
300 //------------------------------------------------------------------
301 /// Find functions by name.
302 ///
303 /// @param[in] name
304 /// The name of the function we are looking for.
305 ///
306 /// @param[in] name_type_mask
307 /// A logical OR of one or more FunctionNameType enum bits that
308 /// indicate what kind of names should be used when doing the
309 /// lookup. Bits include fully qualified names, base names,
310 /// C++ methods, or ObjC selectors.
311 /// See FunctionNameType for more details.
312 ///
313 /// @param[in] append
314 /// If true, any matches will be appended to \a sc_list, else
315 /// matches replace the contents of \a sc_list.
316 ///
317 /// @param[out] sc_list
318 /// A symbol context list that gets filled in with all of the
319 /// matches.
320 ///
321 /// @return
322 /// The number of matches added to \a sc_list.
323 //------------------------------------------------------------------
324 ") FindFunctions;
325 uint32_t
326 FindFunctions (const char *name,
327 uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits
328 bool append,
329 lldb::SBSymbolContextList& sc_list);
330
331 %feature("docstring", "
332 //------------------------------------------------------------------
333 /// Find global and static variables by name.
334 ///
335 /// @param[in] name
336 /// The name of the global or static variable we are looking
337 /// for.
338 ///
339 /// @param[in] max_matches
340 /// Allow the number of matches to be limited to \a max_matches.
341 ///
342 /// @return
343 /// A list of matched variables in an SBValueList.
344 //------------------------------------------------------------------
345 ") FindGlobalVariables;
346 lldb::SBValueList
347 FindGlobalVariables (const char *name,
348 uint32_t max_matches);
349
350 void
351 Clear ();
352
353 bool
354 ResolveLoadAddress (lldb::addr_t vm_addr,
355 lldb::SBAddress& addr);
356
357 SBSymbolContext
358 ResolveSymbolContextForAddress (const SBAddress& addr,
359 uint32_t resolve_scope);
360
361 lldb::SBBreakpoint
362 BreakpointCreateByLocation (const char *file, uint32_t line);
363
364 lldb::SBBreakpoint
365 BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line);
366
367 lldb::SBBreakpoint
368 BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL);
369
370 lldb::SBBreakpoint
371 BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL);
372
373 lldb::SBBreakpoint
374 BreakpointCreateByAddress (addr_t address);
375
376 uint32_t
377 GetNumBreakpoints () const;
378
379 lldb::SBBreakpoint
380 GetBreakpointAtIndex (uint32_t idx) const;
381
382 bool
383 BreakpointDelete (break_id_t break_id);
384
385 lldb::SBBreakpoint
386 FindBreakpointByID (break_id_t break_id);
387
388 bool
389 EnableAllBreakpoints ();
390
391 bool
392 DisableAllBreakpoints ();
393
394 bool
395 DeleteAllBreakpoints ();
396
397 lldb::SBBroadcaster
398 GetBroadcaster () const;
399
400#ifndef SWIG
401 bool
402 operator == (const lldb::SBTarget &rhs) const;
403
404 bool
405 operator != (const lldb::SBTarget &rhs) const;
406
407#endif
408
409#ifndef SWIG
410 bool
411 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level);
412#endif
413
414 bool
415 GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level) const;
416
417protected:
418 friend class SBAddress;
419 friend class SBDebugger;
420 friend class SBFunction;
421 friend class SBProcess;
422 friend class SBSymbol;
423 friend class SBModule;
424
425 //------------------------------------------------------------------
426 // Constructors are private, use static Target::Create function to
427 // create an instance of this class.
428 //------------------------------------------------------------------
429
430 SBTarget (const lldb::TargetSP& target_sp);
431
432 void
433 reset (const lldb::TargetSP& target_sp);
434
435 lldb_private::Target *
436 operator ->() const;
437
438 lldb_private::Target *
439 get() const;
440
441private:
442 //------------------------------------------------------------------
443 // For Target only
444 //------------------------------------------------------------------
445
446 lldb::TargetSP m_opaque_sp;
447};
448
449} // namespace lldb