• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- 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 
10 namespace lldb {
11 
12 %feature("docstring",
13 "Represents a container for holding any error code.
14 
15 For 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 
46 checks that after the attach, there is no error condition by asserting
47 that error.Success() is True and we get back a valid process object.
48 
49 And (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 
56 checks that after calling the target.Launch() method there's no error
57 condition and we get back a void process object.
58 ") SBError;
59 class SBError {
60 public:
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);
105 
106     %pythoncode %{
107         __swig_getmethods__["value"] = GetError
108         if _newclass: value = property(GetError, None, doc='''A read only property that returns the same result as GetError().''')
109 
110         __swig_getmethods__["fail"] = Fail
111         if _newclass: fail = property(Fail, None, doc='''A read only property that returns the same result as Fail().''')
112 
113         __swig_getmethods__["success"] = Success
114         if _newclass: success = property(Success, None, doc='''A read only property that returns the same result as Success().''')
115 
116         __swig_getmethods__["description"] = GetCString
117         if _newclass: description = property(GetCString, None, doc='''A read only property that returns the same result as GetCString().''')
118 
119         __swig_getmethods__["type"] = GetType
120         if _newclass: type = property(GetType, None, doc='''A read only property that returns the same result as GetType().''')
121 
122     %}
123 
124 };
125 
126 } // namespace lldb
127