IDE, DBG: Starting on DebuggerConfigStorage

git-svn-id: trunk@32380 -
This commit is contained in:
martin 2011-09-17 11:32:32 +00:00
parent a829d4e499
commit 63a6d0bb60
5 changed files with 71 additions and 60 deletions

View File

@ -42,7 +42,7 @@ interface
uses uses
TypInfo, Classes, SysUtils, Laz_XMLCfg, math, FileUtil, TypInfo, Classes, SysUtils, Laz_XMLCfg, math, FileUtil,
LCLProc, IDEProcs, DebugUtils, maps; LCLProc, LazConfigStorage, IDEProcs, DebugUtils, maps;
type type
// datatype pointing to data on the target // datatype pointing to data on the target
@ -164,6 +164,20 @@ type
EDBGExceptions = class(EDebuggerException); EDBGExceptions = class(EDebuggerException);
type type
{ TDebuggerConfigStore }
(* TODO: maybe revert relations. Create this in Debugger, and call environmentoptions for the configstore only? *)
TDebuggerConfigStore = class
private
FConfigStore: TConfigStorage;
FDebuggerClass: String;
public
property ConfigStore: TConfigStorage read FConfigStore write FConfigStore;
procedure Load;
procedure Save;
public
property DebuggerClass: String read FDebuggerClass write FDebuggerClass;
end;
{ TRefCountedObject } { TRefCountedObject }
@ -2849,6 +2863,42 @@ begin
Result:=bpaStop; Result:=bpaStop;
end; end;
{ TDebuggerConfigStore }
procedure TDebuggerConfigStore.Load;
type
TDebuggerType = (dtNone, dtGnuDebugger, dtSSHGNUDebugger);
const
DebuggerName: array[TDebuggerType] of string = (
'(None)','GNU debugger (gdb)', 'GNU debugger through SSH (gdb)'
);
function DebuggerNameToType(const s: string): TDebuggerType;
begin
for Result:=Low(TDebuggerType) to High(TDebuggerType) do
if CompareText(DebuggerName[Result],s)=0 then exit;
Result:=dtNone;
end;
var
OldDebuggerType: TDebuggerType;
begin
FDebuggerClass := FConfigStore.GetValue('Class', '');
if FDebuggerClass='' then begin
// try old format
OldDebuggerType := DebuggerNameToType(FConfigStore.GetValue('Type', ''));
if OldDebuggerType=dtGnuDebugger then
FDebuggerClass:='TGDBMIDEBUGGER';
end;
end;
procedure TDebuggerConfigStore.Save;
begin
FConfigStore.SetDeleteValue('Class', FDebuggerClass, '');
FConfigStore.DeletePath('Type');
end;
{ TDebuggerUnitInfoProvider } { TDebuggerUnitInfoProvider }
function TDebuggerUnitInfoProvider.GetInfo(Index: Integer): TDebuggerUnitInfo; function TDebuggerUnitInfoProvider.GetInfo(Index: Integer): TDebuggerUnitInfo;

View File

@ -136,7 +136,7 @@ begin
DbgClass := DebugBoss.Debuggers[n]; DbgClass := DebugBoss.Debuggers[n];
List.AddObject(DbgClass.Caption, TObject(n)); List.AddObject(DbgClass.Caption, TObject(n));
if (FCurDebuggerClass = nil) if (FCurDebuggerClass = nil)
and (CompareText(DbgClass.ClassName, EnvironmentOptions.DebuggerClass) = 0) and (CompareText(DbgClass.ClassName, EnvironmentOptions.DebuggerConfig.DebuggerClass) = 0)
then CurClass := DbgClass; then CurClass := DbgClass;
end; end;
@ -343,8 +343,8 @@ begin
TDebuggerProperties(FCurrentDebPropertiesList.Objects[i])); TDebuggerProperties(FCurrentDebPropertiesList.Objects[i]));
if FCurDebuggerClass = nil if FCurDebuggerClass = nil
then DebuggerClass := '' then DebuggerConfig.DebuggerClass := ''
else DebuggerClass := FCurDebuggerClass.ClassName; else DebuggerConfig.DebuggerClass := FCurDebuggerClass.ClassName;
end; end;
end; end;

View File

