BareMetal: Use a derived class for debug support factory

Change-Id: I58ef72b6b7b74a0d83d8e6fbe5bd7538b5363f99
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-01-06 13:19:43 +01:00
parent 4ddd28ae22
commit 57adf73a89
5 changed files with 53 additions and 42 deletions

View File

@@ -14,6 +14,10 @@ const char MENU_ID[] = "BareMetal.Menu";
const char DEBUG_SERVER_PROVIDERS_SETTINGS_ID[] = "EE.BareMetal.DebugServerProvidersOptions";
//FIXME: The values were wrong after c654677bf729369e, but we keep them for now.
const char BAREMETAL_CUSTOMRUNCONFIG_ID[] = "BareMetal"; // Sic!
const char BAREMETAL_RUNCONFIG_ID[] = "BareMetalCustom"; // Sic!
// GDB Debugger Server Provider Ids.
const char GDBSERVER_OPENOCD_PROVIDER_ID[] = "BareMetal.GdbServerProvider.OpenOcd";
const char GDBSERVER_JLINK_PROVIDER_ID[] = "BareMetal.GdbServerProvider.JLink";

View File

@@ -3,6 +3,7 @@
#include "baremetaldebugsupport.h"
#include "baremetalconstants.h"
#include "baremetaldevice.h"
#include "baremetaltr.h"
@@ -15,6 +16,7 @@
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runconfigurationaspects.h>
#include <projectexplorer/target.h>
@@ -30,7 +32,10 @@ using namespace Utils;
namespace BareMetal::Internal {
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
{
public:
explicit BareMetalDebugSupport(ProjectExplorer::RunControl *runControl)
: Debugger::DebuggerRunTool(runControl)
{
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
@@ -50,7 +55,8 @@ BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
addStartDependency(runner);
}
void BareMetalDebugSupport::start()
private:
void start() final
{
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
QTC_ASSERT(dev, reportFailure(); return);
@@ -64,5 +70,15 @@ void BareMetalDebugSupport::start()
else
DebuggerRunTool::start();
}
};
BareMetalDebugSupportFactory::BareMetalDebugSupportFactory()
{
setProduct<BareMetalDebugSupport>();
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
addSupportedRunConfig(BareMetal::Constants::BAREMETAL_RUNCONFIG_ID);
addSupportedRunConfig(BareMetal::Constants::BAREMETAL_CUSTOMRUNCONFIG_ID);
}
} // BareMetal::Internal

View File

@@ -7,13 +7,11 @@
namespace BareMetal::Internal {
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
class BareMetalDebugSupportFactory final
: public ProjectExplorer::RunWorkerFactory
{
public:
explicit BareMetalDebugSupport(ProjectExplorer::RunControl *runControl);
private:
void start() final;
BareMetalDebugSupportFactory();
};
} // BareMetal::Internal

View File

@@ -42,7 +42,6 @@ public:
}
};
// BareMetalPluginPrivate
class BareMetalPluginPrivate
@@ -57,13 +56,7 @@ public:
DebugServerProvidersSettingsPage debugServerProviderSettinsPage;
DebugServerProviderManager debugServerProviderManager;
BareMetalDeployConfigurationFactory deployConfigurationFactory;
RunWorkerFactory runWorkerFactory{
RunWorkerFactory::make<BareMetalDebugSupport>(),
{ProjectExplorer::Constants::NORMAL_RUN_MODE, ProjectExplorer::Constants::DEBUG_RUN_MODE},
{runConfigurationFactory.runConfigurationId(),
customRunConfigurationFactory.runConfigurationId()}
};
BareMetalDebugSupportFactory runWorkerFactory;
};
// BareMetalPlugin

View File

@@ -79,7 +79,7 @@ Tasks BareMetalCustomRunConfiguration::checkForIssues() const
BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
{
registerRunConfiguration<BareMetalRunConfiguration>("BareMetalCustom");
registerRunConfiguration<BareMetalRunConfiguration>(Constants::BAREMETAL_RUNCONFIG_ID);
setDecorateDisplayNames(true);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}
@@ -89,7 +89,7 @@ BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory()
: FixedRunConfigurationFactory(Tr::tr("Custom Executable"), true)
{
registerRunConfiguration<BareMetalCustomRunConfiguration>("BareMetal");
registerRunConfiguration<BareMetalCustomRunConfiguration>(Constants::BAREMETAL_CUSTOMRUNCONFIG_ID);
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
}