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