forked from qt-creator/qt-creator
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:
@@ -14,6 +14,10 @@ const char MENU_ID[] = "BareMetal.Menu";
|
|||||||
|
|
||||||
const char DEBUG_SERVER_PROVIDERS_SETTINGS_ID[] = "EE.BareMetal.DebugServerProvidersOptions";
|
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.
|
// GDB Debugger Server Provider Ids.
|
||||||
const char GDBSERVER_OPENOCD_PROVIDER_ID[] = "BareMetal.GdbServerProvider.OpenOcd";
|
const char GDBSERVER_OPENOCD_PROVIDER_ID[] = "BareMetal.GdbServerProvider.OpenOcd";
|
||||||
const char GDBSERVER_JLINK_PROVIDER_ID[] = "BareMetal.GdbServerProvider.JLink";
|
const char GDBSERVER_JLINK_PROVIDER_ID[] = "BareMetal.GdbServerProvider.JLink";
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "baremetaldebugsupport.h"
|
#include "baremetaldebugsupport.h"
|
||||||
|
|
||||||
|
#include "baremetalconstants.h"
|
||||||
#include "baremetaldevice.h"
|
#include "baremetaldevice.h"
|
||||||
#include "baremetaltr.h"
|
#include "baremetaltr.h"
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
#include <projectexplorer/buildsteplist.h>
|
#include <projectexplorer/buildsteplist.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
#include <projectexplorer/runconfiguration.h>
|
#include <projectexplorer/runconfiguration.h>
|
||||||
#include <projectexplorer/runconfigurationaspects.h>
|
#include <projectexplorer/runconfigurationaspects.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
@@ -30,39 +32,53 @@ using namespace Utils;
|
|||||||
|
|
||||||
namespace BareMetal::Internal {
|
namespace BareMetal::Internal {
|
||||||
|
|
||||||
BareMetalDebugSupport::BareMetalDebugSupport(RunControl *runControl)
|
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
|
||||||
: Debugger::DebuggerRunTool(runControl)
|
|
||||||
{
|
{
|
||||||
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
public:
|
||||||
if (!dev) {
|
explicit BareMetalDebugSupport(ProjectExplorer::RunControl *runControl)
|
||||||
reportFailure(Tr::tr("Cannot debug: Kit has no device."));
|
: Debugger::DebuggerRunTool(runControl)
|
||||||
return;
|
{
|
||||||
|
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
||||||
|
if (!dev) {
|
||||||
|
reportFailure(Tr::tr("Cannot debug: Kit has no device."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString providerId = dev->debugServerProviderId();
|
||||||
|
IDebugServerProvider *p = DebugServerProviderManager::findProvider(providerId);
|
||||||
|
if (!p) {
|
||||||
|
reportFailure(Tr::tr("No debug server provider found for %1").arg(providerId));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RunWorker *runner = p->targetRunner(runControl))
|
||||||
|
addStartDependency(runner);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString providerId = dev->debugServerProviderId();
|
private:
|
||||||
IDebugServerProvider *p = DebugServerProviderManager::findProvider(providerId);
|
void start() final
|
||||||
if (!p) {
|
{
|
||||||
reportFailure(Tr::tr("No debug server provider found for %1").arg(providerId));
|
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
||||||
return;
|
QTC_ASSERT(dev, reportFailure(); return);
|
||||||
|
IDebugServerProvider *p = DebugServerProviderManager::findProvider(
|
||||||
|
dev->debugServerProviderId());
|
||||||
|
QTC_ASSERT(p, reportFailure(); return);
|
||||||
|
|
||||||
|
QString errorMessage;
|
||||||
|
if (!p->aboutToRun(this, errorMessage))
|
||||||
|
reportFailure(errorMessage);
|
||||||
|
else
|
||||||
|
DebuggerRunTool::start();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (RunWorker *runner = p->targetRunner(runControl))
|
BareMetalDebugSupportFactory::BareMetalDebugSupportFactory()
|
||||||
addStartDependency(runner);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BareMetalDebugSupport::start()
|
|
||||||
{
|
{
|
||||||
const auto dev = qSharedPointerCast<const BareMetalDevice>(device());
|
setProduct<BareMetalDebugSupport>();
|
||||||
QTC_ASSERT(dev, reportFailure(); return);
|
addSupportedRunMode(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
||||||
IDebugServerProvider *p = DebugServerProviderManager::findProvider(
|
addSupportedRunMode(ProjectExplorer::Constants::DEBUG_RUN_MODE);
|
||||||
dev->debugServerProviderId());
|
addSupportedRunConfig(BareMetal::Constants::BAREMETAL_RUNCONFIG_ID);
|
||||||
QTC_ASSERT(p, reportFailure(); return);
|
addSupportedRunConfig(BareMetal::Constants::BAREMETAL_CUSTOMRUNCONFIG_ID);
|
||||||
|
|
||||||
QString errorMessage;
|
|
||||||
if (!p->aboutToRun(this, errorMessage))
|
|
||||||
reportFailure(errorMessage);
|
|
||||||
else
|
|
||||||
DebuggerRunTool::start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // BareMetal::Internal
|
} // BareMetal::Internal
|
||||||
|
@@ -7,13 +7,11 @@
|
|||||||
|
|
||||||
namespace BareMetal::Internal {
|
namespace BareMetal::Internal {
|
||||||
|
|
||||||
class BareMetalDebugSupport final : public Debugger::DebuggerRunTool
|
class BareMetalDebugSupportFactory final
|
||||||
|
: public ProjectExplorer::RunWorkerFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit BareMetalDebugSupport(ProjectExplorer::RunControl *runControl);
|
BareMetalDebugSupportFactory();
|
||||||
|
|
||||||
private:
|
|
||||||
void start() final;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // BareMetal::Internal
|
} // BareMetal::Internal
|
||||||
|
@@ -42,7 +42,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// BareMetalPluginPrivate
|
// BareMetalPluginPrivate
|
||||||
|
|
||||||
class BareMetalPluginPrivate
|
class BareMetalPluginPrivate
|
||||||
@@ -57,13 +56,7 @@ public:
|
|||||||
DebugServerProvidersSettingsPage debugServerProviderSettinsPage;
|
DebugServerProvidersSettingsPage debugServerProviderSettinsPage;
|
||||||
DebugServerProviderManager debugServerProviderManager;
|
DebugServerProviderManager debugServerProviderManager;
|
||||||
BareMetalDeployConfigurationFactory deployConfigurationFactory;
|
BareMetalDeployConfigurationFactory deployConfigurationFactory;
|
||||||
|
BareMetalDebugSupportFactory runWorkerFactory;
|
||||||
RunWorkerFactory runWorkerFactory{
|
|
||||||
RunWorkerFactory::make<BareMetalDebugSupport>(),
|
|
||||||
{ProjectExplorer::Constants::NORMAL_RUN_MODE, ProjectExplorer::Constants::DEBUG_RUN_MODE},
|
|
||||||
{runConfigurationFactory.runConfigurationId(),
|
|
||||||
customRunConfigurationFactory.runConfigurationId()}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// BareMetalPlugin
|
// BareMetalPlugin
|
||||||
|
@@ -79,7 +79,7 @@ Tasks BareMetalCustomRunConfiguration::checkForIssues() const
|
|||||||
|
|
||||||
BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
|
BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
|
||||||
{
|
{
|
||||||
registerRunConfiguration<BareMetalRunConfiguration>("BareMetalCustom");
|
registerRunConfiguration<BareMetalRunConfiguration>(Constants::BAREMETAL_RUNCONFIG_ID);
|
||||||
setDecorateDisplayNames(true);
|
setDecorateDisplayNames(true);
|
||||||
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
|
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
|
||||||
}
|
}
|
||||||
@@ -89,7 +89,7 @@ BareMetalRunConfigurationFactory::BareMetalRunConfigurationFactory()
|
|||||||
BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory()
|
BareMetalCustomRunConfigurationFactory::BareMetalCustomRunConfigurationFactory()
|
||||||
: FixedRunConfigurationFactory(Tr::tr("Custom Executable"), true)
|
: FixedRunConfigurationFactory(Tr::tr("Custom Executable"), true)
|
||||||
{
|
{
|
||||||
registerRunConfiguration<BareMetalCustomRunConfiguration>("BareMetal");
|
registerRunConfiguration<BareMetalCustomRunConfiguration>(Constants::BAREMETAL_CUSTOMRUNCONFIG_ID);
|
||||||
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
|
addSupportedTargetDeviceType(BareMetal::Constants::BareMetalOsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user