@ -2342,7 +2342,7 @@ function TDebugManager.DoCreateBreakPoint(const AFilename: string;
ALine: integer; WarnIfNoDebugger: boolean): TModalResult; ALine: integer; WarnIfNoDebugger: boolean): TModalResult;
begin begin
if WarnIfNoDebugger if WarnIfNoDebugger
and ((FindDebuggerClass(EnvironmentOptions.DebuggerClass)=nil) and ((FindDebuggerClass(EnvironmentOptions.DebuggerConfig.DebuggerClass)=nil)
or (not FileIsExecutable(EnvironmentOptions.DebuggerFilename))) or (not FileIsExecutable(EnvironmentOptions.DebuggerFilename)))
then begin then begin
if QuestionDlg(lisDbgMangNoDebuggerSpecified, if QuestionDlg(lisDbgMangNoDebuggerSpecified,
@ -2457,7 +2457,7 @@ end;
function TDebugManager.GetDebuggerClass: TDebuggerClass; function TDebugManager.GetDebuggerClass: TDebuggerClass;
begin begin
Result := FindDebuggerClass(EnvironmentOptions.DebuggerClass); Result := FindDebuggerClass(EnvironmentOptions.DebuggerConfig.DebuggerClass);
if Result = nil then if Result = nil then
Result := TProcessDebugger; Result := TProcessDebugger;
end; end;

View File

@ -72,14 +72,6 @@ type
{ Debugging } { Debugging }
type
TDebuggerType = (dtNone, dtGnuDebugger, dtSSHGNUDebugger);
const
DebuggerName: array[TDebuggerType] of string = (
'(None)','GNU debugger (gdb)', 'GNU debugger through SSH (gdb)'
);
type type
TDebuggerEventLogColor = record TDebuggerEventLogColor = record
Foreground: TColor; Foreground: TColor;
@ -193,6 +185,7 @@ type
FShowMenuGlyphs: TApplicationShowGlyphs; FShowMenuGlyphs: TApplicationShowGlyphs;
FXMLCfg: TRttiXMLConfig; FXMLCfg: TRttiXMLConfig;
FConfigStore: TXMLOptionsStorage; FConfigStore: TXMLOptionsStorage;
FDbgConfigStore: TXMLOptionsStorage; // for debugger
// auto save // auto save
FAutoSaveEditorFiles: boolean; FAutoSaveEditorFiles: boolean;
@ -265,8 +258,8 @@ type
// TODO: store per debuggerclass options // TODO: store per debuggerclass options
// Maybe these should go to a new TDebuggerOptions class // Maybe these should go to a new TDebuggerOptions class
FDebuggerConfig: TDebuggerConfigStore;
FDebuggerSearchPath: string; FDebuggerSearchPath: string;
FDebuggerClass: string;
FDebuggerFilename: string; // per debugger class FDebuggerFilename: string; // per debugger class
FDebuggerFileHistory: TStringList; // per debugger class FDebuggerFileHistory: TStringList; // per debugger class
FDebuggerProperties: TStringList; // per debugger class FDebuggerProperties: TStringList; // per debugger class
@ -350,7 +343,6 @@ type
property Filename: string read FFilename write SetFilename; property Filename: string read FFilename write SetFilename;
procedure CreateConfig; procedure CreateConfig;
procedure GetDefaultFPCSourceDirectory; procedure GetDefaultFPCSourceDirectory;
function IsDebuggerClassDefined: boolean;
function GetTestBuildDirectory: string; function GetTestBuildDirectory: string;
function GetFPCSourceDirectory: string; function GetFPCSourceDirectory: string;
function GetCompilerFilename: string; function GetCompilerFilename: string;
@ -378,6 +370,7 @@ type
procedure SaveDebuggerPropertiesList; procedure SaveDebuggerPropertiesList;
procedure SaveDebuggerProperties(DebuggerClass: String; Properties: TDebuggerProperties); procedure SaveDebuggerProperties(DebuggerClass: String; Properties: TDebuggerProperties);
procedure LoadDebuggerProperties(DebuggerClass: String; Properties: TDebuggerProperties); procedure LoadDebuggerProperties(DebuggerClass: String; Properties: TDebuggerProperties);
property DebuggerConfig: TDebuggerConfigStore read FDebuggerConfig;
// auto save // auto save
property AutoSaveEditorFiles: boolean read FAutoSaveEditorFiles property AutoSaveEditorFiles: boolean read FAutoSaveEditorFiles
@ -479,7 +472,6 @@ type
write SetMakeFilename; write SetMakeFilename;
property MakeFileHistory: TStringList read FMakeFileHistory property MakeFileHistory: TStringList read FMakeFileHistory
write FMakeFileHistory; write FMakeFileHistory;
property DebuggerClass: String read FDebuggerClass write FDebuggerClass;
property DebuggerFilename: string read FDebuggerFilename property DebuggerFilename: string read FDebuggerFilename
write SetDebuggerFilename; write SetDebuggerFilename;
property DebuggerFileHistory: TStringList read FDebuggerFileHistory property DebuggerFileHistory: TStringList read FDebuggerFileHistory
@ -584,7 +576,6 @@ type
var var
EnvironmentOptions: TEnvironmentOptions = nil; EnvironmentOptions: TEnvironmentOptions = nil;
function DebuggerNameToType(const s: string): TDebuggerType;
function PascalExtToType(const Ext: string): TPascalExtType; function PascalExtToType(const Ext: string): TPascalExtType;
function AmbiguousFileActionNameToType(const Action: string): TAmbiguousFileAction; function AmbiguousFileActionNameToType(const Action: string): TAmbiguousFileAction;
function CharCaseFileActionNameToType(const Action: string): TCharCaseFileAction; function CharCaseFileActionNameToType(const Action: string): TCharCaseFileAction;
@ -607,13 +598,6 @@ const
implementation implementation
function DebuggerNameToType(const s: string): TDebuggerType;
begin
for Result:=Low(TDebuggerType) to High(TDebuggerType) do
if CompareText(DebuggerName[Result],s)=0 then exit;
Result:=dtNone;
end;
function PascalExtToType(const Ext: string): TPascalExtType; function PascalExtToType(const Ext: string): TPascalExtType;
begin begin
if Ext<>'' then if Ext<>'' then
@ -843,6 +827,10 @@ begin
FAskForFilenameOnNewFile:=false; FAskForFilenameOnNewFile:=false;
FLowercaseDefaultFilename:=true; FLowercaseDefaultFilename:=true;
//debug
(* TODO: maybe revert relations. Create this in Debugger, and call environmentoptions for the configstore only? *)
FDebuggerConfig := TDebuggerConfigStore.Create;
// lazdoc // lazdoc
FLazDocPaths:=SetDirSeparators(DefaultLazDocPath); FLazDocPaths:=SetDirSeparators(DefaultLazDocPath);
end; end;
@ -869,7 +857,9 @@ begin
if IDEWindowIntf.IDEDialogLayoutList=FIDEDialogLayoutList then if IDEWindowIntf.IDEDialogLayoutList=FIDEDialogLayoutList then
IDEWindowIntf.IDEDialogLayoutList:=nil; IDEWindowIntf.IDEDialogLayoutList:=nil;
FreeAndNil(FIDEDialogLayoutList); FreeAndNil(FIDEDialogLayoutList);
FreeAndNil(FDebuggerConfig);
FreeAndNil(FConfigStore); FreeAndNil(FConfigStore);
FreeAndNil(FDbgConfigStore);
FreeAndNil(FXMLCfg); FreeAndNil(FXMLCfg);
inherited Destroy; inherited Destroy;
end; end;
@ -955,13 +945,6 @@ var
end; end;
end; end;
procedure LoadDebuggerType(var ADebuggerType: TDebuggerType;
const Path: string);
begin
ADebuggerType:=DebuggerNameToType(
XMLConfig.GetValue(Path+'Debugger/Type',''));
end;
procedure LoadPascalFileExt(const Path: string); procedure LoadPascalFileExt(const Path: string);
begin begin
fPascalFileExtension:=PascalExtToType(XMLConfig.GetValue( fPascalFileExtension:=PascalExtToType(XMLConfig.GetValue(
@ -977,7 +960,6 @@ var
var var
CurDebuggerClass: String; CurDebuggerClass: String;
OldDebuggerType: TDebuggerType;
Path: String; Path: String;
CurPath: String; CurPath: String;
i, j: Integer; i, j: Integer;
@ -1138,18 +1120,7 @@ begin
,Path+'BackupOtherFiles/'); ,Path+'BackupOtherFiles/');
// Debugger // Debugger
// first try to load the old type FDebuggerConfig.Load;
// it will be overwritten by Class if found
CurDebuggerClass := XMLConfig.GetValue(
Path+'Debugger/Class','');
if CurDebuggerClass='' then begin
// try old format
OldDebuggerType := DebuggerNameToType(XMLConfig.GetValue(
Path+'Debugger/Type',''));
if OldDebuggerType=dtGnuDebugger then
CurDebuggerClass:='TGDBMIDEBUGGER';
end;
DebuggerClass:=CurDebuggerClass;
DebuggerFilename:=XMLConfig.GetValue( DebuggerFilename:=XMLConfig.GetValue(
Path+'DebuggerFilename/Value',''); Path+'DebuggerFilename/Value','');
LoadRecentList(XMLConfig,FDebuggerFileHistory, LoadRecentList(XMLConfig,FDebuggerFileHistory,
@ -1330,12 +1301,6 @@ var
end; end;
end; end;
procedure SaveDebuggerType(ADebuggerType: TDebuggerType; Path:string);
begin
XMLConfig.SetDeleteValue(Path+'Debugger/Type',DebuggerName[ADebuggerType],
DebuggerName[dtNone]);
end;
var var
Path: String; Path: String;
i, j: Integer; i, j: Integer;
@ -1487,8 +1452,7 @@ begin
,Path+'BackupOtherFiles/'); ,Path+'BackupOtherFiles/');
// debugger // debugger
XMLConfig.SetDeleteValue(Path+'Debugger/Class', FDebuggerConfig.Save;
FDebuggerClass,'');
SaveDebuggerPropertiesList; SaveDebuggerPropertiesList;
XMLConfig.SetDeleteValue(Path+'DebuggerFilename/Value', XMLConfig.SetDeleteValue(Path+'DebuggerFilename/Value',
FDebuggerFilename,''); FDebuggerFilename,'');
@ -1658,12 +1622,6 @@ begin
IDEWindowCreators.SimpleLayoutStorage.CreateWindowLayout(DefaultObjectInspectorName); IDEWindowCreators.SimpleLayoutStorage.CreateWindowLayout(DefaultObjectInspectorName);
end; end;
function TEnvironmentOptions.IsDebuggerClassDefined: boolean;
begin
Result := (FDebuggerClass <> '')
and (CompareText(FDebuggerClass, DebuggerName[dtNone]) <> 0);
end;
function TEnvironmentOptions.GetTestBuildDirectory: string; function TEnvironmentOptions.GetTestBuildDirectory: string;
begin begin
Result:=AppendPathDelim(TestBuildDirectory); Result:=AppendPathDelim(TestBuildDirectory);
@ -1822,6 +1780,7 @@ function TEnvironmentOptions.GetXMLCfg(CleanConfig: boolean): TXMLConfig;
begin begin
if FileHasChangedOnDisk or (FXMLCfg=nil) then begin if FileHasChangedOnDisk or (FXMLCfg=nil) then begin
FreeAndNil(FConfigStore); FreeAndNil(FConfigStore);
FreeAndNil(FDbgConfigStore);
FreeAndNil(FXMLCfg); FreeAndNil(FXMLCfg);
InvalidateFileStateCache; InvalidateFileStateCache;
if CleanConfig then if CleanConfig then
@ -1830,6 +1789,8 @@ begin
FXMLCfg:=TRttiXMLConfig.Create(Filename); FXMLCfg:=TRttiXMLConfig.Create(Filename);
FConfigStore:=TXMLOptionsStorage.Create(FXMLCfg); FConfigStore:=TXMLOptionsStorage.Create(FXMLCfg);
ObjectInspectorOptions.ConfigStore:=FConfigStore; ObjectInspectorOptions.ConfigStore:=FConfigStore;
FDbgConfigStore:=TXMLOptionsStorage.Create(FXMLCfg, 'EnvironmentOptions/Debugger/');
FDebuggerConfig.ConfigStore := FDbgConfigStore;
end; end;
Result:=FXMLCfg; Result:=FXMLCfg;
end; end;

View File

@ -11888,7 +11888,7 @@ begin
Result := mrAbort; Result := mrAbort;
Exit; Exit;
end; end;
debugln('[TMainIDE.DoRunProject] B ',EnvironmentOptions.DebuggerClass); debugln('[TMainIDE.DoRunProject] B ',EnvironmentOptions.DebuggerConfig.DebuggerClass);
Result := mrCancel; Result := mrCancel;