Debugger: add settings manager for source location mappings.

- If it was necessary to help the debugger locate a particular source
  file due to it not being found on disk at the location specified in
  the debug information, the associated user-supplied path mappings
  are now saved and restored in the team settings. The file manager still
  needs a bit of extra work to apply these as files are added though.
This commit is contained in:
Rene Gollent 2013-09-16 13:28:28 +02:00
parent e968e4b090
commit b9b126139a
8 changed files with 267 additions and 3 deletions

View File

@ -181,6 +181,7 @@ Application Debugger :
BreakpointSetting.cpp
GuiTeamUiSettings.cpp
SettingsManager.cpp
TeamFileManagerSettings.cpp
TeamSettings.cpp
TeamUiSettings.cpp
TeamUiSettingsFactory.cpp

View File

@ -1991,6 +1991,8 @@ TeamDebugger::_LoadSettings()
breakpointSetting->IsEnabled());
}
fFileManager->LoadLocationMappings(fTeamSettings.FileManagerSettings());
const TeamUiSettings* uiSettings = fTeamSettings.UiSettingFor(
fUserInterface->ID());
if (uiSettings != NULL)
@ -2022,6 +2024,8 @@ TeamDebugger::_SaveSettings()
settings.AddUiSettings(clonedSettings);
}
}
fFileManager->SaveLocationMappings(settings.FileManagerSettings());
locker.Unlock();
// save the settings

View File

@ -1,6 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2011-2012, Rene Gollent, rene@gollent.com.
* Copyright 2011-2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
@ -15,6 +15,7 @@
#include "LocatableFile.h"
#include "SourceFile.h"
#include "StringUtils.h"
#include "TeamFileManagerSettings.h"
// #pragma mark - EntryPath
@ -542,7 +543,8 @@ FileManager::FileManager()
fLock("file manager"),
fTargetDomain(NULL),
fSourceDomain(NULL),
fSourceFiles(NULL)
fSourceFiles(NULL),
fLocationMappings()
{
}
@ -636,10 +638,18 @@ FileManager::GetSourceFile(const BString& path)
void
FileManager::SourceEntryLocated(const BString& path, const BString& locatedPath)
FileManager::SourceEntryLocated(const BString& path,
const BString& locatedPath)
{
AutoLocker<FileManager> locker(this);
fSourceDomain->EntryLocated(path, locatedPath);
BMessage archivedMapping;
if (archivedMapping.AddString("source:path", path) == B_OK
&& archivedMapping.AddString("source:locatedpath", locatedPath)
== B_OK) {
fLocationMappings.AddMessage("source:mapping", &archivedMapping);
}
}
@ -687,6 +697,30 @@ FileManager::LoadSourceFile(LocatableFile* file, SourceFile*& _sourceFile)
}
status_t
FileManager::LoadLocationMappings(TeamFileManagerSettings* settings)
{
for (int32 i = 0; i < settings->CountSourceMappings(); i++) {
BString sourcePath;
BString locatedPath;
if (settings->GetSourceMappingAt(i, sourcePath, locatedPath) != B_OK)
return B_NO_MEMORY;
SourceEntryLocated(sourcePath, locatedPath);
}
return B_OK;
}
status_t
FileManager::SaveLocationMappings(TeamFileManagerSettings* settings)
{
return settings->SetTo(fLocationMappings);
}
FileManager::SourceFileEntry*
FileManager::_LookupSourceFile(const BString& path)
{

View File

@ -1,11 +1,13 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef FILE_MANAGER_H
#define FILE_MANAGER_H
#include <Locker.h>
#include <Message.h>
#include <String.h>
#include <util/DoublyLinkedList.h>
@ -15,6 +17,7 @@
class LocatableEntry;
class LocatableFile;
class SourceFile;
class TeamFileManagerSettings;
class FileManager {
@ -47,6 +50,11 @@ public:
SourceFile*& _sourceFile);
// returns a reference
status_t LoadLocationMappings(TeamFileManagerSettings*
settings);
status_t SaveLocationMappings(TeamFileManagerSettings*
settings);
private:
struct EntryPath;
struct EntryHashDefinition;
@ -70,6 +78,7 @@ private:
Domain* fTargetDomain;
Domain* fSourceDomain;
SourceFileTable* fSourceFiles;
BMessage fLocationMappings;
};

View File

