Skip to content

Commit f52ef6b

Browse files
authored
Merge pull request #6279 from medismailben/stable/20221013
Various Scripted Process fixes and improvements
2 parents 230e541 + b5ba9a5 commit f52ef6b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+710
-613
lines changed

lldb/bindings/interface/SBProcess.i

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,12 @@ public:
344344
bool
345345
GetDescription (lldb::SBStream &description);
346346

347+
%feature("autodoc", "
348+
Returns the implementation object of the process plugin if available. None
349+
otherwise.") GetScriptedImplementation;
350+
ScriptedObject
351+
GetScriptedImplementation();
352+
347353
%feature("autodoc", "
348354
Returns the process' extended crash information.") GetExtendedCrashInformation;
349355
lldb::SBStructuredData

lldb/bindings/python/python-swigsafecast.swig

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,6 @@ PythonObject ToSWIGHelper(void *obj, swig_type_info *info) {
55
return {PyRefType::Owned, SWIG_NewPointerObj(obj, info, SWIG_POINTER_OWN)};
66
}
77

8-
/// A class that automatically clears an SB object when it goes out of scope.
9-
/// Use for cases where the SB object points to a temporary/unowned entity.
10-
template <typename T> class ScopedPythonObject : PythonObject {
11-
public:
12-
ScopedPythonObject(T *sb, swig_type_info *info)
13-
: PythonObject(ToSWIGHelper(sb, info)), m_sb(sb) {}
14-
~ScopedPythonObject() {
15-
if (m_sb)
16-
*m_sb = T();
17-
}
18-
ScopedPythonObject(ScopedPythonObject &&rhs)
19-
: PythonObject(std::move(rhs)), m_sb(std::exchange(rhs.m_sb, nullptr)) {}
20-
ScopedPythonObject(const ScopedPythonObject &) = delete;
21-
ScopedPythonObject &operator=(const ScopedPythonObject &) = delete;
22-
ScopedPythonObject &operator=(ScopedPythonObject &&) = delete;
23-
24-
const PythonObject &obj() const { return *this; }
25-
26-
private:
27-
T *m_sb;
28-
};
29-
308
PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBValue> value_sb) {
319
return ToSWIGHelper(value_sb.release(), SWIGTYPE_p_lldb__SBValue);
3210
}
@@ -55,6 +33,10 @@ PythonObject ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
5533
SWIGTYPE_p_lldb__SBBreakpoint);
5634
}
5735

36+
PythonObject ToSWIGWrapper(const Status& status) {
37+
return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
38+
}
39+
5840
PythonObject ToSWIGWrapper(std::unique_ptr<lldb::SBStream> stream_sb) {
5941
return ToSWIGHelper(stream_sb.release(), SWIGTYPE_p_lldb__SBStream);
6042
}

lldb/bindings/python/python-typemaps.swig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@
5454
free((char *) $1);
5555
}
5656

