[haiku-commits] haiku: hrev50227 - in src/apps/debugger/target_host_interface: . local

  • From: anevilyak@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 14 Apr 2016 02:11:00 +0200 (CEST)

hrev50227 adds 2 changesets to branch 'master'
old head: fbf9ac1ce4ca8c756351dd9128a9fccfeea25545
new head: 0a1838cb4496bd25c1c8d32365f671f80b89af35
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=0a1838cb4496+%5Efbf9ac1ce4ca

----------------------------------------------------------------------------

7dde731f400b: Debugger: Add missing roster method implementations.
  
  TargetHostInterfaceRoster:
  - Implement counting/retrieving interfaces, as well as requesting the
    creation of a new instance.

0a1838cb4496: Debugger: Implement Create/Attach on LocalTargetHostInterface.
  
  LocalTargetHostInterface:
  - Implement the create and attach functionality. In theory, this completes
    everything that's needed in order to adjust the main application to do
    all debugger interface creation via the roster.

                                         [ Rene Gollent <rene@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

3 files changed, 95 insertions(+), 6 deletions(-)
.../TargetHostInterfaceRoster.cpp                | 54 ++++++++++++++++++++
.../TargetHostInterfaceRoster.h                  |  9 ++--
.../local/LocalTargetHostInterface.cpp           | 38 ++++++++++++--

############################################################################

Commit:      7dde731f400b3b75f510d0fe710b8874b0b7a4b8
URL:         http://cgit.haiku-os.org/haiku/commit/?id=7dde731f400b
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Tue Apr 12 20:58:02 2016 UTC

Debugger: Add missing roster method implementations.

TargetHostInterfaceRoster:
- Implement counting/retrieving interfaces, as well as requesting the
  creation of a new instance.

----------------------------------------------------------------------------

diff --git 
a/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.cpp 
b/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.cpp
index a44324d..de8b644 100644
--- a/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.cpp
+++ b/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.cpp
@@ -7,6 +7,7 @@
 #include <new>
 
 #include <AutoDeleter.h>
+#include <AutoLocker.h>
 
 #include "LocalTargetHostInterfaceInfo.h"
 #include "TargetHostInterface.h"
@@ -99,3 +100,56 @@ TargetHostInterfaceRoster::RegisterInterfaceInfos()
 
        return B_OK;
 }
+
+
+int32
+TargetHostInterfaceRoster::CountInterfaceInfos() const
+{
+       return fInterfaceInfos.CountItems();
+}
+
+
+TargetHostInterfaceInfo*
+TargetHostInterfaceRoster::InterfaceInfoAt(int32 index) const
+{
+       return fInterfaceInfos.ItemAt(index);
+}
+
+
+status_t
+TargetHostInterfaceRoster::CreateInterface(TargetHostInterfaceInfo* info,
+       Settings* settings, TargetHostInterface*& _interface)
+{
+       // TODO: this should eventually verify that an active interface with
+       // matching settings/type doesn't already exist, and if so, return that
+       // directly rather than instantiating a new one, since i.e. the 
interface
+       // for the local host only requires one instance.
+       AutoLocker<TargetHostInterfaceRoster> locker(this);
+       TargetHostInterface* interface;
+       status_t error = info->CreateInterface(settings, interface);
+       if (error != B_OK)
+               return error;
+
+       BReference<TargetHostInterface> interfaceReference(interface, true);
+       if (!fActiveInterfaces.AddItem(interface))
+               return B_NO_MEMORY;
+
+       _interface = interface;
+       interfaceReference.Detach();
+       return B_OK;
+}
+
+
+int32
+TargetHostInterfaceRoster::CountActiveInterfaces() const
+{
+       return fActiveInterfaces.CountItems();
+}
+
+
+TargetHostInterface*
+TargetHostInterfaceRoster::ActiveInterfaceAt(int32 index) const
+{
+       return fActiveInterfaces.ItemAt(index);
+}
+
diff --git 
a/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.h 
b/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.h
index 2a16892..6f3f12b 100644
--- a/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.h
+++ b/src/apps/debugger/target_host_interface/TargetHostInterfaceRoster.h
@@ -25,18 +25,21 @@ public:
        static  status_t                        CreateDefault();
        static  void                            DeleteDefault();
 
