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