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 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 12 | class SBLaunchInfo |
| 13 | { |
Greg Clayton | 98ca1e6 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 14 | public: |
| 15 | SBLaunchInfo (const char **argv); |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 16 | |
| 17 | uint32_t |
| 18 | GetUserID(); |
| 19 | |
| 20 | uint32_t |
| 21 | GetGroupID(); |
| 22 | |
| 23 | bool |
| 24 | UserIDIsValid (); |
| 25 | |
| 26 | bool |
| 27 | GroupIDIsValid (); |
| 28 | |
| 29 | void |
| 30 | SetUserID (uint32_t uid); |
| 31 | |
| 32 | void |
| 33 | SetGroupID (uint32_t gid); |
| 34 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 35 | uint32_t |
| 36 | GetNumArguments (); |
| 37 | |
| 38 | const char * |
| 39 | GetArgumentAtIndex (uint32_t idx); |
| 40 | |
| 41 | void |
| 42 | SetArguments (const char **argv, bool append); |
| 43 | |
| 44 | uint32_t |
| 45 | GetNumEnvironmentEntries (); |
| 46 | |
| 47 | const char * |
| 48 | GetEnvironmentEntryAtIndex (uint32_t idx); |
| 49 | |
| 50 | void |
| 51 | SetEnvironmentEntries (const char **envp, bool append); |
| 52 | |
| 53 | void |
| 54 | Clear (); |
| 55 | |
| 56 | const char * |
| 57 | GetWorkingDirectory () const; |
| 58 | |
| 59 | void |
| 60 | SetWorkingDirectory (const char *working_dir); |
| 61 | |
| 62 | uint32_t |
| 63 | GetLaunchFlags (); |
| 64 | |
| 65 | void |
| 66 | SetLaunchFlags (uint32_t flags); |
| 67 | |
| 68 | const char * |
| 69 | GetProcessPluginName (); |
| 70 | |
| 71 | void |
| 72 | SetProcessPluginName (const char *plugin_name); |
| 73 | |
| 74 | const char * |
| 75 | GetShell (); |
| 76 | |
| 77 | void |
| 78 | SetShell (const char * path); |
| 79 | |
| 80 | uint32_t |
| 81 | GetResumeCount (); |
| 82 | |
| 83 | void |
| 84 | SetResumeCount (uint32_t c); |
| 85 | |
| 86 | bool |
| 87 | AddCloseFileAction (int fd); |
| 88 | |
| 89 | bool |
| 90 | AddDuplicateFileAction (int fd, int dup_fd); |
| 91 | |
| 92 | bool |
| 93 | AddOpenFileAction (int fd, const char *path, bool read, bool write); |
| 94 | |
| 95 | bool |
| 96 | AddSuppressFileAction (int fd, bool read, bool write); |
| 97 | }; |
| 98 | |
| 99 | class SBAttachInfo |
| 100 | { |
| 101 | public: |
| 102 | SBAttachInfo (); |
| 103 | |
| 104 | SBAttachInfo (lldb::pid_t pid); |
| 105 | |
| 106 | SBAttachInfo (const char *path, bool wait_for); |
| 107 | |
| 108 | SBAttachInfo (const lldb::SBAttachInfo &rhs); |
| 109 | |
| 110 | lldb::pid_t |
| 111 | GetProcessID (); |
| 112 | |
| 113 | void |
| 114 | SetProcessID (lldb::pid_t pid); |
| 115 | |
| 116 | void |
| 117 | SetExecutable (const char *path); |
| 118 | |
| 119 | void |
| 120 | SetExecutable (lldb::SBFileSpec exe_file); |
| 121 | |
| 122 | bool |
| 123 | GetWaitForLaunch (); |
| 124 | |
| 125 | void |
| 126 | SetWaitForLaunch (bool b); |
| 127 | |
| 128 | uint32_t |
| 129 | GetResumeCount (); |
| 130 | |
| 131 | void |
| 132 | SetResumeCount (uint32_t c); |
| 133 | |
| 134 | const char * |
| 135 | GetProcessPluginName (); |
| 136 | |
| 137 | void |
| 138 | SetProcessPluginName (const char *plugin_name); |
| 139 | |
| 140 | uint32_t |
Greg Clayton | 80efa5e | 2012-02-24 23:56:06 +0000 | [diff] [blame] | 141 | GetUserID(); |
| 142 | |
| 143 | uint32_t |
| 144 | GetGroupID(); |
| 145 | |
| 146 | bool |
| 147 | UserIDIsValid (); |
| 148 | |
| 149 | bool |
| 150 | GroupIDIsValid (); |
| 151 | |
| 152 | void |
| 153 | SetUserID (uint32_t uid); |
| 154 | |
| 155 | void |
| 156 | SetGroupID (uint32_t gid); |
| 157 | |
| 158 | uint32_t |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 159 | GetEffectiveUserID(); |
| 160 | |
| 161 | uint32_t |
| 162 | GetEffectiveGroupID(); |
| 163 | |
| 164 | bool |
| 165 | EffectiveUserIDIsValid (); |
| 166 | |
| 167 | bool |
| 168 | EffectiveGroupIDIsValid (); |
| 169 | |
| 170 | void |
| 171 | SetEffectiveUserID (uint32_t uid); |
| 172 | |
| 173 | void |
| 174 | SetEffectiveGroupID (uint32_t gid); |
| 175 | |
| 176 | lldb::pid_t |
| 177 | GetParentProcessID (); |
| 178 | |
| 179 | void |
| 180 | SetParentProcessID (lldb::pid_t pid); |
| 181 | |
| 182 | bool |
| 183 | ParentProcessIDIsValid(); |
| 184 | }; |
| 185 | |
| 186 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 187 | %feature("docstring", |
| 188 | "Represents the target program running under the debugger. |
| 189 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 190 | SBTarget supports module, breakpoint, and watchpoint iterations. For example, |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 191 | |
| 192 | for m in target.module_iter(): |
| 193 | print m |
| 194 | |
| 195 | produces: |
| 196 | |
| 197 | (x86_64) /Volumes/data/lldb/svn/trunk/test/python_api/lldbutil/iter/a.out |
| 198 | (x86_64) /usr/lib/dyld |
| 199 | (x86_64) /usr/lib/libstdc++.6.dylib |
| 200 | (x86_64) /usr/lib/libSystem.B.dylib |
| 201 | (x86_64) /usr/lib/system/libmathCommon.A.dylib |
| 202 | (x86_64) /usr/lib/libSystem.B.dylib(__commpage) |
| 203 | |
| 204 | and, |
| 205 | |
| 206 | for b in target.breakpoint_iter(): |
| 207 | print b |
| 208 | |
| 209 | produces: |
| 210 | |
| 211 | SBBreakpoint: id = 1, file ='main.cpp', line = 66, locations = 1 |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 212 | SBBreakpoint: id = 2, file ='main.cpp', line = 85, locations = 1 |
| 213 | |
| 214 | and, |
| 215 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 216 | for wp_loc in target.watchpoint_iter(): |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 217 | print wp_loc |
| 218 | |
| 219 | produces: |
| 220 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 221 | Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 222 | declare @ '/Volumes/data/lldb/svn/trunk/test/python_api/watchpoint/main.c:12' |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 223 | hw_index = 0 hit_count = 2 ignore_count = 0" |
Johnny Chen | c3fba81 | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 224 | ) SBTarget; |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 225 | class SBTarget |
| 226 | { |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 227 | public: |
| 228 | //------------------------------------------------------------------ |
| 229 | // Broadcaster bits. |
| 230 | //------------------------------------------------------------------ |
| 231 | enum |
| 232 | { |
| 233 | eBroadcastBitBreakpointChanged = (1 << 0), |
| 234 | eBroadcastBitModulesLoaded = (1 << 1), |
| 235 | eBroadcastBitModulesUnloaded = (1 << 2) |
| 236 | }; |
| 237 | |
| 238 | //------------------------------------------------------------------ |
| 239 | // Constructors |
| 240 | //------------------------------------------------------------------ |
| 241 | SBTarget (); |
| 242 | |
| 243 | SBTarget (const lldb::SBTarget& rhs); |
| 244 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 245 | //------------------------------------------------------------------ |
| 246 | // Destructor |
| 247 | //------------------------------------------------------------------ |
| 248 | ~SBTarget(); |
| 249 | |
Jim Ingham | 5a15e69 | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 250 | static const char * |
| 251 | GetBroadcasterClassName (); |
| 252 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 253 | bool |
| 254 | IsValid() const; |
| 255 | |
| 256 | lldb::SBProcess |
| 257 | GetProcess (); |
| 258 | |
| 259 | %feature("docstring", " |
| 260 | //------------------------------------------------------------------ |
| 261 | /// Launch a new process. |
| 262 | /// |
| 263 | /// Launch a new process by spawning a new process using the |
| 264 | /// target object's executable module's file as the file to launch. |
| 265 | /// Arguments are given in \a argv, and the environment variables |
| 266 | /// are in \a envp. Standard input and output files can be |
| 267 | /// optionally re-directed to \a stdin_path, \a stdout_path, and |
| 268 | /// \a stderr_path. |
| 269 | /// |
| 270 | /// @param[in] listener |
| 271 | /// An optional listener that will receive all process events. |
| 272 | /// If \a listener is valid then \a listener will listen to all |
| 273 | /// process events. If not valid, then this target's debugger |
| 274 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 275 | /// |
| 276 | /// @param[in] argv |
| 277 | /// The argument array. |
| 278 | /// |
| 279 | /// @param[in] envp |
| 280 | /// The environment array. |
| 281 | /// |
| 282 | /// @param[in] launch_flags |
| 283 | /// Flags to modify the launch (@see lldb::LaunchFlags) |
| 284 | /// |
| 285 | /// @param[in] stdin_path |
| 286 | /// The path to use when re-directing the STDIN of the new |
| 287 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 288 | /// terminal will be used. |
| 289 | /// |
| 290 | /// @param[in] stdout_path |
| 291 | /// The path to use when re-directing the STDOUT of the new |
| 292 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 293 | /// terminal will be used. |
| 294 | /// |
| 295 | /// @param[in] stderr_path |
| 296 | /// The path to use when re-directing the STDERR of the new |
| 297 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 298 | /// terminal will be used. |
| 299 | /// |
| 300 | /// @param[in] working_directory |
| 301 | /// The working directory to have the child process run in |
| 302 | /// |
| 303 | /// @param[in] launch_flags |
| 304 | /// Some launch options specified by logical OR'ing |
| 305 | /// lldb::LaunchFlags enumeration values together. |
| 306 | /// |
| 307 | /// @param[in] stop_at_endtry |
| 308 | /// If false do not stop the inferior at the entry point. |
| 309 | /// |
| 310 | /// @param[out] |
| 311 | /// An error object. Contains the reason if there is some failure. |
| 312 | /// |
| 313 | /// @return |
| 314 | /// A process object for the newly created process. |
| 315 | //------------------------------------------------------------------ |
| 316 | |
| 317 | For example, |
| 318 | |
| 319 | process = target.Launch(self.dbg.GetListener(), None, None, |
| 320 | None, '/tmp/stdout.txt', None, |
| 321 | None, 0, False, error) |
| 322 | |
| 323 | launches a new process by passing nothing for both the args and the envs |
| 324 | and redirect the standard output of the inferior to the /tmp/stdout.txt |
| 325 | file. It does not specify a working directory so that the debug server |
| 326 | will use its idea of what the current working directory is for the |
| 327 | inferior. Also, we ask the debugger not to stop the inferior at the |
| 328 | entry point. If no breakpoint is specified for the inferior, it should |
| 329 | run to completion if no user interaction is required. |
| 330 | ") Launch; |
| 331 | lldb::SBProcess |
| 332 | Launch (SBListener &listener, |
| 333 | char const **argv, |
| 334 | char const **envp, |
| 335 | const char *stdin_path, |
| 336 | const char *stdout_path, |
| 337 | const char *stderr_path, |
| 338 | const char *working_directory, |
| 339 | uint32_t launch_flags, // See LaunchFlags |
| 340 | bool stop_at_entry, |
| 341 | lldb::SBError& error); |
| 342 | |
| 343 | %feature("docstring", " |
| 344 | //------------------------------------------------------------------ |
| 345 | /// Launch a new process with sensible defaults. |
| 346 | /// |
| 347 | /// @param[in] argv |
| 348 | /// The argument array. |
| 349 | /// |
| 350 | /// @param[in] envp |
| 351 | /// The environment array. |
| 352 | /// |
| 353 | /// @param[in] working_directory |
| 354 | /// The working directory to have the child process run in |
| 355 | /// |
| 356 | /// Default: listener |
| 357 | /// Set to the target's debugger (SBTarget::GetDebugger()) |
| 358 | /// |
| 359 | /// Default: launch_flags |
| 360 | /// Empty launch flags |
| 361 | /// |
| 362 | /// Default: stdin_path |
| 363 | /// Default: stdout_path |
| 364 | /// Default: stderr_path |
| 365 | /// A pseudo terminal will be used. |
| 366 | /// |
| 367 | /// @return |
| 368 | /// A process object for the newly created process. |
| 369 | //------------------------------------------------------------------ |
| 370 | |
| 371 | For example, |
| 372 | |
| 373 | process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) |
| 374 | |
| 375 | launches a new process by passing 'X', 'Y', 'Z' as the args to the |
| 376 | executable. |
| 377 | ") LaunchSimple; |
| 378 | lldb::SBProcess |
| 379 | LaunchSimple (const char **argv, |
| 380 | const char **envp, |
| 381 | const char *working_directory); |
| 382 | |
Greg Clayton | 0a8dcac | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 383 | lldb::SBProcess |
| 384 | Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); |
| 385 | |
| 386 | lldb::SBProcess |
| 387 | Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); |
| 388 | |
| 389 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 390 | %feature("docstring", " |
| 391 | //------------------------------------------------------------------ |
| 392 | /// Attach to process with pid. |
| 393 | /// |
| 394 | /// @param[in] listener |
| 395 | /// An optional listener that will receive all process events. |
| 396 | /// If \a listener is valid then \a listener will listen to all |
| 397 | /// process events. If not valid, then this target's debugger |
| 398 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 399 | /// |
| 400 | /// @param[in] pid |
| 401 | /// The process ID to attach to. |
| 402 | /// |
| 403 | /// @param[out] |
| 404 | /// An error explaining what went wrong if attach fails. |
| 405 | /// |
| 406 | /// @return |
| 407 | /// A process object for the attached process. |
| 408 | //------------------------------------------------------------------ |
| 409 | ") AttachToProcessWithID; |
| 410 | lldb::SBProcess |
| 411 | AttachToProcessWithID (SBListener &listener, |
| 412 | lldb::pid_t pid, |
| 413 | lldb::SBError& error); |
| 414 | |
| 415 | %feature("docstring", " |
| 416 | //------------------------------------------------------------------ |
| 417 | /// Attach to process with name. |
| 418 | /// |
| 419 | /// @param[in] listener |
| 420 | /// An optional listener that will receive all process events. |
| 421 | /// If \a listener is valid then \a listener will listen to all |
| 422 | /// process events. If not valid, then this target's debugger |
| 423 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 424 | /// |
| 425 | /// @param[in] name |
| 426 | /// Basename of process to attach to. |
| 427 | /// |
| 428 | /// @param[in] wait_for |
| 429 | /// If true wait for a new instance of 'name' to be launched. |
| 430 | /// |
| 431 | /// @param[out] |
| 432 | /// An error explaining what went wrong if attach fails. |
| 433 | /// |
| 434 | /// @return |
| 435 | /// A process object for the attached process. |
| 436 | //------------------------------------------------------------------ |
| 437 | ") AttachToProcessWithName; |
| 438 | lldb::SBProcess |
| 439 | AttachToProcessWithName (SBListener &listener, |
| 440 | const char *name, |
| 441 | bool wait_for, |
| 442 | lldb::SBError& error); |
| 443 | |
| 444 | %feature("docstring", " |
| 445 | //------------------------------------------------------------------ |
| 446 | /// Connect to a remote debug server with url. |
| 447 | /// |
| 448 | /// @param[in] listener |
| 449 | /// An optional listener that will receive all process events. |
| 450 | /// If \a listener is valid then \a listener will listen to all |
| 451 | /// process events. If not valid, then this target's debugger |
| 452 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 453 | /// |
| 454 | /// @param[in] url |
| 455 | /// The url to connect to, e.g., 'connect://localhost:12345'. |
| 456 | /// |
| 457 | /// @param[in] plugin_name |
| 458 | /// The plugin name to be used; can be NULL. |
| 459 | /// |
| 460 | /// @param[out] |
| 461 | /// An error explaining what went wrong if the connect fails. |
| 462 | /// |
| 463 | /// @return |
| 464 | /// A process object for the connected process. |
| 465 | //------------------------------------------------------------------ |
| 466 | ") ConnectRemote; |
| 467 | lldb::SBProcess |
| 468 | ConnectRemote (SBListener &listener, |
| 469 | const char *url, |
| 470 | const char *plugin_name, |
| 471 | SBError& error); |
| 472 | |
| 473 | lldb::SBFileSpec |
| 474 | GetExecutable (); |
| 475 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 476 | bool |
| 477 | AddModule (lldb::SBModule &module); |
| 478 | |
| 479 | lldb::SBModule |
| 480 | AddModule (const char *path, |
| 481 | const char *triple, |
| 482 | const char *uuid); |
| 483 | |
Greg Clayton | f0bc815 | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 484 | lldb::SBModule |
| 485 | AddModule (const char *path, |
| 486 | const char *triple, |
| 487 | const char *uuid_cstr, |
| 488 | const char *symfile); |
| 489 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 490 | uint32_t |
| 491 | GetNumModules () const; |
| 492 | |
| 493 | lldb::SBModule |
| 494 | GetModuleAtIndex (uint32_t idx); |
| 495 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 496 | bool |
| 497 | RemoveModule (lldb::SBModule module); |
| 498 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 499 | lldb::SBDebugger |
| 500 | GetDebugger() const; |
| 501 | |
| 502 | lldb::SBModule |
| 503 | FindModule (const lldb::SBFileSpec &file_spec); |
| 504 | |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 505 | lldb::ByteOrder |
| 506 | GetByteOrder (); |
| 507 | |
| 508 | uint32_t |
| 509 | GetAddressByteSize(); |
| 510 | |
| 511 | const char * |
| 512 | GetTriple (); |
| 513 | |
Greg Clayton | 3e8c25f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 514 | lldb::SBError |
| 515 | SetSectionLoadAddress (lldb::SBSection section, |
| 516 | lldb::addr_t section_base_addr); |
| 517 | |
| 518 | lldb::SBError |
| 519 | ClearSectionLoadAddress (lldb::SBSection section); |
| 520 | |
| 521 | lldb::SBError |
| 522 | SetModuleLoadAddress (lldb::SBModule module, |
| 523 | int64_t sections_offset); |
| 524 | |
| 525 | lldb::SBError |
| 526 | ClearModuleLoadAddress (lldb::SBModule module); |
| 527 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 528 | %feature("docstring", " |
| 529 | //------------------------------------------------------------------ |
| 530 | /// Find functions by name. |
| 531 | /// |
| 532 | /// @param[in] name |
| 533 | /// The name of the function we are looking for. |
| 534 | /// |
| 535 | /// @param[in] name_type_mask |
| 536 | /// A logical OR of one or more FunctionNameType enum bits that |
| 537 | /// indicate what kind of names should be used when doing the |
| 538 | /// lookup. Bits include fully qualified names, base names, |
| 539 | /// C++ methods, or ObjC selectors. |
| 540 | /// See FunctionNameType for more details. |
| 541 | /// |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 542 | /// @return |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 543 | /// A lldb::SBSymbolContextList that gets filled in with all of |
| 544 | /// the symbol contexts for all the matches. |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 545 | //------------------------------------------------------------------ |
| 546 | ") FindFunctions; |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 547 | lldb::SBSymbolContextList |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 548 | FindFunctions (const char *name, |
Greg Clayton | 7dd5c51 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 549 | uint32_t name_type_mask = lldb::eFunctionNameTypeAny); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 550 | |
| 551 | lldb::SBType |
| 552 | FindFirstType (const char* type); |
| 553 | |
| 554 | lldb::SBTypeList |
| 555 | FindTypes (const char* type); |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 556 | |
Jim Ingham | cc63746 | 2011-09-13 00:29:56 +0000 | [diff] [blame] | 557 | lldb::SBSourceManager |
| 558 | GetSourceManager (); |
| 559 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 560 | %feature("docstring", " |
| 561 | //------------------------------------------------------------------ |
| 562 | /// Find global and static variables by name. |
| 563 | /// |
| 564 | /// @param[in] name |
| 565 | /// The name of the global or static variable we are looking |
| 566 | /// for. |
| 567 | /// |
| 568 | /// @param[in] max_matches |
| 569 | /// Allow the number of matches to be limited to \a max_matches. |
| 570 | /// |
| 571 | /// @return |
| 572 | /// A list of matched variables in an SBValueList. |
| 573 | //------------------------------------------------------------------ |
| 574 | ") FindGlobalVariables; |
| 575 | lldb::SBValueList |
| 576 | FindGlobalVariables (const char *name, |
| 577 | uint32_t max_matches); |
| 578 | |
| 579 | void |
| 580 | Clear (); |
| 581 | |
Greg Clayton | a395506 | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 582 | lldb::SBAddress |
| 583 | ResolveLoadAddress (lldb::addr_t vm_addr); |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 584 | |
| 585 | SBSymbolContext |
| 586 | ResolveSymbolContextForAddress (const SBAddress& addr, |
| 587 | uint32_t resolve_scope); |
| 588 | |
| 589 | lldb::SBBreakpoint |
| 590 | BreakpointCreateByLocation (const char *file, uint32_t line); |
| 591 | |
| 592 | lldb::SBBreakpoint |
| 593 | BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); |
| 594 | |
| 595 | lldb::SBBreakpoint |
| 596 | BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); |
| 597 | |
| 598 | lldb::SBBreakpoint |
Jim Ingham | 1fb8a2d | 2011-10-11 01:18:55 +0000 | [diff] [blame] | 599 | BreakpointCreateByName (const char *symbol_name, |
| 600 | uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits |
| 601 | const SBFileSpecList &module_list, |
| 602 | const SBFileSpecList &comp_unit_list); |
| 603 | |
| 604 | lldb::SBBreakpoint |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 605 | BreakpointCreateByNames (const char *symbol_name[], |
| 606 | uint32_t num_names, |
| 607 | uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits |
| 608 | const SBFileSpecList &module_list, |
| 609 | const SBFileSpecList &comp_unit_list); |
| 610 | |
| 611 | lldb::SBBreakpoint |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 612 | BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); |
| 613 | |
| 614 | lldb::SBBreakpoint |
Jim Ingham | 03c8ee5 | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 615 | BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); |
| 616 | |
| 617 | lldb::SBBreakpoint |
Jim Ingham | 4722b10 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 618 | BreakpointCreateForException (lldb::LanguageType language, |
| 619 | bool catch_bp, |
| 620 | bool throw_bp); |
| 621 | |
| 622 | lldb::SBBreakpoint |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 623 | BreakpointCreateByAddress (addr_t address); |
| 624 | |
| 625 | uint32_t |
| 626 | GetNumBreakpoints () const; |
| 627 | |
| 628 | lldb::SBBreakpoint |
| 629 | GetBreakpointAtIndex (uint32_t idx) const; |
| 630 | |
| 631 | bool |
| 632 | BreakpointDelete (break_id_t break_id); |
| 633 | |
| 634 | lldb::SBBreakpoint |
| 635 | FindBreakpointByID (break_id_t break_id); |
| 636 | |
| 637 | bool |
| 638 | EnableAllBreakpoints (); |
| 639 | |
| 640 | bool |
| 641 | DisableAllBreakpoints (); |
| 642 | |
| 643 | bool |
| 644 | DeleteAllBreakpoints (); |
| 645 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 646 | uint32_t |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 647 | GetNumWatchpoints () const; |
| 648 | |
| 649 | lldb::SBWatchpoint |
| 650 | GetWatchpointAtIndex (uint32_t idx) const; |
| 651 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 652 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 653 | DeleteWatchpoint (lldb::watch_id_t watch_id); |
| 654 | |
| 655 | lldb::SBWatchpoint |
| 656 | FindWatchpointByID (lldb::watch_id_t watch_id); |
| 657 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 658 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 659 | EnableAllWatchpoints (); |
| 660 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 661 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 662 | DisableAllWatchpoints (); |
| 663 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 664 | bool |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 665 | DeleteAllWatchpoints (); |
| 666 | |
| 667 | lldb::SBWatchpoint |
| 668 | WatchAddress (lldb::addr_t addr, |
| 669 | size_t size, |
| 670 | bool read, |
Johnny Chen | 3f88349 | 2012-06-04 23:19:54 +0000 | [diff] [blame] | 671 | bool write, |
| 672 | SBError &error); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 673 | |
Johnny Chen | 092bd15 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 674 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 675 | lldb::SBBroadcaster |
| 676 | GetBroadcaster () const; |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 677 | |
| 678 | lldb::SBInstructionList |
Greg Clayton | a989307 | 2012-03-06 22:24:44 +0000 | [diff] [blame] | 679 | ReadInstructions (lldb::SBAddress base_addr, uint32_t count); |
| 680 | |
| 681 | lldb::SBInstructionList |
Sean Callanan | ef1f690 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 682 | GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); |
| 683 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 684 | bool |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 685 | GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 686 | |
| 687 | %pythoncode %{ |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 688 | class modules_access(object): |
| 689 | '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' |
| 690 | def __init__(self, sbtarget): |
| 691 | self.sbtarget = sbtarget |
| 692 | |
| 693 | def __len__(self): |
| 694 | if self.sbtarget: |
Filipe Cabecinhas | 3cae38b | 2012-05-11 20:39:42 +0000 | [diff] [blame] | 695 | return int(self.sbtarget.GetNumModules()) |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 696 | return 0 |
| 697 | |
| 698 | def __getitem__(self, key): |
| 699 | num_modules = self.sbtarget.GetNumModules() |
| 700 | if type(key) is int: |
| 701 | if key < num_modules: |
| 702 | return self.sbtarget.GetModuleAtIndex(key) |
| 703 | elif type(key) is str: |
| 704 | if key.find('/') == -1: |
| 705 | for idx in range(num_modules): |
| 706 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 707 | if module.file.basename == key: |
| 708 | return module |
| 709 | else: |
| 710 | for idx in range(num_modules): |
| 711 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 712 | if module.file.fullpath == key: |
| 713 | return module |
| 714 | # See if the string is a UUID |
| 715 | the_uuid = uuid.UUID(key) |
| 716 | if the_uuid: |
| 717 | for idx in range(num_modules): |
| 718 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 719 | if module.uuid == the_uuid: |
| 720 | return module |
| 721 | elif type(key) is uuid.UUID: |
| 722 | for idx in range(num_modules): |
| 723 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 724 | if module.uuid == key: |
| 725 | return module |
| 726 | elif type(key) is re.SRE_Pattern: |
| 727 | matching_modules = [] |
| 728 | for idx in range(num_modules): |
| 729 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 730 | re_match = key.search(module.path.fullpath) |
| 731 | if re_match: |
| 732 | matching_modules.append(module) |
| 733 | return matching_modules |
| 734 | else: |
| 735 | print "error: unsupported item type: %s" % type(key) |
| 736 | return None |
| 737 | |
| 738 | def get_modules_access_object(self): |
Greg Clayton | b6a5ba6 | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 739 | '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 740 | return self.modules_access (self) |
| 741 | |
| 742 | def get_modules_array(self): |
Greg Clayton | b6a5ba6 | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 743 | '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 744 | modules = [] |
| 745 | for idx in range(self.GetNumModules()): |
| 746 | modules.append(self.GetModuleAtIndex(idx)) |
| 747 | return modules |
| 748 | |
| 749 | __swig_getmethods__["modules"] = get_modules_array |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 750 | if _newclass: modules = property(get_modules_array, None, doc='''A read only property that returns a list() of lldb.SBModule objects contained in this target. This list is a list all modules that the target currently is tracking (the main executable and all dependent shared libraries).''') |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 751 | |
| 752 | __swig_getmethods__["module"] = get_modules_access_object |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 753 | if _newclass: module = property(get_modules_access_object, None, doc=r'''A read only property that returns an object that implements python operator overloading with the square brackets().\n target.module[<int>] allows array access to any modules.\n target.module[<str>] allows access to modules by basename, full path, or uuid string value.\n target.module[uuid.UUID()] allows module access by UUID.\n target.module[re] allows module access using a regular expression that matches the module full path.''') |
Greg Clayton | b302dff | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 754 | |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 755 | __swig_getmethods__["process"] = GetProcess |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 756 | if _newclass: process = property(GetProcess, None, doc='''A read only property that returns an lldb object that represents the process (lldb.SBProcess) that this target owns.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 757 | |
| 758 | __swig_getmethods__["executable"] = GetExecutable |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 759 | if _newclass: executable = property(GetExecutable, None, doc='''A read only property that returns an lldb object that represents the main executable module (lldb.SBModule) for this target.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 760 | |
| 761 | __swig_getmethods__["debugger"] = GetDebugger |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 762 | if _newclass: debugger = property(GetDebugger, None, doc='''A read only property that returns an lldb object that represents the debugger (lldb.SBDebugger) that owns this target.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 763 | |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 764 | __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 765 | if _newclass: num_breakpoints = property(GetNumBreakpoints, None, doc='''A read only property that returns the number of breakpoints that this target has as an integer.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 766 | |
| 767 | __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 768 | if _newclass: num_watchpoints = property(GetNumWatchpoints, None, doc='''A read only property that returns the number of watchpoints that this target has as an integer.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 769 | |
| 770 | __swig_getmethods__["broadcaster"] = GetBroadcaster |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 771 | if _newclass: broadcaster = property(GetBroadcaster, None, doc='''A read only property that an lldb object that represents the broadcaster (lldb.SBBroadcaster) for this target.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 772 | |
| 773 | __swig_getmethods__["byte_order"] = GetByteOrder |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 774 | if _newclass: byte_order = property(GetByteOrder, None, doc='''A read only property that returns an lldb enumeration value (lldb.eByteOrderLittle, lldb.eByteOrderBig, lldb.eByteOrderInvalid) that represents the byte order for this target.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 775 | |
| 776 | __swig_getmethods__["addr_size"] = GetAddressByteSize |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 777 | if _newclass: addr_size = property(GetAddressByteSize, None, doc='''A read only property that returns the size in bytes of an address for this target.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 778 | |
| 779 | __swig_getmethods__["triple"] = GetTriple |
Greg Clayton | 2a94be1 | 2012-06-29 22:00:42 +0000 | [diff] [blame^] | 780 | if _newclass: triple = property(GetTriple, None, doc='''A read only property that returns the target triple (arch-vendor-os) for this target as a string.''') |
Greg Clayton | 1b92520 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 781 | %} |
| 782 | |
Johnny Chen | ebd63b2 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 783 | }; |
| 784 | |
| 785 | } // namespace lldb |