lawrence_danna created this revision. lawrence_danna added reviewers: labath, jingham, JDevlieghere. Herald added a project: LLDB.
Move breakpoints from the old, bad ArgInfo::count to the new, better ArgInfo::max_positional_args. Soon ArgInfo::count will be no more. This functionality is tested in `TestFormatters.py`, `TestDataFormatterSynthVal.py`, `TestDataFormatterSynthType.py`. You may notice that the old code was passing 0 arguments when count was 1, and passing 1 argument when count is 2. This is no longer necessary because max_positional_args counts the self pointer correctly. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D69469 Files: 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 @@ -499,11 +499,17 @@ if (!pfunc.IsAllocated()) return 0; + auto arg_info = pfunc.GetArgInfo(); + if (!arg_info) { + llvm::consumeError(arg_info.takeError()); + return 0; + } + PythonObject result; - auto argc = pfunc.GetNumArguments(); - if (argc.count == 1) + + if (arg_info.get().max_positional_args < 1) result = pfunc(); - else if (argc.count == 2) + else result = pfunc(PythonInteger(max)); if (!result.IsAllocated()) @@ -515,13 +521,13 @@ size_t ret_val = int_result.GetInteger(); - if (PyErr_Occurred()) + if (PyErr_Occurred()) //FIXME use Expected to catch python exceptions { PyErr_Print(); PyErr_Clear(); } - if (argc.count == 1) + if (arg_info.get().max_positional_args < 1) ret_val = std::min(ret_val, static_cast<size_t>(max)); return ret_val;
Index: lldb/scripts/Python/python-wrapper.swig =================================================================== --- lldb/scripts/Python/python-wrapper.swig +++ lldb/scripts/Python/python-wrapper.swig @@ -499,11 +499,17 @@ if (!pfunc.IsAllocated()) return 0; + auto arg_info = pfunc.GetArgInfo(); + if (!arg_info) { + llvm::consumeError(arg_info.takeError()); + return 0; + } + PythonObject result; - auto argc = pfunc.GetNumArguments(); - if (argc.count == 1) + + if (arg_info.get().max_positional_args < 1) result = pfunc(); - else if (argc.count == 2) + else result = pfunc(PythonInteger(max)); if (!result.IsAllocated()) @@ -515,13 +521,13 @@ size_t ret_val = int_result.GetInteger(); - if (PyErr_Occurred()) + if (PyErr_Occurred()) //FIXME use Expected to catch python exceptions { PyErr_Print(); PyErr_Clear(); } - if (argc.count == 1) + if (arg_info.get().max_positional_args < 1) ret_val = std::min(ret_val, static_cast<size_t>(max)); return ret_val;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits