Johnny Chen | dc7d3c1 | 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 | 0e61568 | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 12 | class SBLaunchInfo |
| 13 | { |
Greg Clayton | 38d1f05 | 2012-02-24 20:59:25 +0000 | [diff] [blame] | 14 | public: |
| 15 | SBLaunchInfo (const char **argv); |
Greg Clayton | 0e61568 | 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 | 0e61568 | 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 | cd16df9 | 2012-07-20 21:37:13 +0000 | [diff] [blame] | 128 | bool |
| 129 | GetIgnoreExisting (); |
| 130 | |
| 131 | void |
| 132 | SetIgnoreExisting (bool b); |
| 133 | |
Greg Clayton | 0e61568 | 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 | 41bd8ac | 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 | 0e61568 | 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 | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 193 | %feature("docstring", |
| 194 | "Represents the target program running under the debugger. |
| 195 | |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 196 | SBTarget supports module, breakpoint, and watchpoint iterations. For example, |
Johnny Chen | dc7d3c1 | 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 | d4dd799 | 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 | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 222 | for wp_loc in target.watchpoint_iter(): |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 223 | print wp_loc |
| 224 | |
| 225 | produces: |
| 226 | |
Johnny Chen | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 227 | Watchpoint 1: addr = 0x1034ca048 size = 4 state = enabled type = rw |
Johnny Chen | d4dd799 | 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 | 01a6786 | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 229 | hw_index = 0 hit_count = 2 ignore_count = 0" |
Johnny Chen | 357033b | 2011-07-18 20:13:38 +0000 | [diff] [blame] | 230 | ) SBTarget; |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 231 | class SBTarget |
| 232 | { |
Johnny Chen | dc7d3c1 | 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 | 1b5792e | 2012-12-18 02:03:49 +0000 | [diff] [blame] | 241 | eBroadcastBitModulesUnloaded = (1 << 2), |
Enrico Granata | f15ee4e | 2013-04-05 18:49:06 +0000 | [diff] [blame] | 242 | eBroadcastBitWatchpointChanged = (1 << 3), |
| 243 | eBroadcastBitSymbolsLoaded = (1 << 4) |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | //------------------------------------------------------------------ |
| 247 | // Constructors |
| 248 | //------------------------------------------------------------------ |
| 249 | SBTarget (); |
| 250 | |
| 251 | SBTarget (const lldb::SBTarget& rhs); |
| 252 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 253 | //------------------------------------------------------------------ |
| 254 | // Destructor |
| 255 | //------------------------------------------------------------------ |
| 256 | ~SBTarget(); |
| 257 | |
Jim Ingham | 4bddaeb | 2012-02-16 06:50:00 +0000 | [diff] [blame] | 258 | static const char * |
| 259 | GetBroadcasterClassName (); |
| 260 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 261 | bool |
| 262 | IsValid() const; |
| 263 | |
| 264 | lldb::SBProcess |
| 265 | GetProcess (); |
| 266 | |
| 267 | %feature("docstring", " |
| 268 | //------------------------------------------------------------------ |
| 269 | /// Launch a new process. |
| 270 | /// |
| 271 | /// Launch a new process by spawning a new process using the |
| 272 | /// target object's executable module's file as the file to launch. |
| 273 | /// Arguments are given in \a argv, and the environment variables |
| 274 | /// are in \a envp. Standard input and output files can be |
| 275 | /// optionally re-directed to \a stdin_path, \a stdout_path, and |
| 276 | /// \a stderr_path. |
| 277 | /// |
| 278 | /// @param[in] listener |
| 279 | /// An optional listener that will receive all process events. |
| 280 | /// If \a listener is valid then \a listener will listen to all |
| 281 | /// process events. If not valid, then this target's debugger |
| 282 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 283 | /// |
| 284 | /// @param[in] argv |
| 285 | /// The argument array. |
| 286 | /// |
| 287 | /// @param[in] envp |
| 288 | /// The environment array. |
| 289 | /// |
| 290 | /// @param[in] launch_flags |
| 291 | /// Flags to modify the launch (@see lldb::LaunchFlags) |
| 292 | /// |
| 293 | /// @param[in] stdin_path |
| 294 | /// The path to use when re-directing the STDIN of the new |
| 295 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 296 | /// terminal will be used. |
| 297 | /// |
| 298 | /// @param[in] stdout_path |
| 299 | /// The path to use when re-directing the STDOUT of the new |
| 300 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 301 | /// terminal will be used. |
| 302 | /// |
| 303 | /// @param[in] stderr_path |
| 304 | /// The path to use when re-directing the STDERR of the new |
| 305 | /// process. If all stdXX_path arguments are NULL, a pseudo |
| 306 | /// terminal will be used. |
| 307 | /// |
| 308 | /// @param[in] working_directory |
| 309 | /// The working directory to have the child process run in |
| 310 | /// |
| 311 | /// @param[in] launch_flags |
| 312 | /// Some launch options specified by logical OR'ing |
| 313 | /// lldb::LaunchFlags enumeration values together. |
| 314 | /// |
| 315 | /// @param[in] stop_at_endtry |
| 316 | /// If false do not stop the inferior at the entry point. |
| 317 | /// |
| 318 | /// @param[out] |
| 319 | /// An error object. Contains the reason if there is some failure. |
| 320 | /// |
| 321 | /// @return |
| 322 | /// A process object for the newly created process. |
| 323 | //------------------------------------------------------------------ |
| 324 | |
| 325 | For example, |
| 326 | |
| 327 | process = target.Launch(self.dbg.GetListener(), None, None, |
| 328 | None, '/tmp/stdout.txt', None, |
| 329 | None, 0, False, error) |
| 330 | |
| 331 | launches a new process by passing nothing for both the args and the envs |
| 332 | and redirect the standard output of the inferior to the /tmp/stdout.txt |
| 333 | file. It does not specify a working directory so that the debug server |
| 334 | will use its idea of what the current working directory is for the |
| 335 | inferior. Also, we ask the debugger not to stop the inferior at the |
| 336 | entry point. If no breakpoint is specified for the inferior, it should |
| 337 | run to completion if no user interaction is required. |
| 338 | ") Launch; |
| 339 | lldb::SBProcess |
| 340 | Launch (SBListener &listener, |
| 341 | char const **argv, |
| 342 | char const **envp, |
| 343 | const char *stdin_path, |
| 344 | const char *stdout_path, |
| 345 | const char *stderr_path, |
| 346 | const char *working_directory, |
| 347 | uint32_t launch_flags, // See LaunchFlags |
| 348 | bool stop_at_entry, |
| 349 | lldb::SBError& error); |
| 350 | |
| 351 | %feature("docstring", " |
| 352 | //------------------------------------------------------------------ |
| 353 | /// Launch a new process with sensible defaults. |
| 354 | /// |
| 355 | /// @param[in] argv |
| 356 | /// The argument array. |
| 357 | /// |
| 358 | /// @param[in] envp |
| 359 | /// The environment array. |
| 360 | /// |
| 361 | /// @param[in] working_directory |
| 362 | /// The working directory to have the child process run in |
| 363 | /// |
| 364 | /// Default: listener |
| 365 | /// Set to the target's debugger (SBTarget::GetDebugger()) |
| 366 | /// |
| 367 | /// Default: launch_flags |
| 368 | /// Empty launch flags |
| 369 | /// |
| 370 | /// Default: stdin_path |
| 371 | /// Default: stdout_path |
| 372 | /// Default: stderr_path |
| 373 | /// A pseudo terminal will be used. |
| 374 | /// |
| 375 | /// @return |
| 376 | /// A process object for the newly created process. |
| 377 | //------------------------------------------------------------------ |
| 378 | |
| 379 | For example, |
| 380 | |
| 381 | process = target.LaunchSimple(['X', 'Y', 'Z'], None, os.getcwd()) |
| 382 | |
| 383 | launches a new process by passing 'X', 'Y', 'Z' as the args to the |
| 384 | executable. |
| 385 | ") LaunchSimple; |
| 386 | lldb::SBProcess |
| 387 | LaunchSimple (const char **argv, |
| 388 | const char **envp, |
| 389 | const char *working_directory); |
| 390 | |
Greg Clayton | 0e61568 | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 391 | lldb::SBProcess |
| 392 | Launch (lldb::SBLaunchInfo &launch_info, lldb::SBError& error); |
Greg Clayton | 4d8ad55 | 2013-03-25 22:40:51 +0000 | [diff] [blame] | 393 | |
| 394 | %feature("docstring", " |
| 395 | //------------------------------------------------------------------ |
| 396 | /// Load a core file |
| 397 | /// |
| 398 | /// @param[in] core_file |
| 399 | /// File path of the core dump. |
| 400 | /// |
| 401 | /// @return |
| 402 | /// A process object for the newly created core file. |
| 403 | //------------------------------------------------------------------ |
| 404 | |
| 405 | For example, |
| 406 | |
| 407 | process = target.LoadCore('./a.out.core') |
| 408 | |
| 409 | loads a new core file and returns the process object. |
| 410 | ") LoadCore; |
| 411 | lldb::SBProcess |
| 412 | LoadCore(const char *core_file); |
Greg Clayton | 0e61568 | 2012-02-24 05:03:03 +0000 | [diff] [blame] | 413 | |
| 414 | lldb::SBProcess |
| 415 | Attach (lldb::SBAttachInfo &attach_info, lldb::SBError& error); |
| 416 | |
| 417 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 418 | %feature("docstring", " |
| 419 | //------------------------------------------------------------------ |
| 420 | /// Attach to process with pid. |
| 421 | /// |
| 422 | /// @param[in] listener |
| 423 | /// An optional listener that will receive all process events. |
| 424 | /// If \a listener is valid then \a listener will listen to all |
| 425 | /// process events. If not valid, then this target's debugger |
| 426 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 427 | /// |
| 428 | /// @param[in] pid |
| 429 | /// The process ID to attach to. |
| 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 | ") AttachToProcessWithID; |
| 438 | lldb::SBProcess |
| 439 | AttachToProcessWithID (SBListener &listener, |
| 440 | lldb::pid_t pid, |
| 441 | lldb::SBError& error); |
| 442 | |
| 443 | %feature("docstring", " |
| 444 | //------------------------------------------------------------------ |
| 445 | /// Attach to process with name. |
| 446 | /// |
| 447 | /// @param[in] listener |
| 448 | /// An optional listener that will receive all process events. |
| 449 | /// If \a listener is valid then \a listener will listen to all |
| 450 | /// process events. If not valid, then this target's debugger |
| 451 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 452 | /// |
| 453 | /// @param[in] name |
| 454 | /// Basename of process to attach to. |
| 455 | /// |
| 456 | /// @param[in] wait_for |
| 457 | /// If true wait for a new instance of 'name' to be launched. |
| 458 | /// |
| 459 | /// @param[out] |
| 460 | /// An error explaining what went wrong if attach fails. |
| 461 | /// |
| 462 | /// @return |
| 463 | /// A process object for the attached process. |
| 464 | //------------------------------------------------------------------ |
| 465 | ") AttachToProcessWithName; |
| 466 | lldb::SBProcess |
| 467 | AttachToProcessWithName (SBListener &listener, |
| 468 | const char *name, |
| 469 | bool wait_for, |
| 470 | lldb::SBError& error); |
| 471 | |
| 472 | %feature("docstring", " |
| 473 | //------------------------------------------------------------------ |
| 474 | /// Connect to a remote debug server with url. |
| 475 | /// |
| 476 | /// @param[in] listener |
| 477 | /// An optional listener that will receive all process events. |
| 478 | /// If \a listener is valid then \a listener will listen to all |
| 479 | /// process events. If not valid, then this target's debugger |
| 480 | /// (SBTarget::GetDebugger()) will listen to all process events. |
| 481 | /// |
| 482 | /// @param[in] url |
| 483 | /// The url to connect to, e.g., 'connect://localhost:12345'. |
| 484 | /// |
| 485 | /// @param[in] plugin_name |
| 486 | /// The plugin name to be used; can be NULL. |
| 487 | /// |
| 488 | /// @param[out] |
| 489 | /// An error explaining what went wrong if the connect fails. |
| 490 | /// |
| 491 | /// @return |
| 492 | /// A process object for the connected process. |
| 493 | //------------------------------------------------------------------ |
| 494 | ") ConnectRemote; |
| 495 | lldb::SBProcess |
| 496 | ConnectRemote (SBListener &listener, |
| 497 | const char *url, |
| 498 | const char *plugin_name, |
| 499 | SBError& error); |
| 500 | |
| 501 | lldb::SBFileSpec |
| 502 | GetExecutable (); |
| 503 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 504 | bool |
| 505 | AddModule (lldb::SBModule &module); |
| 506 | |
| 507 | lldb::SBModule |
| 508 | AddModule (const char *path, |
| 509 | const char *triple, |
| 510 | const char *uuid); |
| 511 | |
Greg Clayton | b210aec | 2012-04-23 20:23:39 +0000 | [diff] [blame] | 512 | lldb::SBModule |
| 513 | AddModule (const char *path, |
| 514 | const char *triple, |
| 515 | const char *uuid_cstr, |
| 516 | const char *symfile); |
| 517 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 518 | uint32_t |
| 519 | GetNumModules () const; |
| 520 | |
| 521 | lldb::SBModule |
| 522 | GetModuleAtIndex (uint32_t idx); |
| 523 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 524 | bool |
| 525 | RemoveModule (lldb::SBModule module); |
| 526 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 527 | lldb::SBDebugger |
| 528 | GetDebugger() const; |
| 529 | |
| 530 | lldb::SBModule |
| 531 | FindModule (const lldb::SBFileSpec &file_spec); |
| 532 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 533 | lldb::ByteOrder |
| 534 | GetByteOrder (); |
| 535 | |
| 536 | uint32_t |
| 537 | GetAddressByteSize(); |
| 538 | |
| 539 | const char * |
| 540 | GetTriple (); |
| 541 | |
Greg Clayton | cac9c5f | 2011-09-24 00:52:29 +0000 | [diff] [blame] | 542 | lldb::SBError |
| 543 | SetSectionLoadAddress (lldb::SBSection section, |
| 544 | lldb::addr_t section_base_addr); |
| 545 | |
| 546 | lldb::SBError |
| 547 | ClearSectionLoadAddress (lldb::SBSection section); |
| 548 | |
| 549 | lldb::SBError |
| 550 | SetModuleLoadAddress (lldb::SBModule module, |
| 551 | int64_t sections_offset); |
| 552 | |
| 553 | lldb::SBError |
| 554 | ClearModuleLoadAddress (lldb::SBModule module); |
| 555 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 556 | %feature("docstring", " |
| 557 | //------------------------------------------------------------------ |
| 558 | /// Find functions by name. |
| 559 | /// |
| 560 | /// @param[in] name |
| 561 | /// The name of the function we are looking for. |
| 562 | /// |
| 563 | /// @param[in] name_type_mask |
| 564 | /// A logical OR of one or more FunctionNameType enum bits that |
| 565 | /// indicate what kind of names should be used when doing the |
| 566 | /// lookup. Bits include fully qualified names, base names, |
| 567 | /// C++ methods, or ObjC selectors. |
| 568 | /// See FunctionNameType for more details. |
| 569 | /// |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 570 | /// @return |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 571 | /// A lldb::SBSymbolContextList that gets filled in with all of |
| 572 | /// the symbol contexts for all the matches. |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 573 | //------------------------------------------------------------------ |
| 574 | ") FindFunctions; |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 575 | lldb::SBSymbolContextList |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 576 | FindFunctions (const char *name, |
Greg Clayton | 5569e64 | 2012-02-06 01:44:54 +0000 | [diff] [blame] | 577 | uint32_t name_type_mask = lldb::eFunctionNameTypeAny); |
Enrico Granata | 6f3533f | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 578 | |
| 579 | lldb::SBType |
| 580 | FindFirstType (const char* type); |
| 581 | |
| 582 | lldb::SBTypeList |
| 583 | FindTypes (const char* type); |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 584 | |
Greg Clayton | b43165b | 2012-12-05 21:24:42 +0000 | [diff] [blame] | 585 | lldb::SBType |
| 586 | GetBasicType(lldb::BasicType type); |
| 587 | |
Jim Ingham | e37d605 | 2011-09-13 00:29:56 +0000 | [diff] [blame] | 588 | lldb::SBSourceManager |
| 589 | GetSourceManager (); |
| 590 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 591 | %feature("docstring", " |
| 592 | //------------------------------------------------------------------ |
| 593 | /// Find global and static variables by name. |
| 594 | /// |
| 595 | /// @param[in] name |
| 596 | /// The name of the global or static variable we are looking |
| 597 | /// for. |
| 598 | /// |
| 599 | /// @param[in] max_matches |
| 600 | /// Allow the number of matches to be limited to \a max_matches. |
| 601 | /// |
| 602 | /// @return |
| 603 | /// A list of matched variables in an SBValueList. |
| 604 | //------------------------------------------------------------------ |
| 605 | ") FindGlobalVariables; |
| 606 | lldb::SBValueList |
| 607 | FindGlobalVariables (const char *name, |
| 608 | uint32_t max_matches); |
| 609 | |
Enrico Granata | bcd80b4 | 2013-01-16 18:53:52 +0000 | [diff] [blame] | 610 | %feature("docstring", " |
| 611 | //------------------------------------------------------------------ |
| 612 | /// Find the first global (or static) variable by name. |
| 613 | /// |
| 614 | /// @param[in] name |
| 615 | /// The name of the global or static variable we are looking |
| 616 | /// for. |
| 617 | /// |
| 618 | /// @return |
| 619 | /// An SBValue that gets filled in with the found variable (if any). |
| 620 | //------------------------------------------------------------------ |
| 621 | ") FindFirstGlobalVariable; |
| 622 | lldb::SBValue |
| 623 | FindFirstGlobalVariable (const char* name); |
| 624 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 625 | void |
| 626 | Clear (); |
| 627 | |
Greg Clayton | 00e6fbf | 2011-07-22 16:46:35 +0000 | [diff] [blame] | 628 | lldb::SBAddress |
| 629 | ResolveLoadAddress (lldb::addr_t vm_addr); |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 630 | |
| 631 | SBSymbolContext |
| 632 | ResolveSymbolContextForAddress (const SBAddress& addr, |
| 633 | uint32_t resolve_scope); |
| 634 | |
| 635 | lldb::SBBreakpoint |
| 636 | BreakpointCreateByLocation (const char *file, uint32_t line); |
| 637 | |
| 638 | lldb::SBBreakpoint |
| 639 | BreakpointCreateByLocation (const lldb::SBFileSpec &file_spec, uint32_t line); |
| 640 | |
| 641 | lldb::SBBreakpoint |
| 642 | BreakpointCreateByName (const char *symbol_name, const char *module_name = NULL); |
| 643 | |
| 644 | lldb::SBBreakpoint |
Jim Ingham | 2dd7f7f | 2011-10-11 01:18:55 +0000 | [diff] [blame] | 645 | BreakpointCreateByName (const char *symbol_name, |
| 646 | uint32_t func_name_type, // Logical OR one or more FunctionNameType enum bits |
| 647 | const SBFileSpecList &module_list, |
| 648 | const SBFileSpecList &comp_unit_list); |
| 649 | |
| 650 | lldb::SBBreakpoint |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 651 | BreakpointCreateByNames (const char *symbol_name[], |
| 652 | uint32_t num_names, |
| 653 | uint32_t name_type_mask, // Logical OR one or more FunctionNameType enum bits |
| 654 | const SBFileSpecList &module_list, |
| 655 | const SBFileSpecList &comp_unit_list); |
| 656 | |
| 657 | lldb::SBBreakpoint |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 658 | BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name = NULL); |
| 659 | |
| 660 | lldb::SBBreakpoint |
Jim Ingham | 969795f | 2011-09-21 01:17:13 +0000 | [diff] [blame] | 661 | BreakpointCreateBySourceRegex (const char *source_regex, const lldb::SBFileSpec &source_file, const char *module_name = NULL); |
| 662 | |
| 663 | lldb::SBBreakpoint |
Jim Ingham | fab10e8 | 2012-03-06 00:37:27 +0000 | [diff] [blame] | 664 | BreakpointCreateForException (lldb::LanguageType language, |
| 665 | bool catch_bp, |
| 666 | bool throw_bp); |
| 667 | |
| 668 | lldb::SBBreakpoint |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 669 | BreakpointCreateByAddress (addr_t address); |
| 670 | |
| 671 | uint32_t |
| 672 | GetNumBreakpoints () const; |
| 673 | |
| 674 | lldb::SBBreakpoint |
| 675 | GetBreakpointAtIndex (uint32_t idx) const; |
| 676 | |
| 677 | bool |
| 678 | BreakpointDelete (break_id_t break_id); |
| 679 | |
| 680 | lldb::SBBreakpoint |
| 681 | FindBreakpointByID (break_id_t break_id); |
| 682 | |
| 683 | bool |
| 684 | EnableAllBreakpoints (); |
| 685 | |
| 686 | bool |
| 687 | DisableAllBreakpoints (); |
| 688 | |
| 689 | bool |
| 690 | DeleteAllBreakpoints (); |
| 691 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 692 | uint32_t |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 693 | GetNumWatchpoints () const; |
| 694 | |
| 695 | lldb::SBWatchpoint |
| 696 | GetWatchpointAtIndex (uint32_t idx) const; |
| 697 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 698 | bool |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 699 | DeleteWatchpoint (lldb::watch_id_t watch_id); |
| 700 | |
| 701 | lldb::SBWatchpoint |
| 702 | FindWatchpointByID (lldb::watch_id_t watch_id); |
| 703 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 704 | bool |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 705 | EnableAllWatchpoints (); |
| 706 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 707 | bool |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 708 | DisableAllWatchpoints (); |
| 709 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 710 | bool |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 711 | DeleteAllWatchpoints (); |
| 712 | |
| 713 | lldb::SBWatchpoint |
| 714 | WatchAddress (lldb::addr_t addr, |
| 715 | size_t size, |
| 716 | bool read, |
Johnny Chen | b90827e | 2012-06-04 23:19:54 +0000 | [diff] [blame] | 717 | bool write, |
| 718 | SBError &error); |
Greg Clayton | 1b282f9 | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 719 | |
Johnny Chen | d4dd799 | 2011-09-27 01:19:20 +0000 | [diff] [blame] | 720 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 721 | lldb::SBBroadcaster |
| 722 | GetBroadcaster () const; |
Sean Callanan | 50952e9 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 723 | |
| 724 | lldb::SBInstructionList |
Greg Clayton | 9c76611 | 2012-03-06 22:24:44 +0000 | [diff] [blame] | 725 | ReadInstructions (lldb::SBAddress base_addr, uint32_t count); |
| 726 | |
| 727 | lldb::SBInstructionList |
Jim Ingham | 0f063ba | 2013-03-02 00:26:47 +0000 | [diff] [blame] | 728 | ReadInstructions (lldb::SBAddress base_addr, uint32_t count, const char *flavor_string); |
| 729 | |
| 730 | lldb::SBInstructionList |
Sean Callanan | 50952e9 | 2011-12-14 23:49:37 +0000 | [diff] [blame] | 731 | GetInstructions (lldb::SBAddress base_addr, const void *buf, size_t size); |
| 732 | |
Jim Ingham | 0f063ba | 2013-03-02 00:26:47 +0000 | [diff] [blame] | 733 | lldb::SBInstructionList |
| 734 | GetInstructionsWithFlavor (lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size); |
| 735 | |
Greg Clayton | e14e192 | 2012-12-04 02:22:16 +0000 | [diff] [blame] | 736 | lldb::SBSymbolContextList |
| 737 | FindSymbols (const char *name, lldb::SymbolType type = eSymbolTypeAny); |
| 738 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 739 | bool |
Greg Clayton | da7bc7d | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 740 | GetDescription (lldb::SBStream &description, lldb::DescriptionLevel description_level); |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 741 | |
Greg Clayton | 13fbb99 | 2013-02-01 00:47:49 +0000 | [diff] [blame] | 742 | lldb::addr_t |
| 743 | GetStackRedZoneSize(); |
| 744 | |
Enrico Granata | c338733 | 2013-05-03 01:29:27 +0000 | [diff] [blame] | 745 | bool |
| 746 | operator == (const lldb::SBTarget &rhs) const; |
| 747 | |
| 748 | bool |
| 749 | operator != (const lldb::SBTarget &rhs) const; |
| 750 | |
Greg Clayton | 4b63a5c | 2013-01-04 18:10:18 +0000 | [diff] [blame] | 751 | lldb::SBValue |
| 752 | EvaluateExpression (const char *expr, const lldb::SBExpressionOptions &options); |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 753 | %pythoncode %{ |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 754 | class modules_access(object): |
| 755 | '''A helper object that will lazily hand out lldb.SBModule objects for a target when supplied an index, or by full or partial path.''' |
| 756 | def __init__(self, sbtarget): |
| 757 | self.sbtarget = sbtarget |
| 758 | |
| 759 | def __len__(self): |
| 760 | if self.sbtarget: |
Filipe Cabecinhas | 1a96ef8 | 2012-05-11 20:39:42 +0000 | [diff] [blame] | 761 | return int(self.sbtarget.GetNumModules()) |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 762 | return 0 |
| 763 | |
| 764 | def __getitem__(self, key): |
| 765 | num_modules = self.sbtarget.GetNumModules() |
| 766 | if type(key) is int: |
| 767 | if key < num_modules: |
| 768 | return self.sbtarget.GetModuleAtIndex(key) |
| 769 | elif type(key) is str: |
| 770 | if key.find('/') == -1: |
| 771 | for idx in range(num_modules): |
| 772 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 773 | if module.file.basename == key: |
| 774 | return module |
| 775 | else: |
| 776 | for idx in range(num_modules): |
| 777 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 778 | if module.file.fullpath == key: |
| 779 | return module |
| 780 | # See if the string is a UUID |
Greg Clayton | 1fb7c62 | 2013-03-07 02:58:47 +0000 | [diff] [blame] | 781 | try: |
| 782 | the_uuid = uuid.UUID(key) |
| 783 | if the_uuid: |
| 784 | for idx in range(num_modules): |
| 785 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 786 | if module.uuid == the_uuid: |
| 787 | return module |
| 788 | except: |
| 789 | return None |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 790 | elif type(key) is uuid.UUID: |
| 791 | for idx in range(num_modules): |
| 792 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 793 | if module.uuid == key: |
| 794 | return module |
| 795 | elif type(key) is re.SRE_Pattern: |
| 796 | matching_modules = [] |
| 797 | for idx in range(num_modules): |
| 798 | module = self.sbtarget.GetModuleAtIndex(idx) |
| 799 | re_match = key.search(module.path.fullpath) |
| 800 | if re_match: |
| 801 | matching_modules.append(module) |
| 802 | return matching_modules |
| 803 | else: |
| 804 | print "error: unsupported item type: %s" % type(key) |
| 805 | return None |
| 806 | |
| 807 | def get_modules_access_object(self): |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 808 | '''An accessor function that returns a modules_access() object which allows lazy module access from a lldb.SBTarget object.''' |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 809 | return self.modules_access (self) |
| 810 | |
| 811 | def get_modules_array(self): |
Greg Clayton | b62bb8c | 2012-02-03 03:22:53 +0000 | [diff] [blame] | 812 | '''An accessor function that returns a list() that contains all modules in a lldb.SBTarget object.''' |
Greg Clayton | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 813 | modules = [] |
| 814 | for idx in range(self.GetNumModules()): |
| 815 | modules.append(self.GetModuleAtIndex(idx)) |
| 816 | return modules |
| 817 | |
| 818 | __swig_getmethods__["modules"] = get_modules_array |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 819 | 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 | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 820 | |
| 821 | __swig_getmethods__["module"] = get_modules_access_object |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 822 | 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 | 6b2bd93 | 2012-02-01 08:09:32 +0000 | [diff] [blame] | 823 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 824 | __swig_getmethods__["process"] = GetProcess |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 825 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 826 | |
| 827 | __swig_getmethods__["executable"] = GetExecutable |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 828 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 829 | |
| 830 | __swig_getmethods__["debugger"] = GetDebugger |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 831 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 832 | |
Greg Clayton | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 833 | __swig_getmethods__["num_breakpoints"] = GetNumBreakpoints |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 834 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 835 | |
| 836 | __swig_getmethods__["num_watchpoints"] = GetNumWatchpoints |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 837 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 838 | |
| 839 | __swig_getmethods__["broadcaster"] = GetBroadcaster |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 840 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 841 | |
| 842 | __swig_getmethods__["byte_order"] = GetByteOrder |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 843 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 844 | |
| 845 | __swig_getmethods__["addr_size"] = GetAddressByteSize |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 846 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 847 | |
| 848 | __swig_getmethods__["triple"] = GetTriple |
Greg Clayton | 5ef31a9 | 2012-06-29 22:00:42 +0000 | [diff] [blame] | 849 | 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 | 13d1950 | 2012-01-29 06:07:39 +0000 | [diff] [blame] | 850 | %} |
| 851 | |
Johnny Chen | dc7d3c1 | 2011-07-16 21:15:39 +0000 | [diff] [blame] | 852 | }; |
| 853 | |
| 854 | } // namespace lldb |