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