blob: bebf2d7d72a59c80cc34a849f54c25184a95e06b [file] [log] [blame]
Johnny Chenfdc4a862011-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 Chen89577292011-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;
Adrian McCarthy1d34f742015-10-13 17:54:15 +000059
Johnny Chenfdc4a862011-07-19 22:41:47 +000060class SBError {
61public:
62 SBError ();
63
64 SBError (const lldb::SBError &rhs);
65
66 ~SBError();
67
68 const char *
69 GetCString () const;
70
71 void
72 Clear ();
73
74 bool
75 Fail () const;
76
77 bool
78 Success () const;
79
80 uint32_t
81 GetError () const;
82
83 lldb::ErrorType
84 GetType () const;
85
86 void
87 SetError (uint32_t err, lldb::ErrorType type);
88
89 void
90 SetErrorToErrno ();
91
92 void
93 SetErrorToGenericError ();
94
95 void
96 SetErrorString (const char *err_str);
97
Adrian McCarthy1d34f742015-10-13 17:54:15 +000098 %varargs(3, char *str = NULL) SetErrorStringWithFormat;
Johnny Chenfdc4a862011-07-19 22:41:47 +000099 int
100 SetErrorStringWithFormat (const char *format, ...);
101
102 bool
103 IsValid () const;
104
105 bool
106 GetDescription (lldb::SBStream &description);
Greg Clayton13d19502012-01-29 06:07:39 +0000107
108 %pythoncode %{
109 __swig_getmethods__["value"] = GetError
Greg Clayton5ef31a92012-06-29 22:00:42 +0000110 if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
Greg Clayton13d19502012-01-29 06:07:39 +0000111
112 __swig_getmethods__["fail"] = Fail
Greg Clayton5ef31a92012-06-29 22:00:42 +0000113 if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
Greg Clayton13d19502012-01-29 06:07:39 +0000114
115 __swig_getmethods__["success"] = Success
Greg Clayton5ef31a92012-06-29 22:00:42 +0000116 if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
Greg Clayton13d19502012-01-29 06:07:39 +0000117
118 __swig_getmethods__["description"] = GetCString
Greg Clayton5ef31a92012-06-29 22:00:42 +0000119 if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
Greg Clayton13d19502012-01-29 06:07:39 +0000120
121 __swig_getmethods__["type"] = GetType
Greg Clayton5ef31a92012-06-29 22:00:42 +0000122 if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
Greg Clayton13d19502012-01-29 06:07:39 +0000123
124 %}
125
Johnny Chenfdc4a862011-07-19 22:41:47 +0000126};
127
128} // namespace lldb