57+
%typemap(out) lldb::ScriptedObject {
58+
$result = nullptr;
59+
if (const void* impl = $1)
60+
$result = (PyObject*) impl;
61+
if (!$result) {
62+
$result = Py_None;
63+
Py_INCREF(Py_None);
64+
}
65+
}
66+
5767
%typemap(out) char** {
5868
int len;
5969
int i;

lldb/bindings/python/static-binding/LLDBWrapPython.cpp

Lines changed: 109 additions & 52 deletions
Large diffs are not rendered by default.

lldb/bindings/python/static-binding/lldb.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,12 @@ def lldb_iter(obj, getsize, getelem):
744744

745745
eDynamicDontRunTarget = _lldb.eDynamicDontRunTarget
746746

747+
eBindAuto = _lldb.eBindAuto
748+
749+
eBind = _lldb.eBind
750+
751+
eDontBind = _lldb.eDontBind
752+
747753
eStopShowColumnAnsiOrCaret = _lldb.eStopShowColumnAnsiOrCaret
748754

749755
eStopShowColumnAnsi = _lldb.eStopShowColumnAnsi
@@ -952,6 +958,8 @@ def lldb_iter(obj, getsize, getelem):
952958

953959
eArgTypeStopHookID = _lldb.eArgTypeStopHookID
954960

961+
eArgTypeBindGenTypeParamValue = _lldb.eArgTypeBindGenTypeParamValue
962+
955963
eArgTypeLastArg = _lldb.eArgTypeLastArg
956964

957965
eSymbolTypeAny = _lldb.eSymbolTypeAny
@@ -1616,6 +1624,12 @@ def lldb_iter(obj, getsize, getelem):
16161624

16171625
eTraceCursorSeekTypeEnd = _lldb.eTraceCursorSeekTypeEnd
16181626

1627+
eDWIMPrintVerbosityNone = _lldb.eDWIMPrintVerbosityNone
1628+
1629+
eDWIMPrintVerbosityExpression = _lldb.eDWIMPrintVerbosityExpression
1630+
1631+
eDWIMPrintVerbosityFull = _lldb.eDWIMPrintVerbosityFull
1632+
16191633
class SBAddress(object):
16201634
r"""
16211635
A section + offset based address class.
@@ -8841,6 +8855,14 @@ def GetDescription(self, description):
88418855
r"""GetDescription(SBProcess self, SBStream description) -> bool"""
88428856
return _lldb.SBProcess_GetDescription(self, description)
88438857

8858+
def GetScriptedImplementation(self):
8859+
r"""
8860+
8861+
Returns the implementation object of the process plugin if available. None
8862+
otherwise.
8863+
"""
8864+
return _lldb.SBProcess_GetScriptedImplementation(self)
8865+
88448866
def GetExtendedCrashInformation(self):
88458867
r"""
88468868

lldb/examples/darwin/heap_find/heap.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,19 +1503,19 @@ def __lldb_init_module(debugger, internal_dict):
15031503
malloc_info.__doc__ = get_malloc_info_options().format_help()
15041504
objc_refs.__doc__ = get_objc_refs_options().format_help()
15051505
debugger.HandleCommand(
1506-
'command script add -f %s.ptr_refs ptr_refs' %
1506+
'command script add -o -f %s.ptr_refs ptr_refs' %
15071507
__name__)
15081508
debugger.HandleCommand(
1509-
'command script add -f %s.cstr_refs cstr_refs' %
1509+
'command script add -o -f %s.cstr_refs cstr_refs' %
15101510
__name__)
15111511
debugger.HandleCommand(
1512-
'command script add -f %s.malloc_info malloc_info' %
1512+
'command script add -o -f %s.malloc_info malloc_info' %
15131513
__name__)
15141514
debugger.HandleCommand(
1515-
'command script add -f %s.find_variable find_variable' %
1515+
'command script add -o -f %s.find_variable find_variable' %
15161516
__name__)
1517-
# debugger.HandleCommand('command script add -f %s.section_ptr_refs section_ptr_refs' % package_name)
1517+
# debugger.HandleCommand('command script add -o -f %s.section_ptr_refs section_ptr_refs' % package_name)
15181518
debugger.HandleCommand(
1519-
'command script add -f %s.objc_refs objc_refs' %
1519+
'command script add -o -f %s.objc_refs objc_refs' %
15201520
__name__)
15211521
print('"malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help.')

lldb/examples/python/bsd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def __lldb_init_module(debugger, dict):
558558
# interpreter.
559559
# Add any commands contained in this module to LLDB
560560
debugger.HandleCommand(
561-
'command script add -c %s.VerifyDebugMapCommand %s' % (
561+
'command script add -o -c %s.VerifyDebugMapCommand %s' % (
562562
__name__, VerifyDebugMapCommand.name))
563563
print('The "%s" command has been installed, type "help %s" for detailed '
564564
'help.' % (VerifyDebugMapCommand.name, VerifyDebugMapCommand.name))

lldb/examples/python/cmdtemplate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def register_lldb_command(cls, debugger, module_name):
2424
parser = cls.create_options()
2525
cls.__doc__ = parser.format_help()
2626
# Add any commands contained in this module to LLDB
27-
command = 'command script add -c %s.%s %s' % (module_name,
27+
command = 'command script add -o -c %s.%s %s' % (module_name,
2828
cls.__name__,
2929
cls.program)
3030
debugger.HandleCommand(command)

lldb/examples/python/crashlog.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,15 @@ class InteractiveCrashLogException(Exception):
417417
pass
418418

419419
class CrashLogParser:
420-
"CrashLog parser base class and factory."
421-
def __new__(cls, debugger, path, verbose):
420+
@staticmethod
421+
def create(debugger, path, verbose):
422422
data = JSONCrashLogParser.is_valid_json(path)
423423
if data:
424-
self = object.__new__(JSONCrashLogParser)
425-
self.data = data
426-
return self
424+
parser = JSONCrashLogParser(debugger, path, verbose)
425+
parser.data = data
426+
return parser
427427
else:
428-
return object.__new__(TextCrashLogParser)
428+
return TextCrashLogParser(debugger, path, verbose)
429429

430430
def __init__(self, debugger, path, verbose):
431431
self.path = os.path.expanduser(path)
@@ -1076,7 +1076,7 @@ def load_crashlog_in_scripted_process(debugger, crash_log_file, options, result)
10761076
if not os.path.exists(crashlog_path):
10771077
raise InteractiveCrashLogException("crashlog file %s does not exist" % crashlog_path)
10781078

1079-
crashlog = CrashLogParser(debugger, crashlog_path, False).parse()
1079+
crashlog = CrashLogParser.create(debugger, crashlog_path, False).parse()
10801080

10811081
target = lldb.SBTarget()
10821082
# 1. Try to use the user-provided target
@@ -1332,7 +1332,7 @@ def should_run_in_interactive_mode(options, ci):
13321332
except InteractiveCrashLogException as e:
13331333
result.SetError(str(e))
13341334
else:
1335-
crash_log = CrashLogParser(debugger, crash_log_file, options.verbose).parse()
1335+
crash_log = CrashLogParser.create(debugger, crash_log_file, options.verbose).parse()
13361336
SymbolicateCrashLog(crash_log, options)
13371337

13381338
if __name__ == '__main__':
@@ -1344,8 +1344,8 @@ def should_run_in_interactive_mode(options, ci):
13441344

13451345
def __lldb_init_module(debugger, internal_dict):
13461346
debugger.HandleCommand(
1347-
'command script add -c lldb.macosx.crashlog.Symbolicate crashlog')
1347+
'command script add -o -c lldb.macosx.crashlog.Symbolicate crashlog')
13481348
debugger.HandleCommand(
1349-
'command script add -f lldb.macosx.crashlog.save_crashlog save_crashlog')
1349+
'command script add -o -f lldb.macosx.crashlog.save_crashlog save_crashlog')
13501350
print('"crashlog" and "save_crashlog" commands have been installed, use '
13511351
'the "--help" options on these commands for detailed help.')

lldb/examples/python/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,5 +128,5 @@ def __lldb_init_module(debugger, internal_dict):
128128
# This initializer is being run from LLDB in the embedded command interpreter
129129
# Add any commands contained in this module to LLDB
130130
debugger.HandleCommand(
131-
'command script add -f delta.parse_time_log parse_time_log')
131+
'command script add -o -f delta.parse_time_log parse_time_log')
132132
print('The "parse_time_log" command is now installed and ready for use, type "parse_time_log --help" for more information')

0 commit comments

Comments
 (0)