[Lldb-commits] [PATCH] D68737: SBFile::GetFile: convert SBFile back into python native files.

2019-10-26 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added a comment.

In D68737#1722181 , @mgorny wrote:

> Well, I found another problem with these series, specifically starting at 
> this commit. Any use of `script` in LLDB ends up with:
>
>   (lldb) script True
>   True
>   close failed in file object destructor:
>   IOError: [Errno 9] Bad file descriptor
>
>
> I'd suspect the same fd is using in more than one file but that's only a 
> guess.
>
> The curious part is that I've tried `ktruss`-ing the process and I don't see 
> any failed `close()` syscalls.


I just tested it on commit ef7a154d17f2e38ba3c8bfa33f240b60464e4cc7 
 (from 
Thurday), on 8.1_STABLE, And I don't see that happening.

  netbsd# ./bin/lldb
  (lldb) script True
  True
  (lldb) exit


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68737/new/

https://reviews.llvm.org/D68737



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 5e30780 - Correct size_t format specifier

2019-10-26 Thread Benjamin Kramer via lldb-commits

Author: Shu-Chun Weng
Date: 2019-10-26T10:38:06+02:00
New Revision: 5e307808557f4786c6438c9cfd67784073c5a3b7

URL: 
https://github.com/llvm/llvm-project/commit/5e307808557f4786c6438c9cfd67784073c5a3b7
DIFF: 
https://github.com/llvm/llvm-project/commit/5e307808557f4786c6438c9cfd67784073c5a3b7.diff

LOG: Correct size_t format specifier

Differential Revision: https://reviews.llvm.org/D69455

Added: 


Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index 0c48ac498ec8..15c3e241fce7 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1257,7 +1257,7 @@ Status 
ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
 oneliner += "(frame, bp_loc, internal_dict)";
   } else {
 error.SetErrorStringWithFormat("expected 3 or 4 argument "
-   "function, %s has %d",
+   "function, %s has %zu",
function_name, num_args);
 return error;
   }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69455: Correct size_t format specifier

2019-10-26 Thread Benjamin Kramer via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5e307808557f: Correct size_t format specifier (authored by 
scw, committed by bkramer).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69455/new/

https://reviews.llvm.org/D69455

Files:
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1257,7 +1257,7 @@
 oneliner += "(frame, bp_loc, internal_dict)";
   } else {
 error.SetErrorStringWithFormat("expected 3 or 4 argument "
-   "function, %s has %d",
+   "function, %s has %zu",
function_name, num_args);
 return error;
   }


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1257,7 +1257,7 @@
 oneliner += "(frame, bp_loc, internal_dict)";
   } else {
 error.SetErrorStringWithFormat("expected 3 or 4 argument "
-   "function, %s has %d",
+   "function, %s has %zu",
function_name, num_args);
 return error;
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68737: SBFile::GetFile: convert SBFile back into python native files.

2019-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

Hmm, that's weird. It happened on the buildbot which is running some recent 8.x 
kernel, and on my testing machine with 9.x.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68737/new/

https://reviews.llvm.org/D68737



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69468: [LLDB][breakpoints] ArgInfo::count -> ArgInfo::max_positional_args

2019-10-26 Thread Lawrence D'Anna via Phabricator via lldb-commits
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.

It looks like this functionality is already well tested by 
`TestBreakpointCommandsFromPython.py`, so there's no need to write
additional tests for it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69468

Files:
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/scripts/Python/python-wrapper.swig
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -256,11 +256,10 @@
   BreakpointOptions *bp_options,
   std::unique_ptr &data_up) override;
 
-  Status SetBreakpointCommandCallback(
-  BreakpointOptions *bp_options, 
-   const char *command_body_text,
-   StructuredData::ObjectSP extra_args_sp,
-   bool uses_extra_args);
+  Status SetBreakpointCommandCallback(BreakpointOptions *bp_options,
+  const char *command_body_text,
+  StructuredData::ObjectSP extra_args_sp,
+  bool uses_extra_args);
 
   /// Set a one-liner as the callback for the watchpoint.
   void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
@@ -378,10 +377,9 @@
   python::PythonDictionary &GetSessionDictionary();
 
   python::PythonDictionary &GetSysModuleDictionary();
-  
-  llvm::Expected 
-  GetNumFixedArgumentsForCallable(const llvm::StringRef &callable_name) 
-  override;
+
+  llvm::Expected GetMaxPositionalArgumentsForCallable(
+  const llvm::StringRef &callable_name) override;
 
   bool GetEmbeddedInterpreterModuleObjects();
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -782,10 +782,9 @@
   return m_sys_module_dict;
 }
 
-llvm::Expected
-ScriptInterpreterPythonImpl::GetNumFixedArgumentsForCallable(
-const llvm::StringRef &callable_name)
-{
+llvm::Expected
+ScriptInterpreterPythonImpl::GetMaxPositionalArgumentsForCallable(
+const llvm::StringRef &callable_name) {
   if (callable_name.empty()) {
 return llvm::createStringError(
 llvm::inconvertibleErrorCode(),
@@ -796,16 +795,15 @@
  Locker::NoSTDIN);
   auto dict = PythonModule::MainModule()
   .ResolveName(m_dictionary_name);
-  auto pfunc 
- = PythonObject::ResolveNameWithDictionary(callable_name, 
-   dict);
+  auto pfunc = PythonObject::ResolveNameWithDictionary(
+  callable_name, dict);
   if (!pfunc.IsAllocated()) {
 return llvm::createStringError(
 llvm::inconvertibleErrorCode(),
 "can't find callable: %s", callable_name.str().c_str());
   }
   PythonCallable::ArgInfo arg_info = pfunc.GetNumArguments();
-  return arg_info.count;
+  return arg_info.max_positional_args;
 }
 
 static std::string GenerateUniqueName(const char *base_name_wanted,
@@ -1232,22 +1230,22 @@
   // For now just cons up a oneliner that calls the provided function.
   std::string oneliner("return ");
   oneliner += function_name;
-  
-  llvm::Expected maybe_args 
-  = GetNumFixedArgumentsForCallable(function_name);
+
+  llvm::Expected maybe_args =
+  GetMaxPositionalArgumentsForCallable(function_name);
   if (!maybe_args) {
-error.SetErrorStringWithFormat("could not get num args: %s", 
+error.SetErrorStringWithFormat(
+"could not get num args: %s",
 llvm::toString(maybe_args.takeError()).c_str());
 return error;
   }
-  size_t num_args = *maybe_args;
-  
+  size_t max_args = *maybe_args;
+
   bool uses_extra_args = false;
-  if (num_args == 4) {
+  if (max_args >= 4) {
 uses_extra_args = true;
 oneliner += "(frame, bp_loc, extra_args, internal_dict)";
-  }
-  else if (num_args == 3) {
+  } else if (max_args >= 3) {
 if (extra_args_sp) {
   error.SetErrorString("cannot pass extra_args to a three argument callback"
   );
@@ -1257,12 +1255,12 @@
 oneliner += "(frame, bp_loc, internal_dict)";
   } else {
 error.SetErrorStringWithFormat("expected 3 or 4 argument "
-   "function, %s has %zu",
-   function_name, num_args);
+  

[Lldb-commits] [PATCH] D69469: [LLDB][formatters] ArgInfo::count -> ArgInfo::max_positional_args

2019-10-26 Thread Lawrence D'Anna via Phabricator via lldb-commits
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(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(max));
 
 return ret_val;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits