diff --git a/src/apps/debugger/Debugger.cpp b/src/apps/debugger/Debugger.cpp index 603a2124b9..775fd407bc 100644 --- a/src/apps/debugger/Debugger.cpp +++ b/src/apps/debugger/Debugger.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011-2015, Rene Gollent, rene@gollent.com. + * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -23,6 +23,7 @@ #include "debug_utils.h" #include "CommandLineUserInterface.h" +#include "DebuggerInterface.h" #include "GraphicalUserInterface.h" #include "ImageDebugLoadingStateHandlerRoster.h" #include "MessageCodes.h" @@ -310,12 +311,22 @@ start_team_debugger(team_id teamID, SettingsManager* settingsManager, userInterfaceReference.SetTo(userInterface, true); } + BReference interfaceReference; + DebuggerInterface* debuggerInterface + = new(std::nothrow) DebuggerInterface(teamID); + if (debuggerInterface == NULL) + return NULL; + interfaceReference.SetTo(debuggerInterface, true); + + if (debuggerInterface->Init() != B_OK) + return NULL; + status_t error = B_NO_MEMORY; TeamDebugger* debugger = new(std::nothrow) TeamDebugger(listener, userInterface, settingsManager); - if (debugger) { - error = debugger->Init(teamID, threadID, commandLineArgc, + if (debugger != NULL) { + error = debugger->Init(debuggerInterface, threadID, commandLineArgc, commandLineArgv, stopInMain); } diff --git a/src/apps/debugger/controllers/TeamDebugger.cpp b/src/apps/debugger/controllers/TeamDebugger.cpp index e86bfb90f2..9d6e5f9791 100644 --- a/src/apps/debugger/controllers/TeamDebugger.cpp +++ b/src/apps/debugger/controllers/TeamDebugger.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2010-2015, Rene Gollent, rene@gollent.com. + * Copyright 2010-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -321,7 +321,7 @@ TeamDebugger::~TeamDebugger() status_t -TeamDebugger::Init(team_id teamID, thread_id threadID, int argc, +TeamDebugger::Init(DebuggerInterface* interface, thread_id threadID, int argc, const char* const* argv, bool stopInMain) { bool targetIsLocal = true; @@ -330,20 +330,14 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, int argc, // the first thing we want to do when running PostMessage(MSG_LOAD_SETTINGS); - fTeamID = teamID; - status_t error = _HandleSetArguments(argc, argv); if (error != B_OK) return error; - // create debugger interface - fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID); - if (fDebuggerInterface == NULL) - return B_NO_MEMORY; + fDebuggerInterface = interface; + fDebuggerInterface->AcquireReference(); + fTeamID = interface->TeamID(); - error = fDebuggerInterface->Init(); - if (error != B_OK) - return error; // create file manager fFileManager = new(std::nothrow) FileManager; diff --git a/src/apps/debugger/controllers/TeamDebugger.h b/src/apps/debugger/controllers/TeamDebugger.h index 7e645860bf..7cce854a1e 100644 --- a/src/apps/debugger/controllers/TeamDebugger.h +++ b/src/apps/debugger/controllers/TeamDebugger.h @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2013-2015, Rene Gollent, rene@gollent.com. + * Copyright 2013-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef TEAM_DEBUGGER_H @@ -42,8 +42,8 @@ public: SettingsManager* settingsManager); ~TeamDebugger(); - status_t Init(team_id teamID, thread_id threadID, - int argc, + status_t Init(DebuggerInterface* interface, + thread_id threadID, int argc, const char* const* argv, bool stopInMain); diff --git a/src/apps/debugger/debugger_interface/DebuggerInterface.h b/src/apps/debugger/debugger_interface/DebuggerInterface.h index 6465acc8f7..386730a159 100644 --- a/src/apps/debugger/debugger_interface/DebuggerInterface.h +++ b/src/apps/debugger/debugger_interface/DebuggerInterface.h @@ -41,6 +41,9 @@ public: bool Connected() const { return fNubPort >= 0; } + team_id TeamID() const + { return fTeamID; } + Architecture* GetArchitecture() const { return fArchitecture; }