From 0a1838cb4496bd25c1c8d32365f671f80b89af35 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 13 Apr 2016 19:58:58 -0400 Subject: [PATCH] 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. --- .../local/LocalTargetHostInterface.cpp | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp b/src/apps/debugger/target_host_interface/local/LocalTargetHostInterface.cpp index b25cece5fb..e9a5a474b7 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 #include +#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 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); }