polyakov.alex updated this revision to Diff 151682.
polyakov.alex retitled this revision from "[lldb, lldb-mi] Add method 
AddCurrentTargetSharedObjectPath to the SBDebugger." to "[WIP] New class 
SBTargetSettings to store and manipulate all target's properties.".
polyakov.alex edited the summary of this revision.
polyakov.alex added a comment.
Herald added a subscriber: mgorny.

As we discussed previously, it would be nice to have a class in SB API that 
will manipulate with SBTarget's properties.
I started to work on this and , as I expected, faced with a problem:
`TargetProperties` class doesn't have a property with image search paths while 
`Target` does. It means that we should have a pointer to `Target` to implement 
things like 
`SBTargetSettings::AppendImageSearchPath(const char *from, const char *to, 
SBError &error)`.

We may store an additional pointer to `Target`, but, as I understood, it's not 
what we want from `SBTargetSettings` to be.
Moreover, it looks strange that image search path isn't a part of 
`TargetProperties` while executable and debug file search paths are.

I'm looking forward for your comments about this.


https://reviews.llvm.org/D47302

Files:
  include/lldb/API/SBTarget.h
  include/lldb/API/SBTargetSettings.h
  source/API/CMakeLists.txt
  source/API/SBTargetSettings.cpp

Index: source/API/SBTargetSettings.cpp
===================================================================
--- /dev/null
+++ source/API/SBTargetSettings.cpp
@@ -0,0 +1,41 @@
+//===-- SBTargetSettings.cpp --------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "lldb/API/SBTargetSettings.h"
+
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/Log.h"
+#include "llvm/Support/Casting.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// SBTargetSettings constructors
+//----------------------------------------------------------------------
+SBTargetSettings::SBTargetSettings() : m_opaque_sp() {}
+
+SBTargetSettings::SBTargetSettings(const lldb::SBTarget &sb_target)
+    : m_opaque_sp(sb_target.GetSP()) {}
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+SBTargetSettings::~SBTargetSettings() = default;
+
+void SBTargetSettings::AppendImageSearchPath(const char *from,
+                                             const char *to) {
+  SBError error;
+  AppendImageSearchPath(from, to, error);
+}
+
+void SBTargetSettings::AppendImageSearchPath(const char *from,
+                                             const char *to,
+                                             SBError &error) {
+}
Index: source/API/CMakeLists.txt
===================================================================
--- source/API/CMakeLists.txt
+++ source/API/CMakeLists.txt
@@ -63,6 +63,7 @@
   SBSymbolContext.cpp
   SBSymbolContextList.cpp
   SBTarget.cpp
+  SBTargetSettings.cpp
   SBThread.cpp
   SBThreadCollection.cpp
   SBThreadPlan.cpp
Index: include/lldb/API/SBTargetSettings.h
===================================================================
--- /dev/null
+++ include/lldb/API/SBTargetSettings.h
@@ -0,0 +1,50 @@
+//===-- SBTargetSettings.h ----------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_SBTargetSettings_h_
+#define LLDB_SBTargetSettings_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/API/SBTarget.h"
+#include "lldb/API/SBError.h"
+
+namespace lldb {
+
+class LLDB_API SBTargetSettings {
+public:
+  //------------------------------------------------------------------
+  // Constructors
+  //------------------------------------------------------------------
+  SBTargetSettings();
+
+  SBTargetSettings(const lldb::SBTarget &sb_target);
+
+  //------------------------------------------------------------------
+  // Destructor
+  //------------------------------------------------------------------
+  ~SBTargetSettings();
+
+  void AppendImageSearchPath(const char *from, const char *to);
+
+  void AppendImageSearchPath(const char *from, const char *to, SBError &error);
+
+  //size_t GetNumImageSearchPaths() const;
+
+  //const char *GetImageSearchPathAtIndex(size_t i);
+
+private:
+  lldb::TargetPropertiesSP m_opaque_sp;
+};
+
+} // namespace lldb
+
+#endif // LLDB_SBTargetSettings_h_
Index: include/lldb/API/SBTarget.h
===================================================================
--- include/lldb/API/SBTarget.h
+++ include/lldb/API/SBTarget.h
@@ -826,6 +826,7 @@
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBTargetSettings;
   friend class SBValue;
 
   //------------------------------------------------------------------
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to