Browse Source

Change debugging information generation to use DWARF 2 rather than .s file comments.
Delete ParseDebugSFile and related routines.


git-svn-id: file:///var/svn/tigccpp/trunk@222 9552661e-59e3-4036-b4f2-dbe53926924f

kevinkofler 19 years ago
parent
commit
c7f614328d
4 changed files with 9 additions and 164 deletions
  1. 1 1
      tigcc/ide/MainUnit.pas
  2. 0 97
      tigcc/ide/ParsingUnit.pas
  3. 3 60
      tigcc/ide/SourceFileUnit.pas
  4. 5 6
      tigcc/tigcc/TiGcc.dpr

+ 1 - 1
tigcc/ide/MainUnit.pas

@@ -2286,7 +2286,7 @@ begin
 			try
 				if FileExists (Temp + 'TEMPPROG.PCK') then
 					DeleteFile (Temp + 'TEMPPROG.PCK');
-				if OperationSuccessful and (not OperationCancelled) and DeleteAssemblyFiles and (not DebugInfo) then
+				if OperationSuccessful and (not OperationCancelled) and DeleteAssemblyFiles then
 					with SourceFiles do
 						for I := 0 to Count - 1 do
 							with TSourceFile (Items [I]) do

+ 0 - 97
tigcc/ide/ParsingUnit.pas

@@ -21,9 +21,6 @@ type
 
 	PBoolean = ^Boolean;
 
-	TLineChangeEvent = procedure(StartLine, Change: Integer) of object;
-	TLineContentsEvent = function(StartLine, EndLine: Integer): string of object;
-
 type
 	TCalcInt1 = packed record
 		Int: Byte;
@@ -123,11 +120,8 @@ const
 	MaxCalcAllocBlock = $FFF0;
 
 procedure ParseSFile(Contents: TStringList);
-procedure ParseDebugSFile(Contents: TStringList; OnLineChange: TLineChangeEvent; LineContents: TStringList; OnGetLineContents: TLineContentsEvent);
 procedure ParsePStarter(const InputFile: string; const OutputFile: string; const PackVar: string);
 
-procedure ParseDebugSFileDisk(Contents: TStringList; const SourceFileName: string);
-
 function GetCalcVarSize(ContentLength: LongWord; const Extension: string = ''): LongWord;
 function GetTransferFileSize(ContentLength: LongWord; const Extension: string = ''; OutputBin: Boolean = False): LongWord;
 procedure ProduceTransferFile(Output: Pointer; Contents: Pointer; ContentLength: LongWord; CalcDest: TCalcDest; const DestFolder, DestVarName: string; VarTag: Byte; const Extension: string = ''; OutputBin: Boolean = False);
@@ -252,84 +246,6 @@ begin
 	end;
 end;
 
