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 | |
| 280 | uint32_t |
| 281 | GetNumModules () const; |
| 282 | |
| 283 | lldb::SBModule |
| 284 | GetModuleAtIndex (uint32_t idx); |
| 285 | |
| 286 | lldb::SBDebugger |
| 287 | GetDebugger() const; |
| 288 | |
| 289 | lldb::SBModule |
| 290 | FindModule (const lldb::SBFileSpec &file_spec); |
| 291 | |
| 292 | %feature("docstring", " |
| 293 | //------------------------------------------------------------------ |
| 294 | /// Find functions by name. |
| 295 | /// |
| 296 | /// @param[in] name |
| 297 | /// The name of the function we are looking for. |
| 298 | /// |
| 299 | /// @param[in] name_type_mask |
| 300 | /// A logical OR of one or more FunctionNameType enum bits that |
| 301 | /// indicate what kind of names should be used when doing the |
| 302 | /// lookup. Bits include fully qualified names, base names, |
| 303 | /// C++ methods, or ObjC selectors. |
| 304 | /// See FunctionNameType for more details. |
| 305 | /// |
| 306 | /// @param[in] append |
| 307 | /// If true, any matches will be appended to \a sc_list, else |
| 308 | /// matches replace the contents of \a sc_list. |
| 309 | /// |
| 310 | /// @param[out] sc_list |
| 311 | /// A symbol context list that gets filled in with all of the |
| 312 | /// matches. |
| 313 | /// |
| 314 | /// @return |
| 315 | /// The number of matches added to \a sc_list. |
| 316 | //------------------------------------------------------------------ |
| 317 | ") FindFunctions; |
| 318 | uint32_t |
| 319 | FindFunctions (const char *name, |
| 320 | uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits |
| 321 | bool append, |
| 322 | lldb::SBSymbolContextList& sc_list); |
| 323 | |
| 324 | %feature("docstring", " |
| 325 | //------------------------------------------------------------------ |
| 326 | /// Find global and static variables by name. |
| 327 | /// |
| 328 | /// @param[in] name |
| 329 | /// The name of the global or static variable we are looking |
| 330 | /// for. |
| 331 | /// |
| 332 | /// @param[in] max_matches |
| 333 | /// Allow the number of matches to be limited to \a max_matches. |
| 334 | /// |
| 335 | /// @return |
| 336 | /// A list of matched variables in an SBValueList. |
| 337 | //------------------------------------------------------------------ |
| 338 | ") FindGlobalVariables; |
| 339 | lldb::SBValueList |
| 340 | FindGlobalVariables (const char *name, |
| 341 | uint32_t max_matches); |
| 342 | |
| 343 | void |
| 344 | Clear (); |
| 345 | |
| 346 | bool |
| 347 | ResolveLoadAddress (lldb::addr_t vm_addr, |
| 348 | lldb::SBAddress& addr); |
| 349 | |
| 350 | SBSymbolContext |
| 351 | ResolveSymbolContextForAddress (const SBAddress& addr, |
| 352 | uint32_t resolve_scope); |
| 353 | |
| 354 | lldb::SBBreakpoint |
| 355 | BreakpointCreateByLocation (const char *file, uint32_t line); |
| 356 | |
| 357 | lldb::SBBreakpoint |
| 358 | BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); |
| 359 | |
| 360 | lldb::SBBreakpoint |
| 361 | BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); |
| 362 | |
| 363 | lldb::SBBreakpoint |
| 364 | BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); |
| 365 | |
| 366 | lldb::SBBreakpoint |
| 367 | BreakpointCreateByAddress (addr_t address); |
| 368 | |
| 369 | uint32_t |
| 370 | GetNumBreakpoints () const; |
| 371 | |
| 372 | lldb::SBBreakpoint |
| 373 | GetBreakpointAtIndex (uint32_t idx) const; |
| 374 | |
| 375 | bool |
| 376 | BreakpointDelete (break_id_t break_id); |
| 377 | |
| 378 | lldb::SBBreakpoint |
| 379 | FindBreakpointByID (break_id_t break_id); |
| 380 | |
| 381 | bool |
| 382 | EnableAllBreakpoints (); |
| 383 | |
| 384 | bool |
| 385 | DisableAllBreakpoints (); |
| 386 | |
| 387 | bool |
| 388 | DeleteAllBreakpoints (); |
| 389 | |
| 390 | lldb::SBBroadcaster |
| 391 | GetBroadcaster () const; |
| 392 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 393 | bool |
| 394 | GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level) const; |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 395 | }; |
| 396 | |
| 397 | } // namespace lldb |