[Lldb-commits] [PATCH] D69153: convert LLDBSwigPythonCallTypeScript to ArgInfo::max_positional_args
Lawrence D'Anna via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Sat Oct 19 00:11:29 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbdcad0aca0a0: convert LLDBSwigPythonCallTypeScript to ArgInfo::max_positional_args (authored by lawrence_danna).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69153/new/
https://reviews.llvm.org/D69153
Files:
lldb/packages/Python/lldbsuite/test/commands/expression/formatters/TestFormatters.py
lldb/packages/Python/lldbsuite/test/commands/expression/formatters/formatters.py
lldb/scripts/Python/python-wrapper.swig
Index: lldb/scripts/Python/python-wrapper.swig
===================================================================
--- lldb/scripts/Python/python-wrapper.swig
+++ lldb/scripts/Python/python-wrapper.swig
@@ -163,14 +163,19 @@
}
PythonObject result;
- auto argc = pfunc.GetNumArguments();
- // if the third argument is supported, or varargs are allowed
+ auto argc = pfunc.GetArgInfo();
+ if (!argc) {
+ llvm::consumeError(argc.takeError());
+ return false;
+ }
+
PythonObject value_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_value));
PythonObject options_arg(PyRefType::Owned, SBTypeToSWIGWrapper(sb_options));
- if (argc.count == 3 || argc.has_varargs)
- result = pfunc(value_arg,dict,options_arg);
- else
+
+ if (argc.get().max_positional_args < 3)
result = pfunc(value_arg,dict);
+ else
+ result = pfunc(value_arg,dict,options_arg);
retval = result.Str().GetString().str();
Index: lldb/packages/Python/lldbsuite/test/commands/expression/formatters/formatters.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/commands/expression/formatters/formatters.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/formatters/formatters.py
@@ -1,3 +1,5 @@
+import lldb
+
def foo_SummaryProvider(valobj, dict):
a = valobj.GetChildMemberWithName('a')
a_ptr = valobj.GetChildMemberWithName('a_ptr')
@@ -15,3 +17,8 @@
', i_ptr = ' + str(i_ptr.GetValueAsUnsigned(0)) + ' -> ' + str(i_ptr.Dereference().GetValueAsUnsigned(0)) + \
', b_ref = ' + str(b_ref.GetValueAsUnsigned(0)) + \
', h = ' + str(h.GetValueAsUnsigned(0)) + ' , k = ' + str(k.GetValueAsUnsigned(0))
+
+def foo_SummaryProvider3(valobj, dict, options):
+ if not isinstance(options, lldb.SBTypeSummaryOptions):
+ raise Exception()
+ return foo_SummaryProvider(valobj, dict) + ", WITH_OPTS"
\ No newline at end of file
Index: lldb/packages/Python/lldbsuite/test/commands/expression/formatters/TestFormatters.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/commands/expression/formatters/TestFormatters.py
+++ lldb/packages/Python/lldbsuite/test/commands/expression/formatters/TestFormatters.py
@@ -74,6 +74,21 @@
# EXPR-TYPES-NEW-FOO-NEXT: }
# EXPR-TYPES-NEW-FOO-NEXT: }
+
+ self.runCmd("type summary add -F formatters.foo_SummaryProvider3 foo")
+ self.filecheck("expression foo1", __file__, '-check-prefix=EXPR-FOO1opts')
+ # EXPR-FOO1opts: (foo) $
+ # EXPR-FOO1opts-SAME: a = 12
+ # EXPR-FOO1opts-SAME: a_ptr = {{[0-9]+}} -> 13
+ # EXPR-FOO1opts-SAME: i = 24
+ # EXPR-FOO1opts-SAME: i_ptr = {{[0-9]+}} -> 25
+ # EXPR-FOO1opts-SAME: b_ref = {{[0-9]+}}
+ # EXPR-FOO1opts-SAME: h = 27
+ # EXPR-FOO1opts-SAME: k = 29
+ # EXPR-FOO1opts-SAME: WITH_OPTS
+
+ self.runCmd("type summary delete foo")
+
self.runCmd("type summary add -F formatters.foo_SummaryProvider foo")
self.expect("expression new int(12)",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69153.225742.patch
Type: text/x-patch
Size: 3157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191019/249d904b/attachment.bin>
More information about the lldb-commits
mailing list