blob: d8dece2b22dca7e94cb9b0b559060240daba8669 [file] [log] [blame]
Johnny Chen5cb6cab2011-07-19 22:41:47 +00001//===-- SWIG Interface for SBError ------------------------------*- 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
10namespace lldb {
11
Johnny Chenc7162a52011-07-20 00:23:11 +000012%feature("docstring",
13"Represents a container for holding any error code.
14
15For example (from test/python_api/hello_world/TestHelloWorld.py),
16
17 def hello_world_attach_with_id_api(self):
18 '''Create target, spawn a process, and attach to it by id.'''
19
20 target = self.dbg.CreateTarget(self.exe)
21
22 # Spawn a new process and don't display the stdout if not in TraceOn() mode.
23 import subprocess
24 popen = subprocess.Popen([self.exe, 'abc', 'xyz'],
25 stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
26
27 listener = lldb.SBListener('my.attach.listener')
28 error = lldb.SBError()
29 process = target.AttachToProcessWithID(listener, popen.pid, error)
30
31 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
32
33 # Let's check the stack traces of the attached process.
34 import lldbutil
35 stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
36 self.expect(stacktraces, exe=False,
37 substrs = ['main.c:%d' % self.line2,
38 '(int)argc=3'])
39
40 listener = lldb.SBListener('my.attach.listener')
41 error = lldb.SBError()
42 process = target.AttachToProcessWithID(listener, popen.pid, error)
43
44 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
45
46checks that after the attach, there is no error condition by asserting
47that error.Success() is True and we get back a valid process object.
48
49And (from test/python_api/event/TestEvent.py),
50
51 # Now launch the process, and do not stop at entry point.
52 error = lldb.SBError()
53 process = target.Launch(listener, None, None, None, None, None, None, 0, False, error)
54 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
55
56checks that after calling the target.Launch() method there's no error
57condition and we get back a void process object.
58") SBError;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000059class SBError {
60public:
61 SBError ();
62
63 SBError (const lldb::SBError &rhs);
64
65 ~SBError();
66
67 const char *
68 GetCString () const;
69
70 void
71 Clear ();
72
73 bool
74 Fail () const;
75
76 bool
77 Success () const;
78
79 uint32_t
80 GetError () const;
81
82 lldb::ErrorType
83 GetType () const;
84
85 void
86 SetError (uint32_t err, lldb::ErrorType type);
87
88 void
89 SetErrorToErrno ();
90
91 void
92 SetErrorToGenericError ();
93
94 void
95 SetErrorString (const char *err_str);
96
97 int
98 SetErrorStringWithFormat (const char *format, ...);
99
100 bool
101 IsValid () const;
102
103 bool
104 GetDescription (lldb::SBStream &description);
Greg Clayton1b925202012-01-29 06:07:39 +0000105
106 %pythoncode %{
107 __swig_getmethods__["value"] = GetError
Greg Clayton2a94be12012-06-29 22:00:42 +0000108 if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
Greg Clayton1b925202012-01-29 06:07:39 +0000109
110 __swig_getmethods__["fail"] = Fail
Greg Clayton2a94be12012-06-29 22:00:42 +0000111 if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
Greg Clayton1b925202012-01-29 06:07:39 +0000112
113 __swig_getmethods__["success"] = Success
Greg Clayton2a94be12012-06-29 22:00:42 +0000114 if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
Greg Clayton1b925202012-01-29 06:07:39 +0000115
116 __swig_getmethods__["description"] = GetCString
Greg Clayton2a94be12012-06-29 22:00:42 +0000117 if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
Greg Clayton1b925202012-01-29 06:07:39 +0000118
119 __swig_getmethods__["type"] = GetType
Greg Clayton2a94be12012-06-29 22:00:42 +0000120 if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
Greg Clayton1b925202012-01-29 06:07:39 +0000121
122 %}
123
Johnny Chen5cb6cab2011-07-19 22:41:47 +0000124};
125
126} // namespace lldb