@ -0,0 +1,128 @@
/*
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#include "TeamFileManagerSettings.h"
TeamFileManagerSettings::TeamFileManagerSettings()
:
fValues()
{
}
TeamFileManagerSettings::~TeamFileManagerSettings()
{
}
TeamFileManagerSettings&
TeamFileManagerSettings::operator=(const TeamFileManagerSettings& other)
{
fValues = other.fValues;
return *this;
}
const char*
TeamFileManagerSettings::ID() const
{
return "FileManager";
}
status_t
TeamFileManagerSettings::SetTo(const BMessage& archive)
{
try {
fValues = archive;
} catch (...) {
return B_NO_MEMORY;
}
return B_OK;
}
status_t
TeamFileManagerSettings::WriteTo(BMessage& archive) const
{
try {
archive = fValues;
} catch (...) {
return B_NO_MEMORY;
}
return B_OK;
}
int32
TeamFileManagerSettings::CountSourceMappings() const
{
type_code type;
int32 count = 0;
if (fValues.GetInfo("source:mapping", &type, &count) == B_OK)
return count;
return 0;
}
status_t
TeamFileManagerSettings::AddSourceMapping(const BString& sourcePath,
const BString& locatedPath)
{
BMessage mapping;
if (mapping.AddString("source:path", sourcePath) != B_OK
|| mapping.AddString("source:locatedpath", locatedPath) != B_OK
|| fValues.AddMessage("source:mapping", &mapping) != B_OK) {
return B_NO_MEMORY;
}
return B_OK;
}
status_t
TeamFileManagerSettings::RemoveSourceMappingAt(int32 index)
{
return fValues.RemoveData("mapping", index);
}
status_t
TeamFileManagerSettings::GetSourceMappingAt(int32 index, BString& sourcePath,
BString& locatedPath)
{
BMessage mapping;
status_t error = fValues.FindMessage("mapping", index, &mapping);
if (error != B_OK)
return error;
error = mapping.FindString("source:path", &sourcePath);
if (error != B_OK)
return error;
return mapping.FindString("source:locatedpath", &locatedPath);
}
TeamFileManagerSettings*
TeamFileManagerSettings::Clone() const
{
TeamFileManagerSettings* settings = new(std::nothrow)
TeamFileManagerSettings();
if (settings == NULL)
return NULL;
if (settings->SetTo(fValues) != B_OK) {
delete settings;
return NULL;
}
return settings;
}

View File

@ -0,0 +1,41 @@
/*
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_FILE_MANAGER_SETTINGS_H
#define TEAM_FILE_MANAGER_SETTINGS_H
#include <Message.h>
class TeamFileManagerSettings {
public:
TeamFileManagerSettings();
virtual ~TeamFileManagerSettings();
TeamFileManagerSettings&
operator=(
const TeamFileManagerSettings& other);
// throws std::bad_alloc;
const char* ID() const;
status_t SetTo(const BMessage& archive);
status_t WriteTo(BMessage& archive) const;
int32 CountSourceMappings() const;
status_t AddSourceMapping(const BString& sourcePath,
const BString& locatedPath);
status_t RemoveSourceMappingAt(int32 index);
status_t GetSourceMappingAt(int32 index,
BString& sourcePath, BString& locatedPath);
virtual TeamFileManagerSettings*
Clone() const;
// throws std::bad_alloc
private:
BMessage fValues;
};
#endif // TEAM_FILE_MANAGER_SETTINGS_H

View File

@ -16,6 +16,7 @@
#include "ArchivingUtils.h"
#include "BreakpointSetting.h"
#include "Team.h"
#include "TeamFileManagerSettings.h"
#include "TeamUiSettings.h"
#include "TeamUiSettingsFactory.h"
#include "UserBreakpoint.h"
@ -23,6 +24,7 @@
TeamSettings::TeamSettings()
{
fFileManagerSettings = new TeamFileManagerSettings();
}
@ -115,6 +117,12 @@ TeamSettings::SetTo(const BMessage& archive)
}
}
if (archive.FindMessage("filemanagersettings", &childArchive) == B_OK) {
error = fFileManagerSettings->SetTo(childArchive);
if (error != B_OK)
return error;
}
return B_OK;
}
@ -149,6 +157,14 @@ TeamSettings::WriteTo(BMessage& archive) const
return error;
}
error = fFileManagerSettings->WriteTo(childArchive);
if (error != B_OK)
return error;
error = archive.AddMessage("filemanagersettings", &childArchive);
if (error != B_OK)
return error;
return B_OK;
}
@ -234,10 +250,32 @@ TeamSettings::operator=(const TeamSettings& other)
}
}
*fFileManagerSettings = *other.fFileManagerSettings;
return *this;
}
TeamFileManagerSettings*
TeamSettings::FileManagerSettings() const
{
return fFileManagerSettings;
}
status_t
TeamSettings::SetFileManagerSettings(TeamFileManagerSettings* settings)
{
try {
*fFileManagerSettings = *settings;
} catch (...) {
return B_NO_MEMORY;
}
return B_OK;
}
void
TeamSettings::_Unset()
{

View File

@ -1,5 +1,6 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2013, Rene Gollent, rene@gollent.com.
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_SETTINGS_H
@ -15,6 +16,7 @@ class BMessage;
class Team;
class BreakpointSetting;
class TeamUiSettings;
class TeamFileManagerSettings;
class TeamSettings {
@ -41,6 +43,11 @@ public:
TeamSettings& operator=(const TeamSettings& other);
// throws std::bad_alloc
TeamFileManagerSettings*
FileManagerSettings() const;
status_t SetFileManagerSettings(
TeamFileManagerSettings* settings);
private:
typedef BObjectList<BreakpointSetting> BreakpointList;
typedef BObjectList<TeamUiSettings> UiSettingsList;
@ -51,6 +58,8 @@ private:
private:
BreakpointList fBreakpoints;
UiSettingsList fUiSettings;
TeamFileManagerSettings*
fFileManagerSettings;
BString fTeamName;
};