+                       bool                            Lock()          { 
return fLock.Lock(); }
+                       void                            Unlock()        { 
fLock.Unlock(); }
+
                        status_t                        Init();
                        status_t                        
RegisterInterfaceInfos();
 
-                       int32                           CountInterfaceInfos();
+                       int32                           CountInterfaceInfos() 
const;
                        TargetHostInterfaceInfo*
                                                                
InterfaceInfoAt(int32 index) const;
 
                        status_t                        
CreateInterface(TargetHostInterfaceInfo* info,
                                                                        
Settings* settings,
-                                                                       
TargetHostInterface*& _interface) const;
+                                                                       
TargetHostInterface*& _interface);
 
-                       int32                           CountActiveInterfaces();
+                       int32                           CountActiveInterfaces() 
const;
                        TargetHostInterface* ActiveInterfaceAt(int32 index) 
const;
 
 private:

############################################################################

Revision:    hrev50227
Commit:      0a1838cb4496bd25c1c8d32365f671f80b89af35
URL:         http://cgit.haiku-os.org/haiku/commit/?id=0a1838cb4496
Author:      Rene Gollent <rene@xxxxxxxxxxx>
Date:        Wed Apr 13 23:58:58 2016 UTC

Debugger: Implement Create/Attach on LocalTargetHostInterface.

LocalTargetHostInterface:
- Implement the create and attach functionality. In theory, this completes
  everything that's needed in order to adjust the main application to do
  all debugger interface creation via the roster.

----------------------------------------------------------------------------

diff --git 
a/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp 
b/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp
index b25cece..e9a5a47 100644
--- a/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp
+++ b/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp
@@ -16,6 +16,9 @@
 #include <system_info.h>
 #include <util/KMessage.h>
 
+#include "debug_utils.h"
+
+#include "LocalDebuggerInterface.h"
 #include "TargetHost.h"
 
 using std::set;
@@ -124,10 +127,35 @@ LocalTargetHostInterface::GetTargetHost()
 
 
 status_t
-LocalTargetHostInterface::Attach(team_id id, thread_id threadID,
+LocalTargetHostInterface::Attach(team_id teamID, thread_id threadID,
        DebuggerInterface*& _interface)
 {
-       return B_NOT_SUPPORTED;
+       if (teamID < 0 && threadID < 0)
+               return B_BAD_VALUE;
+
+       status_t error;
+       if (teamID < 0) {
+               thread_info threadInfo;
+               error = get_thread_info(threadID, &threadInfo);
+               if (error != B_OK)
+                       return error;
+
+               teamID = threadInfo.team;
+       }
+
+       LocalDebuggerInterface* interface
+               = new(std::nothrow) LocalDebuggerInterface(teamID);
+       if (interface == NULL)
+               return B_NO_MEMORY;
+
+       BReference<DebuggerInterface> interfaceReference(interface, true);
+       error = interface->Init();
+       if (error != B_OK)
+               return error;
+
+       _interface = interface;
+       interfaceReference.Detach();
+       return B_OK;
 }
 
 
@@ -135,7 +163,11 @@ status_t
 LocalTargetHostInterface::CreateTeam(int commandLineArgc,
        const char* const* arguments, DebuggerInterface*& _interface)
 {
-       return B_NOT_SUPPORTED;
+       thread_id thread = load_program(arguments, commandLineArgc, false);
+       if (thread < 0)
+               return thread;
+
+       return Attach(-1, thread, _interface);
 }
 
 


Other related posts:

  • » [haiku-commits] haiku: hrev50227 - in src/apps/debugger/target_host_interface: . local - anevilyak