fix bug #506: pass quoted files and paths to gdb that possibly contain spaces

git-svn-id: trunk@6615 -
This commit is contained in:
micha 2005-01-16 19:02:02 +00:00
parent b5f2c228e2
commit 5f8026a62c
5 changed files with 51 additions and 31 deletions

View File

@ -95,12 +95,12 @@ endif
ifeq ($(LAZARUS_OPT),)
$(MAKE) --assume-new=lazarus.pp lazarus$(EXEEXT)
else
$(MAKE) --assume-new=lazarus.pp lazarus$(EXEEXT) OPT='$(OPT) $(LAZARUS_OPT)'
$(MAKE) --assume-new=lazarus.pp lazarus$(EXEEXT) OPT='$(LAZARUS_OPT) $(OPT)'
endif
#-----------------------------------------------------------------------------
idepkg:
$(MAKE) --assume-new=lazarus.pp lazarus$(EXEEXT) OPT='$(OPT) $(LAZARUS_OPT) @$(LAZARUS_IDE_CONFIG)'
$(MAKE) --assume-new=lazarus.pp lazarus$(EXEEXT) OPT='$(LAZARUS_OPT) $(OPT) @$(LAZARUS_IDE_CONFIG)'
#-----------------------------------------------------------------------------
starter:
@ -110,7 +110,7 @@ endif
ifeq ($(LAZARUS_OPT),)
$(MAKE) --assume-new=startlazarus.lpr startlazarus$(EXEEXT)
else
$(MAKE) --assume-new=startlazarus.lpr startlazarus$(EXEEXT) OPT='$(OPT) $(LAZARUS_OPT)'
$(MAKE) --assume-new=startlazarus.lpr startlazarus$(EXEEXT) OPT='$(LAZARUS_OPT) $(OPT)'
endif
#-----------------------------------------------------------------------------

View File

@ -461,7 +461,7 @@ begin
GDBStop;
if AValue <> ''
then begin
SendCmdLn('file %s', [AValue], True);
SendCmdLn('file "%s"', [AValue], True);
FHasSymbols := Pos('no debugging symbols', OutputLines.Text) = 0;
if not FHasSymbols
then DebugLn('WARNING: File ''',AValue, ''' has no debug symbols');
@ -598,6 +598,9 @@ end;
end.
{ =============================================================================
$Log$
Revision 1.13 2005/01/16 19:02:02 micha
fix bug 506: pass quoted files and paths to gdb that possibly contain spaces
Revision 1.12 2004/09/14 21:30:36 vincents
replaced writeln by DebugLn

View File

@ -390,6 +390,15 @@ begin
Result.Add(AResultValues);
end;
function ConvertToGDBPath(APath: string): string;
// GDB wants forward slashes in its filenames, even on win32.
begin
Result := APath;
if DirectorySeparator <> '/' then
Result := StringReplace(Result, DirectorySeparator, '/', [rfReplaceAll]);
Result := '"' + Result + '"';
end;
{ =========================================================================== }
{ TGDBMIDebuggerProperties }
{ =========================================================================== }
@ -411,23 +420,6 @@ begin
end;
function TGDBMIDebugger.ChangeFileName: Boolean;
function GetFileNameForGDB: string;
// GDB wants forward slashes in its filenames, even on win32.
var
SeperatorPos: integer;
begin
Result := FileName;
if DirectorySeparator = '/' then Exit;
repeat
SeperatorPos := Pos(DirectorySeparator, Result);
if SeperatorPos <= 0 then Exit;
Delete(Result, SeperatorPos, 1);
Insert('/', Result, SeperatorPos);
until False;
end;
procedure ClearBreakpoint(var ABreakID: Integer);
begin
if ABreakID = -1 then Exit;
@ -446,7 +438,7 @@ begin
ClearBreakpoint(FRunErrorBreakID);
S := GetFileNameForGDB;
S := ConvertToGDBPath(FileName);
if not ExecuteCommand('-file-exec-and-symbols %s', [S], ResultState, [cfIgnoreError]) then Exit;
if (ResultState = dsError)
and (FileName <> '')
@ -1895,7 +1887,7 @@ begin
end;
if WorkingDir <> ''
then ExecuteCommand('-environment-cd %s', [WorkingDir], []);
then ExecuteCommand('-environment-cd %s', [ConvertToGDBPath(WorkingDir)], []);
FTargetFlags := [tfHasSymbols]; // Set until proven otherwise
@ -2654,6 +2646,9 @@ initialization
end.
{ =============================================================================
$Log$
Revision 1.58 2005/01/16 19:02:02 micha
fix bug 506: pass quoted files and paths to gdb that possibly contain spaces
Revision 1.57 2004/11/22 22:00:21 mattias
fixed cgilazide uses clause

View File

@ -853,17 +853,33 @@ end;
procedure SplitCmdLine(const CmdLine: string;
var ProgramFilename, Params: string);
var p: integer;
var p, s, l: integer;
quote: char;
begin
p:=1;
while (p<=length(CmdLine)) and (CmdLine[p]>' ') do begin
if (CmdLine[p] in ['/','\']) and (CmdLine[p]<>PathDelim) then begin
// skip special char
s:=1;
if (CmdLine[p] in ['"','''']) then
begin
// skip quoted string
quote:=CmdLine[p];
inc(s);
repeat
inc(p);
until (p>Length(CmdLine)) or (CmdLine[p]=quote);
// go past last character or quoted string
l:=p-s;
inc(p);
end else begin
while (p<=length(CmdLine)) and (CmdLine[p]>' ') do begin
if (CmdLine[p] in ['/','\']) and (CmdLine[p]<>PathDelim) then begin
// skip special char
inc(p);
end;
inc(p);
end;
inc(p);
l:=p-s;
end;
ProgramFilename:=LeftStr(CmdLine,p-1);
ProgramFilename:=Copy(CmdLine,s,l);
while (p<=length(CmdLine)) and (CmdLine[p]<=' ') do inc(p);
Params:=RightStr(CmdLine,length(CmdLine)-p+1);
end;

View File

@ -8506,6 +8506,8 @@ begin
end;
function TMainIDE.GetRunCommandLine: string;
var
TargetFileName: string;
begin
if Project1.RunParameterOptions.UseLaunchingApplication then
Result := Project1.RunParameterOptions.LaunchingApplicationPathPlusParams
@ -8516,10 +8518,11 @@ begin
then begin
Result:=Project1.RunParameterOptions.CmdLineParams;
if MacroList.SubstituteStr(Result) then begin
TargetFileName:='"'+GetProjectTargetFilename+'"';
if Result='' then
Result:=GetProjectTargetFilename
Result:=TargetFileName
else
Result:=GetProjectTargetFilename+' '+Result;
Result:=TargetFilename+' '+Result;
end else
Result:='';
end else begin
@ -11379,6 +11382,9 @@ end.
{ =============================================================================
$Log$
Revision 1.835 2005/01/16 19:02:02 micha
fix bug 506: pass quoted files and paths to gdb that possibly contain spaces
Revision 1.834 2005/01/16 13:34:54 mattias
implemented loading .lpk on cmd line