[Lldb-commits] [PATCH] D68317: factor out an abstract base class for File

2019-10-02 Thread Lawrence D'Anna via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373564: factor out an abstract base class for File (authored 
by lawrence_danna, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68317?vs=222851=222962#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D68317

Files:
  lldb/trunk/include/lldb/Host/File.h
  lldb/trunk/scripts/Python/python-typemaps.swig
  lldb/trunk/source/API/SBDebugger.cpp
  lldb/trunk/source/API/SBFile.cpp
  lldb/trunk/source/Core/Debugger.cpp
  lldb/trunk/source/Core/StreamFile.cpp
  lldb/trunk/source/Host/common/File.cpp
  lldb/trunk/source/Host/common/FileSystem.cpp
  lldb/trunk/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  
lldb/trunk/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/trunk/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
  
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/trunk/source/Target/Process.cpp
  lldb/trunk/unittests/Host/FileTest.cpp

Index: lldb/trunk/unittests/Host/FileTest.cpp
===
--- lldb/trunk/unittests/Host/FileTest.cpp
+++ lldb/trunk/unittests/Host/FileTest.cpp
@@ -31,7 +31,7 @@
   FILE *stream = fdopen(fd, "r");
   ASSERT_TRUE(stream);
 
-  File file(stream, true);
+  NativeFile file(stream, true);
   EXPECT_EQ(file.GetWaitableHandle(), fd);
 }
 
@@ -46,7 +46,7 @@
   llvm::FileRemover remover(name);
   ASSERT_GE(fd, 0);
 
-  File file(fd, File::eOpenOptionWrite, true);
+  NativeFile file(fd, File::eOpenOptionWrite, true);
   ASSERT_TRUE(file.IsValid());
 
   FILE *stream = file.GetStream();
Index: lldb/trunk/source/API/SBDebugger.cpp
===
--- lldb/trunk/source/API/SBDebugger.cpp
+++ lldb/trunk/source/API/SBDebugger.cpp
@@ -289,7 +289,7 @@
 void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBDebugger, SetInputFileHandle, (FILE *, bool), fh,
  transfer_ownership);
-  SetInputFile(std::make_shared(fh, transfer_ownership));
+  SetInputFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
 // Shouldn't really be settable after initialization as this could cause lots
@@ -319,7 +319,7 @@
 // FIXME Jonas Devlieghere: shouldn't this error be propagated out to the
 // reproducer somehow if fh is NULL?
 if (fh) {
-  file_sp = std::make_shared(fh, true);
+  file_sp = std::make_shared(fh, true);
 }
   }
 
@@ -335,7 +335,7 @@
 void SBDebugger::SetOutputFileHandle(FILE *fh, bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBDebugger, SetOutputFileHandle, (FILE *, bool), fh,
  transfer_ownership);
-  SetOutputFile(std::make_shared(fh, transfer_ownership));
+  SetOutputFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
 SBError SBDebugger::SetOutputFile(SBFile file) {
@@ -356,7 +356,7 @@
 void SBDebugger::SetErrorFileHandle(FILE *fh, bool transfer_ownership) {
   LLDB_RECORD_METHOD(void, SBDebugger, SetErrorFileHandle, (FILE *, bool), fh,
  transfer_ownership);
-  SetErrorFile(std::make_shared(fh, transfer_ownership));
+  SetErrorFile((FileSP)std::make_shared(fh, transfer_ownership));
 }
 
 SBError SBDebugger::SetErrorFile(SBFile file) {
Index: lldb/trunk/source/API/SBFile.cpp
===
--- lldb/trunk/source/API/SBFile.cpp
+++ lldb/trunk/source/API/SBFile.cpp
@@ -21,14 +21,14 @@
 SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); }
 
 SBFile::SBFile(FILE *file, bool transfer_ownership) {
-  m_opaque_sp = std::make_shared(file, transfer_ownership);
+  m_opaque_sp = std::make_shared(file, transfer_ownership);
 }
 
 SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) {
   LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode,
   transfer_owndership);
   auto options = File::GetOptionsFromMode(mode);
