1 //===-- SWIG Interface for SBError ------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 "Represents a container for holding any error code.
14 For example (from test/python_api/hello_world/TestHelloWorld.py),
16 def hello_world_attach_with_id_api(self):
17 '''Create target, spawn a process, and attach to it by id.'''
19 target = self.dbg.CreateTarget(self.exe)
21 # Spawn a new process and don't display the stdout if not in TraceOn() mode.
23 popen = subprocess.Popen([self.exe, 'abc', 'xyz'],
24 stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
26 listener = lldb.SBListener('my.attach.listener')
27 error = lldb.SBError()
28 process = target.AttachToProcessWithID(listener, popen.pid, error)
30 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
32 # Let's check the stack traces of the attached process.
34 stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
35 self.expect(stacktraces, exe=False,
36 substrs = ['main.c:%d' % self.line2,
39 listener = lldb.SBListener('my.attach.listener')
40 error = lldb.SBError()
41 process = target.AttachToProcessWithID(listener, popen.pid, error)
43 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
45 checks that after the attach, there is no error condition by asserting
46 that error.Success() is True and we get back a valid process object.
48 And (from test/python_api/event/TestEvent.py),
50 # Now launch the process, and do not stop at entry point.
51 error = lldb.SBError()
52 process = target.Launch(listener, None, None, None, None, None, None, 0, False, error)
53 self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
55 checks that after calling the target.Launch() method there's no error
56 condition and we get back a void process object.") SBError;
62 SBError (const lldb::SBError &rhs);
85 SetError (uint32_t err, lldb::ErrorType type);
91 SetErrorToGenericError ();
94 SetErrorString (const char *err_str);
96 %varargs(3, char *str = NULL) SetErrorStringWithFormat;
98 SetErrorStringWithFormat (const char *format, ...);
103 explicit operator bool() const;
106 GetDescription (lldb::SBStream &description);
108 STRING_EXTENSION(SBError)
112 value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
113 fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
114 success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
115 description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
116 type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')