xref: /freebsd/contrib/llvm-project/lldb/bindings/interface/SBErrorDocstrings.i (revision 06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e)
1*06c3fb27SDimitry Andric %feature("docstring",
2*06c3fb27SDimitry Andric "Represents a container for holding any error code.
3*06c3fb27SDimitry Andric 
4*06c3fb27SDimitry Andric For example (from test/python_api/hello_world/TestHelloWorld.py), ::
5*06c3fb27SDimitry Andric 
6*06c3fb27SDimitry Andric     def hello_world_attach_with_id_api(self):
7*06c3fb27SDimitry Andric         '''Create target, spawn a process, and attach to it by id.'''
8*06c3fb27SDimitry Andric 
9*06c3fb27SDimitry Andric         target = self.dbg.CreateTarget(self.exe)
10*06c3fb27SDimitry Andric 
11*06c3fb27SDimitry Andric         # Spawn a new process and don't display the stdout if not in TraceOn() mode.
12*06c3fb27SDimitry Andric         import subprocess
13*06c3fb27SDimitry Andric         popen = subprocess.Popen([self.exe, 'abc', 'xyz'],
14*06c3fb27SDimitry Andric                                  stdout = open(os.devnull, 'w') if not self.TraceOn() else None)
15*06c3fb27SDimitry Andric 
16*06c3fb27SDimitry Andric         listener = lldb.SBListener('my.attach.listener')
17*06c3fb27SDimitry Andric         error = lldb.SBError()
18*06c3fb27SDimitry Andric         process = target.AttachToProcessWithID(listener, popen.pid, error)
19*06c3fb27SDimitry Andric 
20*06c3fb27SDimitry Andric         self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
21*06c3fb27SDimitry Andric 
22*06c3fb27SDimitry Andric         # Let's check the stack traces of the attached process.
23*06c3fb27SDimitry Andric         import lldbutil
24*06c3fb27SDimitry Andric         stacktraces = lldbutil.print_stacktraces(process, string_buffer=True)
25*06c3fb27SDimitry Andric         self.expect(stacktraces, exe=False,
26*06c3fb27SDimitry Andric             substrs = ['main.c:%d' % self.line2,
27*06c3fb27SDimitry Andric                        '(int)argc=3'])
28*06c3fb27SDimitry Andric 
29*06c3fb27SDimitry Andric         listener = lldb.SBListener('my.attach.listener')
30*06c3fb27SDimitry Andric         error = lldb.SBError()
31*06c3fb27SDimitry Andric         process = target.AttachToProcessWithID(listener, popen.pid, error)
32*06c3fb27SDimitry Andric 
33*06c3fb27SDimitry Andric         self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
34*06c3fb27SDimitry Andric 
35*06c3fb27SDimitry Andric checks that after the attach, there is no error condition by asserting
36*06c3fb27SDimitry Andric that error.Success() is True and we get back a valid process object.
37*06c3fb27SDimitry Andric 
38*06c3fb27SDimitry Andric And (from test/python_api/event/TestEvent.py), ::
39*06c3fb27SDimitry Andric 
40*06c3fb27SDimitry Andric         # Now launch the process, and do not stop at entry point.
41*06c3fb27SDimitry Andric         error = lldb.SBError()
42*06c3fb27SDimitry Andric         process = target.Launch(listener, None, None, None, None, None, None, 0, False, error)
43*06c3fb27SDimitry Andric         self.assertTrue(error.Success() and process, PROCESS_IS_VALID)
44*06c3fb27SDimitry Andric 
45*06c3fb27SDimitry Andric checks that after calling the target.Launch() method there's no error
46*06c3fb27SDimitry Andric condition and we get back a void process object.") lldb::SBError;
47