-  m_opaque_sp = std::make_shared(fd, options, transfer_owndership);
+  m_opaque_sp = std::make_shared(fd, options, transfer_owndership);
 }
 
 SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) {
Index: lldb/trunk/source/Core/StreamFile.cpp
===
--- lldb/trunk/source/Core/StreamFile.cpp
+++ lldb/trunk/source/Core/StreamFile.cpp
@@ -25,11 +25,11 @@
 
 StreamFile::StreamFile(int fd, bool transfer_ownership) : Stream() {
   m_file_sp =
-  std::make_shared(fd, 

[Lldb-commits] [PATCH] D68317: factor out an abstract base class for File

2019-10-02 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna added inline comments.



Comment at: lldb/include/lldb/Host/File.h:377-381
+  template 
+  static std::shared_ptr make_shared(Args... args) {
+return std::static_pointer_cast(
+std::make_shared(args...));
+  }

labath wrote:
> Please delete this stuff, and just use regular std::make_shared. (BTW, 
> shared_ptr is implicitly convertible to shared_ptr)
Huh, I swear when i tried that yesterday the compiler was saying it wasn't 
implicitly convertible. Now, it is as you say.   Must have been gremlins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68317



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


[Lldb-commits] [PATCH] D68317: factor out an abstract base class for File

2019-10-02 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Makes sense to me, just delete the custom make_shared stuff.




Comment at: lldb/include/lldb/Host/File.h:377-381
+  template 
+  static std::shared_ptr make_shared(Args... args) {
+return std::static_pointer_cast(
+std::make_shared(args...));
+  }

Please delete this stuff, and just use regular std::make_shared. (BTW, 
shared_ptr is implicitly convertible to shared_ptr)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68317



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


[Lldb-commits] [PATCH] D68317: factor out an abstract base class for File

2019-10-01 Thread Lawrence D'Anna via Phabricator via lldb-commits
lawrence_danna created this revision.
lawrence_danna added reviewers: JDevlieghere, jasonmolenda, labath.
Herald added a project: LLDB.
lawrence_danna added a parent revision: D68181: SBDebugger::SetInputFile, 
SetOutputFile, etc..
lawrence_danna added a child revision: D68188: allow arbitrary python streams 
to be converted to SBFile.

This patch factors out File as an abstract base 
class and moves most of its actual functionality into
a subclass called NativeFile.   In the next patch, 
I'm going to be adding subclasses of File that 
don't necessarily have any connection to actual OS files, 
so they will not inherit from NativeFile.

This patch was split out as a prerequisite for
https://reviews.llvm.org/D68188


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68317

Files:
  lldb/include/lldb/Host/File.h
  lldb/scripts/Python/python-typemaps.swig
  lldb/source/API/SBDebugger.cpp
  lldb/source/API/SBFile.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/StreamFile.cpp
  lldb/source/Host/common/File.cpp
  lldb/source/Host/common/FileSystem.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.mm
  lldb/source/Plugins/Process/Darwin/NativeProcessDarwin.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Target/Process.cpp
  lldb/unittests/Host/FileTest.cpp

Index: lldb/unittests/Host/FileTest.cpp
===
--- lldb/unittests/Host/FileTest.cpp
+++ lldb/unittests/Host/FileTest.cpp
@@ -31,7 +31,7 @@
   FILE *stream = fdopen(fd, "r");
   ASSERT_TRUE(stream);
 
-  File file(stream, true);
+  NativeFile file(stream, true);
   EXPECT_EQ(file.GetWaitableHandle(), fd);
 }
 
@@ -46,7 +46,7 @@
   llvm::FileRemover remover(name);
   ASSERT_GE(fd, 0);
 
-  File file(fd, File::eOpenOptionWrite, true);
+  NativeFile file(fd, File::eOpenOptionWrite, true);
   ASSERT_TRUE(file.IsValid());
 
   FILE *stream = file.GetStream();
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -4422,9 +4422,9 @@
 
 protected:
   Process *m_process;
-  File m_read_file;  // Read from this file (usually actual STDIN for LLDB
-  File m_write_file; // Write to this file (usually the master pty for getting
- // io to debuggee)
+  NativeFile m_read_file;  // Read from this file (usually actual STDIN for LLDB
+  NativeFile m_write_file; // Write to this file (usually the master pty for
+   // getting io to debuggee)
   Pipe m_pipe;
   std::atomic m_is_running{false};
 };
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -719,9 +719,9 @@
 
   PythonDictionary _module_dict = GetSysModuleDictionary();
   if (sys_module_dict.IsValid()) {
-File in_file(in, false);
-File out_file(out, false);
-File err_file(err, false);
+NativeFile in_file(in, false);
+NativeFile out_file(out, false);
+NativeFile err_file(err, false);
 
 lldb::FileSP in_sp;
 lldb::StreamFileSP out_sp;
Index: lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -1024,8 +1024,8 @@
   // File object knows about that.
   PythonString py_mode = GetAttributeValue("mode").AsType();
   auto options = File::GetOptionsFromMode(py_mode.GetString());
-  auto file = std::make_unique(PyObject_AsFileDescriptor(m_py_obj),
- options, false);
+  auto file = std::unique_ptr(
+  new NativeFile(PyObject_AsFileDescriptor(m_py_obj), options, false));
   if (!file->IsValid())
 return nullptr;
   return file;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -546,7 +546,7 @@
   int err = -1;
   int save_errno = 0;
   if (fd >= 0) {
-File file(fd, 0, true);
+NativeFile file(fd, 0, true);
 Status error = file.Close();
 err = 0;
 save_errno = error.GetError();
@@ -577,7 +577,7 @@