-procedure ParseDebugSFile(Contents: TStringList; OnLineChange: TLineChangeEvent; LineContents: TStringList; OnGetLineContents: TLineContentsEvent);
-function GetLineContents(StartLine, EndLine: Integer): string;
-var
-	I: Integer;
-begin
-	if Assigned (OnGetLineContents) then
-		Result := OnGetLineContents (StartLine, EndLine)
-	else if Assigned (LineContents) then begin
-		Result := '';
-		for I := StartLine - 1 to EndLine - 1 do
-			if (I >= 0) and (I < LineContents.Count) then
-				Insert (LineContents.Strings [I] + #13#10, Result, Length (Result) + 1);
-		Delete (Result, Length (Result) - 1, 2);
-	end else
-		Result := '';
-end;
-var
-	I,
-	P,
-	LastLine,
-	RecontinueLine,
-	LastDebugLine,
-	CurDebugLine: Integer;
-	S: string;
-begin
-	LastLine := -1;
-	LastDebugLine := -1;
-	RecontinueLine := -1;
-	I := 0;
-	with Contents do
-		while I <= Count do begin
-			if (I < Count) and (Copy (Strings [I], 1, Length (#9'.def'#9)) = #9'.def'#9) then begin
-				Delete (I);
-				if Assigned (OnLineChange) then
-					OnLineChange (I, -1);
-				Dec (I);
-			end else if (I >= Count) or (Copy (Strings [I], 1, Length (#9'.ln'#9)) = #9'.ln'#9) then begin
-				if I < Count then begin
-					S := Strings [I];
-					System.Delete (S, 1, Length (#9'.ln'#9));
-					try
-						CurDebugLine := StrToInt (S);
-					except
-						CurDebugLine := LastDebugLine;
-					end;
-					System.Insert (LineIndicator, S, 1);
-					System.Insert (#9, S, Length (S) + 1);
-					Strings [I] := S;
-				end else
-					CurDebugLine := LastDebugLine + 1;
-				if (LastLine >= 0) and (CurDebugLine >= 0) then begin
-					S := Strings [LastLine];
-					if CurDebugLine < LastDebugLine then begin
-						System.Insert (StringReplace (Trim (GetLineContents (LastDebugLine, LastDebugLine)), #9, '', [rfReplaceAll]) + ' ...', S, Length (S) + 1);
-						RecontinueLine := LastDebugLine;
-					end else begin
-						if (RecontinueLine >= 0) and (CurDebugLine >= RecontinueLine) then begin
-							System.Insert (StringReplace (Trim (GetLineContents (LastDebugLine, LastDebugLine)) + ' ...', #9, '', [rfReplaceAll]), S, Length (S) + 1);
-							RecontinueLine := -1;
-						end else
-							System.Insert (StringReplace (Trim (GetLineContents (LastDebugLine, CurDebugLine - 1)), #9, '', [rfReplaceAll]), S, Length (S) + 1);
-					end;
-					repeat
-						P := Pos (#10, S);
-						if P <= 0 then
-							P := Pos (#13, S);
-						if P > 0 then
-							S [P] := ' ';
-					until P <= 0;
-					Strings [LastLine] := S;
-				end;
-				LastLine := I;
-				LastDebugLine := CurDebugLine;
-			end;
-			Inc (I);
-		end;
-end;
-
 procedure ParsePStarter(const InputFile: string; const OutputFile: string; const PackVar: string);
 const
 	TempProg = 'TEMPPROG';
@@ -361,19 +277,6 @@ begin
 	end;
 end;
 
-procedure ParseDebugSFileDisk(Contents: TStringList; const SourceFileName: string);
-var
-	L: TStringList;
-begin
-	L := TStringList.Create;
-	with L do try
-		LoadFromFile (SourceFileName);
-		ParseDebugSFile (Contents, nil, L, nil);
-	finally
-		Free;
-	end;
-end;
-
 { Functions to read integers machine-independently }
 
 function ReadCalcInt(Int: TCalcInt1): Byte;

+ 3 - 60
tigcc/ide/SourceFileUnit.pas

@@ -138,7 +138,6 @@ type
 		procedure TestChange; override;
 		procedure AskForReload; virtual;
 		procedure UpdateEditor; virtual;
-		function GetLineContents(StartLine, EndLine: Integer): string;
 		function GetCompiledLineStart(Line: Integer): Integer; virtual;
 		property TextEditor: TMemoComponent read GetTextEditor;
 		property Content: string read GetContent write SetContent;
@@ -199,9 +198,6 @@ type
 	end;
 
 	TCSourceFile = class(TSourceTextSourceFile)
-	private
-		FSFileChangedLines: TIntegerList;
-		FSFileLineChanges: TIntegerList;
 	protected
 		CurErrFunction: string;
 		InAssemblingState: Boolean;
@@ -209,9 +205,6 @@ type
 		class function GetCompilable: Boolean; override;
 		procedure SetModified(const Value: Boolean); override;
 		function GetContentType: TSourceFileType; override;
-		procedure SFileLineChange(StartLine, Change: Integer);
-		procedure SFileMapLine(var Line: Integer);
-		procedure SFileClear;
 		procedure ProcessErrorLine(Line: string); override;
 		procedure ProcessSFile(const SourceFile, DestFile: string);
 	public
@@ -895,17 +888,6 @@ begin
 	Result := TextEditor;
 end;
 
-function TTextSourceFile.GetLineContents(StartLine, EndLine: Integer): string;
-var
-	Start: Integer;
-begin
-	if Assigned (TextEditor) then begin
-		Start := GetCompiledLineStart (StartLine);
-		Result := Copy (TextEditor.Text, Start, GetCompiledLineStart (EndLine + 1) - Start);
-	end else
-		Result := '';
-end;
-
 class function TTextSourceFile.GetPrintable: Boolean;
 begin
 	Result := True;
@@ -1727,7 +1709,7 @@ begin
 		if AssumeUndefined then
 			Switches := Switches + ' -Werror-implicit-function-declaration';
 		if DebugInfo then
-			Switches := Switches + ' -gcoff -mcoff-abslines';
+			Switches := Switches + ' -gdwarf-2 -g3 -fasynchronous-unwind-tables';
 		if ProjectTarget = ptFargo then
 			Switches := Switches + ' -DFARGO'
 		else if ProjectTarget = ptFlashOS then
@@ -1761,6 +1743,8 @@ begin
 				Switches := Switches + ' --all-relocs';
 			if OptimizeReturns or (ProjectTarget = ptArchive) then
 				Switches := Switches + ' --keep-locals';
+			if DebugInfo then
+				Switches := Switches + ' --gdwarf2';
 			try
 				MainConsole.StartProcess (WithBackslash (TIGCCFolder) + AsLocation + 'As.exe', '-I ' + Folder + ' ' + Switches + ' "' + Folder + 'tempprog.s" -o ' + Temp + 'tempprog.o', WithoutBackslash (WithBackslash (TIGCCFolder) + AsLocation));
 				WaitForMainConsole ('Compilation');
@@ -1776,7 +1760,6 @@ begin
 			end;
 			ProcessErrors (MainConsole.LastErrText);
 		end;
-		SFileClear;
 		CompUpdate;
 		try
 			if FileExists (Folder + 'TEMPPROG.C') then
@@ -1792,12 +1775,6 @@ begin
 		Invalidated := False;
 end;
 
-destructor TCSourceFile.Destroy;
-begin
-	SFileClear;
-	inherited;
-end;
-
 class function TCSourceFile.GetClassFilter: string;
 begin
 	Result := 'C Files (*.c)|*.c';
@@ -1914,8 +1891,6 @@ begin
 					try
 						S := Copy (Line, 1, Pos (':', Line) - 1);
 						P := StrToInt (S);
-						if InAssemblingState then
-							SFileMapLine (P);
 						Delete (Line, 1, Length (S) + 1);
 						if (Length (Line) > 0) and (Line [1] in ['0'..'9']) then try
 							S := Copy (Line, 1, Pos (':', Line) - 1);
@@ -1988,8 +1963,6 @@ begin
 			OperationSuccessful := False;
 		end;
 		SaveToFile (SourceFile);
-		if DebugInfo then
-			ParseDebugSFile (L, SFileLineChange, nil, GetLineContents);
 		SaveToFile (DestFile);
 	finally
 		Free;
@@ -2019,36 +1992,6 @@ begin
 	end;
 end;
 
-procedure TCSourceFile.SFileClear;
-begin
-	if Assigned (FSFileChangedLines) then
-		FSFileChangedLines.Free;
-	if Assigned (FSFileLineChanges) then
-		FSFileLineChanges.Free;
-	FSFileChangedLines := nil;
-	FSFileLineChanges := nil;
-end;
-
-procedure TCSourceFile.SFileLineChange(StartLine, Change: Integer);
-begin
-	if not Assigned (FSFileChangedLines) then
-		FSFileChangedLines := TIntegerList.Create;
-	if not Assigned (FSFileLineChanges) then
-		FSFileLineChanges := TIntegerList.Create;
-	FSFileChangedLines.Add (StartLine);
-	FSFileLineChanges.Add (Change);
-end;
-
-procedure TCSourceFile.SFileMapLine(var Line: Integer);
-var
-	I: Integer;
-begin
-	if Assigned (FSFileChangedLines) and Assigned (FSFileLineChanges) then
-		for I := 0 to FSFileChangedLines.Count - 1 do
-			if Line > FSFileChangedLines.Items [I] then
-				Inc (Line, FSFileLineChanges.Items [I]);
-end;
-
 procedure TCSourceFile.UpdateEditor;
 begin
 	inherited;

+ 5 - 6
tigcc/tigcc/TiGcc.dpr

@@ -718,8 +718,10 @@ begin
 			if (GCCFiles.Count > 0) or (Pos ('--', GCCLine) > 0) then begin
 				if (Pos (' -S', GCCLine) <= 0) and (Pos (' -E', GCCLine) <= 0) then
 					Insert (' -S', GCCLine, Length (GCCLine) + 1);
-				if DebugInfo then
-					Insert (' -gcoff -mcoff-abslines', GCCLine, Length (GCCLine) + 1);
+				if DebugInfo then begin
+					Insert (' -gdwarf-2 -g3 -fasynchronous-unwind-tables', GCCLine, Length (GCCLine) + 1);
+					Insert (' --gdwarf2', AsLine, Length (AsLine) + 1);
+				end;
 				if Length (DataVar) > 0 then
 					Insert (' -mno-merge-sections', GCCLine, Length (GCCLine) + 1);
 				if FlashOSMode then
@@ -738,15 +740,12 @@ begin
 					if FileExists (T) then begin
 						if GCCFile then begin
 							if Assemble then begin
-								if not DebugInfo then
-									DelFiles.Add (T);
+								DelFiles.Add (T);
 							end;
 							L := TStringList.Create;
 							with L do try
 								LoadFromFile (T);
 								ParseSFile (L);
-								if DebugInfo then
-									ParseDebugSFileDisk (L, S);
 								SaveToFile (T);
 							finally
 								Free;